re PR lto/87906 (ICE in tree check: expected block, have function_decl in block_ultim...
authorRichard Biener <rguenther@suse.de>
Wed, 7 Nov 2018 08:06:57 +0000 (08:06 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 7 Nov 2018 08:06:57 +0000 (08:06 +0000)
2018-11-07  Richard Biener  <rguenther@suse.de>

PR lto/87906
* tree-streamer-in.c (lto_input_ts_block_tree_pointers): Fixup
BLOCK_ABSTRACT_ORIGIN to be the ultimate origin.

* g++.dg/lto/pr87906_0.C: New testcase.
* g++.dg/lto/pr87906_1.C: Likewise.

From-SVN: r265861

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lto/pr87906_0.C [new file with mode: 0644]
gcc/testsuite/g++.dg/lto/pr87906_1.C [new file with mode: 0644]
gcc/tree-streamer-in.c

index d1fde63..a34bf51 100644 (file)
@@ -1,3 +1,9 @@
+2018-11-07  Richard Biener  <rguenther@suse.de>
+
+       PR lto/87906
+       * tree-streamer-in.c (lto_input_ts_block_tree_pointers): Fixup
+       BLOCK_ABSTRACT_ORIGIN to be the ultimate origin.
+
 2018-11-07  Alexandre Oliva <aoliva@redhat.com>
 
        PR rtl-optimization/87874
index 66a09d6..5b07259 100644 (file)
@@ -1,3 +1,9 @@
+2018-11-07  Richard Biener  <rguenther@suse.de>
+
+       PR lto/87906
+       * g++.dg/lto/pr87906_0.C: New testcase.
+       * g++.dg/lto/pr87906_1.C: Likewise.
+
 2018-11-07  Alexandre Oliva <aoliva@redhat.com>
 
        PR rtl-optimization/87874
diff --git a/gcc/testsuite/g++.dg/lto/pr87906_0.C b/gcc/testsuite/g++.dg/lto/pr87906_0.C
new file mode 100644 (file)
index 0000000..08e7ed3
--- /dev/null
@@ -0,0 +1,35 @@
+// { dg-lto-do link }
+// { dg-lto-options { { -O -fPIC -flto } } }
+// { dg-extra-ld-options "-shared -nostdlib" }
+
+namespace com {
+namespace sun {
+namespace star {}
+} // namespace sun
+} // namespace com
+namespace a = com::sun::star;
+namespace com {
+namespace sun {
+namespace star {
+namespace uno {
+class a {
+public:
+  ~a();
+};
+
+class b {
+public:
+  ~b();
+  a c;
+};
+class c {
+  b e;
+};
+class RuntimeException : b {};
+} // namespace uno
+} // namespace star
+} // namespace sun
+} // namespace com
+template <typename> void d(int) { throw a::uno::RuntimeException(); }
+int f;
+void g() { d<a::uno::b>(f); }
diff --git a/gcc/testsuite/g++.dg/lto/pr87906_1.C b/gcc/testsuite/g++.dg/lto/pr87906_1.C
new file mode 100644 (file)
index 0000000..ee5849f
--- /dev/null
@@ -0,0 +1,23 @@
+namespace com {
+namespace sun {
+namespace star {
+namespace uno {
+class a {
+public:
+  ~a();
+};
+class b {
+public:
+~b();
+  a c;
+};
+class RuntimeException : b {};
+} // namespace uno
+class C : uno::RuntimeException {};
+} // namespace star
+} // namespace sun
+} // namespace com
+using com::sun::star::C;
+using com::sun::star::uno::RuntimeException;
+void d() { throw RuntimeException(); }
+void e() { C(); }
index f1e8244..a1e67d6 100644 (file)
@@ -914,6 +914,12 @@ lto_input_ts_block_tree_pointers (struct lto_input_block *ib,
 
   BLOCK_SUPERCONTEXT (expr) = stream_read_tree (ib, data_in);
   BLOCK_ABSTRACT_ORIGIN (expr) = stream_read_tree (ib, data_in);
+  /* We may end up prevailing a decl with DECL_ORIGIN (t) != t here
+     which breaks the invariant that BLOCK_ABSTRACT_ORIGIN is the
+     ultimate origin.  Fixup here.
+     ???  This should get fixed with moving to DIE references.  */
+  if (DECL_P (BLOCK_ORIGIN (expr)))
+    BLOCK_ABSTRACT_ORIGIN (expr) = DECL_ORIGIN (BLOCK_ABSTRACT_ORIGIN (expr));
   /* Do not stream BLOCK_NONLOCALIZED_VARS.  We cannot handle debug information
      for early inlined BLOCKs so drop it on the floor instead of ICEing in
      dwarf2out.c.  */