re PR c/7741 (ICE on conflicting types (make_decl_rtl at varasm.c:834))
authorEric Botcazou <ebotcazou@libertysurf.fr>
Mon, 10 Feb 2003 12:45:54 +0000 (13:45 +0100)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Mon, 10 Feb 2003 12:45:54 +0000 (12:45 +0000)
PR c/7741
* c-decl.c (duplicate_decls): Discard the initializer of the
new decl when the types are conflicting.

Co-Authored-By: Christian Ehrhardt <ehrhardt@mathematik.uni-ulm.de>
From-SVN: r62631

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

index f1879ddcb1e12fc4e3812514e3685350f8341d0a..d0a9caedfa453a28f4db8ba3df77857d9c1b652f 100644 (file)
@@ -1,3 +1,10 @@
+2003-02-10  Eric Botcazou  <ebotcazou@libertysurf.fr>
+            Christian Ehrhardt  <ehrhardt@mathematik.uni-ulm.de>
+
+       PR c/7741
+       * c-decl.c (duplicate_decls): Discard the initializer of the
+       new decl when the types are conflicting.
+
 2003-02-10  Josef Zlomek  <zlomekj@suse.cz>
 
        * Makefile.in (sreal.o): Added.
index a5439316d2e54d89b16a1522be902f29db76da1b..01a35874ecb89172b3a391445033b9a819bcf2b0 100644 (file)
@@ -1140,6 +1140,12 @@ duplicate_decls (newdecl, olddecl, different_binding_level)
            }
        }
       error_with_decl (olddecl, "previous declaration of `%s'");
+
+      /* This is safer because the initializer might contain references
+        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;
     }
   /* TLS cannot follow non-TLS declaration.  */
   else if (TREE_CODE (olddecl) == VAR_DECL && TREE_CODE (newdecl) == VAR_DECL
index d9082807b76deeb945d288e839486dcd1b6a77fa..fd9d5501d3aa85a866bdff2055a0529e91ac78b7 100644 (file)
@@ -1,3 +1,8 @@
+2003-02-10  Eric Botcazou  <ebotcazou@libertysurf.fr>
+            Christian Ehrhardt  <ehrhardt@mathematik.uni-ulm.de>
+
+       * gcc.dg/decl-2.c: New test.
+
 Mon Feb 10 11:41:20 CET 2003  Jan Hubicka  <jh@suse.cz>
 
        * gcc.dg/i386-fpcvt-1.c:  New test.
diff --git a/gcc/testsuite/gcc.dg/decl-2.c b/gcc/testsuite/gcc.dg/decl-2.c
new file mode 100644 (file)
index 0000000..44fbc73
--- /dev/null
@@ -0,0 +1,10 @@
+/* PR c/7411 */
+/* Contributed by Christian Ehrhardt */
+/* { dg-do compile } */
+
+void foo(void)
+{
+  char c;  /* { dg-error "previous declaration" } */
+  int i;
+  int c = i;  /* { dg-error "conflicting types" } */
+}