[incremental] Patch: FYI: smash types in VAR_DECL

Tom Tromey tromey@redhat.com
Thu Mar 13 18:10:00 GMT 2008


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

We weren't smashing types and decls in a VAR_DECL's DECL_INITIAL.
This meant that we would not emit a static function in a case like
this:

    static int doit (void);

    struct table {
      int (*func) (void);
    };

    struct table functions[] =
      {
        doit,
        0
      };

    static int doit (void) { return 23; }

This patch fixes the problem and lets us get a bit closer to building
libjava.

Tom

ChangeLog:
2008-03-13  Tom Tromey  <tromey@redhat.com>

	* c-decl.c (hand_off_decls) <VAR_DECL>: Call
	rewrite_types_and_globals on the DECL_INITIAL.

Index: c-decl.c
===================================================================
--- c-decl.c	(revision 132956)
+++ c-decl.c	(working copy)
@@ -8625,6 +8625,14 @@
 	       when a tentative file-scope definition is seen.
 	       But at end of compilation, do output code for them.  */
 	    DECL_DEFER_OUTPUT (decl) = 1;
+	  else
+	    {
+	      bool save = c_override_global_bindings_to_false;
+	      c_override_global_bindings_to_false = true;
+	      walk_tree (&DECL_INITIAL (decl), rewrite_types_and_globals,
+			 map, NULL);
+	      c_override_global_bindings_to_false = save;
+	    }
 	  rest_of_decl_compilation (decl, true, false);
 	  break;
 



More information about the Gcc-patches mailing list