re PR c++/61455 (Internal compiler error, and other confused errors, when using array...
authorIgor Zamyatin <igor.zamyatin@intel.com>
Fri, 1 Aug 2014 16:54:27 +0000 (16:54 +0000)
committerKirill Yukhin <kyukhin@gcc.gnu.org>
Fri, 1 Aug 2014 16:54:27 +0000 (16:54 +0000)
PR middle-end/61455

gcc/c-family/
* array-notation-common.c (extract_array_notation_exprs): Handling
of DECL_EXPR added.

gcc/c/
* c-array-notation.c (expand_array_notations): Handling
of DECL_EXPR added.

gcc/cp/
* cp-array-notation.c (expand_array_notation_exprs): Handling of
DECL_EXPR improved. Changed handling for INIT_EXPR.

gcc/testsuite/
* c-c++-common/cilk-plus/AN/pr61455.c: New test.
* c-c++-common/cilk-plus/AN/pr61455-2.c: Likewise.

From-SVN: r213491

gcc/c-family/ChangeLog
gcc/c-family/array-notation-common.c
gcc/c/ChangeLog
gcc/c/c-array-notation.c
gcc/cp/ChangeLog
gcc/cp/cp-array-notation.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/cilk-plus/AN/pr61455-2.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/cilk-plus/AN/pr61455.c [new file with mode: 0644]

index 55e4a66df4ad1ffb6ef9276115daabf041d35a61..af7d135529a60cabfc8cda06764f12325eee36b6 100644 (file)
@@ -1,3 +1,9 @@
+2014-08-01  Igor Zamyatin  <igor.zamyatin@intel.com>
+
+       PR middle-end/61455
+       * array-notation-common.c (extract_array_notation_exprs): Handling
+       of DECL_EXPR added.
+
 2014-08-01  Jakub Jelinek  <jakub@redhat.com>
 
        * c-common.h (min_align_of_type): Removed prototype.
index c0100398a8bd9083541aac7d16274480ba5f20ec..84f6f452799487a0534ad9aa523ab00e798dd749 100644 (file)
@@ -329,6 +329,14 @@ extract_array_notation_exprs (tree node, bool ignore_builtin_fn,
       vec_safe_push (*array_list, node);
       return;
     }
+  if (TREE_CODE (node) == DECL_EXPR)
+    {
+      tree x = DECL_EXPR_DECL (node);
+      if (DECL_INITIAL (x))
+       extract_array_notation_exprs (DECL_INITIAL (x),
+                                     ignore_builtin_fn,
+                                     array_list);
+    }
   else if (TREE_CODE (node) == STATEMENT_LIST)
     {
       tree_stmt_iterator ii_tsi;
index aec8cf1a1f9fbddf8ae23fe12f929e49e0ab7473..186a19dbd4fb40927494046722afd5026486c6b1 100644 (file)
@@ -1,3 +1,9 @@
+2014-08-01  Igor Zamyatin  <igor.zamyatin@intel.com>
+
+       PR middle-end/61455
+       * c-array-notation.c (expand_array_notations): Handling
+       of DECL_EXPR added.
+
 2014-07-31  Marc Glisse  <marc.glisse@inria.fr>
 
        PR c++/60517
index 67a89315e9cf592ee4ff6975c24123646d7aa906..597adc912a6270e425788587a47de921dae89d0b 100644 (file)
@@ -1265,6 +1265,25 @@ expand_array_notations (tree *tp, int *walk_subtrees, void *)
                                         rhs_loc, rhs, TREE_TYPE (rhs));
       }
       break;
+    case DECL_EXPR:
+      {
+       tree x = DECL_EXPR_DECL (*tp);
+       if (DECL_INITIAL (x))
+         {
+           location_t loc = DECL_SOURCE_LOCATION (x);
+           tree lhs = x;
+           tree rhs = DECL_INITIAL (x);
+           DECL_INITIAL (x) = NULL;
+           tree new_modify_expr = build_modify_expr (loc, lhs,
+                                                     TREE_TYPE (lhs),
+                                                     NOP_EXPR,
+                                                     loc, rhs,
+                                                     TREE_TYPE(rhs));
+           expand_array_notations (&new_modify_expr, walk_subtrees, NULL);
+           *tp = new_modify_expr;
+         }
+      }
+      break;
     case CALL_EXPR:
       *tp = fix_array_notation_call_expr (*tp);
       break;
