re PR c/28502 (ICE with invalid declaration after definition)
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>
Sat, 5 Aug 2006 23:41:22 +0000 (23:41 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Sat, 5 Aug 2006 23:41:22 +0000 (23:41 +0000)
PR c/28502
* c-decl.c (validate_proto_after_old_defn): Return false on invalid
argument.

* gcc.dg/proto-1.c: New test.

From-SVN: r115957

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

index 0cbdf6d928e57f991806244000985d345ee636b0..4ac1f1f949bbb6a071c85071c25e8cfdabb532d7 100644 (file)
@@ -1,5 +1,9 @@
 2006-08-05  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
+       PR c/28502
+       * c-decl.c (validate_proto_after_old_defn): Return false on invalid
+       argument.
+
        PR c/27721
        * c-typeck.c (build_modify_expr): Test earlier for non-lvalues.
 
index b900e8a8d5d1399ced1ce17bf8eeeb9568615403..9a0e747c71384a6c58dfa85040bfa37460d9cef0 100644 (file)
@@ -1083,8 +1083,14 @@ validate_proto_after_old_defn (tree newdecl, tree newtype, tree oldtype)
 
   for (;;)
     {
-      tree oldargtype = TYPE_MAIN_VARIANT (TREE_VALUE (oldargs));
-      tree newargtype = TYPE_MAIN_VARIANT (TREE_VALUE (newargs));
+      tree oldargtype = TREE_VALUE (oldargs);
+      tree newargtype = TREE_VALUE (newargs);
+
+      if (oldargtype == error_mark_node || newargtype == error_mark_node)
+       return false;
+
+      oldargtype = TYPE_MAIN_VARIANT (oldargtype);
+      newargtype = TYPE_MAIN_VARIANT (newargtype);
 
       if (END_OF_ARGLIST (oldargtype) && END_OF_ARGLIST (newargtype))
        break;
index 89f1d4a6e31d8cd8dc04babf233470eb17bf5cbd..0cdbbefb0094265c72a75bd4a83bdb8484dc9c28 100644 (file)
@@ -1,5 +1,8 @@
 2006-08-05  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
+       PR c/28502
+       * gcc.dg/proto-1.c: New test.
+
        PR c/27721
        * gcc.dg/lvalue-4.c: New test.
 
diff --git a/gcc/testsuite/gcc.dg/proto-1.c b/gcc/testsuite/gcc.dg/proto-1.c
new file mode 100644 (file)
index 0000000..13c59a8
--- /dev/null
@@ -0,0 +1,5 @@
+/* PR c/28502 */
+/* { dg-do compile } */
+
+void foo() {}      /* { dg-error "previous" } */
+void foo(void[]);  /* { dg-error "array of voids" } */