This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[incremental] Patch: FYI: smash types in VAR_DECL

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

    static int doit (void);

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

    struct table functions[] =

    static int doit (void) { return 23; }

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


2008-03-13  Tom Tromey  <>

	* 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);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]