This is the mail archive of the gcc-patches@gcc.gnu.org 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: post-merge c-format.c fix


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

This fixes a bug introduced by the merge, and found while compiling
bits of gcc with the new compiler.

The real fix is in init_dynamic_diag_info; the GC stuff is probably
not strictly necessary, but is good defense in case we do end up
trying to GC the trees found here.

Basically the problem was that on the trunk, the variable 't' is a
function-scope static, but on the branch it is a real local, so taking
its address is a no-no.

Tom

ChangeLog:
2008-02-27  Tom Tromey  <tromey@redhat.com>

	* Makefile.in (c-format.o): Depend on gt-c-format.h.
	* c-format.c (struct format_state): Mark with GTY.
	(global_format_state): Likewise.
	(construct_format_state): Allocate global_format_state via GC.
	(c_format_finalize): Don't free global_format_state.
	Include gt-c-format.h.
	(init_dynamic_diag_info): Use global diag_t, not '&t'.
	* c-config-lang.in (gtfiles): Add c-format.h, c-format.c.

Index: c-config-lang.in
===================================================================
--- c-config-lang.in	(revision 132644)
+++ c-config-lang.in	(working copy)
@@ -22,4 +22,4 @@
 # files used by C that have garbage collection GTY macros in them
 # which therefore need to be scanned by gengtype.c.
 
-gtfiles="\$(srcdir)/c-lang.c \$(srcdir)/c-tree.h \$(srcdir)/c-decl.c \$(srcdir)/c-common.c \$(srcdir)/c-common.h \$(srcdir)/c-pragma.h \$(srcdir)/c-pragma.c \$(srcdir)/c-objc-common.c \$(srcdir)/c-parser.c"
+gtfiles="\$(srcdir)/c-lang.c \$(srcdir)/c-tree.h \$(srcdir)/c-decl.c \$(srcdir)/c-common.c \$(srcdir)/c-common.h \$(srcdir)/c-pragma.h \$(srcdir)/c-pragma.c \$(srcdir)/c-objc-common.c \$(srcdir)/c-parser.c \$(srcdir)/c-format.h \$(srcdir)/c-format.c"
Index: c-format.c
===================================================================
--- c-format.c	(revision 132688)
+++ c-format.c	(working copy)
@@ -787,27 +787,30 @@
 
 /* An ad-hoc structure holding any global state needed by functions in
    this module.  */
-struct format_state
+struct format_state GTY (())
 {
   /* Memory can be allocated on this obstack by functions in this
      module.  The obstack is deleted at module cleanup time.  */
-  struct obstack obstack;
+  struct obstack GTY ((skip)) obstack;
 
   /* State needed for init_dynamic_asm_fprintf_info.  */
   tree fprintf_hwi;
 
   /* State needed for init_dynamic_gfc_info.  */
   tree locus;
-  format_char_info *gfc_fci;
+  format_char_info * GTY ((skip)) gfc_fci;
 
   /* State needed for init_dynamic_diag_info.  */
   tree diag_t, diag_loc, diag_hwi;
-  format_char_info *diag_fci, *tdiag_fci, *cdiag_fci, *cxxdiag_fci;
-  format_length_info *diag_ls;
+  format_char_info * GTY ((skip)) diag_fci;
+  format_char_info * GTY ((skip)) tdiag_fci;
+  format_char_info * GTY ((skip)) cdiag_fci;
+  format_char_info * GTY ((skip)) cxxdiag_fci;
+  format_length_info * GTY ((skip)) diag_ls;
 };
 
 /* The global format_state object.  */
-static struct format_state *global_format_state;
+static GTY (()) struct format_state *global_format_state;
 
 /* Structure detailing the results of checking a format function call
    where the format expression may be a conditional expression with
@@ -892,7 +895,7 @@
 {
   gcc_assert (!global_format_state);
   /* For the time being this is a singleton module.  */
