The below adds additional verification to fld_type_variant that there's only one variant matching fld_type_variant_equal_p on the chain. The PR shows that variants built with build_qualified_type can be equal to others in that regard but not with regard to what build_qualified_type does.
Bootstrapped and tested on x86_64-unknown-linux-gnu, will push later. PR lto/113207 * ipa-free-lang-data.cc (fld_type_variant): Add extra checking. --- gcc/ipa-free-lang-data.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gcc/ipa-free-lang-data.cc b/gcc/ipa-free-lang-data.cc index 2885975b4e0..8c4fb3c6b64 100644 --- a/gcc/ipa-free-lang-data.cc +++ b/gcc/ipa-free-lang-data.cc @@ -150,7 +150,12 @@ fld_type_variant (tree first, tree t, class free_lang_data_d *fld, return t; for (tree v = first; v; v = TYPE_NEXT_VARIANT (v)) if (fld_type_variant_equal_p (t, v, inner_type)) - return v; + { + if (flag_checking) + for (tree v2 = TYPE_NEXT_VARIANT (v); v2; v2 = TYPE_NEXT_VARIANT (v2)) + gcc_assert (!fld_type_variant_equal_p (t, v2, inner_type)); + return v; + } tree v = build_variant_type_copy (first); TYPE_READONLY (v) = TYPE_READONLY (t); TYPE_VOLATILE (v) = TYPE_VOLATILE (t); -- 2.43.0