commit:     236e7b39fc0545df14b4df5e45d37c1b844ddc23
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 10 14:55:15 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Dec 10 14:55:42 2024 +0000
URL:        https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=236e7b39

15.0.0: update C23 FAM patches

Signed-off-by: Sam James <sam <AT> gentoo.org>

 ...mpatibility-for-types-with-flexible-array.patch | 304 ++-------------------
 ...atibility-for-types-with-flexible-array-2.patch | 250 +++++++++++++++++
 ...724-testsuite-fix-LTO-flags-in-pr112716.c.patch |  27 --
 15.0.0/gentoo/README.history                       |   2 +-
 4 files changed, 278 insertions(+), 305 deletions(-)

diff --git 
a/15.0.0/gentoo/74_all_PR117724-Fix-type-compatibility-for-types-with-flexible-array.patch
 
b/15.0.0/gentoo/74_all_PR117724-Fix-type-compatibility-for-types-with-flexible-array.patch
index 3c20493..1b682ad 100644
--- 
a/15.0.0/gentoo/74_all_PR117724-Fix-type-compatibility-for-types-with-flexible-array.patch
+++ 
b/15.0.0/gentoo/74_all_PR117724-Fix-type-compatibility-for-types-with-flexible-array.patch
@@ -1,75 +1,35 @@
-From e1d3dfa0936ca5b50c87f6ddf5347fa401a703f6 Mon Sep 17 00:00:00 2001
-Message-ID: 
<e1d3dfa0936ca5b50c87f6ddf5347fa401a703f6.1733713329.git....@gentoo.org>
+From 511aac7c85e6cc2ce474e1169dadd17c570743ec Mon Sep 17 00:00:00 2001
+Message-ID: 
<511aac7c85e6cc2ce474e1169dadd17c570743ec.1733842378.git....@gentoo.org>
 From: Martin Uecker <uec...@tugraz.at>
-Date: Mon, 9 Dec 2024 00:11:58 +0100
+Date: Tue, 10 Dec 2024 13:29:27 +0100
 Subject: [PATCH 1/2] Fix type compatibility for types with flexible array
- member [PR113688,PR114014,PR117724]
+ member [PR113688,PR114713,PR117724]
 MIME-Version: 1.0
 Content-Type: text/plain; charset=UTF-8
 Content-Transfer-Encoding: 8bit
 
-Hi Richard,
-
-this is another version.  It now adds an "ignore_size" flag
-to gimple_canonical_types_compatible_p and uses this instead
-of having the complicated special case for arrays at the
-end.  Also zero-sized members are now ignored again, except
-if they are arrays at the end where then only the size is
-ignored.  This can still be stricter than before for theĀ 
-case where there are zero-sized arrays at the end (e.g.
-before element type could differ).
-
-Martin
+As requested, I split up into one part for the TYPE_MODE andĀ 
+another one for the array size to help with git bisecting.  This
+is the first part.
 
 Bootstrapped and regression tested on x86_64.
 
-Fix type compatibility for types with flexible array member 
[PR113688,PR114014,PR117724]
-
-    verify_type checks the compatibility of TYPE_CANONICAL using
-    gimple_canonical_types_compatible_p.   But it is stricter than what the
-    C standard requires and therefor inconsistent with how TYPE_CANONICAL is 
set
-    in the C FE.  Here, the logic is changed to ignore the array size when it
-    is the last element of a structure or union.  To not get errors because of
-    an inconsistent number of members, zero-sized arrays which are the last
-    element are not ignored anymore when checking the fields of a struct (which
-    in this particular case is stricter than what was done before).  Finally,
-    exceptions are added that allow the TYPE_MODE of a type with an array as
-    last member and of such arrays to differ from another compatible type.
+Allow the TYPE_MODE of a type with an array as last member to differ from
+another compatible type.
 
-            PR c/112716
-            PR c/113688
-            PR c/114014
-            PR c/117724
+gcc/ChangeLog:
+        * tree.cc (gimple_canonical_types_compatible_p): Add exception.
+        (verify_type): Add exception.
 
