re PR debug/42425 (ICE declaring local class)
authorRichard Guenther <rguenther@suse.de>
Mon, 26 Apr 2010 09:13:00 +0000 (09:13 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 26 Apr 2010 09:13:00 +0000 (09:13 +0000)
2010-04-26  Richard Guenther  <rguenther@suse.de>

PR lto/42425
* tree.c (free_lang_data_in_type): Do not free TYPE_CONTEXT
if emitting debug information and it is either a function
or a namespace decl.

* g++.dg/lto/20100423-2_0.C: New testcase.

From-SVN: r158722

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lto/20100423-2_0.C [new file with mode: 0644]
gcc/tree.c

index 3b4ed3c..54ad269 100644 (file)
@@ -1,3 +1,10 @@
+2010-04-26  Richard Guenther  <rguenther@suse.de>
+
+       PR lto/42425
+       * tree.c (free_lang_data_in_type): Do not free TYPE_CONTEXT
+       if emitting debug information and it is either a function
+       or a namespace decl.
+
 2010-04-26  Ira Rosen  <irar@il.ibm.com>
 
        * tree-vectorizer.h (struct _stmt_vec_info): Add new field to 
index badf910..e041658 100644 (file)
@@ -1,3 +1,8 @@
+2010-04-26  Richard Guenther  <rguenther@suse.de>
+
+       PR lto/42425
+       * g++.dg/lto/20100423-2_0.C: New testcase.
+
 2010-04-26  Ira Rosen  <irar@il.ibm.com>
 
        * gcc.dg/vect/bb-slp-23.c: New test.
diff --git a/gcc/testsuite/g++.dg/lto/20100423-2_0.C b/gcc/testsuite/g++.dg/lto/20100423-2_0.C
new file mode 100644 (file)
index 0000000..2ab6bdc
--- /dev/null
@@ -0,0 +1,14 @@
+// { dg-lto-do assemble }
+// { dg-lto-options {{-flto -g}} }
+
+struct A
+{
+  virtual ~A();
+};
+
+void foo()
+{
+  struct B : A {};
+  B b;
+}
+
index 561367b..8eeecff 100644 (file)
@@ -4258,7 +4258,12 @@ free_lang_data_in_type (tree type)
       TYPE_LANG_SLOT_1 (type) = NULL_TREE;
     }
 
-  TYPE_CONTEXT (type) = NULL_TREE;
+  if (debug_info_level < DINFO_LEVEL_TERSE
+      || (TYPE_CONTEXT (type)
+         && TREE_CODE (TYPE_CONTEXT (type)) != FUNCTION_DECL
+         && TREE_CODE (TYPE_CONTEXT (type)) != NAMESPACE_DECL))
+    TYPE_CONTEXT (type) = NULL_TREE;
+
   if (debug_info_level < DINFO_LEVEL_TERSE)
     TYPE_STUB_DECL (type) = NULL_TREE;
 }