re PR c/77767 (Side-effect from VLA array parameters lost)

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.

From-SVN: r243832
This commit is contained in:
Jakub Jelinek 2016-12-21 01:07:49 +01:00 committed by Jakub Jelinek
parent a388bdc777
commit d17680f342
4 changed files with 39 additions and 2 deletions

View File

@ -1,3 +1,9 @@
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.
2016-12-20 Richard Biener <rguenther@suse.de>
* gimple-parser.c (c_parser_gimple_compound_statement): Improve

View File

@ -5580,11 +5580,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)

View File

@ -1,3 +1,8 @@
2016-12-21 Jakub Jelinek <jakub@redhat.com>
PR c/77767
* gcc.c-torture/execute/pr77767.c: New test.
2016-12-20 Pat Haugen <pthaugen@us.ibm.com>
* gcc.dg/sms-3.c: Add -fno-sched-pressure for powerpc.

View File

@ -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;
}