]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
lto/113207 - make fld_type_variant more picky
authorRichard Biener <rguenther@suse.de>
Mon, 3 Feb 2025 13:16:45 +0000 (14:16 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 28 Apr 2025 13:12:44 +0000 (15:12 +0200)
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.

gcc/ipa-free-lang-data.cc

index 2885975b4e08af6adce1da47292f51d6cbb89ed9..8c4fb3c6b64373da80795c5b459efd2e51c02a11 100644 (file)
@@ -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);