You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.2 KiB
56 lines
1.2 KiB
2017-05-30 Jakub Jelinek <jakub@redhat.com> |
|
|
|
Backported from mainline |
|
2016-12-21 Jakub Jelinek <jakub@redhat.com> |
|
|
|
PR c/77767 |
|
* c-decl.c (grokdeclarator): If *expr is non-NULL, append expression |
|
to *expr instead of overwriting it. |
|
|
|
* gcc.c-torture/execute/pr77767.c: New test. |
|
|
|
--- gcc/c/c-decl.c |
|
+++ gcc/c/c-decl.c |
|
@@ -5409,11 +5409,21 @@ grokdeclarator (const struct c_declarator *declarator, |
|
if (TREE_CODE (type) == ERROR_MARK) |
|
return error_mark_node; |
|
if (expr == NULL) |
|
- expr = &expr_dummy; |
|
+ { |
|
+ expr = &expr_dummy; |
|
+ expr_dummy = NULL_TREE; |
|
+ } |
|
if (expr_const_operands == NULL) |
|
expr_const_operands = &expr_const_operands_dummy; |
|
|
|
- *expr = declspecs->expr; |
|
+ if (declspecs->expr) |
|
+ { |
|
+ if (*expr) |
|
+ *expr = build2 (COMPOUND_EXPR, TREE_TYPE (declspecs->expr), *expr, |
|
+ declspecs->expr); |
|
+ else |
|
+ *expr = declspecs->expr; |
|
+ } |
|
*expr_const_operands = declspecs->expr_const_operands; |
|
|
|
if (decl_context == FUNCDEF) |
|
--- /dev/null |
|
+++ gcc/testsuite/gcc.c-torture/execute/pr77767.c |
|
@@ -0,0 +1,16 @@ |
|
+/* PR c/77767 */ |
|
+ |
|
+void |
|
+foo (int a, int b[a++], int c, int d[c++]) |
|
+{ |
|
+ if (a != 2 || c != 2) |
|
+ __builtin_abort (); |
|
+} |
|
+ |
|
+int |
|
+main () |
|
+{ |
|
+ int e[10]; |
|
+ foo (1, e, 1, e); |
|
+ return 0; |
|
+}
|
|
|