@@ -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;
@@ -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;
@@ -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;
new file mode 100644
@@ -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;
+}
new file mode 100644
@@ -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" } */
+}