public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Candidate fix for PR c/7353
@ 2002-10-07 16:52 Zack Weinberg
  2002-10-07 22:59 ` Richard Henderson
  0 siblings, 1 reply; 21+ messages in thread
From: Zack Weinberg @ 2002-10-07 16:52 UTC (permalink / raw)
  To: gcc-patches

PR c/7353, distilled, reports that 

typedef A = 0;  /* equivalent to 'typedef int A;' */

produces an ICE with all versions of GCC since 3.0.  This is an
obscure, rarely-used extension, but if we're going to have it, it
should work.

There are two bugs.  One is that make_decl_rtl is being called on a
TYPE_DECL; it quite properly aborts.  The other is that the code for
handling 'typedef T = expr' was not updated when DECL_ORIGINAL_TYPE
was invented, so we abort in gen_typedef_die.

I believe this patch fixes the bug.  I have one remaining concern:
given

typedef A = 0;
A a;

gdb reports

(gdb) ptype a
type = int

Shouldn't that be type = A?  It does do the same thing for

typedef int B;
B b;

so perhaps this is as intended.

zw

	* c-decl.c (finish_decl): When processing 'typedef T = expr',
	TREE_TYPE (T) should be a copy of TREE_TYPE (expr), as is done
	for normal typedefs.
	* toplev.c (rest_of_decl_compilation): Do not call
	make_decl_rtl on TYPE_DECLs.

===================================================================
Index: c-decl.c
--- c-decl.c	22 Sep 2002 02:03:14 -0000	1.350
+++ c-decl.c	7 Oct 2002 23:45:48 -0000
@@ -2994,7 +2994,8 @@ finish_decl (decl, init, asmspec_tree)
       else
 	{
 	  /* typedef foo = bar; store the type of bar as the type of foo.  */
-	  TREE_TYPE (decl) = TREE_TYPE (init);
+	  TREE_TYPE (decl) = build_type_copy (TREE_TYPE (init));
+	  DECL_ORIGINAL_TYPE (decl) = TREE_TYPE (init);
 	  DECL_INITIAL (decl) = init = 0;
 	}
     }
===================================================================
Index: toplev.c
--- toplev.c	7 Oct 2002 03:01:39 -0000	1.679
+++ toplev.c	7 Oct 2002 23:45:52 -0000
@@ -2272,8 +2272,9 @@ rest_of_decl_compilation (decl, asmspec,
 
   /* Forward declarations for nested functions are not "external",
      but we need to treat them as if they were.  */
-  if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
-      || TREE_CODE (decl) == FUNCTION_DECL)
+  if (TREE_CODE (decl) == FUNCTION_DECL
+      || (TREE_CODE (decl) == VAR_DECL
+	  && (TREE_STATIC (decl) || DECL_EXTERNAL (decl))))
     {
       timevar_push (TV_VARCONST);
 

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2002-11-01 20:05 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-07 16:52 Candidate fix for PR c/7353 Zack Weinberg
2002-10-07 22:59 ` Richard Henderson
2002-10-07 23:12   ` Neil Booth
2002-10-08 18:33     ` Phil Edwards
2002-10-09 11:30     ` Mike Stump
2002-10-07 23:57   ` Zack Weinberg
2002-10-08  2:58     ` Michael Matz
2002-10-08 11:04     ` Richard Henderson
2002-10-09  1:09     ` Joseph S. Myers
2002-10-09  9:50       ` Mark Mitchell
2002-10-09 10:01         ` Zack Weinberg
2002-10-09  9:55       ` Zack Weinberg
2002-10-09 10:01         ` Mark Mitchell
2002-10-09 11:22           ` Zack Weinberg
2002-10-09 11:33             ` Mark Mitchell
2002-10-31 23:03             ` Jason Merrill
2002-11-01  9:45               ` Zack Weinberg
2002-11-01 10:38                 ` Jason Merrill
2002-11-01 10:47                   ` Paolo Carlini
2002-11-01 11:50                   ` Zack Weinberg
2002-11-01 12:05                     ` Mark Mitchell

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).