re PR c/9928 (ICE on duplicate enum declaration)
authorEric Botcazou <ebotcazou@libertysurf.fr>
Wed, 12 Mar 2003 09:54:38 +0000 (10:54 +0100)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Wed, 12 Mar 2003 09:54:38 +0000 (09:54 +0000)
PR c/9928
* c-decl.c (duplicate_decls): Discard the initializer of the new decl
only if it is a VAR_DECL.

From-SVN: r64235

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

index f0f4738ad339efedcdb6101206cc9cf0f61a103f..7dc4ec5a490ee39fc49e648721ded8e23cd5f8e9 100644 (file)
@@ -1,3 +1,9 @@
+2003-03-12  Eric Botcazou  <ebotcazou@libertysurf.fr>
+
+       PR c/9928
+       * c-decl.c (duplicate_decls): Discard the initializer of the new decl
+       only if it is a VAR_DECL.
+
 2003-03-12  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        PR optimization/9888
index f7996f1a8126bff746ba3c16d5a82b2041abbf81..2aa0ee77f67fdb2474723efc8565fd8a53baa637 100644 (file)
@@ -1146,7 +1146,8 @@ duplicate_decls (newdecl, olddecl, different_binding_level)
         to variables that were declared between olddecl and newdecl. This
         will make the initializer invalid for olddecl in case it gets
         assigned to olddecl below.  */
-      DECL_INITIAL (newdecl) = 0;
+      if (TREE_CODE (newdecl) == VAR_DECL)
+       DECL_INITIAL (newdecl) = 0;
     }
   /* TLS cannot follow non-TLS declaration.  */
   else if (TREE_CODE (olddecl) == VAR_DECL && TREE_CODE (newdecl) == VAR_DECL
index 3e0633c3ef19c771003f60fae0b61aa9c8523404..73405565b9ccd8b49ae5c8041a1c2bf8b56741d8 100644 (file)
@@ -1,3 +1,7 @@
+2003-03-12  Eric Botcazou  <ebotcazou@libertysurf.fr>
+
+       * gcc.dg/decl-3.c: New test.
+
 2003-03-12  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        * gcc.dg/i386-loop-2.c: New test.
diff --git a/gcc/testsuite/gcc.dg/decl-3.c b/gcc/testsuite/gcc.dg/decl-3.c
new file mode 100644 (file)
index 0000000..b8d00d0
--- /dev/null
@@ -0,0 +1,5 @@
+/* PR c/9928 */
+/* { dg-do compile } */
+
+enum { CODES }; /* { dg-error "previous declaration" } */
+enum { CODES }; /* { dg-error "conflicting types" } */