From: Richard Biener Date: Mon, 3 Feb 2025 13:16:45 +0000 (+0100) Subject: lto/113207 - make fld_type_variant more picky X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=83d7dcfc0e447daf93d3df824a37181a7964c2f0;p=thirdparty%2Fgcc.git lto/113207 - make fld_type_variant more picky 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. PR lto/113207 * ipa-free-lang-data.cc (fld_type_variant): Add extra checking. --- 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);