-  global_format_state = XCNEW (struct format_state);
+  global_format_state = GGC_CNEW (struct format_state);
   gcc_obstack_init (&global_format_state->obstack);
 }
 
@@ -903,7 +906,6 @@
   if (global_format_state)
     {
       obstack_free (&global_format_state->obstack, NULL);
-      free (global_format_state);
       global_format_state = NULL;
       /* dynamic_format_types was allocated on the obstack.  */
       dynamic_format_types = NULL;
@@ -2726,7 +2728,8 @@
 	  global_format_state->diag_fci[i].pointer_count = 1;
 	  i = find_char_info_specifier_index (global_format_state->diag_fci,
 					      'K');
-	  global_format_state->diag_fci[i].types[0].type = &t;
+	  global_format_state->diag_fci[i].types[0].type
+	    = &global_format_state->diag_t;
 	  global_format_state->diag_fci[i].pointer_count = 1;
 	}
 
@@ -2759,7 +2762,8 @@
 	  global_format_state->tdiag_fci[i].pointer_count = 1;
 	  i = find_char_info_specifier_index (global_format_state->tdiag_fci,
 					      'K');
-	  global_format_state->tdiag_fci[i].types[0].type = &t;
+	  global_format_state->tdiag_fci[i].types[0].type
+	    = &global_format_state->diag_t;
 	  global_format_state->tdiag_fci[i].pointer_count = 1;
 	}
 
@@ -2792,7 +2796,8 @@
 	  global_format_state->cdiag_fci[i].pointer_count = 1;
 	  i = find_char_info_specifier_index (global_format_state->cdiag_fci,
 					      'K');
-	  global_format_state->cdiag_fci[i].types[0].type = &t;
+	  global_format_state->cdiag_fci[i].types[0].type
+	    = &global_format_state->diag_t;
 	  global_format_state->cdiag_fci[i].pointer_count = 1;
 	}
 
@@ -2825,7 +2830,8 @@
 	  global_format_state->cxxdiag_fci[i].pointer_count = 1;
 	  i = find_char_info_specifier_index (global_format_state->cxxdiag_fci,
 					      'K');
-	  global_format_state->cxxdiag_fci[i].types[0].type = &t;
+	  global_format_state->cxxdiag_fci[i].types[0].type
+	    = &global_format_state->diag_t;
 	  global_format_state->cxxdiag_fci[i].pointer_count = 1;
 	}
     }
@@ -2942,3 +2948,5 @@
 
   return NULL_TREE;
 }
+
+#include "gt-c-format.h"
Index: stringpool.c
===================================================================
--- stringpool.c	(revision 132644)
+++ stringpool.c	(working copy)
@@ -1,5 +1,5 @@
 /* String pool for GCC.
-   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007
+   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -185,7 +185,13 @@
   if (marking)
     ht_forall (ident_hash, mark_ident, NULL);
   else
-    ht_remove_identifiers (ident_hash, check_ident);
+    {
+      unsigned int previous = ident_hash->nelements;
+      ht_remove_identifiers (ident_hash, check_ident);
+      fprintf (stderr, "Collection removed %u identifiers (%u -> %u)\n",
+	       previous - ident_hash->nelements, previous,
+	       ident_hash->nelements);
+    }
 }
 
 /* Pointer-walking routine for strings (not very interesting, since
Index: Makefile.in
===================================================================
--- Makefile.in	(revision 132688)
+++ Makefile.in	(working copy)
@@ -1826,7 +1826,7 @@
 
 c-format.o : c-format.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) langhooks.h \
 	$(C_COMMON_H) $(FLAGS_H) toplev.h intl.h $(DIAGNOSTIC_H) alloc-pool.h \
-	c-format.h
+	c-format.h gt-c-format.h
 
 c-semantics.o : c-semantics.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
 	$(TREE_H) $(FLAGS_H) toplev.h output.h $(RTL_H) $(GGC_H) \


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