From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 977031581F0 for ; Thu, 12 Dec 2024 12:28:42 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id E6BABE093A; Thu, 12 Dec 2024 12:28:41 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id C6A99E093A for ; Thu, 12 Dec 2024 12:28:41 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B784C342F8E for ; Thu, 12 Dec 2024 12:28:40 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 51497E96 for ; Thu, 12 Dec 2024 12:28:39 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1734006501.5dc272f0f180fae9fc937881a213cbe907e5a8f8.sam@gentoo> Subject: [gentoo-commits] proj/gcc-patches:master commit in: 15.0.0/gentoo/ X-VCS-Repository: proj/gcc-patches X-VCS-Files: 15.0.0/gentoo/74_all_PR117724-Fix-type-compatibility-for-types-with-flexible-array.patch 15.0.0/gentoo/75_all_PR117724-Fix-type-compatibility-for-types-with-flexible-array-2.patch 15.0.0/gentoo/README.history X-VCS-Directories: 15.0.0/gentoo/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 5dc272f0f180fae9fc937881a213cbe907e5a8f8 X-VCS-Branch: master Date: Thu, 12 Dec 2024 12:28:39 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: f62ab896-9410-48b4-a62a-3d31b5367590 X-Archives-Hash: 8153e426ab1a626262f9087bfd0475b1 commit: 5dc272f0f180fae9fc937881a213cbe907e5a8f8 Author: Sam James gentoo org> AuthorDate: Thu Dec 12 12:27:59 2024 +0000 Commit: Sam James gentoo org> CommitDate: Thu Dec 12 12:28:21 2024 +0000 URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=5dc272f0 15.0.0: drop C23 FAM fixes Now upstream. Signed-off-by: Sam James gentoo.org> ...mpatibility-for-types-with-flexible-array.patch | 80 ------- ...atibility-for-types-with-flexible-array-2.patch | 250 --------------------- 15.0.0/gentoo/README.history | 5 + 3 files changed, 5 insertions(+), 330 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 deleted file mode 100644 index 1b682ad..0000000 --- a/15.0.0/gentoo/74_all_PR117724-Fix-type-compatibility-for-types-with-flexible-array.patch +++ /dev/null @@ -1,80 +0,0 @@ -From 511aac7c85e6cc2ce474e1169dadd17c570743ec Mon Sep 17 00:00:00 2001 -Message-ID: <511aac7c85e6cc2ce474e1169dadd17c570743ec.1733842378.git.sam@gentoo.org> -From: Martin Uecker -Date: Tue, 10 Dec 2024 13:29:27 +0100 -Subject: [PATCH 1/2] Fix type compatibility for types with flexible array - member [PR113688,PR114713,PR117724] -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -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. - -Allow the TYPE_MODE of a type with an array as last member to differ from -another compatible type. - -gcc/ChangeLog: - * tree.cc (gimple_canonical_types_compatible_p): Add exception. - (verify_type): Add exception. - -gcc/lto/ChangeLog: - * lto-common.cc (hash_canonical_type): Add exception. ---- - 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..940502099128 100644 ---- a/gcc/lto/lto-common.cc -+++ b/gcc/lto/lto-common.cc -@@ -254,7 +254,8 @@ hash_canonical_type (tree type) - checked. */ - code = tree_code_for_canonical_type_merging (TREE_CODE (type)); - hstate.add_int (code); -- hstate.add_int (TYPE_MODE (type)); -+ if (!RECORD_OR_UNION_TYPE_P (type)) -+ hstate.add_int (TYPE_MODE (type)); - - /* Incorporate common features of numerical types. */ - if (INTEGRAL_TYPE_P (type) -diff --git a/gcc/tree.cc b/gcc/tree.cc -index 83a03374a325..1391af6bd4c3 100644 ---- a/gcc/tree.cc -+++ b/gcc/tree.cc -@@ -13914,8 +13914,11 @@ gimple_canonical_types_compatible_p (const_tree t1, const_tree t2, - || TREE_CODE (t1) == NULLPTR_TYPE) - return true; - -- /* Can't be the same type if they have different mode. */ -- 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. */ -+ if (!RECORD_OR_UNION_TYPE_P (t1) -+ && TYPE_MODE (t1) != TYPE_MODE (t2)) - return false; - - /* Non-aggregate types can be handled cheaply. */ -@@ -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. */ -+ && !RECORD_OR_UNION_TYPE_P (t) -+ && !RECORD_OR_UNION_TYPE_P (TYPE_CANONICAL (t)) - && TYPE_MODE (t) != TYPE_MODE (TYPE_CANONICAL (t))) - { - error ("% of % is not compatible"); - -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 deleted file mode 100644 index 1f35b83..0000000 --- a/15.0.0/gentoo/75_all_PR117724-Fix-type-compatibility-for-types-with-flexible-array-2.patch +++ /dev/null @@ -1,250 +0,0 @@ -From 4bc7c98e86392a36f75029eabbe096d1bf9e85b5 Mon Sep 17 00:00:00 2001 -Message-ID: <4bc7c98e86392a36f75029eabbe096d1bf9e85b5.1733842378.git.sam@gentoo.org> -In-Reply-To: <511aac7c85e6cc2ce474e1169dadd17c570743ec.1733842378.git.sam@gentoo.org> -References: <511aac7c85e6cc2ce474e1169dadd17c570743ec.1733842378.git.sam@gentoo.org> -From: Martin Uecker -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/README.history b/15.0.0/gentoo/README.history index abc05c8..8b73c10 100644 --- a/15.0.0/gentoo/README.history +++ b/15.0.0/gentoo/README.history @@ -1,3 +1,8 @@ +32 ???? + + - 74_all_PR117724-Fix-type-compatibility-for-types-with-flexible-array.patch + - 75_all_PR117724-Fix-type-compatibility-for-types-with-flexible-array-2.patch + 31 10 December 2024 U 24_all_DEF_GENTOO_SCP-fstack-clash-protection.patch