-    gcc/ChangeLog:
-            * tree.cc (gimple_canonical_types_compatible_p): Add
-              `ignore_size' parameter and revise logic.
-            (verify_type): Add exceptions.
-
-    gcc/lto/ChangeLog:
-            * lto-common.cc (hash_canonical_type): Add exceptions.
-
-    gcc/testsuite/ChangeLog:
-            * gcc.dg/pr112716.c: New test.
-            * gcc.dg/pr113688.c: New test.
-            * gcc.dg/pr114014.c: New test.
-            * gcc.dg/pr117724.c: New test.
+gcc/lto/ChangeLog:
+        * lto-common.cc (hash_canonical_type): Add exception.
 ---
- gcc/lto/lto-common.cc           |  9 ++++--
- gcc/testsuite/gcc.dg/pr112716.c | 40 +++++++++++++++++++++++++
- gcc/testsuite/gcc.dg/pr113688.c |  8 +++++
- gcc/testsuite/gcc.dg/pr114014.c | 14 +++++++++
- gcc/testsuite/gcc.dg/pr117724.c | 16 ++++++++++
- gcc/tree.cc                     | 53 +++++++++++++++++++++++++--------
- gcc/tree.h                      |  3 +-
- 7 files changed, 127 insertions(+), 16 deletions(-)
- create mode 100644 gcc/testsuite/gcc.dg/pr112716.c
- create mode 100644 gcc/testsuite/gcc.dg/pr113688.c
- create mode 100644 gcc/testsuite/gcc.dg/pr114014.c
- create mode 100644 gcc/testsuite/gcc.dg/pr117724.c
+ gcc/lto/lto-common.cc |  3 ++-
+ gcc/tree.cc           | 12 +++++++++---
+ 2 files changed, 11 insertions(+), 4 deletions(-)
 
 diff --git a/gcc/lto/lto-common.cc b/gcc/lto/lto-common.cc
-index 86a309f92b40..f65a9d1c7b6f 100644
+index 86a309f92b40..940502099128 100644
 --- a/gcc/lto/lto-common.cc
 +++ b/gcc/lto/lto-common.cc
 @@ -254,7 +254,8 @@ hash_canonical_type (tree type)
@@ -82,143 +42,11 @@ index 86a309f92b40..f65a9d1c7b6f 100644
  
    /* Incorporate common features of numerical types.  */
    if (INTEGRAL_TYPE_P (type)
-@@ -332,7 +333,11 @@ hash_canonical_type (tree type)
-           && (! DECL_SIZE (f)
-               || ! integer_zerop (DECL_SIZE (f))))
-         {
--          iterative_hash_canonical_type (TREE_TYPE (f), hstate);
-+          tree t = TREE_TYPE (f);
-+          if (!TREE_CHAIN (f)
-+              && TREE_CODE (t) == ARRAY_TYPE)
-+            t = TREE_TYPE  (t);
-+          iterative_hash_canonical_type (t, hstate);
-           nf++;
-         }
- 
-diff --git a/gcc/testsuite/gcc.dg/pr112716.c b/gcc/testsuite/gcc.dg/pr112716.c
-new file mode 100644
-index 000000000000..109dd252f0d6
---- /dev/null
-+++ b/gcc/testsuite/gcc.dg/pr112716.c
-@@ -0,0 +1,40 @@
-+/* { dg-do compile } */
-+/* { dg-options "-lfto -O2" } */
-+
-+#define T1 int[n]
-+#define T2 int[n]
-+
-+// TU 1
-+void bar(void*);
-+
-+[[gnu::noinline,gnu::noipa]]
-+int foo(void *p, void *q)
-+{
-+      int n = 5;
-+      struct foo { int x; typeof(T1) y; } *p2 = p;
-+      p2->x = 1;
-+      bar(q);
-+      return p2->x;
-+}
-+
-+int main()
-+{
-+      int n = 5;
-+      void *p = __builtin_malloc(sizeof(struct foo { int x; typeof(T1) y; }));
-+
-+      if (!p)
-+              return 0;
-+
-+      if (2 != foo(p, p))
-+              __builtin_abort();
-+
-+      return 0;
-+}
-+// TU 2
-+void bar(void* q)
-+{
-+      int n = 5;
-+      struct foo { int x; typeof(T2) y; } *q2 = q;
-+      q2->x = 2;
-+}
-+
-diff --git a/gcc/testsuite/gcc.dg/pr113688.c b/gcc/testsuite/gcc.dg/pr113688.c
-new file mode 100644
-index 000000000000..8dee8c86f1bf
---- /dev/null
-+++ b/gcc/testsuite/gcc.dg/pr113688.c
-@@ -0,0 +1,8 @@
-+/* { dg-do compile } */
-+/* { dg-options "-g" } */
-+
-+struct S{int x,y[1];}*a;
-+int main(void){
-+      struct S{int x,y[];};
-+}
-+
-diff --git a/gcc/testsuite/gcc.dg/pr114014.c b/gcc/testsuite/gcc.dg/pr114014.c
-new file mode 100644
-index 000000000000..1531ffab1b75
---- /dev/null
-+++ b/gcc/testsuite/gcc.dg/pr114014.c
-@@ -0,0 +1,14 @@
-+/* PR c/114014
-+ * { dg-do compile }
-+ * { dg-options "-std=gnu23 -g" } */
-+
-+struct r {
-+  int a;
-+  char b[];
-+};
-+struct r {
-+  int a;
-+  char b[0];
-+};
-+
-+
-diff --git a/gcc/testsuite/gcc.dg/pr117724.c b/gcc/testsuite/gcc.dg/pr117724.c
-new file mode 100644
-index 000000000000..d631daeb644d
---- /dev/null
-+++ b/gcc/testsuite/gcc.dg/pr117724.c
-@@ -0,0 +1,16 @@
-+/* { dg-do compile } */
-+/* { dg-options "-g" } */
-+
-+struct {
-+  unsigned long len;
-+  unsigned long size;
-+  char data[];
-+};                    /* { dg-warning "unnamed struct" } */
-+struct {
-+  struct {
-+    unsigned long len;
-+    unsigned long size;
-+    char data[6];
-+  };
-+};                    /* { dg-warning "unnamed struct" } */
-+
 diff --git a/gcc/tree.cc b/gcc/tree.cc
-index 83a03374a325..da4b7f5daa8c 100644
+index 83a03374a325..1391af6bd4c3 100644
 --- a/gcc/tree.cc
 +++ b/gcc/tree.cc
-@@ -13837,11 +13837,13 @@ type_with_interoperable_signedness (const_tree type)
-    verifier.  If TRUST_TYPE_CANONICAL we do not look into structure of types
-    that have TYPE_CANONICAL defined and assume them equivalent.  This is 
useful
-    only for LTO because only in these cases TYPE_CANONICAL equivalence
--   correspond to one defined by gimple_canonical_types_compatible_p.  */
--
-+   correspond to one defined by gimple_canonical_types_compatible_p.
-+   If IGNORE_SIZE, we allow a mismatch of the mode and the number of
-+   elements for arrays.  */
- bool
- gimple_canonical_types_compatible_p (const_tree t1, const_tree t2,
--                                   bool trust_type_canonical)
-+                                   bool trust_type_canonical,
-+                                   bool ignore_size)
- {
-   /* Type variants should be same as the main variant.  When not doing sanity
-      checking to verify this fact, go to main variants and save some work.  */
-@@ -13914,8 +13916,12 @@ gimple_canonical_types_compatible_p (const_tree t1, 
const_tree t2,
+@@ -13914,8 +13914,11 @@ gimple_canonical_types_compatible_p (const_tree t1, 
const_tree t2,
        || TREE_CODE (t1) == NULLPTR_TYPE)
      return true;
  
@@ -226,81 +54,17 @@ index 83a03374a325..da4b7f5daa8c 100644
 -  if (TYPE_MODE (t1) != TYPE_MODE (t2))
 +  /* Can't be compatible types if they have different mode.  Because of
 +     flexible array members, we allow mismatching modes for structures or
-+     unions and for arrays when we ignore the size.  */
++     unions.  */
 +  if (!RECORD_OR_UNION_TYPE_P (t1)
-+      && (!ignore_size || TREE_CODE (t1) != ARRAY_TYPE)
-+      && (TYPE_MODE (t1) != TYPE_MODE (t2)))
++      && TYPE_MODE (t1) != TYPE_MODE (t2))
      return false;
  
    /* Non-aggregate types can be handled cheaply.  */
-@@ -13966,15 +13972,19 @@ gimple_canonical_types_compatible_p (const_tree t1, 
const_tree t2,
-     {
-     case ARRAY_TYPE:
-       /* Array types are the same if the element types are the same and
--       the number of elements are the same.  */
-+       minimum and maximum index are the same.  */
-       if (!gimple_canonical_types_compatible_p (TREE_TYPE (t1), TREE_TYPE 
(t2),
--                                              trust_type_canonical)
-+                                              trust_type_canonical,
-+                                              ignore_size)
-         || TYPE_STRING_FLAG (t1) != TYPE_STRING_FLAG (t2)
-         || TYPE_REVERSE_STORAGE_ORDER (t1) != TYPE_REVERSE_STORAGE_ORDER (t2)
-         || TYPE_NONALIASED_COMPONENT (t1) != TYPE_NONALIASED_COMPONENT (t2))
-       return false;
-       else
-       {
-+        if (ignore_size)
-+          return true;
-+
-         tree i1 = TYPE_DOMAIN (t1);
-         tree i2 = TYPE_DOMAIN (t2);
- 
-@@ -14060,23 +14070,36 @@ gimple_canonical_types_compatible_p (const_tree t1, 
const_tree t2,
-            f1 || f2;
-            f1 = TREE_CHAIN (f1), f2 = TREE_CHAIN (f2))
-         {
--          /* Skip non-fields and zero-sized fields.  */
-+          /* Skip non-fields and zero-sized fields, except zero-sized
-+             arrays at the end.  */
-           while (f1 && (TREE_CODE (f1) != FIELD_DECL
-                         || (DECL_SIZE (f1)
--                            && integer_zerop (DECL_SIZE (f1)))))
-+                            && integer_zerop (DECL_SIZE (f1))
-+                            && (TREE_CHAIN (f1)
-+                                || TREE_CODE (TREE_TYPE (f1))
-+                                   != ARRAY_TYPE))))
-             f1 = TREE_CHAIN (f1);
-           while (f2 && (TREE_CODE (f2) != FIELD_DECL
-                         || (DECL_SIZE (f2)
--                            && integer_zerop (DECL_SIZE (f2)))))
-+                            && integer_zerop (DECL_SIZE (f2))
-+                            && (TREE_CHAIN (f2)
-+                                || TREE_CODE (TREE_TYPE (f2))
-+                                   != ARRAY_TYPE))))
-             f2 = TREE_CHAIN (f2);
-           if (!f1 || !f2)
-             break;
--          /* The fields must have the same name, offset and type.  */
-+
-+          tree t1 = TREE_TYPE (f1);
-+          tree t2 = TREE_TYPE (f2);
-+
-+          /* If the last element is an array, we allow a mismatch in size. */
-+          bool ignore_size = (TREE_CHAIN (f1) == NULL_TREE
-+                              && TREE_CODE (t1) == ARRAY_TYPE);
-+
-           if (DECL_NONADDRESSABLE_P (f1) != DECL_NONADDRESSABLE_P (f2)
-               || !gimple_compare_field_offset (f1, f2)
-               || !gimple_canonical_types_compatible_p
--                    (TREE_TYPE (f1), TREE_TYPE (f2),
--                     trust_type_canonical))
-+                    (t1, t2, trust_type_canonical, ignore_size))
-             return false;
-         }
- 
-@@ -14220,6 +14243,10 @@ verify_type (const_tree t)
+@@ -14218,8 +14221,11 @@ verify_type (const_tree t)
+       debug_tree (ct);
+       error_found = true;
      }
- 
+-
    if (COMPLETE_TYPE_P (t) && TYPE_CANONICAL (t)
 +      /* We allow a mismatch for structure or union because of
 +       flexible array members.  */
@@ -309,22 +73,8 @@ index 83a03374a325..da4b7f5daa8c 100644
        && TYPE_MODE (t) != TYPE_MODE (TYPE_CANONICAL (t)))
      {
        error ("%<TYPE_MODE%> of %<TYPE_CANONICAL%> is not compatible");
-diff --git a/gcc/tree.h b/gcc/tree.h
-index 75054839d9b6..6608754a3e20 100644
---- a/gcc/tree.h
-+++ b/gcc/tree.h
-@@ -5844,7 +5844,8 @@ extern unsigned int tree_map_base_hash (const void *);
- extern bool tree_map_base_marked_p (const void *);
- extern void DEBUG_FUNCTION verify_type (const_tree t);
- extern bool gimple_canonical_types_compatible_p (const_tree, const_tree,
--                                               bool trust_type_canonical = 
true);
-+                                               bool trust_type_canonical = 
true,
-+                                               bool ignore_size = false);
- extern bool type_with_interoperable_signedness (const_tree);
- extern bitmap get_nonnull_args (const_tree);
- extern int get_range_pos_neg (tree);
 
-base-commit: 6205144d6b566f32a58c4fa4f5e7e2343ad07c62
+base-commit: 34dfb30ca8dba6bc184e563b0ddc26a5239294e3
 -- 
 2.47.1
 

diff --git 
a/15.0.0/gentoo/75_all_PR117724-Fix-type-compatibility-for-types-with-flexible-array-2.patch
 
b/15.0.0/gentoo/75_all_PR117724-Fix-type-compatibility-for-types-with-flexible-array-2.patch
new file mode 100644
index 0000000..1f35b83
--- /dev/null
+++ 
b/15.0.0/gentoo/75_all_PR117724-Fix-type-compatibility-for-types-with-flexible-array-2.patch
@@ -0,0 +1,250 @@
+From 4bc7c98e86392a36f75029eabbe096d1bf9e85b5 Mon Sep 17 00:00:00 2001
+Message-ID: 
<4bc7c98e86392a36f75029eabbe096d1bf9e85b5.1733842378.git....@gentoo.org>
+In-Reply-To: 
<511aac7c85e6cc2ce474e1169dadd17c570743ec.1733842378.git....@gentoo.org>
+References: 
<511aac7c85e6cc2ce474e1169dadd17c570743ec.1733842378.git....@gentoo.org>
+From: Martin Uecker <uec...@tugraz.at>
+Date: Tue, 10 Dec 2024 13:31:50 +0100
+Subject: [PATCH 2/2] Fix type compatibility for types with flexible array
+ member [PR113688,PR114713,PR117724]
+
+The second part now only contains the changes for array size.
+
+I added back a special case for this instead of having the
+'ignore_size' flag (which I would nevertheless assume might be
+needed in the future when matching pointer types).
+
+In this version, I added an exception to the special case to ignore
+the case were both are zero-sized arrays, because this seems to be
+the only case were the new code would otherwise be stricter than the
+old code.
+
+I also replaced/fixed one test where I accidentally included a similar
+test for another closely related bug involving VLA types.
+
+Bootstrapped and regression tested on x86_64.
+
+For checking or computing TYPE_CANONICAL, ignore the array size when it is
+the last element of a structure or union.  To not get errors because of
+an inconsistent number of members, zero-sized arrays which are the last
+element are not ignored anymore when checking the fields of a struct.
+
+       PR c/113688
+       PR c/114014
+       PR c/114713
+       PR c/117724
+
+gcc/ChangeLog:
+       * tree.cc (gimple_canonical_types_compatible_p): Add exception.
+
+gcc/lto/ChangeLog:
+       * lto-common.cc (hash_canonical_type): Add exception.
+
+gcc/testsuite/ChangeLog:
+       * gcc.dg/pr113688.c: New test.
+       * gcc.dg/pr114014.c: New test.
+       * gcc.dg/pr114713.c: New test.
+       * gcc.dg/pr117724.c: New test.
+---
+ gcc/lto/lto-common.cc           |  6 +++++-
+ gcc/testsuite/gcc.dg/pr113688.c |  8 +++++++
+ gcc/testsuite/gcc.dg/pr114014.c | 14 ++++++++++++
+ gcc/testsuite/gcc.dg/pr114713.c | 35 ++++++++++++++++++++++++++++++
+ gcc/testsuite/gcc.dg/pr117724.c | 16 ++++++++++++++
+ gcc/tree.cc                     | 38 ++++++++++++++++++++++++++-------
+ 6 files changed, 108 insertions(+), 9 deletions(-)
+ create mode 100644 gcc/testsuite/gcc.dg/pr113688.c
+ create mode 100644 gcc/testsuite/gcc.dg/pr114014.c
+ create mode 100644 gcc/testsuite/gcc.dg/pr114713.c
+ create mode 100644 gcc/testsuite/gcc.dg/pr117724.c
+
+diff --git a/gcc/lto/lto-common.cc b/gcc/lto/lto-common.cc
+index 940502099128..f65a9d1c7b6f 100644
+--- a/gcc/lto/lto-common.cc
++++ b/gcc/lto/lto-common.cc
+@@ -333,7 +333,11 @@ hash_canonical_type (tree type)
+           && (! DECL_SIZE (f)
+               || ! integer_zerop (DECL_SIZE (f))))
+         {
+-          iterative_hash_canonical_type (TREE_TYPE (f), hstate);
++          tree t = TREE_TYPE (f);
++          if (!TREE_CHAIN (f)
++              && TREE_CODE (t) == ARRAY_TYPE)
++            t = TREE_TYPE  (t);
++          iterative_hash_canonical_type (t, hstate);
+           nf++;
+         }
+ 
+diff --git a/gcc/testsuite/gcc.dg/pr113688.c b/gcc/testsuite/gcc.dg/pr113688.c
+new file mode 100644
+index 000000000000..8dee8c86f1bf
+--- /dev/null
++++ b/gcc/testsuite/gcc.dg/pr113688.c
+@@ -0,0 +1,8 @@
++/* { dg-do compile } */
++/* { dg-options "-g" } */
++
++struct S{int x,y[1];}*a;
++int main(void){
++      struct S{int x,y[];};
++}
++
+diff --git a/gcc/testsuite/gcc.dg/pr114014.c b/gcc/testsuite/gcc.dg/pr114014.c
+new file mode 100644
+index 000000000000..1531ffab1b75
+--- /dev/null
++++ b/gcc/testsuite/gcc.dg/pr114014.c
+@@ -0,0 +1,14 @@
++/* PR c/114014
++ * { dg-do compile }
++ * { dg-options "-std=gnu23 -g" } */
++
++struct r {
++  int a;
++  char b[];
++};
++struct r {
++  int a;
++  char b[0];
++};
++
++
+diff --git a/gcc/testsuite/gcc.dg/pr114713.c b/gcc/testsuite/gcc.dg/pr114713.c
+new file mode 100644
+index 000000000000..1f0ad39c433c
+--- /dev/null
++++ b/gcc/testsuite/gcc.dg/pr114713.c
+@@ -0,0 +1,35 @@
++/* { dg-do run } */
++/* { dg-require-effective-target lto } */
++/* { dg-options "-flto -O2" } */
++
++struct foo { int x; char a[]; };
++
++void test_bar(void* b);
++
++__attribute__((noinline))
++int test_foo(struct foo* a, void* b)
++{
++        a->x = 1;
++        test_bar(b);
++        return a->x;
++}
++
++int main()
++{
++        struct foo y;
++
++        if (2 != test_foo(&y, &y))
++                __builtin_abort();
++
++        return 0;
++}
++
++// TU2
++struct foo { int x; char a[0]; };
++
++void test_bar(void* b)
++{
++        struct foo *p = b;
++        p->x = 2;
++}
++
+diff --git a/gcc/testsuite/gcc.dg/pr117724.c b/gcc/testsuite/gcc.dg/pr117724.c
+new file mode 100644
+index 000000000000..d631daeb644d
+--- /dev/null
++++ b/gcc/testsuite/gcc.dg/pr117724.c
+@@ -0,0 +1,16 @@
++/* { dg-do compile } */
++/* { dg-options "-g" } */
++
++struct {
++  unsigned long len;
++  unsigned long size;
++  char data[];
++};                    /* { dg-warning "unnamed struct" } */
++struct {
++  struct {
++    unsigned long len;
++    unsigned long size;
++    char data[6];
++  };
++};                    /* { dg-warning "unnamed struct" } */
++
+diff --git a/gcc/tree.cc b/gcc/tree.cc
+index 1391af6bd4c3..9803d16805c4 100644
+--- a/gcc/tree.cc
++++ b/gcc/tree.cc
+@@ -13838,7 +13838,6 @@ type_with_interoperable_signedness (const_tree type)
+    that have TYPE_CANONICAL defined and assume them equivalent.  This is 
useful
+    only for LTO because only in these cases TYPE_CANONICAL equivalence
+    correspond to one defined by gimple_canonical_types_compatible_p.  */
+-
+ bool
+ gimple_canonical_types_compatible_p (const_tree t1, const_tree t2,
+                                    bool trust_type_canonical)
+@@ -13969,7 +13968,7 @@ gimple_canonical_types_compatible_p (const_tree t1, 
const_tree t2,
+     {
+     case ARRAY_TYPE:
+       /* Array types are the same if the element types are the same and
+-       the number of elements are the same.  */
++       minimum and maximum index are the same.  */
+       if (!gimple_canonical_types_compatible_p (TREE_TYPE (t1), TREE_TYPE 
(t2),
+                                               trust_type_canonical)
+         || TYPE_STRING_FLAG (t1) != TYPE_STRING_FLAG (t2)
+@@ -14063,23 +14062,46 @@ gimple_canonical_types_compatible_p (const_tree t1, 
const_tree t2,
+            f1 || f2;
+            f1 = TREE_CHAIN (f1), f2 = TREE_CHAIN (f2))
+         {
+-          /* Skip non-fields and zero-sized fields.  */
++          /* Skip non-fields and zero-sized fields, except zero-sized
++             arrays at the end.  */
+           while (f1 && (TREE_CODE (f1) != FIELD_DECL
+                         || (DECL_SIZE (f1)
+-                            && integer_zerop (DECL_SIZE (f1)))))
++                            && integer_zerop (DECL_SIZE (f1))
++                            && (TREE_CHAIN (f1)
++                                || TREE_CODE (TREE_TYPE (f1))
++                                   != ARRAY_TYPE))))
+             f1 = TREE_CHAIN (f1);
+           while (f2 && (TREE_CODE (f2) != FIELD_DECL
+                         || (DECL_SIZE (f2)
+-                            && integer_zerop (DECL_SIZE (f2)))))
++                            && integer_zerop (DECL_SIZE (f2))
++                            && (TREE_CHAIN (f2)
++                                || TREE_CODE (TREE_TYPE (f2))
++                                   != ARRAY_TYPE))))
+             f2 = TREE_CHAIN (f2);
+           if (!f1 || !f2)
+             break;
+-          /* The fields must have the same name, offset and type.  */
++
++          tree t1 = TREE_TYPE (f1);
++          tree t2 = TREE_TYPE (f2);
++
++          /* If the last element are arrays, we only compare the element
++             types.  */
++          if (TREE_CHAIN (f1) == NULL_TREE && TREE_CODE (t1) == ARRAY_TYPE
++              && TREE_CHAIN (f2) == NULL_TREE && TREE_CODE (t2) == ARRAY_TYPE)
++            {
++              /* If both arrays have zero size, this is a match.  */
++              if (DECL_SIZE (f1) && integer_zerop (DECL_SIZE (f1))
++                  && DECL_SIZE (f2) && integer_zerop (DECL_SIZE (f2)))
++                return true;
++
++              t1 = TREE_TYPE (t1);
++              t2 = TREE_TYPE (t2);
++            }
++
+           if (DECL_NONADDRESSABLE_P (f1) != DECL_NONADDRESSABLE_P (f2)
+               || !gimple_compare_field_offset (f1, f2)
+               || !gimple_canonical_types_compatible_p
+-                    (TREE_TYPE (f1), TREE_TYPE (f2),
+-                     trust_type_canonical))
++                    (t1, t2, trust_type_canonical))
+             return false;
+         }
+ 
+-- 
+2.47.1
+

diff --git 
a/15.0.0/gentoo/75_all_PR117724-testsuite-fix-LTO-flags-in-pr112716.c.patch 
b/15.0.0/gentoo/75_all_PR117724-testsuite-fix-LTO-flags-in-pr112716.c.patch
deleted file mode 100644
index f36840e..0000000
--- a/15.0.0/gentoo/75_all_PR117724-testsuite-fix-LTO-flags-in-pr112716.c.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From 2f961c392ab359286ef1350d37e50e7841773d7b Mon Sep 17 00:00:00 2001
-Message-ID: 
<2f961c392ab359286ef1350d37e50e7841773d7b.1733713329.git....@gentoo.org>
-In-Reply-To: 
<e1d3dfa0936ca5b50c87f6ddf5347fa401a703f6.1733713329.git....@gentoo.org>
-References: 
<e1d3dfa0936ca5b50c87f6ddf5347fa401a703f6.1733713329.git....@gentoo.org>
-From: Sam James <s...@gentoo.org>
-Date: Mon, 9 Dec 2024 03:01:47 +0000
-Subject: [PATCH 2/2] testsuite: fix LTO flags in pr112716.c
-
----
- gcc/testsuite/gcc.dg/pr112716.c | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
-diff --git a/gcc/testsuite/gcc.dg/pr112716.c b/gcc/testsuite/gcc.dg/pr112716.c
-index 109dd252f0d6..873eedaafd18 100644
---- a/gcc/testsuite/gcc.dg/pr112716.c
-+++ b/gcc/testsuite/gcc.dg/pr112716.c
-@@ -1,5 +1,6 @@
- /* { dg-do compile } */
--/* { dg-options "-lfto -O2" } */
-+/* { dg-options "-flto -O2" } */
-+/* { dg-require-effective-target lto } */
- 
- #define T1 int[n]
- #define T2 int[n]
--- 
-2.47.1
-

diff --git a/15.0.0/gentoo/README.history b/15.0.0/gentoo/README.history
index 639981b..50ec527 100644
--- a/15.0.0/gentoo/README.history
+++ b/15.0.0/gentoo/README.history
@@ -3,7 +3,7 @@
        U 24_all_DEF_GENTOO_SCP-fstack-clash-protection.patch
        U 26_all_enable-cet.patch
        + 
74_all_PR117724-Fix-type-compatibility-for-types-with-flexible-array.patch
-       + 75_all_PR117724-testsuite-fix-LTO-flags-in-pr112716.c.patch
+       + 
75_all_PR117724-Fix-type-compatibility-for-types-with-flexible-array-2.patch
        + 
76_all_PR117854-config-nvptx-fix-bashisms-with-gen-copyright.sh-use.patch
 
 30     8 December 2024

Reply via email to