[incremental] Patch: FYI: fix up VAR_DECLs after lookup

Tom Tromey tromey@redhat.com
Sat Dec 15 00:16:00 GMT 2007


I'm checking this in on the incremental-compiler branch.

This is sort of a lame patch -- it isn't really complete.  But, right
now I'm thinking it is more the direction I want to go: fix up decls
at lookup time, then (later) have a pass that smashes them back together.
I think this approach is maybe the only way to avoid hacking a lot of
c-common.c, which I'd rather avoid.

Tom

ChangeLog:
2007-12-14  Tom Tromey  <tromey@redhat.com>

	* c-decl.c (lookup_name): Wrap variables in a VIEW_CONVERT_EXPR.

Index: c-decl.c
===================================================================
--- c-decl.c	(revision 130936)
+++ c-decl.c	(working copy)
@@ -2956,9 +2956,21 @@
   struct c_binding *b = I_SYMBOL_BINDING (name);
   if (b && !b->invisible)
     {
+      tree result = b->decl;
       if (B_IN_FILE_SCOPE (b))
-	c_parser_lookup_callback (name, b->decl, false);
-      return b->decl;
+	{
+	  c_parser_lookup_callback (name, result, false);
+	  /* We should only need to handle smashed types for
+	     file-scope things.  */
+	  if (TREE_TYPE (result) != error_mark_node
+	      && TREE_CODE (result) == VAR_DECL)
+	    {
+	      tree newtype = C_SMASHED_TYPE_VARIANT (TREE_TYPE (result));
+	      if (newtype != TREE_TYPE (result))
+		result = build1 (VIEW_CONVERT_EXPR, newtype, result);
+	    }
+	}
+      return result;
     }
   c_parser_lookup_callback (name, NULL_TREE, false);
   return 0;



More information about the Gcc-patches mailing list