index 62e4fe49c6b9a03f5eef9fe3f4ee00bcde320137..017ec514510d04a25480181592960bf30a34aeb3 100644 (file)
@@ -1,3 +1,9 @@
+2014-07-08  Igor Zamyatin  <igor.zamyatin@intel.com>
+
+       PR middle-end/61455
+       * cp-array-notation.c (expand_array_notation_exprs): Handling of
+       DECL_EXPR improved. Changed handling for INIT_EXPR.
+
 2014-08-01  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * pt.c (lookup_template_class_1): Use DECL_TYPE_TEMPLATE_P.
index b45449bc44df5998bd729d9844bb9d32157f2c8d..31253ff7d07a01f8e1631db775be2864a8c82edb 100644 (file)
@@ -1148,13 +1148,13 @@ expand_array_notation_exprs (tree t)
     case PARM_DECL:
     case NON_LVALUE_EXPR:
     case NOP_EXPR:
-    case INIT_EXPR:
     case ADDR_EXPR:
     case ARRAY_REF:
     case BIT_FIELD_REF:
     case VECTOR_CST:
     case COMPLEX_CST:
       return t;
+    case INIT_EXPR:
     case MODIFY_EXPR:
       if (contains_array_notation_expr (t))
        t = expand_an_in_modify_expr (loc, TREE_OPERAND (t, 0), NOP_EXPR, 
@@ -1176,13 +1176,24 @@ expand_array_notation_exprs (tree t)
        return t;
       }
     case DECL_EXPR:
-      {
-       tree x = DECL_EXPR_DECL (t);
-       if (t && TREE_CODE (x) != FUNCTION_DECL)
+      if (contains_array_notation_expr (t))
+       {
+         tree x = DECL_EXPR_DECL (t);
          if (DECL_INITIAL (x))
-           t = expand_unary_array_notation_exprs (t);
+           {
+             location_t loc = DECL_SOURCE_LOCATION (x);
+             tree lhs = x;
+             tree rhs = DECL_INITIAL (x);
+             DECL_INITIAL (x) = NULL;
+             tree new_modify_expr = build_modify_expr (loc, lhs,
+                                                       TREE_TYPE (lhs),
+                                                       NOP_EXPR,
+                                                       loc, rhs,
+                                                       TREE_TYPE(rhs));
+             t = expand_array_notation_exprs (new_modify_expr);
+           }
+       }
       return t;
-      }
     case STATEMENT_LIST:
       {
        tree_stmt_iterator i;
index cc4e3d1e367cfc059d46faba567486776d5e8454..95ebf2f6ae9166a135aae0956b16803322b4903d 100644 (file)
@@ -1,3 +1,9 @@
+2014-07-08  Igor Zamyatin  <igor.zamyatin@intel.com>
+
+       PR middle-end/61455
+       * c-c++-common/cilk-plus/AN/pr61455.c: New test.
+       * c-c++-common/cilk-plus/AN/pr61455-2.c: Likewise.
+
 2014-08-01  Jiong Wang  <jiong.wang@arm.com>
 
        * gcc.target/aarch64/legitimize_stack_var_before_reload_1.c: New
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/AN/pr61455-2.c b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr61455-2.c
new file mode 100644 (file)
index 0000000..60b4248
--- /dev/null
@@ -0,0 +1,13 @@
+/* PR c++/61455 */
+/* { dg-options "-fcilkplus" } */
+
+int a[3] = {2, 3, 4};
+
+int main ()
+{
+  int c = 10;
+  int b = __sec_reduce_add(a[:]);
+  if (b+c != 19)
+    __builtin_abort();
+  return 0;
+}
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/AN/pr61455.c b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr61455.c
new file mode 100644 (file)
index 0000000..35a11b6
--- /dev/null
@@ -0,0 +1,9 @@
+/* PR c++/61455 */
+/* { dg-do compile } */
+/* { dg-options "-fcilkplus" } */
+
+void foo ()
+{
+  int a[2];
+  int b = a[:]; /* { dg-error "cannot be scalar" } */
+}