Patchwork Fix find_decls_types_r / free_lang_data_in_type inconsistency

login
register
mail settings
Submitter Richard Guenther
Date July 4, 2012, 10:34 a.m.
Message ID <alpine.LNX.2.00.1207041233590.17233@jbgna.fhfr.qr>
Download mbox | patch
Permalink /patch/168948/
State New
Headers show

Comments

Richard Guenther - July 4, 2012, 10:34 a.m.
The previous patch adjusting free_lang_data_in_type missed to adjust
find_decls_types_r.  We might not be visiting all types we use in the
end due to this.

LTO bootstrapped and tested on x86_64-unknown-linux-gnu, applying to
trunk and branch.

Richard.

2012-07-04  Richard Guenther  <rguenther@suse.de>

	* tree.c (find_decls_types_r): Handle TYPE_CONTEXT the same
	as in free_lang_data_in_type.

Patch

Index: gcc/tree.c
===================================================================
--- gcc/tree.c	(revision 189248)
+++ gcc/tree.c	(working copy)
@@ -4910,7 +4910,15 @@  find_decls_types_r (tree *tp, int *ws, v
       fld_worklist_push (TYPE_MAIN_VARIANT (t), fld);
       /* Do not walk TYPE_NEXT_VARIANT.  We do not stream it and thus
          do not and want not to reach unused variants this way.  */
-      fld_worklist_push (TYPE_CONTEXT (t), fld);
+      if (TYPE_CONTEXT (t))
+	{
+	  tree ctx = TYPE_CONTEXT (t);
+	  /* We adjust BLOCK TYPE_CONTEXTs to the innermost non-BLOCK one.
+	     So push that instead.  */
+	  while (ctx && TREE_CODE (ctx) == BLOCK)
+	    ctx = BLOCK_SUPERCONTEXT (ctx);
+	  fld_worklist_push (ctx, fld);
+	}
       /* Do not walk TYPE_CANONICAL.  We do not stream it and thus do not
 	 and want not to reach unused types this way.  */