re PR c/71426 (gcc ICE on x86_64-linux-gnu in get_parm_info, at c/c-decl.c:7059)
authorMarek Polacek <polacek@redhat.com>
Wed, 8 Jun 2016 06:41:55 +0000 (06:41 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Wed, 8 Jun 2016 06:41:55 +0000 (06:41 +0000)
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.

From-SVN: r237196

gcc/c/ChangeLog
gcc/c/c-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/noncompile/pr71426.c [new file with mode: 0644]

index 8617f08f97805fc56dceb138691407500f262b81..9f0b91afb6af5864cd0f9722100856da1df8e247 100644 (file)
@@ -3,6 +3,10 @@
        PR c/71418
        * c-decl.c (grokdeclarator): Check TYPE_P.
 
+       PR c/71426
+       * c-decl.c (get_parm_info): Don't crash on an assert on invalid
+       code.
+
 2016-06-07  David Malcolm  <dmalcolm@redhat.com>
 
        * c-parser.c (c_parser_postfix_expression): In __builtin_offsetof
index ac83e2fa5190fe532106464cb395714e19c1d511..5c08c5947c03dc3db7b467c83195cd5d93554a98 100644 (file)
@@ -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:
index 607f21c3329b735e853f0253f093d944ff0fd5c1..0177653452b9cf8b5020bc4558b871eb1ff36e4c 100644 (file)
@@ -3,6 +3,9 @@
        PR c/71418
        * gcc.dg/noncompile/pr71418.c: New test.
 
+       PR c/71426
+       * gcc.dg/noncompile/pr71426.c: New test.
+
 2016-06-07  Jan Hubicka  <hubicka@ucw.cz>
 
        * gcc.dg/ipa/inlinehint-4.c: Disable partial inlining.
diff --git a/gcc/testsuite/gcc.dg/noncompile/pr71426.c b/gcc/testsuite/gcc.dg/noncompile/pr71426.c
new file mode 100644 (file)
index 0000000..874e189
--- /dev/null
@@ -0,0 +1,5 @@
+/* PR c/71426 */
+/* { dg-do compile } */
+/* { dg-options "-w" } */
+
+int f (int x[x - x ()]); /* { dg-error "undeclared" } */