re PR debug/53470 (ICE when linking with -g in splice_child_die, at dwarf2out.c:4264)
authorRichard Guenther <rguenther@suse.de>
Mon, 11 Jun 2012 14:14:09 +0000 (14:14 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 11 Jun 2012 14:14:09 +0000 (14:14 +0000)
2012-06-11  Richard Guenther  <rguenther@suse.de>

PR middle-end/53470
* tree.c (free_lang_data_in_type): Do not clear TYPE_CONTEXT but
replace it with the first non-BLOCK context.

* g++.dg/lto/pr53470_0.C: New testcase.
* gcc.dg/lto/pr53470_0.c: Likewise.

From-SVN: r188387

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

index d3127b00bb08d53a82b8f9c302519022590ff431..fa5a6728c7a716095abe9b80be667ae2145c1c94 100644 (file)
@@ -1,3 +1,9 @@
+2012-06-11  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/53470
+       * tree.c (free_lang_data_in_type): Do not clear TYPE_CONTEXT but
+       replace it with the first non-BLOCK context.
+
 2012-06-11  Richard Guenther  <rguenther@suse.de>
 
        * alias.c (aliases_everything_p): Remove.
index baa04c04ad2223792bf7b646b24a0a17affb53ce..b57f1713f502d5ba063c4565af9b70169cc98274 100644 (file)
@@ -1,3 +1,9 @@
+2012-06-11  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/53470
+       * g++.dg/lto/pr53470_0.C: New testcase.
+       * gcc.dg/lto/pr53470_0.c: Likewise.
+
 2012-06-11  Richard Guenther  <rguenther@suse.de>
 
        PR c++/53616
diff --git a/gcc/testsuite/g++.dg/lto/pr53470_0.C b/gcc/testsuite/g++.dg/lto/pr53470_0.C
new file mode 100644 (file)
index 0000000..217c02a
--- /dev/null
@@ -0,0 +1,26 @@
+// { dg-lto-do link }
+// { dg-lto-options { { -g -flto } } }
+
+class sp_counted_base;
+class shared_count {
+  sp_counted_base *pi_;
+public:
+  template<class Y> shared_count(Y) : pi_() {}
+  ~shared_count() {}
+};
+template<class T> struct shared_ptr {
+  T element_type;
+  template<class Y> shared_ptr(Y) : pn(0) {}
+  shared_count pn;
+};
+template<class> class ECGetterBase;
+template<class T> struct ExtensionCord {
+  struct Holder {
+    ECGetterBase<T> *getter_;
+  };
+  ExtensionCord() : holder_(new Holder) {}
+
+  shared_ptr<Holder> holder_;
+};
+ExtensionCord<int> a;
+int main() {}
diff --git a/gcc/testsuite/gcc.dg/lto/pr53470_0.c b/gcc/testsuite/gcc.dg/lto/pr53470_0.c
new file mode 100644 (file)
index 0000000..3c799f6
--- /dev/null
@@ -0,0 +1,9 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options { { -flto } { -flto -g } } } */
+
+int main ()
+{
+  { 
+    union A { } v; 
+  }
+}
index e180340c12ce80281835d3165e2f980e33b1d564..d3c2a19d7d6f0ac0770cde8c3ab834a1e5909f45 100644 (file)
@@ -4575,11 +4575,17 @@ free_lang_data_in_type (tree type)
   free_lang_data_in_one_sizepos (&TYPE_SIZE (type));
   free_lang_data_in_one_sizepos (&TYPE_SIZE_UNIT (type));
 
-  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 (TYPE_CONTEXT (type)
+      && TREE_CODE (TYPE_CONTEXT (type)) == BLOCK)
+    {
+      tree ctx = TYPE_CONTEXT (type);
+      do
+       {
+         ctx = BLOCK_SUPERCONTEXT (ctx);
+       }
+      while (ctx && TREE_CODE (ctx) == BLOCK);
+      TYPE_CONTEXT (type) = ctx;
+    }
 }