Hello Everyone,
    These patches are for the C-Compiler in Cilkplus branch. It is an extension 
to the patch given in submission: 
http://gcc.gnu.org/ml/gcc-patches/2011-12/msg01473.html. The first patch will 
handle cases where array notations are used as condition for if-then-else and 
switch statements. The second patch will insert test cases for this feature.

Thanking You,

Yours Sincerely,

Balaji V. Iyer.
diff --git a/gcc/ChangeLog.cilk b/gcc/ChangeLog.cilk
index 2410953..d53e09e 100644
--- a/gcc/ChangeLog.cilk
+++ b/gcc/ChangeLog.cilk
@@ -1,3 +1,13 @@
+2011-12-23  Balaji V. Iyer  <balaji.v.i...@intel.com>
+
+       * c-array-notations.c (fix_conditional_array_notations): New function.
+       (fix_conditional_array_notations_1): Likewise.
+       (extract_array_notation_exprs): Added a check for STATEMENT_LIST.
+       (replace_array_notations): Likewise.
+       * c-parser.c (c_parser_if_statement): Added a call to the function
+       fix_conditional_array_notations.  Also stored the compound statement
+       to a variable to be passed  into fix_conditional_array_notations.
+
 2011-12-22  Balaji V. Iyer  <balaji.v.i...@intel.com>
 
        * c-typeck.c (find_rank): Moved function to c-array-notations.c
diff --git a/gcc/c-array-notation.c b/gcc/c-array-notation.c
index a435d22..0884263 100644
--- a/gcc/c-array-notation.c
+++ b/gcc/c-array-notation.c
@@ -67,6 +67,13 @@ extract_array_notation_exprs (tree node, tree **array_list, 
int *list_size)
       *array_list = new_array_list;
       return;
     }
+  else if (TREE_CODE (node) == STATEMENT_LIST)
+    {
+      tree_stmt_iterator ii_tsi;
+      for (ii_tsi = tsi_start (node); !tsi_end_p (ii_tsi); tsi_next (&ii_tsi))
+       extract_array_notation_exprs (*tsi_stmt_ptr (ii_tsi), array_list,
+                                     list_size);
+    }
   else
     {
       for (ii = 0; ii < TREE_CODE_LENGTH (TREE_CODE (node)); ii++)
@@ -93,6 +100,13 @@ replace_array_notations (tree *orig, tree *list, tree 
*array_operand,
            *orig = array_operand[ii];
        }
     }
+  else if (TREE_CODE (*orig) == STATEMENT_LIST)
+    {
+      tree_stmt_iterator ii_tsi;
+      for (ii_tsi = tsi_start (*orig); !tsi_end_p (ii_tsi); tsi_next (&ii_tsi))
+       replace_array_notations (tsi_stmt_ptr (ii_tsi), list, array_operand,
+                                array_size);
+    }
   else
     {
       for (ii = 0; ii < TREE_CODE_LENGTH (TREE_CODE (*orig)); ii++)
@@ -417,7 +431,7 @@ build_array_notation_expr (location_t location, tree lhs, 
tree lhs_origtype,
                }
            }
        }
-       replace_array_notations (&rhs, rhs_list, rhs_array_operand,
+      replace_array_notations (&rhs, rhs_list, rhs_array_operand,
                                 rhs_list_size);
        array_expr_rhs = rhs;
     }
@@ -528,3 +542,295 @@ build_array_notation_expr (location_t location, tree lhs, 
tree lhs_origtype,
 
   return loop;
 }
