From: Martin Liska Date: Fri, 29 Nov 2019 09:03:25 +0000 (+0100) Subject: Check for TYPE_NAME in type_with_linkage_p. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=efeeda757691b13e716c6681e7f6af5f85927e92;p=gcc.git Check for TYPE_NAME in type_with_linkage_p. 2019-11-29 Martin Liska PR lto/91574 * ipa-devirt.c (types_same_for_odr): Check for existence of TYPE_NAMEs first. 2019-11-29 Martin Liska PR lto/91574 * g++.dg/lto/pr91574_0.C: New test. From-SVN: r278829 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1ef3bc2de74..229e2b6b7ef 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-11-29 Martin Liska + + PR lto/91574 + * ipa-devirt.c (types_same_for_odr): Check for existence + of TYPE_NAMEs first. + 2019-11-29 Richard Biener PR tree-optimization/92704 diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c index 0b2475ca292..a884a465a5d 100644 --- a/gcc/ipa-devirt.c +++ b/gcc/ipa-devirt.c @@ -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 ". */ + 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))); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b787896dd57..e0c37ddba90 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-11-29 Martin Liska + + PR lto/91574 + * g++.dg/lto/pr91574_0.C: New test. + 2019-11-29 Richard Biener 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 index 00000000000..346a8015c98 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr91574_0.C @@ -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}; +}