Message ID | 20160607124453.GZ3014@redhat.com |
---|---|
State | New |
Headers | show |
On Tue, 7 Jun 2016, Marek Polacek wrote: > cc1 crashed on the following invalid code, because it tripped this assert. > The reason why b->nested was false for the FUNCTION_DECL 'x' was that when > doing pushdecl, we found an incompatible duplicate, so pushdecl just bound > 'x' to FUNCTION_DECL 'x', replacing the old binding, without the TREE_PUBLIC > test that sets 'nested'. > > At first I thought about removing the assert but in the end I decided to add > || seen_error -- for invalid code we might do the same as for ERROR_MARK. > > Bootstrapped/regtested on x86_64-linux, ok for trunk? OK.
diff --git gcc/c/c-decl.c gcc/c/c-decl.c index d79802e..8ceb8ba 100644 --- gcc/c/c-decl.c +++ gcc/c/c-decl.c @@ -7054,9 +7054,9 @@ get_parm_info (bool ellipsis, tree expr) break; case FUNCTION_DECL: - /* FUNCTION_DECLs appear when there is an implicit function - declaration in the parameter list. */ - gcc_assert (b->nested); + /* FUNCTION_DECLs appear when there is an implicit function + declaration in the parameter list. */ + gcc_assert (b->nested || seen_error ()); goto set_shadowed; case CONST_DECL: diff --git gcc/testsuite/gcc.dg/noncompile/pr71426.c gcc/testsuite/gcc.dg/noncompile/pr71426.c index e69de29..874e189 100644 --- gcc/testsuite/gcc.dg/noncompile/pr71426.c +++ gcc/testsuite/gcc.dg/noncompile/pr71426.c @@ -0,0 +1,5 @@ +/* PR c/71426 */ +/* { dg-do compile } */ +/* { dg-options "-w" } */ + +int f (int x[x - x ()]); /* { dg-error "undeclared" } */