+
+static tree
+fix_conditional_array_notations_1 (tree stmt)
+{
+  tree *array_list = NULL;
+  int list_size = 0;
+  tree cond = NULL;
+  int rank = 0, ii = 0, jj = 0;
+  tree **array_ops, *array_var, *array_operand, jj_tree, loop;
+  tree **array_value, **array_stride, **array_length, **array_start;
+  tree *body_label, *body_label_expr, *exit_label, *exit_label_expr;
+  tree *compare_expr, *if_stmt_label, *expr_incr, *ind_init;
+  bool **count_down, **array_vector;
+
+  if (TREE_CODE (stmt) == COND_EXPR)
+    cond = COND_EXPR_COND (stmt);
+  else if (TREE_CODE (stmt) == SWITCH_EXPR)
+    cond = SWITCH_COND (stmt);
+  else if (TREE_CODE (stmt) == FOR_STMT || TREE_CODE (stmt) == CILK_FOR_STMT)
+    cond = FOR_COND (stmt);
+  else
+    return stmt;
+
+  find_rank (cond, &rank);
+  if (rank == 0)
+    return stmt;  
+  
+  extract_array_notation_exprs (cond, &array_list, &list_size);
+
+  if (*array_list == NULL_TREE || list_size == 0)
+    return stmt;
+
+  array_ops = (tree **) xmalloc (sizeof (tree *) * list_size);
+  for (ii = 0; ii < list_size; ii++)
+    array_ops[ii] = (tree *) xmalloc (sizeof (tree) * rank);
+  
+  array_vector = (bool **) xmalloc (sizeof (bool *) * list_size);
+  for (ii = 0; ii < list_size; ii++)
+    array_vector[ii] = (bool *) xmalloc (sizeof (bool) * rank);
+
+  array_value = (tree **) xmalloc (sizeof (tree *) * list_size);
+  array_stride = (tree **) xmalloc (sizeof (tree *) * list_size);
+  array_length = (tree **) xmalloc (sizeof (tree *) * list_size);
+  array_start = (tree **) xmalloc (sizeof (tree *) * list_size);
+
+  for (ii = 0; ii < list_size; ii++)
+    {
+      array_value[ii]  = (tree *) xmalloc (sizeof (tree) * rank);
+      array_stride[ii] = (tree *) xmalloc (sizeof (tree) * rank);
+      array_length[ii] = (tree *) xmalloc (sizeof (tree) * rank);
+      array_start[ii]  = (tree *) xmalloc (sizeof (tree) * rank);
+    }
+
+  body_label = (tree *) xmalloc(sizeof (tree) * rank);
+  body_label_expr = (tree *) xmalloc (sizeof (tree) * rank);
+  exit_label = (tree *) xmalloc (sizeof (tree) * rank);
+  exit_label_expr = (tree *) xmalloc (sizeof (tree) * rank);
+  compare_expr = (tree *) xmalloc (sizeof (tree) * rank);
+  if_stmt_label = (tree *) xmalloc (sizeof (tree) * rank);
+  
+  expr_incr = (tree *) xmalloc (sizeof (tree) * rank);
+  ind_init = (tree *) xmalloc (sizeof (tree) * rank);
+  
+  count_down = (bool **) xmalloc (sizeof (bool *) * list_size);
+  for (ii = 0; ii < list_size; ii++)
+    count_down[ii] = (bool *) xmalloc (sizeof (bool) * rank);
+
+  array_operand = (tree *) xmalloc (sizeof (tree) * list_size);
+  
+  array_var = (tree *) xmalloc (sizeof (tree) * rank);
+  
+
+  for (ii = 0; ii < list_size; ii++)
+    {
+      jj = 0;
+      for (jj_tree = array_list[ii];
+          jj_tree && TREE_CODE (jj_tree) == ARRAY_NOTATION_REF;
+          jj_tree = ARRAY_NOTATION_ARRAY (jj_tree))
+       {
+         array_ops[ii][jj] = jj_tree;
+         jj++;
+       }
+    }
+
+  for (ii = 0; ii < list_size; ii++)
+    {
+      if (TREE_CODE (array_list[ii]) == ARRAY_NOTATION_REF)
+       {
+         for (jj = 0; jj < rank; jj++)
+           {
+             if (TREE_CODE (array_ops[ii][jj]) == ARRAY_NOTATION_REF)
+               {
+                 array_value[ii][jj] =
+                   ARRAY_NOTATION_ARRAY (array_ops[ii][jj]);
+                 array_start[ii][jj] =
+                   ARRAY_NOTATION_START (array_ops[ii][jj]);
+                 array_length[ii][jj] =
+                   ARRAY_NOTATION_LENGTH (array_ops[ii][jj]);
+                 array_stride[ii][jj] =
+                   ARRAY_NOTATION_STRIDE (array_ops[ii][jj]);
+                 array_vector[ii][jj] = true;
+
+                 if (!TREE_CONSTANT (array_length[ii][jj]))
+                     count_down[ii][jj] = false;
+                 else if (tree_int_cst_lt
+                          (array_length[ii][jj],
+                           build_int_cst (TREE_TYPE (array_length[ii][jj]),
+                                          0)))
+                   count_down[ii][jj] = true;
+                 else
+                   count_down[ii][jj] = false;
+               }
+             else
+               array_vector[ii][jj] = false;
+           }
+       }
+    }
+
+  loop = push_stmt_list();
+
+  for (ii = 0; ii < rank; ii++)
+    {
+  
+      array_var[ii] = build_decl (UNKNOWN_LOCATION, VAR_DECL, NULL_TREE,
+                                 integer_type_node);
+      ind_init[ii] =
+       build_modify_expr (UNKNOWN_LOCATION, array_var[ii],
+                          TREE_TYPE (array_var[ii]), NOP_EXPR,
+                          UNKNOWN_LOCATION,
+                          build_int_cst (TREE_TYPE (array_var[ii]), 0),
+                          TREE_TYPE (array_var[ii]));
+       
+    }
+
+  for (ii = 0; ii < rank ; ii++)
+    {
+      /* this will create the if statement label */
+      if_stmt_label[ii] = build_decl (UNKNOWN_LOCATION, LABEL_DECL, NULL_TREE,
+                                     void_type_node);
+      DECL_CONTEXT (if_stmt_label[ii]) = current_function_decl;
+      DECL_ARTIFICIAL (if_stmt_label[ii]) = 0;
+      DECL_IGNORED_P (if_stmt_label[ii]) = 1;
+  
+      /* this label statment will point to the loop body */
+      body_label[ii] = build_decl (UNKNOWN_LOCATION, LABEL_DECL, NULL_TREE,
+                                  void_type_node);
+      DECL_CONTEXT (body_label[ii]) = current_function_decl;
+      DECL_ARTIFICIAL (body_label[ii]) = 0;
+      DECL_IGNORED_P (body_label[ii]) = 1;
+      body_label_expr[ii] = build1 (LABEL_EXPR, void_type_node, 
body_label[ii]);
+
+      /* this will create the exit label..i.e. where the while loop will branch
+        out of
+      */
+      exit_label[ii] = build_decl (UNKNOWN_LOCATION, LABEL_DECL, NULL_TREE,
+                                  void_type_node);
+      DECL_CONTEXT (exit_label[ii]) = current_function_decl;
+      DECL_ARTIFICIAL (exit_label[ii]) = 0;
+      DECL_IGNORED_P (exit_label[ii]) = 1;
+      exit_label_expr[ii] = build1 (LABEL_EXPR, void_type_node, 
exit_label[ii]);
+    }
+
+  for (ii = 0; ii < list_size; ii++)
+    {
+      if (array_vector[ii][0])
+       {
+         array_operand[ii] = array_value[ii][rank - 1];
+         gcc_assert (array_operand[ii]);
+
+         for (jj = rank - 1; jj >= 0; jj--)
+           {
+             if (count_down[ii][jj])
+               {
+                 /* Array[start_index - (induction_var * stride)] */
+                 array_operand[ii] = build_array_ref
+                   (UNKNOWN_LOCATION, array_operand[ii],
+                    build2 (MINUS_EXPR, TREE_TYPE (array_var[jj]),
+                            array_start[ii][jj],
+                            build2 (MULT_EXPR, TREE_TYPE (array_var[jj]),
+                                    array_var[jj], array_stride[ii][jj])));
+               }
+             else
+               {
+                 /* Array[start_index + (induction_var * stride)] */
+                 array_operand[ii] = build_array_ref
+                   (UNKNOWN_LOCATION, array_operand[ii],
+                    build2 (PLUS_EXPR, TREE_TYPE (array_var[jj]),
+                            array_start[ii][jj],
+                            build2 (MULT_EXPR, TREE_TYPE (array_var[jj]),
+                                    array_var[jj], array_stride[ii][jj])));
+               }
+           }
+       }
+    }
+  replace_array_notations (&stmt, array_list, array_operand, list_size);
+
+  for (ii = 0; ii < rank; ii++)
+    {
+      expr_incr[ii] =
+       build2 (MODIFY_EXPR, void_type_node, array_var[ii],
+               build2 (PLUS_EXPR, TREE_TYPE (array_var[ii]), array_var[ii],
+                       build_int_cst (TREE_TYPE (array_var[ii]), 1)));
+    }
+  
+  for (jj = 0; jj < rank; jj++)
+    {
+      if (rank && expr_incr[jj])
+       {
+         if (count_down[0][jj])
+           compare_expr[jj] =
+             build2 (GT_EXPR, boolean_type_node, array_var[jj],
+                     build2 (MULT_EXPR, TREE_TYPE (array_var[jj]),
+                             array_length[0][jj],
+                             build_int_cst (TREE_TYPE (array_var[jj]), -1)));
+         else
+           compare_expr[jj] = build2 (LT_EXPR, boolean_type_node,
+                                      array_var[jj], array_length[0][jj]);
+       }
+    }
+  
+  for (ii = 0; ii < rank; ii++)
+    {
+      add_stmt (ind_init [ii]);
+
+      add_stmt (build1 (LABEL_EXPR, void_type_node, if_stmt_label[ii]));
+      add_stmt (build3 (COND_EXPR, void_type_node, compare_expr[ii],
+                       build1 (GOTO_EXPR, void_type_node, body_label[ii]),
+                       build1 (GOTO_EXPR, void_type_node, exit_label[ii])));
+      add_stmt (body_label_expr[ii]);
+    }
+
+  add_stmt (stmt);
+
+  for (ii = rank - 1; ii >= 0; ii--)
+    {
+      add_stmt (expr_incr[ii]);
+      add_stmt (build1 (GOTO_EXPR, void_type_node, if_stmt_label[ii]));
+      add_stmt (exit_label_expr[ii]);
+    }
+
+  pop_stmt_list (loop);
+
+  free (body_label);
+  free (body_label_expr);
+  free (exit_label);
+  free (exit_label_expr);
+  free (compare_expr);
+  free (if_stmt_label);
+  free (expr_incr);
+  free (ind_init);
+  free (array_operand);
+  free (array_var);
+  
+  for (ii = 0; ii < list_size; ii++)
+    {
+      free (count_down[ii]);
+      free (array_value[ii]);
+      free (array_stride[ii]);
+      free (array_length[ii]);
+      free (array_start[ii]);
+      free (array_ops[ii]);
+      free (array_vector[ii]);
+    }
+
+  free (count_down);
+  free (array_value);
+  free (array_stride);
+  free (array_length);
+  free (array_start);
+  free (array_ops);
+  free (array_vector);
+
+  return loop;
+}
+
+tree
+fix_conditional_array_notations (tree stmt)
+{
+  if (TREE_CODE (stmt) == STATEMENT_LIST)
+    {
+      tree_stmt_iterator tsi;
+      for (tsi = tsi_start (stmt); !tsi_end_p (tsi); tsi_next (&tsi))
+       {
+         tree single_stmt = *tsi_stmt_ptr (tsi);
+         *tsi_stmt_ptr (tsi) =
+           fix_conditional_array_notations_1 (single_stmt);
+       }
+      return stmt;
+    }
+  else
+    return fix_conditional_array_notations_1 (stmt);
+}
diff --git a/gcc/c-parser.c b/gcc/c-parser.c
index ec78eeb..457abee 100644
--- a/gcc/c-parser.c
+++ b/gcc/c-parser.c
@@ -59,6 +59,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "plugin.h"
 
 extern tree c_build_sync (tree *);
