Check for TYPE_NAME in type_with_linkage_p.
authorMartin Liska <mliska@suse.cz>
Fri, 29 Nov 2019 09:03:25 +0000 (10:03 +0100)
committerMartin Liska <marxin@gcc.gnu.org>
Fri, 29 Nov 2019 09:03:25 +0000 (09:03 +0000)
2019-11-29  Martin Liska  <mliska@suse.cz>

PR lto/91574
* ipa-devirt.c (types_same_for_odr): Check for existence
of TYPE_NAMEs first.
2019-11-29  Martin Liska  <mliska@suse.cz>

PR lto/91574
* g++.dg/lto/pr91574_0.C: New test.

From-SVN: r278829

gcc/ChangeLog
gcc/ipa-devirt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lto/pr91574_0.C [new file with mode: 0644]

index 1ef3bc2de74c7d663f72e210c2711922fe9d6129..229e2b6b7ef5f138b1150d4b45a2b1e73e263bde 100644 (file)
@@ -1,3 +1,9 @@
+2019-11-29  Martin Liska  <mliska@suse.cz>
+
+       PR lto/91574
+       * ipa-devirt.c (types_same_for_odr): Check for existence
+       of TYPE_NAMEs first.
+
 2019-11-29  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/92704
index 0b2475ca2923e49809a16d24cc622b2ff792795d..a884a465a5d0758ade2d607ab93bcabe0250e60a 100644 (file)
@@ -356,6 +356,13 @@ types_same_for_odr (const_tree type1, const_tree type2)
       || (type_with_linkage_p (type2) && type_in_anonymous_namespace_p (type2)))
     return false;
 
+  /* If both type has mangled defined check if they are same.
+     Watch for anonymous types which are all mangled as "<anon">.  */
+  if (!type_with_linkage_p (type1) || !type_with_linkage_p (type2))
+    return false;
+  if (type_in_anonymous_namespace_p (type1)
+      || type_in_anonymous_namespace_p (type2))
+    return false;
   return (DECL_ASSEMBLER_NAME (TYPE_NAME (type1))
          == DECL_ASSEMBLER_NAME (TYPE_NAME (type2)));
 }
index b787896dd572025a3db7bd8251b1a5af9a0f7cd5..e0c37ddba900a2cad43bf4abc2a11c4a98b6d9a1 100644 (file)
@@ -1,3 +1,8 @@
+2019-11-29  Martin Liska  <mliska@suse.cz>
+
+       PR lto/91574
+       * g++.dg/lto/pr91574_0.C: New test.
+
 2019-11-29  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/92704
diff --git a/gcc/testsuite/g++.dg/lto/pr91574_0.C b/gcc/testsuite/g++.dg/lto/pr91574_0.C
new file mode 100644 (file)
index 0000000..346a801
--- /dev/null
@@ -0,0 +1,23 @@
+// PR lto/91574
+// { dg-lto-do link }
+// { dg-lto-options { { -fPIC -flto -O2 } } }
+// { dg-require-effective-target shared }
+// { dg-require-effective-target fpic }
+// { dg-extra-ld-options "-shared" }
+
+class A
+{
+public:
+  virtual ~A ();
+  A (A &);
+  virtual unsigned m_fn1 () const;
+};
+class B : A
+{
+  unsigned m_fn1 () const;
+};
+void
+fn1 (B p1)
+{
+  B a[]{p1, p1};
+}