Patchwork Fix PR48073

login
register
mail settings
Submitter Richard Guenther
Date March 11, 2011, 3:58 p.m.
Message ID <alpine.LNX.2.00.1103111657070.25982@zhemvz.fhfr.qr>
Download mbox | patch
Permalink /patch/86432/
State New
Headers show

Comments

Richard Guenther - March 11, 2011, 3:58 p.m.
This fixes PR48073 - we are not interested in types on IDENTIFIER_NODEs
for LTO and thus we don't need to walk types or decls that hang off
such types.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2011-03-11  Richard Guenther  <rguenther@suse.de>

	PR lto/48073
	* tree.c (find_decls_types_r): Do not walk types only reachable
	from IDENTIFIER_NODEs.

	* g++.dg/lto/20110311-1_0.C: New testcase.
Michael Matz - March 11, 2011, 4:08 p.m.
Hi,

On Fri, 11 Mar 2011, Richard Guenther wrote:

> This fixes PR48073 - we are not interested in types on IDENTIFIER_NODEs 
> for LTO and thus we don't need to walk types or decls that hang off such 
> types.

free_lang_data should probably clear TREE_TYPE for IDENTIFIER_NODEs then.


Ciao,
Michael.

Patch

Index: gcc/tree.c
===================================================================
--- gcc/tree.c	(revision 170868)
+++ gcc/tree.c	(working copy)
@@ -4822,7 +4822,8 @@  find_decls_types_r (tree *tp, int *ws, v
       fld_worklist_push (BLOCK_ABSTRACT_ORIGIN (t), fld);
     }
 
-  fld_worklist_push (TREE_TYPE (t), fld);
+  if (TREE_CODE (t) != IDENTIFIER_NODE)
+    fld_worklist_push (TREE_TYPE (t), fld);
 
   return NULL_TREE;
 }
Index: gcc/testsuite/g++.dg/lto/20110311-1_0.C
===================================================================
--- gcc/testsuite/g++.dg/lto/20110311-1_0.C	(revision 0)
+++ gcc/testsuite/g++.dg/lto/20110311-1_0.C	(revision 0)
@@ -0,0 +1,51 @@ 
+/* { dg-lto-do link } */
+/* { dg-extra-ld-options "-r -nostdlib" } */
+
+struct NullType {};
+
+template <class T, class U>
+struct TList
+{
+    typedef T Head;
+    typedef U Tail;
+};
+
+template <class T>
+struct TListLength {};
+
+template <class T, class U>
+struct TListLength<TList<T,U> >
+{
+    enum
+    {
+        Ret = 1 + TListLength<U>::Ret
+    };
+};
+
+template <>
+struct TListLength<NullType>
+{
+    enum
+    {
+        Ret = 0
+    };
+};
+
+template <class Moves>
+class DDQMC
+{
+public:
+    int* moves[TListLength<Moves>::Ret];
+    inline DDQMC();
+private:
+};
+
+template <class Moves>
+DDQMC<Moves>::DDQMC()
+{
+}
+
+int main()
+{
+    typedef DDQMC< TList<float, TList<int, NullType> > > mytype;
+}