Fix PR52178

Message ID alpine.LNX.2.00.1202131545340.4999@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Feb. 13, 2012, 2:48 p.m.
This fixes PR52178, the failure to bootstrap Ada with LTO (well,
until you hit the next problem).  A self-referential DECL_QUALIFIER
makes us think that a QUAL_UNION_TYPE type is of variable-size which
makes us stream that type locally, wrecking type merging and later
ICEing in the type verifier.  While it looks that variably_modified_type_p
should not inspect DECL_QUALIFIER a less intrusive patch for 4.7
notices that DECL_QUALIFIER is unused after gimplification and thus
clears it and does not stream it instead.

LTO bootstrapped until I hit an optimization ICE when optimizing gnat1,
a regular bootstrap & regtest is pending on x86_64-unknown-linux-gnu.


2012-02-13  Richard Guenther  <>

	PR lto/52178
	* tree-streamer-in.c (lto_input_ts_field_decl_tree_pointers):
	Do not stream DECL_QUALIFIER.
	* tree-streamer-out.c (write_ts_field_decl_tree_pointers): Likewise.
	* tree.c (free_lang_data_in_decl): Free DECL_QUALIFIER.
	(find_decls_types_r): Do not walk DECL_QUALIFIER.


Index: gcc/tree-streamer-in.c
--- gcc/tree-streamer-in.c	(revision 184151)
+++ gcc/tree-streamer-in.c	(working copy)
@@ -640,7 +640,7 @@  lto_input_ts_field_decl_tree_pointers (s
   DECL_FIELD_OFFSET (expr) = stream_read_tree (ib, data_in);
   DECL_BIT_FIELD_TYPE (expr) = stream_read_tree (ib, data_in);
-  DECL_QUALIFIER (expr) = stream_read_tree (ib, data_in);
+  /* Do not stream DECL_QUALIFIER, it is useless after gimplification.  */
   DECL_FIELD_BIT_OFFSET (expr) = stream_read_tree (ib, data_in);
   DECL_FCONTEXT (expr) = stream_read_tree (ib, data_in);
Index: gcc/tree-streamer-out.c
--- gcc/tree-streamer-out.c	(revision 184151)
+++ gcc/tree-streamer-out.c	(working copy)
@@ -552,7 +552,7 @@  write_ts_field_decl_tree_pointers (struc
   stream_write_tree (ob, DECL_FIELD_OFFSET (expr), ref_p);
   stream_write_tree (ob, DECL_BIT_FIELD_TYPE (expr), ref_p);
-  stream_write_tree (ob, DECL_QUALIFIER (expr), ref_p);
+  /* Do not stream DECL_QUALIFIER, it is useless after gimplification.  */
   stream_write_tree (ob, DECL_FIELD_BIT_OFFSET (expr), ref_p);
   stream_write_tree (ob, DECL_FCONTEXT (expr), ref_p);
Index: gcc/tree.c
--- gcc/tree.c	(revision 184151)
+++ gcc/tree.c	(working copy)
@@ -4596,7 +4596,10 @@  free_lang_data_in_decl (tree decl)
   free_lang_data_in_one_sizepos (&DECL_SIZE (decl));
   free_lang_data_in_one_sizepos (&DECL_SIZE_UNIT (decl));
   if (TREE_CODE (decl) == FIELD_DECL)
-    free_lang_data_in_one_sizepos (&DECL_FIELD_OFFSET (decl));
+    {
+      free_lang_data_in_one_sizepos (&DECL_FIELD_OFFSET (decl));
+    }
  if (TREE_CODE (decl) == FUNCTION_DECL)
@@ -4800,7 +4803,6 @@  find_decls_types_r (tree *tp, int *ws, v
 	  fld_worklist_push (DECL_FIELD_OFFSET (t), fld);
 	  fld_worklist_push (DECL_BIT_FIELD_TYPE (t), fld);
-	  fld_worklist_push (DECL_QUALIFIER (t), fld);
 	  fld_worklist_push (DECL_FIELD_BIT_OFFSET (t), fld);
 	  fld_worklist_push (DECL_FCONTEXT (t), fld);