diff mbox

[C] Fix ICE-on-invalid with old-style-parameter-declaration and enum (PR c/71266)

Message ID 20160525140058.GC17920@redhat.com
State New
Headers show

Commit Message

Marek Polacek May 25, 2016, 2 p.m. UTC
ICE-on-invalid on old-style-parameter-declaration arising from adding a bogus
parameter to the vector of parameters (seen_args).  Skipping such parameters 
prevents the ICE later on.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2016-05-25  Marek Polacek  <polacek@redhat.com>

	PR c/71266
	* c-decl.c (store_parm_decls_oldstyle): Skip non-PARM_DECLs.

	* gcc.dg/noncompile/old-style-parm-3.c: New test.


	Marek

Comments

Joseph Myers May 25, 2016, 2:50 p.m. UTC | #1
On Wed, 25 May 2016, Marek Polacek wrote:

> ICE-on-invalid on old-style-parameter-declaration arising from adding a bogus
> parameter to the vector of parameters (seen_args).  Skipping such parameters 
> prevents the ICE later on.
> 
> Bootstrapped/regtested on x86_64-linux, ok for trunk?

OK.
diff mbox

Patch

diff --git gcc/c/c-decl.c gcc/c/c-decl.c
index 9441fbb..96bd491 100644
--- gcc/c/c-decl.c
+++ gcc/c/c-decl.c
@@ -8605,8 +8605,11 @@  store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info)
 	    continue;
 	  /* If we got something other than a PARM_DECL it is an error.  */
 	  if (TREE_CODE (decl) != PARM_DECL)
-	    error_at (DECL_SOURCE_LOCATION (decl),
-		      "%qD declared as a non-parameter", decl);
+	    {
+	      error_at (DECL_SOURCE_LOCATION (decl),
+			"%qD declared as a non-parameter", decl);
+	      continue;
+	    }
 	  /* If the declaration is already marked, we have a duplicate
 	     name.  Complain and ignore the duplicate.  */
 	  else if (seen_args.contains (decl))
diff --git gcc/testsuite/gcc.dg/noncompile/old-style-parm-3.c gcc/testsuite/gcc.dg/noncompile/old-style-parm-3.c
index e69de29..f9d6d0f 100644
--- gcc/testsuite/gcc.dg/noncompile/old-style-parm-3.c
+++ gcc/testsuite/gcc.dg/noncompile/old-style-parm-3.c
@@ -0,0 +1,9 @@ 
+/* PR c/71266 */
+/* { dg-do compile } */
+
+int fn1 (a)
+  enum b {  /* { dg-warning "empty declaration" } */
+    a /* { dg-error ".a. declared as a non-parameter" } */
+  };
+{
+}