From 56f1a16caeb447934c4c5209664984560b17e63a Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Tue, 1 Oct 2019 20:21:31 +0200 Subject: [PATCH] re PR c++/91222 (507.cactuBSSN_r build fails in warn_types_mismatch at ipa-devirt.c:1006 since r273571) PR lto/91222 * ipa-devirt.c (warn_types_mismatch): Do not ICE when anonymous type is matched with non-C++ type * g++.dg/lto/odr-6_0.C: New testcase. * g++.dg/lto/odr-6_1.c: New testcase. From-SVN: r276420 --- gcc/ChangeLog | 6 ++++++ gcc/ipa-devirt.c | 10 +++++----- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/lto/odr-6_0.C | 8 ++++++++ gcc/testsuite/g++.dg/lto/odr-6_1.c | 4 ++++ 5 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/g++.dg/lto/odr-6_0.C create mode 100644 gcc/testsuite/g++.dg/lto/odr-6_1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 08951d94f50..be785258579 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-10-01 Jan Hubicka + + PR lto/91222 + * ipa-devirt.c (warn_types_mismatch): Do not ICE when anonymous type + is matched with non-C++ type + 2019-10-01 Prathamesh Kulkarni * tree-if-conv.c (tree_if_conversion): Move call to ifcvt_local_dce diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c index e5028bc6150..3423c4052db 100644 --- a/gcc/ipa-devirt.c +++ b/gcc/ipa-devirt.c @@ -992,14 +992,14 @@ warn_types_mismatch (tree t1, tree t2, location_t loc1, location_t loc2) std::swap (t1, t2); std::swap (loc_t1, loc_t2); } - gcc_assert (TYPE_NAME (t1) && TYPE_NAME (t2) - && TREE_CODE (TYPE_NAME (t1)) == TYPE_DECL - && TREE_CODE (TYPE_NAME (t2)) == TYPE_DECL); + gcc_assert (TYPE_NAME (t1) + && TREE_CODE (TYPE_NAME (t1)) == TYPE_DECL); tree n1 = TYPE_NAME (t1); - tree n2 = TYPE_NAME (t2); + tree n2 = TYPE_NAME (t2) ? TYPE_NAME (t2) : NULL; + if (TREE_CODE (n1) == TYPE_DECL) n1 = DECL_NAME (n1); - if (TREE_CODE (n2) == TYPE_DECL) + if (n2 && TREE_CODE (n2) == TYPE_DECL) n2 = DECL_NAME (n2); /* Most of the time, the type names will match, do not be unnecesarily verbose. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 797c50fefc2..ac73d3e34c7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-10-01 Jan Hubicka + + * g++.dg/lto/odr-6_0.C: New testcase. + * g++.dg/lto/odr-6_1.c: New testcase. + 2019-10-01 Jan Hubicka * gcc.dg/tree-ssa/ssa-thread-12.c: Fix warning introduced by my diff --git a/gcc/testsuite/g++.dg/lto/odr-6_0.C b/gcc/testsuite/g++.dg/lto/odr-6_0.C new file mode 100644 index 00000000000..a03483f742b --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/odr-6_0.C @@ -0,0 +1,8 @@ +// { dg-lto-do link } +extern "C" { +struct { // { dg-lto-message "" 2 } +} admbaserest_; +} +int main() +{ +} diff --git a/gcc/testsuite/g++.dg/lto/odr-6_1.c b/gcc/testsuite/g++.dg/lto/odr-6_1.c new file mode 100644 index 00000000000..ee4bff44659 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/odr-6_1.c @@ -0,0 +1,4 @@ +struct {} admbaserest_; // { dg-lto-message "type of " 2 } + + + -- 2.30.2