summaryrefslogtreecommitdiff
path: root/gcc/ipa-devirt.c
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2019-11-28 21:56:23 +0100
committerMartin Liska <marxin@gcc.gnu.org>2019-11-28 20:56:23 +0000
commit2fb2966c19ab7a5c1a17b5f32de1def2110e7191 (patch)
treecfa7c4246183a52f02e8d2a457cffb16b5618c21 /gcc/ipa-devirt.c
parent3a95e31b34da8d7b01744f1f5958541b0671df5f (diff)
Properly use TYPE_MAIN_VARIANT in warn_types_mismatch.
2019-11-28 Martin Liska <mliska@suse.cz> PR lto/92609 * ipa-devirt.c (warn_types_mismatch): Use TYPE_MAIN_VARIANT consistently. 2019-11-28 Martin Liska <mliska@suse.cz> PR lto/92609 * g++.dg/lto/pr92609_0.C: New test. * g++.dg/lto/pr92609_1.C: New test. From-SVN: r278819
Diffstat (limited to 'gcc/ipa-devirt.c')
-rw-r--r--gcc/ipa-devirt.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c
index c158d3c968d..0b2475ca292 100644
--- a/gcc/ipa-devirt.c
+++ b/gcc/ipa-devirt.c
@@ -986,21 +986,24 @@ warn_types_mismatch (tree t1, tree t2, location_t loc1, location_t loc2)
/* It is a quite common bug to reference anonymous namespace type in
non-anonymous namespace class. */
- if ((type_with_linkage_p (TYPE_MAIN_VARIANT (t1))
- && type_in_anonymous_namespace_p (TYPE_MAIN_VARIANT (t1)))
- || (type_with_linkage_p (TYPE_MAIN_VARIANT (t2))
- && type_in_anonymous_namespace_p (TYPE_MAIN_VARIANT (t2))))
+ tree mt1 = TYPE_MAIN_VARIANT (t1);
+ tree mt2 = TYPE_MAIN_VARIANT (t2);
+ if ((type_with_linkage_p (mt1)
+ && type_in_anonymous_namespace_p (mt1))
+ || (type_with_linkage_p (mt2)
+ && type_in_anonymous_namespace_p (mt2)))
{
- if (!type_with_linkage_p (TYPE_MAIN_VARIANT (t1))
- || !type_in_anonymous_namespace_p (TYPE_MAIN_VARIANT (t1)))
+ if (!type_with_linkage_p (mt1)
+ || !type_in_anonymous_namespace_p (mt1))
{
std::swap (t1, t2);
+ std::swap (mt1, mt2);
std::swap (loc_t1, loc_t2);
}
- gcc_assert (TYPE_NAME (t1)
- && TREE_CODE (TYPE_NAME (t1)) == TYPE_DECL);
- tree n1 = TYPE_NAME (t1);
- tree n2 = TYPE_NAME (t2) ? TYPE_NAME (t2) : NULL;
+ gcc_assert (TYPE_NAME (mt1)
+ && TREE_CODE (TYPE_NAME (mt1)) == TYPE_DECL);
+ tree n1 = TYPE_NAME (mt1);
+ tree n2 = TYPE_NAME (mt2) ? TYPE_NAME (mt2) : NULL;
if (TREE_CODE (n1) == TYPE_DECL)
n1 = DECL_NAME (n1);
@@ -1023,8 +1026,6 @@ warn_types_mismatch (tree t1, tree t2, location_t loc1, location_t loc2)
"the incompatible type defined in another translation unit");
return;
}
- tree mt1 = TYPE_MAIN_VARIANT (t1);
- tree mt2 = TYPE_MAIN_VARIANT (t2);
/* If types have mangled ODR names and they are different, it is most
informative to output those.
This also covers types defined in different namespaces. */