+extern tree fix_conditional_array_notations (tree);
 struct pragma_simd_values local_simd_values;
 
 
@@ -4763,6 +4764,7 @@ c_parser_if_statement (c_parser *parser)
   bool first_if = false;
   tree first_body, second_body;
   bool in_if_block;
+  tree if_stmt;
 
   gcc_assert (c_parser_next_token_is_keyword (parser, RID_IF));
   c_parser_consume_token (parser);
@@ -4781,7 +4783,10 @@ c_parser_if_statement (c_parser *parser)
   else
     second_body = NULL_TREE;
   c_finish_if_stmt (loc, cond, first_body, second_body, first_if);
-  add_stmt (c_end_compound_stmt (loc, block, flag_isoc99));
+  if_stmt = c_end_compound_stmt (loc, block, flag_isoc99);
+  if_stmt = fix_conditional_array_notations (if_stmt);
+  add_stmt (if_stmt);
+  
 }
 
 /* Parse a switch statement (C90 6.6.4, C99 6.8.4).
@@ -4793,7 +4798,7 @@ c_parser_if_statement (c_parser *parser)
 static void
 c_parser_switch_statement (c_parser *parser)
 {
-  tree block, expr, body, save_break;
+  tree block, expr, body, save_break, switch_stmt;
   location_t switch_loc = c_parser_peek_token (parser)->location;
   location_t switch_cond_loc;
   gcc_assert (c_parser_next_token_is_keyword (parser, RID_SWITCH));
@@ -4823,7 +4828,9 @@ c_parser_switch_statement (c_parser *parser)
       add_stmt (t);
     }
   c_break_label = save_break;
-  add_stmt (c_end_compound_stmt (switch_loc, block, flag_isoc99));
+  switch_stmt = c_end_compound_stmt (switch_loc, block, flag_isoc99);
+  switch_stmt = fix_conditional_array_notations (switch_stmt);
+  add_stmt (switch_stmt);
 }
 
 /* Parse a while statement (C90 6.6.5, C99 6.8.5).
@@ -4835,7 +4842,7 @@ c_parser_switch_statement (c_parser *parser)
 static void
 c_parser_while_statement (c_parser *parser)
 {
-  tree block, cond, body, save_break, save_cont;
+  tree block, cond, body, save_break, save_cont, while_stmt;
   location_t loc;
   gcc_assert (c_parser_next_token_is_keyword (parser, RID_WHILE));
   c_parser_consume_token (parser);
@@ -4849,7 +4856,9 @@ c_parser_while_statement (c_parser *parser)
   body = c_parser_c99_block_statement (parser);
   c_finish_loop (loc, cond, NULL, body, c_break_label, c_cont_label,
                 &local_simd_values, true);
-  add_stmt (c_end_compound_stmt (loc, block, flag_isoc99));
+  while_stmt = c_end_compound_stmt (loc, block, flag_isoc99);
+  while_stmt = fix_conditional_array_notations (while_stmt);
+  add_stmt (while_stmt);
   c_break_label = save_break;
   c_cont_label = save_cont;
 }
@@ -4863,7 +4872,7 @@ c_parser_while_statement (c_parser *parser)
 static void
 c_parser_do_statement (c_parser *parser)
 {
-  tree block, cond, body, save_break, save_cont, new_break, new_cont;
+  tree block, cond, body, save_break, save_cont, new_break, new_cont, do_stmt;
   location_t loc;
   gcc_assert (c_parser_next_token_is_keyword (parser, RID_DO));
   c_parser_consume_token (parser);
@@ -4888,7 +4897,9 @@ c_parser_do_statement (c_parser *parser)
     c_parser_skip_to_end_of_block_or_statement (parser);
   c_finish_loop (loc, cond, NULL, body, new_break, new_cont,
                 &local_simd_values, false);
-  add_stmt (c_end_compound_stmt (loc, block, flag_isoc99));
+  do_stmt = c_end_compound_stmt (loc, block, flag_isoc99);
+  do_stmt = fix_conditional_array_notations (do_stmt);
+  add_stmt (do_stmt);
 }
 
 /* Parse a for statement (C90 6.6.5, C99 6.8.5).
@@ -4950,7 +4961,7 @@ c_parser_do_statement (c_parser *parser)
 static void
 c_parser_for_statement (c_parser *parser, bool pragma_simd_found)
 {
-  tree block, cond, incr, save_break, save_cont, body;
+  tree block, cond, incr, save_break, save_cont, body, for_stmt;
   /* The following are only used when parsing an ObjC foreach statement.  */
   tree object_expression;
   /* Silence the bogus uninitialized warning.  */
