diff options
author | Jan Hubicka <jh@suse.cz> | 2020-01-14 21:45:03 +0100 |
---|---|---|
committer | Jan Hubicka <jh@suse.cz> | 2020-01-14 21:52:36 +0100 |
commit | 288c5324bf6e418dd94d718d1619464a4f68ff8e (patch) | |
tree | 0aeb7ca7aeb55f06a2386cc2bba740480d758465 /gcc/ipa-devirt.c | |
parent | 757bf1dff5e8cee34c0a75d06140ca972bfecfa7 (diff) | |
download | gcc-288c5324bf6e418dd94d718d1619464a4f68ff8e.zip gcc-288c5324bf6e418dd94d718d1619464a4f68ff8e.tar.gz gcc-288c5324bf6e418dd94d718d1619464a4f68ff8e.tar.bz2 |
Compare TREE_ADDRESSABLE and TYPE_MODE when ODR checking types.
PR lto/91576
* ipa-devirt.c (odr_types_equivalent_p): Compare TREE_ADDRESSABLE and
TYPE_MODE.
* testsuite/g++.dg/lto/odr-8_0.C: New testcase.
* testsuite/g++.dg/lto/odr-8_1.C: New testcase.
Diffstat (limited to 'gcc/ipa-devirt.c')
-rw-r--r-- | gcc/ipa-devirt.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c index f003195..b609a77 100644 --- a/gcc/ipa-devirt.c +++ b/gcc/ipa-devirt.c @@ -1544,6 +1544,27 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned, return false; } + if (TREE_ADDRESSABLE (t1) != TREE_ADDRESSABLE (t2) + && COMPLETE_TYPE_P (t1) && COMPLETE_TYPE_P (t2)) + { + warn_odr (t1, t2, NULL, NULL, warn, warned, + G_("one type needs to be constructed while other not")); + gcc_checking_assert (RECORD_OR_UNION_TYPE_P (t1)); + return false; + } + /* There is no really good user facing warning for this. + Either the original reason for modes being different is lost during + streaming or we should catch earlier warnings. We however must detect + the mismatch to avoid type verifier from cmplaining on mismatched + types between type and canonical type. See PR91576. */ + if (TYPE_MODE (t1) != TYPE_MODE (t2) + && COMPLETE_TYPE_P (t1) && COMPLETE_TYPE_P (t2)) + { + warn_odr (t1, t2, NULL, NULL, warn, warned, + G_("memory layout mismatch")); + return false; + } + gcc_assert (!TYPE_SIZE_UNIT (t1) || !TYPE_SIZE_UNIT (t2) || operand_equal_p (TYPE_SIZE_UNIT (t1), TYPE_SIZE_UNIT (t2), 0)); |