https://gcc.gnu.org/g:83d7dcfc0e447daf93d3df824a37181a7964c2f0

commit r16-192-g83d7dcfc0e447daf93d3df824a37181a7964c2f0
Author: Richard Biener <rguent...@suse.de>
Date:   Mon Feb 3 14:16:45 2025 +0100

    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:
---
 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 2885975b4e08..8c4fb3c6b643 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);

Reply via email to