From 68060abb2c38caa677007b7aaba287c058c73c76 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Mon, 10 Feb 2003 14:01:50 +0100 Subject: [PATCH] re PR c/7741 (ICE on conflicting types (make_decl_rtl at varasm.c:834)) 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 From-SVN: r62636 --- gcc/ChangeLog | 7 +++++++ gcc/c-decl.c | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4d56e63e0c9d..ece8df5528e5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2003-02-10 Eric Botcazou + Christian Ehrhardt + + PR c/7741 + * c-decl.c (duplicate_decls): Discard the initializer of the + new decl when the types are conflicting. + 2003-02-01 Daniel Jacobowitz * dwarf2out.c (gen_type_die): Check for typedefs before calling diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 2c8857fc4964..ea02f2665569 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -1665,6 +1665,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; } else { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 77abd73f44f2..3ad51e68dede 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-02-10 Eric Botcazou + Christian Ehrhardt + + * gcc.dg/decl-2.c: New test. + 2003-02-06 Kaveh R. Ghazi * gcc.dg/20020430-1.c: Fix dg command typos. -- 2.47.2