From ba1677480a6974a693c8b4136b4a0bc52e19d551 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Sat, 17 Nov 2018 12:35:01 +0100 Subject: [PATCH] =?utf8?q?re=20PR=20ipa/87957=20(ICE=20tree=20check:=20exp?= =?utf8?q?ected=20tree=20that=20contains=20=E2=80=98decl=20minimal?= =?utf8?q?=E2=80=99=20structure,=20have=20=E2=80=98identifier=5Fnode?= =?utf8?q?=E2=80=99=20in=20warn=5Fodr,=20at=20ipa-devirt.c:1051=20since=20?= =?utf8?q?r265519)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit PR ipa/87957 * ipa-devirt.c (warn_odr): Look for main variant to get TYPE_DECL. From-SVN: r266235 --- gcc/ChangeLog | 5 +++++ gcc/ipa-devirt.c | 24 ++++++++++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2fed7468542..a6097fde67c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2018-11-16 Jan Hubicka + + PR ipa/87957 + * ipa-devirt.c (warn_odr): Look for main variant to get TYPE_DECL. + 2018-11-16 Sandra Loosemore * doc/invoke.texi (Option Summary): Fix whitespace and line diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c index 4676bdbdf93..db8d34c4027 100644 --- a/gcc/ipa-devirt.c +++ b/gcc/ipa-devirt.c @@ -1000,11 +1000,11 @@ static void warn_odr (tree t1, tree t2, tree st1, tree st2, bool warn, bool *warned, const char *reason) { - tree decl2 = TYPE_NAME (t2); + tree decl2 = TYPE_NAME (TYPE_MAIN_VARIANT (t2)); if (warned) *warned = false; - if (!warn || !TYPE_NAME(t1)) + if (!warn || !TYPE_NAME(TYPE_MAIN_VARIANT (t1))) return; /* ODR warnings are output druing LTO streaming; we must apply location @@ -1013,10 +1013,22 @@ warn_odr (tree t1, tree t2, tree st1, tree st2, lto_location_cache::current_cache->apply_location_cache (); auto_diagnostic_group d; - if (!warning_at (DECL_SOURCE_LOCATION (TYPE_NAME (t1)), OPT_Wodr, - "type %qT violates the C++ One Definition Rule", - t1)) - return; + if (t1 != TYPE_MAIN_VARIANT (t1) + && TYPE_NAME (t1) != DECL_NAME (TYPE_MAIN_VARIANT (t1))) + { + if (!warning_at (DECL_SOURCE_LOCATION (TYPE_NAME (TYPE_MAIN_VARIANT (t1))), + OPT_Wodr, "type %qT (typedef of %qT) violates the " + "C++ One Definition Rule", + t1, TYPE_MAIN_VARIANT (t1))) + return; + } + else + { + if (!warning_at (DECL_SOURCE_LOCATION (TYPE_NAME (TYPE_MAIN_VARIANT (t1))), + OPT_Wodr, "type %qT violates the C++ One Definition Rule", + t1)) + return; + } if (!st1 && !st2) ; /* For FIELD_DECL support also case where one of fields is -- 2.30.2