@@ -5104,7 +5115,9 @@ c_parser_for_statement (c_parser *parser, bool 
pragma_simd_found)
     c_finish_loop (loc, cond, incr, body, c_break_label, c_cont_label,
                   &local_simd_values,
                   true);
-  add_stmt (c_end_compound_stmt (loc, block, flag_isoc99 || c_dialect_objc 
()));
+  for_stmt = c_end_compound_stmt (loc, block, flag_isoc99 || c_dialect_objc 
());
+  for_stmt = fix_conditional_array_notations (for_stmt);
+  add_stmt (for_stmt);
   c_break_label = save_break;
   c_cont_label = save_cont;
 }
diff --git a/gcc/testsuite/ChangeLog.cilk b/gcc/testsuite/ChangeLog.cilk
index e4df224..33499cf 100644
--- a/gcc/testsuite/ChangeLog.cilk
+++ b/gcc/testsuite/ChangeLog.cilk
@@ -1,3 +1,8 @@
+2011-12-23  Balaji V. Iyer  <balaji.v.i...@intel.com>
+
+       * gcc.dg/cilk-plus/array_notation_test/if_test.c: New.
+       * gcc.dg/cilk-plus/array_notation_test/switch_test.c: New.
+
 2011-12-20  Balaji V. Iyer  <balaji.v.i...@intel.com>
 
        * gcc.dg/cilk-plus/array_notation_test/array_test_ND.c: New N-Dimension
