diff mbox

Fix PR51650

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

Commit Message

Richard Biener Dec. 22, 2011, 3:24 p.m. UTC
This fixes PR51650 - it seems we cannot avoid playing the dwarf2out
way in the LTO frontend, so we need to announce typedefs to it.

The following patch does that, at the most convenient place (it may
look odd though, but it's the only place we'll see all TYPE_DECLs).

LTO bootstrapped and tested on x86_64-unknown-linux-gnu, SPEC 2k6
LTO -g smoke-tested and applied.

Richard.

2011-12-22  Richard Guenther  <rguenther@suse.de>

	PR lto/51650
	* lto.c (uniquify_nodes): Register TYPE_DECLs with the
	debuginfo machinery.

	* g++.dg/lto/pr51650-1_0.C: New testcase.
	* g++.dg/lto/pr51650-2_0.C: Likewise.
diff mbox

Patch

Index: gcc/lto/lto.c
===================================================================
--- gcc/lto/lto.c	(revision 182617)
+++ gcc/lto/lto.c	(working copy)
@@ -881,6 +881,9 @@  uniquify_nodes (struct data_in *data_in,
 	lto_register_var_decl_in_symtab (data_in, t);
       else if (TREE_CODE (t) == FUNCTION_DECL && !DECL_BUILT_IN (t))
 	lto_register_function_decl_in_symtab (data_in, t);
+      else if (!flag_wpa
+	       && TREE_CODE (t) == TYPE_DECL)
+	debug_hooks->type_decl (t, !DECL_FILE_SCOPE_P (t));
       else if (TYPE_P (t) && !TYPE_CANONICAL (t))
 	TYPE_CANONICAL (t) = gimple_register_canonical_type (t);
     }
Index: gcc/testsuite/g++.dg/lto/pr51650-1_0.C
===================================================================
--- gcc/testsuite/g++.dg/lto/pr51650-1_0.C	(revision 0)
+++ gcc/testsuite/g++.dg/lto/pr51650-1_0.C	(revision 0)
@@ -0,0 +1,19 @@ 
+// { dg-lto-do link }
+// { dg-lto-options { { -flto -g } } }
+
+struct T;
+struct C 
+{
+    typedef ::T T;
+    static T *m ()
+      {
+	static T *d;
+	return d;
+      }
+};
+int
+fn ()
+{
+  C::m ();
+}
+int main() {}
Index: gcc/testsuite/g++.dg/lto/pr51650-2_0.C
===================================================================
--- gcc/testsuite/g++.dg/lto/pr51650-2_0.C	(revision 0)
+++ gcc/testsuite/g++.dg/lto/pr51650-2_0.C	(revision 0)
@@ -0,0 +1,9 @@ 
+// { dg-lto-do link }
+// { dg-lto-options { { -flto -g } } }
+
+typedef struct { } X;
+int main ()
+{
+  typedef X **P;
+  P g = 0;
+}