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? 2016-06-07 Marek Polacek <pola...@redhat.com> PR c/71426 * c-decl.c (get_parm_info): Don't crash on an assert on invalid code. * gcc.dg/noncompile/pr71426.c: New test. 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" } */ Marek