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 f0f4738..7dc4ec5 100644 (file)
@@ -1,5 +1,11 @@
 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
        * config/i386/i386.md (jcc_1): Fix range.
        (jcc_2): Likewise.
index f7996f1..2aa0ee7 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 3e0633c..7340556 100644 (file)
@@ -1,5 +1,9 @@
 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.
 
 2003-03-11  Mark Mitchell  <mark@codesourcery.com>
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" } */