* C PATCH for c/71426 (ICE with bogus parameter)
@ 2016-06-07 12:45 Marek Polacek
2016-06-07 21:37 ` Joseph Myers
0 siblings, 1 reply; 2+ messages in thread
From: Marek Polacek @ 2016-06-07 12:45 UTC (permalink / raw)
To: GCC Patches, Joseph Myers
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 <polacek@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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: C PATCH for c/71426 (ICE with bogus parameter)
2016-06-07 12:45 C PATCH for c/71426 (ICE with bogus parameter) Marek Polacek
@ 2016-06-07 21:37 ` Joseph Myers
0 siblings, 0 replies; 2+ messages in thread
From: Joseph Myers @ 2016-06-07 21:37 UTC (permalink / raw)
To: Marek Polacek; +Cc: GCC Patches
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.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-06-07 21:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-07 12:45 C PATCH for c/71426 (ICE with bogus parameter) Marek Polacek
2016-06-07 21:37 ` Joseph Myers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).