diff --git a/gcc/testsuite/gcc.dg/cilk-plus/array_notation_tests/if_test.c 
b/gcc/testsuite/gcc.dg/cilk-plus/array_notation_tests/if_test.c
new file mode 100644
index 0000000..833379b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cilk-plus/array_notation_tests/if_test.c
@@ -0,0 +1,162 @@
+#include <stdio.h>
+
+int main (int argc, char **argv)
+{
+  int x = 3, y, z, array[10], array2[10], TwodArray[10][10], jj,kk,ll ;
+  int FourDArray[10][10][10][10];
+  int ii = 0; 
+
+  if (argc != 3)
+    {
+      fprintf(stderr, "Usage: %s 10 15\n", argv[0]);
+      return;
+    }
+
+  for (ii = 0; ii < 10; ii++)
+    {
+      array[ii] = argc%3;
+      array2[ii]= 10;
+    }
+  
+  for (ii = 0; ii < 10; ii++)
+    printf("%4d ", array[ii]);
+  printf("\n");
+
+  if (!array[:])
+    array2[:] = 5;
+  else
+    array2[:] = 10;
+
+  for (ii = 0; ii < 10; ii++)
+    printf("%4d ", array2[ii]);
+  printf("\n");
+
+  if (!(array[0:10:1] + array[0:10:1]))
+    array2[:] = 5;
+  else
+    array2[:] = 10;
+
+  for (ii = 0; ii < 10; ii++)
+    printf("%4d ", array2[ii]);
+  printf("\n");
+
+  x = atoi (argv[1])-10;
+  y = atoi (argv[1])/2;
+  z = (atoi (argv[1]))/5;
+
+  for (ii = 0; ii < 10; ii++)
+    {
+      if (ii % 2)
+       array[ii] = 0;
+      else
+       array[ii] = 1;
+    }
+
+  /*printf("x = %2d y = %2d z = %2d\n", x, y, z); */
+
+  for (ii = 0; ii < 10; ii++)
+    array[ii] = 10;
+
+  /* This if loop will change all the 10's to 5's */
+  if (array[x:y:z] != 9)
+    array2[:] = 5;
+  else
+    array2[:] = 10;
+
+  for (ii = 0; ii < 10; ii++)
+    printf("%4d ", array2[ii]);
+  printf("\n");
+
+  for (ii = 0; ii < 10; ii++)
+    array2[ii] = 10;
+
+  /* This if loop will change all the 10's to 5's */
+  if (array[atoi(argv[1])-10:atoi(argv[1]): atoi(argv[1])/5])
+    array2[:] = 5;
+  else
+    array2[:] = 10;
+
+  for (ii = 0; ii < 10; ii++)
+    printf("%4d ", array2[ii]);
+  printf("\n");
+
+  for (ii = 0; ii < 10; ii++)
+    for (jj = 0; jj < 10; jj++)
+      TwodArray[ii][jj] = atoi(argv[1]);
+
+
+  for (ii = 0; ii < 10; ii++)
+    array2[ii] = 10;
+
+  /* atoi(argv[1]) == 10, so it will convert all 10's to 5's */
+  if (TwodArray[:][:] != 10) 
+    array2[:] = 10; 
+  else
+    array2[:] = 5;
+
+  for (ii = 0; ii < 10; ii++)
+    printf("%4d ", array2[ii]);
+  printf("\n");
+
+  for (ii = 0; ii < 10; ii++)
+    array2[ii] = 10;
+
+  for (ii = 0; ii < 10; ii++)
+    for (jj = 0; jj < 10; jj++)
+      for (kk = 0; kk < 10; kk++)
+       for (ll = 0; ll < 10; ll++) 
+         FourDArray[ii][jj][kk][ll] = atoi(argv[1]);
+  
+  /* atoi(argv[1]) == 10, so it will convert all 10's to 5's */
+  if (FourDArray[:][:][:][:] != 10) 
+    array2[:] = 10; 
+  else
+    array2[:] = 5;
+
+  for (ii = 0; ii < 10; ii++)
+    printf("%4d ", array2[ii]);
+  printf("\n");
+
+  
+  for (ii = 0; ii < 10; ii++)
+    array2[ii] = 10;
+
+  for (ii = 0; ii < 10; ii++)
+    for (jj = 0; jj < 10; jj++)
+      for (kk = 0; kk < 10; kk++)
+       for (ll = 0; ll < 10; ll++) 
+         FourDArray[ii][jj][kk][ll] = atoi(argv[1]);
+  
+  /* atoi(argv[1]) == 10, so it will convert all 10's to 5's */
+  if (FourDArray[0:10:1][0:5:2][9:10:-1][x:y:z] != 10) 
+    array2[:] = 10; 
+  else
+    array2[:] = 5;
+
+  for (ii = 0; ii < 10; ii++)
+    printf("%4d ", array2[ii]);
+  printf("\n");
+
+    for (ii = 0; ii < 10; ii++)
+    array2[ii] = 10;
+
+  for (ii = 0; ii < 10; ii++)
+    for (jj = 0; jj < 10; jj++)
+      for (kk = 0; kk < 10; kk++)
+       for (ll = 0; ll < 10; ll++) 
+         FourDArray[ii][jj][kk][ll] = atoi(argv[1]);
+  
+  /* atoi(argv[1]) == 10, so it will convert all 10's to 5's */
+  if (FourDArray[0:10:1][0:5:2][9:10:-1][x:y:z] +
+      FourDArray[0:10:1][0:5:2][9:-10:1][x:y:z]  != 20) 
+    array2[:] = 10; 
+  else
+    array2[:] = 5;
+
+  for (ii = 0; ii < 10; ii++)
+    printf("%4d ", array2[ii]);
+  printf("\n");
+
+  
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/cilk-plus/array_notation_tests/switch_test.c 
b/gcc/testsuite/gcc.dg/cilk-plus/array_notation_tests/switch_test.c
new file mode 100644
index 0000000..4e7d201
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cilk-plus/array_notation_tests/switch_test.c
@@ -0,0 +1,229 @@
+#include <stdio.h>
+
+int main (int argc, char **argv)
+{
+  int x = 3, y, z, array[10], array2[10], TwodArray[10][10], jj,kk,ll ;
+  int FourDArray[10][10][10][10];
+  int ii = 0; 
+
+  if (argc != 3)
+    {
+      fprintf(stderr, "Usage: %s 10 15\n", argv[0]);
+      return;
+    }
+
+  for (ii = 0; ii < 10; ii++)
+    {
+      array[ii] = argc%3;
+      array2[ii]= 10;
+    }
+  
+  for (ii = 0; ii < 10; ii++)
+    printf("%4d ", array[ii]);
+  printf("\n");
+#if 1
+  switch (array[:])
+    {
+    case 10:
+      array2[:] = 0;
+      break;
+    case 9:
+      array2[:] = 1;
+      break;
+    case 0:
+      array2[:] = 5;
+      break;
+    case 1:
+      array2[:] = 10;
+      break;
+    default:
+      array2[:] = 6;
+    }
+
+  for (ii = 0; ii < 10; ii++)
+    printf("%4d ", array2[ii]);
+  printf("\n");
+#endif
+  
+#if 1
+  /* this tests for nested if statements */
+  if (!(array[0:10:1] + array[0:10:1]))
+    if ((array[0:10:1] + atoi(argv[1])))
+      array2[:] = 5;
+    else
+      array2[:] = 7;
+  else
+    array2[:] = 10;
+
+  for (ii = 0; ii < 10; ii++)
+    printf("%4d ", array2[ii]);
+  printf("\n");
+
+  x = atoi (argv[1])-10;
+  y = atoi (argv[1])/2;
+  z = (atoi (argv[1]))/5;
+
+  for (ii = 0; ii < 10; ii++)
+    {
+      if (ii % 2)
+       array[ii] = 0;
+      else
+       array[ii] = 1;
+    }
+
+#endif
+
+  /*printf("x = %2d y = %2d z = %2d\n", x, y, z); */
+#if 1
+  for (ii = 0; ii < 10; ii++)
+    array[ii] = 10;
+
+  /* This if loop will change all the 10's to 5's */
+  switch (array[x:y:z])
+    {
+    case 9:
+      array2[:] = 10;
+      break;
+    default:
+      array2[:] = 5;
+      break;
+    }
+
+  for (ii = 0; ii < 10; ii++)
+    printf("%4d ", array2[ii]);
+  printf("\n");
+#endif
+  
+#if 1
+  for (ii = 0; ii < 10; ii++)
+    array2[ii] = 10;
+
+  /* This if loop will change all the 10's to 5's */
+  switch (array[atoi(argv[1])-10:atoi(argv[1]): atoi(argv[1])/5])
+    {
+    case 10:
+      array2[:] = 5;
+      break;
+    default:
+      array2[:] = 10;
+      break;
+    }
+  
+  for (ii = 0; ii < 10; ii++)
+    printf("%4d ", array2[ii]);
+  printf("\n");
+#endif
+
+#if 1
+  for (ii = 0; ii < 10; ii++)
+    for (jj = 0; jj < 10; jj++)
+      TwodArray[ii][jj] = atoi(argv[1]);
+
+
+  for (ii = 0; ii < 10; ii++)
+    array2[ii] = 10;
+
+  /* atoi(argv[1]) == 10, so it will convert all 10's to 5's */
+  switch (TwodArray[:][:])
+    {
+    case 10:
+      array2[:] = 5;
+      break;
+    default:
+      array2[:] = 5 + array2[:];
+      break;
+    }
+
+  for (ii = 0; ii < 10; ii++)
+    printf("%4d ", array2[ii]);
+  printf("\n");
+#endif
+  
+#if 1
+  for (ii = 0; ii < 10; ii++)
+    array2[ii] = 10;
+
+  for (ii = 0; ii < 10; ii++)
+    for (jj = 0; jj < 10; jj++)
+      for (kk = 0; kk < 10; kk++)
+       for (ll = 0; ll < 10; ll++) 
+         FourDArray[ii][jj][kk][ll] = atoi(argv[1]);
+  
+  /* atoi(argv[1]) == 10, so it will convert all 10's to 5's */
+  switch (FourDArray[:][:][:][:])
+    {
+    case 10:
+      array2[:] = 5;
+      break;
+    default:
+      array2[:] = 10;
+      break;
+    }
+
+  for (ii = 0; ii < 10; ii++)
+    printf("%4d ", array2[ii]);
+  printf("\n");
+#endif
+  
+#if 1  
+  for (ii = 0; ii < 10; ii++)
+    array2[ii] = 10;
+
+  for (ii = 0; ii < 10; ii++)
+    for (jj = 0; jj < 10; jj++)
+      for (kk = 0; kk < 10; kk++)
+       for (ll = 0; ll < 10; ll++) 
+         FourDArray[ii][jj][kk][ll] = atoi(argv[1]);
+  
+  /* atoi(argv[1]) == 10, so it will convert all 10's to 5's */
+  switch (FourDArray[0:10:1][0:5:2][9:10:-1][x:y:z]) {
+  case 5:
+    array2[:] = 10;
+    break;
+  case 10:
+    array2[:] = 5;
+    break;
+  default:
+    array2[:] = 9;
+    break;
+  }
+
+  for (ii = 0; ii < 10; ii++)
+    printf("%4d ", array2[ii]);
+  printf("\n");
+
+#endif
+  
+#if 1
+    for (ii = 0; ii < 10; ii++)
+    array2[ii] = 10;
+
+  for (ii = 0; ii < 10; ii++)
+    for (jj = 0; jj < 10; jj++)
+      for (kk = 0; kk < 10; kk++)
+       for (ll = 0; ll < 10; ll++) 
+         FourDArray[ii][jj][kk][ll] = atoi(argv[1]);
+  
+  /* atoi(argv[1]) == 10, so it will convert all 10's to 5's */
+  switch(FourDArray[0:10:1][0:5:2][9:10:-1][x:y:z] +
+        FourDArray[0:10:1][0:5:2][9:-10:1][x:y:z]) {
+  case 10:
+    array2[:] = 10;
+    break;
+  case 15:
+    array2[:] = 132;
+    break;
+  case 20:
+    array2[:] = 5;
+    break;
+  default:
+    array2[:] = 2;
+    break;
+  }
+  for (ii = 0; ii < 10; ii++)
+    printf("%4d ", array2[ii]);
+  printf("\n");
+#endif
+  
+  return 0;
+}

Reply via email to