public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c/7741: [<3.2,3.3> regression] ICE on conflicting types (make_decl_rtl at varasm.c:834)
@ 2002-12-12  9:16 Christian Ehrhardt
  0 siblings, 0 replies; only message in thread
From: Christian Ehrhardt @ 2002-12-12  9:16 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c/7741; it has been noted by GNATS.

From: "Christian Ehrhardt" <ehrhardt@mathematik.uni-ulm.de>
To: gcc-gnats@gcc.gnu.org, gcc-patches@gcc.gnu.org, gnats@kayari.org,
  gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org
Cc:  
Subject: Re: c/7741: [<3.2,3.3> regression] ICE on conflicting types (make_decl_rtl at varasm.c:834)
Date: Thu, 12 Dec 2002 18:06:22 +0100

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7741
 
 Hi,
 
 this PR is about the following illegal code triggering an ICE, I analyzed why:
 int main() {
 	char c;
 	int i;
 	int c = i;
 }
 
 The problem is in duplicate_decls. When duplicate_decl sees the second
 declaration for c with the initializer it effectivly replaces the
 first declaration with the second leading to the equivilent of this code:
 int main ()
 {
 	int c = i;
 	int i;
 }
 
 with the exception that the now undeclared identifier i in the
 initialization auf c is not detected. This will cause the ICE later on.
 I suggest that we replace unconditionally set DECL_INITIAL to NULL
 in duplicate_decls and possibly print an additional warning if the
 initializer like this:
 
 
 --- gcc-cvs/gcc/gcc/c-decl.c.orig	Thu Dec 12 17:59:13 2002
 +++ gcc-cvs/gcc/gcc/c-decl.c	Thu Dec 12 18:03:34 2002
 @@ -1554,7 +1554,7 @@
      return 0;
  
    /* Copy most of the decl-specific fields of NEWDECL into OLDDECL.
 -     But preserve OLDDECL's DECL_UID.  */
 +     But preserve OLDDECL's DECL_UID and drop the initializer.  */
    {
      unsigned olddecl_uid = DECL_UID (olddecl);
  
 @@ -1562,6 +1562,10 @@
  	    (char *) newdecl + sizeof (struct tree_common),
  	    sizeof (struct tree_decl) - sizeof (struct tree_common));
      DECL_UID (olddecl) = olddecl_uid;
 +    /* This is necessary because the initializer might contain references
 +       to varialbes that were declared between olddecl and newdecl. This
 +       will make the initializer invalid for olddecl. */
 +    DECL_INITIAL (olddecl) = NULL;
    }
  
    /* NEWDECL contains the merged attribute lists.
 
    regards   Christian
 
 -- 
 THAT'S ALL FOLKS!


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-12-12 17:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-12  9:16 c/7741: [<3.2,3.3> regression] ICE on conflicting types (make_decl_rtl at varasm.c:834) Christian Ehrhardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).