sys-devel/gcc: Sync with Gentoo

It's from Gentoo commit 4ace0eafe01bc231275cf6963363d7fb0fba8331.
This commit is contained in:
Flatcar Buildbot 2025-02-17 07:10:59 +00:00 committed by Krzesimir Nowak
parent 36e481faa2
commit 5ca28115db
8 changed files with 900 additions and 1 deletions

View File

@ -9,6 +9,7 @@ DIST gcc-12-20250116.tar.xz 79921816 BLAKE2B b4c2ee7fb76b15834b5637d157c39cbdedc
DIST gcc-12-20250123.tar.xz 79912136 BLAKE2B f143da3aaa36020b99c0da4b4951743f90fcbcdf93af325bd76878944187005e80b11657b85ab0cf014434acf5431a45cb29effb9a8e3922092ec5dee6606b51 SHA512 1b9dba666d9538171f935334c5a7106499758f26422a497c748c4ea90983e77bfaaecdb8a96099e1a43c0722e15d34a3c0f549e531cb56ea3a990e71f0b2135b
DIST gcc-12-20250130.tar.xz 79936036 BLAKE2B ceca895f319d4d97e1d936c8caad24b847d95aba24270c5489dda55ed0a2f69f6da58b34705af7ccedd002567e6dba52f91e82a4b79d646e7a885057267838fe SHA512 043ca62adc0d7dc9a3021dc288c2483c0baf4e18b7f155944e79d6b95b4c8efe3ac694ddc8d7ab12d715a9313dd0a5f9fe7271002a497ad0ecdf9e9451f95073
DIST gcc-12-20250206.tar.xz 79919852 BLAKE2B b20f3c61d9f25a78bb3b60243d523552d36728353e75c77cf71831685f83fdc539c5ea52244a41deabe64e4158a62d852478e261be82cc97b4c28e6393d842ac SHA512 34692ec6575ab526123f697888bfa8b48103a3416a82562e292adc845db31adf3eb76179625627b908ed129c893f200657537e3a33ad7f2619b635f285171d64
DIST gcc-12-20250213.tar.xz 79923504 BLAKE2B 0ccfcb0bb5b7ccedc54964c5be0d8eec1cc9ea8e43714cc203bcfd5de16b5725a66727096ade8ab29316e6320466d2b99a82750aa3ac68a7c1b9651958f25b67 SHA512 9914d5a6cb0eb608e321ba4f5da6201c12083e5d2a58ff59875f37d5b0f34ad9324f9150ad27ec85b8e0e56983eff3973653ceb4a0011afdc1489efb044a5a06
DIST gcc-12.4.0-musl-patches-1.tar.xz 3068 BLAKE2B e5e39c24934072ea89e4467d0dc5196f3dadfb5ffba0c856d051648a2fbf57d434a57e95227cdf2b8cea45f0f5555aec2bc372d2f6cb0b69efd87831d248d364 SHA512 b9db204845a25be043d76cae826d42eebeeb4f9be7c3049af6fe7601a552bedfd24731156a6a36b4b5e2e2af656a589a5c556d2b0b3ded33ba290a773ee87c62
DIST gcc-12.4.0-patches-1.tar.xz 15576 BLAKE2B 98c29888de7701b365be7ac9062f0cee3340d58c85485e26f0d02f1483ec64cc9c10651488a4fd937551afe30f4e19777e6766871a724ae3ba6c290c16f4fdf1 SHA512 3f7c5d36e56e07ea9dd143a5d13342a6c1ccbf0643abd1c0bcbfb46bb7c7b1308aef6e3e882031c9c191610f01af906b19be5aa2b139cf617614f46e97463aec
DIST gcc-12.4.0-patches-2.tar.xz 14876 BLAKE2B 6bf5abbb2abba4b9fe9fa153ac4112fe5f563e97cd4e1b885ccd0d88abf1124fa91f20d6be972e2242410447be73bca60014785f8551b8087ed0d4cc3e868225 SHA512 dfd5f02d4c1076fad4ee998b2f620171dd3eb65a1160312def9dae89b18327a06db853f569e0e3c049e5ab06c61488bb6faecec52bafe737fddeb43628c54a1f
@ -18,6 +19,7 @@ DIST gcc-13-20250117.tar.xz 84520416 BLAKE2B 3ce98ce1a17ec5a733e3cb8eab0a6084d5e
DIST gcc-13-20250124.tar.xz 84528596 BLAKE2B db8c45b1babd48158644899fe1a3e263eee6e716bc117be95f53aa30e00bf4a87b6de7c852e558887001cea53fbaaea4fe176f8a2361cf122cd05c36c7a0ae8f SHA512 d5d32c66d22a1fb2fca1db1c473125003ef204c68711459eb358374259efb924ea160c363b7b1c81659cc6bf154de499949c02e9adde1ddb4dcb2f2ebbb27e42
DIST gcc-13-20250131.tar.xz 84530144 BLAKE2B 45a667a31abd556383009d64ab9860ce2815c2446db02b985ec295344aed40060f8e90a01cea907082fdfc25a4572e0baf3fea9739b8777c0b9f76a9eacc4a22 SHA512 909fd58368f379863580e3641b0404e187293db5b3a88c703231726d8aced1241578d5865dcc1c62fcbe3ce030f24e433ff75bfff8266801d829998cab6abb01
DIST gcc-13-20250207.tar.xz 84528380 BLAKE2B da70e92437a364ae75c83199c3d1d075d73d5e3a9d78159633736f15a483771f352d3628c0f99de727790197f60fe9ad40a25d106b6a646a703e72599c419244 SHA512 c99701b181903169ed664e3b53b1f8c84f894b047ff9da0535fd02ab1160a290bbd7e34709d87f611617f24a7f44b1a348ca37d6d60ce356fe8bcb3cf78506fb
DIST gcc-13-20250214.tar.xz 84517404 BLAKE2B 0a37019f5948e16b35b4e5952f6ec90f77a284a2f5b4367c8ac223d9fef952903ce2c5b0807d6fa574a65ecd79c5a33a97a19e3d3face14b48f3ea7a9880ab44 SHA512 f15d0d9598b0c59303660c30298415b0e6a592ce2e4f2bf77ff5c1517a15e9f8308d09421efa6425a9fcccbb5499f70c87859fc98ac41264b64b383d815fa3e4
DIST gcc-13.2.0-musl-patches-2.tar.xz 5292 BLAKE2B c057d6574d03c05854edaa9f3fd40e9149662b04f3ac7a7db3eb078d73a7b535726d1bf52e5b12736dedb2f9898ad731f2e48a6421fcfbf7b90f929dee072fcb SHA512 a691da0c87c443a5e9d23731f4005f27871c5b12bc9102873ffa24d374aa7b9fbd187c4f5635d23fa9ffb17e351e76173c2d3fdf40646e355c4cb314b538de69
DIST gcc-13.2.0-patches-3.tar.xz 30956 BLAKE2B 29ce043b46645640ca1e983397af3e158588ad87575f0bc59451ea4a7dd5e3bb5b190ed031de6a22cd790d423ba111e95d222187dd09985dceb12db9f0a2d907 SHA512 4ffecae7be320124ad0c4e71e39e142b7aa8db0e70b5f486f491d7a33ea31efc6464c6abeea77df02a8bd5cf81f08225d625c8af5c27f9afa32c0d7d989f7a3c
DIST gcc-13.2.0.tar.xz 87858592 BLAKE2B 0034b29d3d6cc05821f0c4253ce077805943aff7b370729dd203bda57d89c107edd657eeddc2fb1e69ea15c7b0323b961f46516c7f4af89a3ccf7fea84701be2 SHA512 d99e4826a70db04504467e349e9fbaedaa5870766cda7c5cab50cdebedc4be755ebca5b789e1232a34a20be1a0b60097de9280efe47bdb71c73251e30b0862a2
@ -27,6 +29,7 @@ DIST gcc-14-20250118.tar.xz 88214804 BLAKE2B dd35140f0565d419eee272f70e668a8614c
DIST gcc-14-20250125.tar.xz 88214960 BLAKE2B c8f89803928db5c0374751b10a7d0bcaacfaa425f2b869fac96d35173afa9adf24d6969cdbfe20eea7425b97c23c14dbfda94bd72f447e530632e33719cd9916 SHA512 8d61d0002de3738ef51bbf0338d849121eb009a2908314511da0f79914f73bb5d1f8b1cc06b932188a3814f3bd6a61d0911da942ccc2352d8e2844f9f10ad039
DIST gcc-14-20250201.tar.xz 88210968 BLAKE2B 609c60e6343d2b947ca179b438d296409fcde779fe8eb96bbc56b105ba4bb3489ec1f0d609482bcfff7b25f5390eef9fced93e451acea17c52a182fe3584d6df SHA512 56362fe7169b6ca25c1fa729919a75c81080db54f43e25444957c72a82584ab7b209f72bdd01240a6bfa91b206e7f430e80bb13313a0b6453c88ca9244f32eb7
DIST gcc-14-20250208.tar.xz 88198624 BLAKE2B 28f3dba8fa1a9b31792140f0b8fcb6aaf6c4a4252f2131d8110024c8fdd5db8d3ebe060a9e9ed7b13c99791c3a3a68be76b9ff4aa9226dc035d965e5f25032ba SHA512 a12105a75c3affc1dd4eb28c3ec75a5d142b37a0b13f91c43a7dd760deedd5a09df3d2cf1f68540eb62c0e6ce47831814aa0a77cc594f79b88c3ab060776d4e1
DIST gcc-14-20250215.tar.xz 88203864 BLAKE2B b98ac4903372463a65ad03ac26432bb52be5242913f3fdcdfb2c864d38494e3b8230bdb8bd7a8aab5df00580765d8918ff014973a7d528afffc45eb57393483c SHA512 f39e79560e7c789a12fa8daf3338d99edb7947c881a1df8e392a6e1a5c84ba7449efbad4dfc23dfcd7d8d0df1eb79182c1a83c158f1d319a3cf01c1eacebe3eb
DIST gcc-14.1.0-musl-patches-1.tar.xz 3600 BLAKE2B 4cd920b7ca1f122cae806707564d8e45bfd48e78c88788a12a301f6068b5a5f335d8885e67479ac536c66aeaa81f2ecb7240ae56e9fc821a7246ab66b453711f SHA512 61c48d90a55dfc2129d96aee69d939d6a89f6407f69f7bd12c1a619f28989f471fd219d731958f8e62b0fd650c32300f0ad8dc06d5df23d9fc8c1a77fe210c25
DIST gcc-14.2.0-patches-7.tar.xz 14244 BLAKE2B 11236e91e1fe83fec8ffaa40ec0cdd4b52a00a951e9aa9a7a0a932b234b8f1a9603333a7ccf55859f4ef53dd4d8ad1fd5c1d2514b6e45fce5b86bb58622a0ecc SHA512 5a4d86d943e31fa068b5a784c0132bd83c23243dcb3cf972557a42e004469a415e1b3185f31b1bb36f916594d475f266a2fda031a414e4a15e0bbfe471269eee
DIST gcc-14.2.0-patches-8.tar.xz 14540 BLAKE2B 09f66035343d4cab694b8ab382170f8e2d546ddffedf3477f26edbd6a798ddf94294f569c2661729d40088d590bc17a4eb651710d8d9f66f33703734a1a82b67 SHA512 7a9a2724ef8db3c57b033d90751192969c16e5eaa8f4777b7f16470222ff3a18771b461bd89feaad701e7f0d573b883b487981588129933c732fb76117728b86
@ -35,12 +38,14 @@ DIST gcc-15-20250119.tar.xz 90709176 BLAKE2B da815cd472c0bb4101fb65fac73e93d8da8
DIST gcc-15-20250126.tar.xz 90895328 BLAKE2B 472b5c0ad2da8525a40530089f02bcdf6b8b3d3e31c1f5f86339d624c3a461ab24d35d815554513ba6dbe807f8f3a7f9e123f63ec0fe33796bee9e6da411deab SHA512 e55a19e07bd10b6c5f4a639d0fe548495297a4a1efe4c2cd4e891f27a2962bd929baeaf312b4f3a9e0a51b105e470de37a717fd8161ff75759aaa6b48c937d8a
DIST gcc-15-20250202.tar.xz 91011652 BLAKE2B 414fac76d3bb3887658387f80c64b587e75f71a8e1f2dc2c455c06a9d333125fdb113b30115ad1c3586fe92c786768c5f01eb1cb7e2cb6811adfb5fb1c46b391 SHA512 403c45199be4fb3f4b29495d26720f75bce20cea42fe0f47959db81f24769e20291a70ca2d63eccbeda9efd5abfb344ef7337c62118093092cd3438a1ef8fff4
DIST gcc-15-20250209.tar.xz 91287472 BLAKE2B e589600b828d560f9de5af01d340f5ac710c23c45fb5e66fe2876e3e73052f435e25c7c630c09b6fbf05381299effae6415a3592a4222687c15e96f54896752e SHA512 fcadf48cdd2cc55a7f0266eaa7643ffeb3c4606c3a6f6780a501b30ab8babe4b15d1cfe55038a65ae789e600119d86819af2ffe2b0800512bd9b3803e2407ec7
DIST gcc-15-20250216.tar.xz 91404792 BLAKE2B 1a007a432c7f7ac6ba0169caf2561e26267ae5c75403ecd52227dbee255eff4c1bca5db9d6ce2e772ee357dc06e648d7ebfb3629117b13d48343a474a17901c6 SHA512 8dcb3968e157a2cb6a06e4ba76a0fd95936025d99f48333aacc554f347d19df8e6b9a0c9c454acd730a5608122ff4c12a712ccdf09919f8e310cf6688c00df84
DIST gcc-15.0.0-musl-patches-2.tar.xz 3076 BLAKE2B 0073248fe4f7dd827980559017b5aa1fb5c4c46acc9ad5c410dc152fd1e44966d3066bf7152338573cb45b1c36027de5f0c519abd414d97a37bccef07f6a5281 SHA512 295f1a669020bbe2874e9b03afd46b5d083073b276fca3543f3767a2d74f35df81cf0a67abad50c200cf7a3af36ec98ff9977cb7d5c19f334af7d3bb1926a3de
DIST gcc-15.0.0-patches-41.tar.xz 33308 BLAKE2B d95b2798837a40380d06818fb047b7a5ea2e5a20de12a760b168c4dbb39c7af6b45621034d17250754f6dbc83dacdd7a75ff41c505b158bcf2090eca678d5f05 SHA512 203bedbab8e5d139ac3421e6347a2aecba48f5757ea524241feff7154eb918dad0c7f9f7505bf9041ab67b7c57170f5ea26f8160af3b268aec2b9a1113325733
DIST gcc-15.0.0-patches-42.tar.xz 26904 BLAKE2B 21fad98bfa977cb359dfeecec5b35d4470429acf103f99e3519a34f87926225e83257f23eb2983adf68d2a8a3089f7769dedfde7302ef9f55c30b59bba47d1bb SHA512 3ede6bf4c908a179b4b9bf8d281385a6ecf64be481479c88ad0b250b6c93050ff76dd2cf6fc9b12bf8b503a123cad2b8c418abc4ab233524d7bd78e1d9f31009
DIST gcc-15.0.0-patches-43.tar.xz 25892 BLAKE2B 1d0dbbe277179aefaab20e03bf152ded962c69fe4b3afcdcf7211a71327149977109fe0e8b2bc198ee16a59ab2569d2b698f216712eaa65c2cdb6de209aa1ffb SHA512 ddf3e6d2876c4d567830de91b39acedda280d739f7948ec02d04b409be10d8e1bb41a510d1b5f78b26e79de18aa2b281f9ce2182088b6b514f2f46389af8c22e
DIST gcc-15.0.0-patches-44.tar.xz 25092 BLAKE2B 4010f1f7ab17e47879db78f11f99ff4c8fe1258dc326aae9af6e25be098d8cc5806223d014a668cf6d2f8e1a36a40ca0a6a5aa87e70f15164460c728d329793e SHA512 329ffc475fde3d5c19382c83fae2ce60fd3c0f1e336f7e87ca2df4689c73747807f1b9665ee00995356b5fbcee3bb1e3092c100d1b08f98f1d0b17d1ec8c8581
DIST gcc-15.0.0-patches-45.tar.xz 25044 BLAKE2B f270b48434ec3ca3b1c52e62efa09a38625d40290fabf059914116423d14173c63cd45fcd496768cdc19eafdb10fabfe651d03ec56bb6b44a0e70eb00814b1dd SHA512 bb301b36c3c033f8d0abde9729f3c22d4867d4f6f9cfcf4456ee0a58331af25205db5d87fe1727fdbc3da04fa84c7434da83cc48c6674671a2db1a7e9b093a0b
DIST gcc-15.0.0-patches-46.tar.xz 22212 BLAKE2B 159b2693ded0b1dbddd271ca56d7f6db3569a8f79155521737b968ad131eee2730d3441dacef821b9dcd31b17ca0bf16a7b24001e7cb4ae1b36c55750184a3f6 SHA512 26d293ee368c75570e606949480feed18a69baad4687beaf2f50629bfc72d542bbce4b1cb6580fe7e578409a108891dc9762bb15c53b611434c83db5dd83d695
DIST gcc-8.5.0-patches-4.tar.xz 18616 BLAKE2B 7594cbaea5daecf1a0b3d526c06aeba0a84c6da66aee2e105a51fda6be8d30a37ccc3814281b284a4582d892a1d556bca063551584edfc2525bed8ea5b6888e7 SHA512 1aa5742c361186637e7855f06feb1a4547e7d4d5de6e51f3d049e0ef3c19e2eff179465f52781739f59422035b7f8e4c0efa3844849f920f3c96acfdc37ca6a6
DIST gcc-8.5.0.tar.xz 63841008 BLAKE2B aa81a1a730fd7371360f6abed6ba78b5843fd18c58d5de5687acc320741b9e430e85df3535a1ef7a26051409be8d2f0945f503e5968480d919103123a99d4b12 SHA512 92f599680e6b7fbce88bcdda810f468777d541e5fddfbb287f7977d51093de2a5178bd0e6a08dfe37090ea10a0508a43ccd00220041abbbec33f1179bfc174d8
DIST gcc-9.5.0-patches-2.tar.xz 14324 BLAKE2B 1d3bf3e673108ad2fcdcb86daefb4603d1c9f6aa815e34d1591054d466b76d6f50cce124ab4760528c4951ea16eb00888a3e6485417f81ebf250548732df4a8e SHA512 a6d6f650aaf0bd193a17ac279649f0544a282cea295824384c59341c3000eac4b574b60e00dd427585d928f9768166abf85168b47772132790ad98854acacbbf

View File

@ -0,0 +1,124 @@
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=556248d7d2cf557423993eb68f6a55ae6bda0cee
From 556248d7d2cf557423993eb68f6a55ae6bda0cee Mon Sep 17 00:00:00 2001
From: Jason Merrill <jason@redhat.com>
Date: Tue, 11 Feb 2025 13:51:32 +0100
Subject: [PATCH] c++: don't default -frange-for-ext-temps in -std=gnu++20
[PR188574]
Since -frange-for-ext-temps has been causing trouble, let's not enable it
by default in pre-C++23 GNU modes for GCC 15, and also allow disabling it in
C++23 and up.
PR c++/188574
gcc/c-family/ChangeLog:
* c-opts.cc (c_common_post_options): Only enable
-frange-for-ext-temps by default in C++23.
gcc/ChangeLog:
* doc/invoke.texi: Adjust -frange-for-ext-temps documentation.
gcc/testsuite/ChangeLog:
* g++.dg/cpp23/range-for3.C: Use -frange-for-ext-temps.
* g++.dg/cpp23/range-for4.C: Adjust expected result.
libgomp/ChangeLog:
* testsuite/libgomp.c++/range-for-4.C: Adjust expected result.
---
gcc/c-family/c-opts.cc | 17 +++--------------
gcc/doc/invoke.texi | 5 ++---
gcc/testsuite/g++.dg/cpp23/range-for3.C | 4 ++--
gcc/testsuite/g++.dg/cpp23/range-for4.C | 4 ++--
libgomp/testsuite/libgomp.c++/range-for-4.C | 2 +-
5 files changed, 10 insertions(+), 22 deletions(-)
diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc
index 87b231861a64..d43b3aef1024 100644
--- a/gcc/c-family/c-opts.cc
+++ b/gcc/c-family/c-opts.cc
@@ -1213,20 +1213,9 @@ c_common_post_options (const char **pfilename)
if (cxx_dialect >= cxx20)
flag_concepts = 1;
- /* Enable lifetime extension of range based for temporaries for C++23.
- Diagnose -std=c++23 -fno-range-for-ext-temps. */
- if (cxx_dialect >= cxx23)
- {
- if (OPTION_SET_P (flag_range_for_ext_temps)
- && !flag_range_for_ext_temps)
- error ("%<-fno-range-for-ext-temps%> is incompatible with C++23");
- flag_range_for_ext_temps = 1;
- }
- /* Otherwise default to enabled in GNU modes but allow user to override. */
- else if (cxx_dialect >= cxx11
- && !flag_iso
- && !OPTION_SET_P (flag_range_for_ext_temps))
- flag_range_for_ext_temps = 1;
+ /* Enable lifetime extension of range based for temporaries for C++23. */
+ SET_OPTION_IF_UNSET (&global_options, &global_options_set,
+ flag_range_for_ext_temps, cxx_dialect >= cxx23);
/* -fimmediate-escalation has no effect when immediate functions are not
supported. */
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 0aef2abf05b9..56d43cb67796 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -3548,9 +3548,8 @@ easier, you can use @option{-fno-pretty-templates} to disable them.
Enable lifetime extension of C++ range based for temporaries.
With @option{-std=c++23} and above this is part of the language standard,
so lifetime of the temporaries is extended until the end of the loop
-regardless of this option. This option allows enabling that behavior also
-in earlier versions of the standard and is enabled by default in the
-GNU dialects, from @option{-std=gnu++11} until @option{-std=gnu++20}.
+by default. This option allows enabling that behavior also
+in earlier versions of the standard.
@opindex fno-rtti
@opindex frtti
diff --git a/gcc/testsuite/g++.dg/cpp23/range-for3.C b/gcc/testsuite/g++.dg/cpp23/range-for3.C
index 301e25886ec6..f95b21b3ceee 100644
--- a/gcc/testsuite/g++.dg/cpp23/range-for3.C
+++ b/gcc/testsuite/g++.dg/cpp23/range-for3.C
@@ -1,7 +1,7 @@
// P2718R0 - Wording for P2644R1 Fix for Range-based for Loop
// { dg-do run { target c++11 } }
-// Verify -frange-for-ext-temps is set by default in -std=gnu++* modes.
-// { dg-options "" }
+// Verify -frange-for-ext-temps works in earlier standards.
+// { dg-additional-options "-frange-for-ext-temps" }
#define RANGE_FOR_EXT_TEMPS 1
#include "range-for1.C"
diff --git a/gcc/testsuite/g++.dg/cpp23/range-for4.C b/gcc/testsuite/g++.dg/cpp23/range-for4.C
index f8c380d32c72..16204974bac9 100644
--- a/gcc/testsuite/g++.dg/cpp23/range-for4.C
+++ b/gcc/testsuite/g++.dg/cpp23/range-for4.C
@@ -1,7 +1,7 @@
// P2718R0 - Wording for P2644R1 Fix for Range-based for Loop
// { dg-do run { target c++11 } }
-// Verify -frange-for-ext-temps is set by default in -std=gnu++* modes.
+// Verify -frange-for-ext-temps is not set by default in -std=gnu++* modes.
// { dg-options "" }
-#define RANGE_FOR_EXT_TEMPS 1
+#define RANGE_FOR_EXT_TEMPS 0
#include "range-for2.C"
diff --git a/libgomp/testsuite/libgomp.c++/range-for-4.C b/libgomp/testsuite/libgomp.c++/range-for-4.C
index 3c10e7349af7..aa6e4da523c1 100644
--- a/libgomp/testsuite/libgomp.c++/range-for-4.C
+++ b/libgomp/testsuite/libgomp.c++/range-for-4.C
@@ -3,5 +3,5 @@
// { dg-additional-options "-std=gnu++17" }
// { dg-require-effective-target tls_runtime }
-#define RANGE_FOR_EXT_TEMPS 1
+#define RANGE_FOR_EXT_TEMPS 0
#include "range-for-1.C"
--
2.43.5

View File

@ -0,0 +1,530 @@
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=26baa2c09b39abf037afad349a318dc5734eae25
From 26baa2c09b39abf037afad349a318dc5734eae25 Mon Sep 17 00:00:00 2001
From: Jakub Jelinek <jakub@redhat.com>
Date: Thu, 13 Feb 2025 10:21:29 +0100
Subject: [PATCH] c++: Fix up regressions caused by for/while loops with
declarations [PR118822]
The recent PR86769 r15-7426 changes regressed the following two testcases,
the first one is more important as it is derived from real-world code.
The first problem is that the chosen
prep = do_pushlevel (sk_block);
// emit something
body = push_stmt_list ();
// emit further stuff
body = pop_stmt_list (body);
prep = do_poplevel (prep);
way of constructing the {FOR,WHILE}_COND_PREP and {FOR,WHILE}_BODY
isn't reliable. If during parsing a label is seen in the body and then
some decl with destructors, sk_cleanup transparent scope is added, but
the correspondiong result from push_stmt_list is saved in
*current_binding_level and pop_stmt_list then pops even that statement list
but only do_poplevel actually attempts to pop the sk_cleanup scope and so we
ICE.
The reason for not doing do_pushlevel (sk_block); do_pushlevel (sk_block);
is that variables should be in the same scope (otherwise various e.g.
redeclaration*.C tests FAIL) and doing do_pushlevel (sk_block); do_pushlevel
(sk_cleanup); wouldn't work either as do_poplevel would silently unwind even
the cleanup one.
The second problem is that my assumption that the declaration in the
condition will have zero or one cleanup is just wrong, at least for
structured bindings used as condition, there can be as many cleanups as
there are names in the binding + 1.
So, the following patch changes the earlier approach. Nothing is removed
from the {FOR,WHILE}_COND_PREP subtrees while doing adjust_loop_decl_cond,
push_stmt_list isn't called either; all it does is remember as an integer
the number of cleanups (CLEANUP_STMT at the end of the STATEMENT_LISTs)
from querying stmt_list_stack and finding the initial *body_p in there
(that integer is stored into {FOR,WHILE}_COND_CLEANUP), and temporarily
{FOR,WHILE}_BODY is set to the last statement (if any) in the innermost
STATEMENT_LIST at the adjust_loop_decl_cond time; then at
finish_{for,while}_stmt a new finish_loop_cond_prep routine takes care of
do_poplevel for the scope (which is in {FOR,WHILE}_COND_PREP) and finds
given {FOR,WHILE}_COND_CLEANUP number and {FOR,WHILE}_BODY tree the right
spot where body statements start and moves that into {FOR,WHILE}_BODY.
Finally genericize_c_loop then inserts the cond, body, continue label, expr
into the right subtree of {FOR,WHILE}_COND_PREP.
The constexpr evaluation unfortunately had to be changed as well, because
we don't want to evaluate everything in BIND_EXPR_BODY (*_COND_PREP ())
right away, we want to evaluate it with the exception of the CLEANUP_STMT
cleanups at the end (given {FOR,WHILE}_COND_CLEANUP levels), and defer
the evaluation of the cleanups until after cond, body, expr are evaluated.
2025-02-13 Jakub Jelinek <jakub@redhat.com>
PR c++/118822
PR c++/118833
gcc/
* tree-iterator.h (tsi_split_stmt_list): Declare.
* tree-iterator.cc (tsi_split_stmt_list): New function.
gcc/c-family/
* c-common.h (WHILE_COND_CLEANUP): Change description in comment.
(FOR_COND_CLEANUP): Likewise.
* c-gimplify.cc (genericize_c_loop): Adjust for COND_CLEANUP
being CLEANUP_STMT/TRY_FINALLY_EXPR trailing nesting depth
instead of actual cleanup.
gcc/cp/
* semantics.cc (adjust_loop_decl_cond): Allow multiple trailing
CLEANUP_STMT levels in *BODY_P. Set *CLEANUP_P to the number
of levels rather than one particular cleanup, keep the cleanups
in *PREP_P. Set *BODY_P to the last stmt in the cur_stmt_list
or NULL if *CLEANUP_P and the innermost cur_stmt_list is empty.
(finish_loop_cond_prep): New function.
(finish_while_stmt, finish_for_stmt): Use it. Don't call
set_one_cleanup_loc.
* constexpr.cc (cxx_eval_loop_expr): Adjust handling of
{FOR,WHILE}_COND_{PREP,CLEANUP}.
gcc/testsuite/
* g++.dg/expr/for9.C: New test.
* g++.dg/cpp26/decomp12.C: New test.
---
gcc/c-family/c-common.h | 6 +-
gcc/c-family/c-gimplify.cc | 41 +++------
gcc/cp/constexpr.cc | 97 +++++++++++++++++--
gcc/cp/semantics.cc | 128 +++++++++++++++++++-------
gcc/testsuite/g++.dg/cpp26/decomp12.C | 46 +++++++++
gcc/testsuite/g++.dg/expr/for9.C | 25 +++++
gcc/tree-iterator.cc | 22 +++++
gcc/tree-iterator.h | 1 +
8 files changed, 297 insertions(+), 69 deletions(-)
create mode 100644 gcc/testsuite/g++.dg/cpp26/decomp12.C
create mode 100644 gcc/testsuite/g++.dg/expr/for9.C
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index bc238430b7a7..ea6c29750567 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -1518,7 +1518,8 @@ extern tree build_userdef_literal (tree suffix_id, tree value,
/* WHILE_STMT accessors. These give access to the condition of the
while statement, the body, and name of the while statement, and
- condition preparation statements and its cleanup, respectively. */
+ condition preparation statements and number of its nested cleanups,
+ respectively. */
#define WHILE_COND(NODE) TREE_OPERAND (WHILE_STMT_CHECK (NODE), 0)
#define WHILE_BODY(NODE) TREE_OPERAND (WHILE_STMT_CHECK (NODE), 1)
#define WHILE_NAME(NODE) TREE_OPERAND (WHILE_STMT_CHECK (NODE), 2)
@@ -1533,7 +1534,8 @@ extern tree build_userdef_literal (tree suffix_id, tree value,
/* FOR_STMT accessors. These give access to the init statement,
condition, update expression, body and name of the for statement,
- and condition preparation statements and its cleanup, respectively. */
+ and condition preparation statements and number of its nested cleanups,
+ respectively. */
#define FOR_INIT_STMT(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 0)
#define FOR_COND(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 1)
#define FOR_EXPR(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 2)
diff --git a/gcc/c-family/c-gimplify.cc b/gcc/c-family/c-gimplify.cc
index d53e0c2dc567..dc5e80dfa6be 100644
--- a/gcc/c-family/c-gimplify.cc
+++ b/gcc/c-family/c-gimplify.cc
@@ -258,8 +258,10 @@ expr_loc_or_loc (const_tree expr, location_t or_loc)
for C++ for/while loops with variable declaration as condition. COND_PREP
is a BIND_EXPR with the declaration and initialization of the condition
variable, into which COND, BODY, continue label if needed and INCR if
- non-NULL should be appended, and COND_CLEANUP are statements which should
- be evaluated after that or if anything in COND, BODY or INCR throws. */
+ non-NULL should be appended, and COND_CLEANUP is number of nested
+ CLEANUP_STMT -> TRY_FINALLY_EXPR statements at the end. If non-NULL,
+ COND, BODY, continue label if needed and INCR if non-NULL should be
+ appended to the body of the COND_CLEANUP's nested TRY_FINALLY_EXPR. */
static void
genericize_c_loop (tree *stmt_p, location_t start_locus, tree cond, tree body,
@@ -278,7 +280,6 @@ genericize_c_loop (tree *stmt_p, location_t start_locus, tree cond, tree body,
walk_tree_1 (&cond_prep, func, data, NULL, lh);
walk_tree_1 (&cond, func, data, NULL, lh);
walk_tree_1 (&incr, func, data, NULL, lh);
- walk_tree_1 (&cond_cleanup, func, data, NULL, lh);
blab = begin_bc_block (bc_break, start_locus);
clab = begin_bc_block (bc_continue, start_locus);
@@ -309,36 +310,24 @@ genericize_c_loop (tree *stmt_p, location_t start_locus, tree cond, tree body,
EXPR;
goto top;
- or
-
- try {
- if (COND); else break;
- BODY;
- cont:
- EXPR;
- } finally {
- COND_CLEANUP
- }
-
- appended into COND_PREP body. */
+ appended into COND_PREP body or body of some TRY_FINALLY_EXPRs
+ at the end of COND_PREP. */
gcc_assert (cond_is_first && TREE_CODE (cond_prep) == BIND_EXPR);
tree top = build1 (LABEL_EXPR, void_type_node,
create_artificial_label (start_locus));
exit = build1 (GOTO_EXPR, void_type_node, LABEL_EXPR_LABEL (top));
append_to_statement_list (top, &outer_stmt_list);
append_to_statement_list (cond_prep, &outer_stmt_list);
- stmt_list = BIND_EXPR_BODY (cond_prep);
- BIND_EXPR_BODY (cond_prep) = NULL_TREE;
stmt_list_p = &BIND_EXPR_BODY (cond_prep);
- if (cond_cleanup && TREE_SIDE_EFFECTS (cond_cleanup))
- {
- t = build2_loc (EXPR_LOCATION (cond_cleanup), TRY_FINALLY_EXPR,
- void_type_node, NULL_TREE, cond_cleanup);
- append_to_statement_list (t, &stmt_list);
- *stmt_list_p = stmt_list;
- stmt_list_p = &TREE_OPERAND (t, 0);
- stmt_list = NULL_TREE;
- }
+ if (cond_cleanup)
+ for (unsigned depth = tree_to_uhwi (cond_cleanup); depth; --depth)
+ {
+ t = tsi_stmt (tsi_last (*stmt_list_p));
+ gcc_assert (TREE_CODE (t) == TRY_FINALLY_EXPR);
+ stmt_list_p = &TREE_OPERAND (t, 0);
+ }
+ stmt_list = *stmt_list_p;
+ *stmt_list_p = NULL_TREE;
tree after_cond = create_artificial_label (cond_locus);
tree goto_after_cond = build1 (GOTO_EXPR, void_type_node, after_cond);
t = build1 (GOTO_EXPR, void_type_node, get_bc_label (bc_break));
diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc
index f142dd32bc80..299b13456873 100644
--- a/gcc/cp/constexpr.cc
+++ b/gcc/cp/constexpr.cc
@@ -7153,6 +7153,7 @@ cxx_eval_loop_expr (const constexpr_ctx *ctx, tree t,
tree body, cond = NULL_TREE, expr = NULL_TREE;
tree cond_prep = NULL_TREE, cond_cleanup = NULL_TREE;
+ unsigned cond_cleanup_depth = 0;
int count = 0;
switch (TREE_CODE (t))
{
@@ -7188,11 +7189,25 @@ cxx_eval_loop_expr (const constexpr_ctx *ctx, tree t,
}
if (cond_prep)
gcc_assert (TREE_CODE (cond_prep) == BIND_EXPR);
- auto cleanup_cond = [=] {
+ auto cleanup_cond = [&] {
/* Clean up the condition variable after each iteration. */
- if (cond_cleanup && !*non_constant_p)
- cxx_eval_constant_expression (ctx, cond_cleanup, vc_discard,
- non_constant_p, overflow_p);
+ if (cond_cleanup_depth && !*non_constant_p)
+ {
+ auto_vec<tree, 4> cleanups (cond_cleanup_depth);
+ tree s = BIND_EXPR_BODY (cond_prep);
+ unsigned i;
+ for (i = cond_cleanup_depth; i; --i)
+ {
+ tree_stmt_iterator iter = tsi_last (s);
+ s = tsi_stmt (iter);
+ cleanups.quick_push (CLEANUP_EXPR (s));
+ s = CLEANUP_BODY (s);
+ }
+ tree c;
+ FOR_EACH_VEC_ELT_REVERSE (cleanups, i, c)
+ cxx_eval_constant_expression (ctx, c, vc_discard, non_constant_p,
+ overflow_p);
+ }
if (cond_prep)
for (tree decl = BIND_EXPR_VARS (cond_prep);
decl; decl = DECL_CHAIN (decl))
@@ -7227,9 +7242,77 @@ cxx_eval_loop_expr (const constexpr_ctx *ctx, tree t,
for (tree decl = BIND_EXPR_VARS (cond_prep);
decl; decl = DECL_CHAIN (decl))
ctx->global->clear_value (decl);
- cxx_eval_constant_expression (ctx, BIND_EXPR_BODY (cond_prep),
- vc_discard, non_constant_p,
- overflow_p, jump_target);
+ if (cond_cleanup)
+ {
+ /* If COND_CLEANUP is non-NULL, we need to evaluate DEPTH
+ nested STATEMENT_LISTs from inside of BIND_EXPR_BODY,
+ but defer the evaluation of CLEANUP_EXPRs of CLEANUP_STMT
+ at the end of those STATEMENT_LISTs. */
+ cond_cleanup_depth = 0;
+ tree s = BIND_EXPR_BODY (cond_prep);
+ for (unsigned depth = tree_to_uhwi (cond_cleanup);
+ depth; --depth)
+ {
+ for (tree_stmt_iterator i = tsi_start (s);
+ !tsi_end_p (i); ++i)
+ {
+ tree stmt = *i;
+ if (TREE_CODE (stmt) == DEBUG_BEGIN_STMT)
+ continue;
+ if (tsi_one_before_end_p (i))
+ {
+ /* The last statement in the STATEMENT_LIST
+ has to be a CLEANUP_STMT (verified in
+ finish_loop_cond_prep). We want to
+ evaluate just its CLEANUP_BODY part but not
+ CLEANUP_EXPR part just yet. */
+ gcc_assert (TREE_CODE (stmt) == CLEANUP_STMT);
+ /* If the CLEANUP_STMT is not actually to be
+ evaluated, don't increment cond_cleanup_depth
+ so that we don't evaluate the CLEANUP_EXPR
+ for it later either. */
+ if (*jump_target)
+ {
+ depth = 1;
+ break;
+ }
+ ++cond_cleanup_depth;
+ /* If not in the innermost one, next iteration
+ will handle CLEANUP_BODY similarly. */
+ if (depth > 1)
+ {
+ s = CLEANUP_BODY (stmt);
+ break;
+ }
+ /* The innermost one can be evaluated normally. */
+ cxx_eval_constant_expression (ctx,
+ CLEANUP_BODY (stmt),
+ vc_discard,
+ non_constant_p,
+ overflow_p,
+ jump_target);
+ break;
+ }
+ /* And so should be evaluated statements which aren't
+ last in the STATEMENT_LIST. */
+ cxx_eval_constant_expression (ctx, stmt, vc_discard,
+ non_constant_p, overflow_p,
+ jump_target);
+ if (*non_constant_p
+ || returns (jump_target)
+ || breaks (jump_target)
+ || continues (jump_target))
+ {
+ depth = 1;
+ break;
+ }
+ }
+ }
+ }
+ else
+ cxx_eval_constant_expression (ctx, BIND_EXPR_BODY (cond_prep),
+ vc_discard, non_constant_p,
+ overflow_p, jump_target);
}
if (cond)
diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc
index 8a2d86576fb0..7c7d3e3c4326 100644
--- a/gcc/cp/semantics.cc
+++ b/gcc/cp/semantics.cc
@@ -790,8 +790,8 @@ finish_cond (tree *cond_p, tree expr)
while (A x = 42) { }
for (; A x = 42;) { }
move the *BODY_P statements as a BIND_EXPR into {FOR,WHILE}_COND_PREP
- and if there is any CLEANUP_STMT at the end, remove that and
- put the cleanup into {FOR,WHILE}_COND_CLEANUP.
+ and if there are any CLEANUP_STMT at the end, remember their count in
+ {FOR,WHILE}_COND_CLEANUP.
genericize_c_loop will then handle it appropriately. In particular,
the {FOR,WHILE}_COND, {FOR,WHILE}_BODY, if used continue label and
FOR_EXPR will be appended into the {FOR,WHILE}_COND_PREP BIND_EXPR,
@@ -807,26 +807,88 @@ adjust_loop_decl_cond (tree *body_p, tree *prep_p, tree *cleanup_p)
return;
gcc_assert (!processing_template_decl);
- if (*body_p != cur_stmt_list)
- {
- /* There can be either no cleanup at all, if the condition
- declaration doesn't have non-trivial destructor, or a single
- one if it does. In that case extract it into *CLEANUP_P. */
- gcc_assert (stmt_list_stack->length () > 1
- && (*stmt_list_stack)[stmt_list_stack->length ()
- - 2] == *body_p);
- tree_stmt_iterator last = tsi_last (*body_p);
- gcc_assert (tsi_one_before_end_p (last)
- && TREE_CODE (tsi_stmt (last)) == CLEANUP_STMT
- && CLEANUP_BODY (tsi_stmt (last)) == cur_stmt_list
- && tsi_end_p (tsi_last (cur_stmt_list))
- && !CLEANUP_EH_ONLY (tsi_stmt (last)));
- *cleanup_p = CLEANUP_EXPR (tsi_stmt (last));
- tsi_delink (&last);
+ *prep_p = *body_p;
+ if (*prep_p != cur_stmt_list)
+ {
+ /* There can be just one CLEANUP_STMT, or there could be multiple
+ nested CLEANUP_STMTs, e.g. for structured bindings used as
+ condition. */
+ gcc_assert (stmt_list_stack->length () > 1);
+ for (unsigned i = stmt_list_stack->length () - 2; ; --i)
+ {
+ tree t = (*stmt_list_stack)[i];
+ tree_stmt_iterator last = tsi_last (t);
+ gcc_assert (tsi_one_before_end_p (last)
+ && TREE_CODE (tsi_stmt (last)) == CLEANUP_STMT
+ && (CLEANUP_BODY (tsi_stmt (last))
+ == (*stmt_list_stack)[i + 1])
+ && !CLEANUP_EH_ONLY (tsi_stmt (last)));
+ if (t == *prep_p)
+ {
+ *cleanup_p = build_int_cst (long_unsigned_type_node,
+ stmt_list_stack->length () - 1 - i);
+ break;
+ }
+ gcc_assert (i >= 1);
+ }
}
current_binding_level->keep = true;
- *prep_p = *body_p;
- *body_p = push_stmt_list ();
+ tree_stmt_iterator iter = tsi_last (cur_stmt_list);
+ /* Temporarily store in {FOR,WHILE}_BODY the last statement of
+ the innnermost statement list or NULL if it has no statement.
+ This is used in finish_loop_cond_prep to find out the splitting
+ point and then {FOR,WHILE}_BODY will be changed to the actual
+ body. */
+ if (tsi_end_p (iter))
+ *body_p = NULL_TREE;
+ else
+ *body_p = tsi_stmt (iter);
+}
+
+/* Finalize {FOR,WHILE}_{BODY,COND_PREP} after the loop body.
+ The above function initialized *BODY_P to the last statement
+ in *PREP_P at that point.
+ Call do_poplevel on *PREP_P and move everything after that
+ former last statement into *BODY_P. genericize_c_loop
+ will later put those parts back together.
+ CLEANUP is {FOR,WHILE}_COND_CLEANUP. */
+
+static void
+finish_loop_cond_prep (tree *body_p, tree *prep_p, tree cleanup)
+{
+ *prep_p = do_poplevel (*prep_p);
+ gcc_assert (TREE_CODE (*prep_p) == BIND_EXPR);
+ if (BIND_EXPR_BODY (*prep_p) == *body_p)
+ {
+ gcc_assert (cleanup == NULL_TREE);
+ *body_p = build_empty_stmt (input_location);
+ return;
+ }
+ tree stmt_list = BIND_EXPR_BODY (*prep_p);
+ gcc_assert (TREE_CODE (stmt_list) == STATEMENT_LIST);
+ if (cleanup)
+ {
+ tree_stmt_iterator iter = tsi_last (stmt_list);
+ gcc_assert (TREE_CODE (tsi_stmt (iter)) == CLEANUP_STMT);
+ for (unsigned depth = tree_to_uhwi (cleanup); depth > 1; --depth)
+ {
+ gcc_assert (TREE_CODE (CLEANUP_BODY (tsi_stmt (iter)))
+ == STATEMENT_LIST);
+ iter = tsi_last (CLEANUP_BODY (tsi_stmt (iter)));
+ gcc_assert (TREE_CODE (tsi_stmt (iter)) == CLEANUP_STMT);
+ }
+ if (*body_p == NULL_TREE)
+ {
+ *body_p = CLEANUP_BODY (tsi_stmt (iter));
+ CLEANUP_BODY (tsi_stmt (iter)) = build_empty_stmt (input_location);
+ return;
+ }
+ stmt_list = CLEANUP_BODY (tsi_stmt (iter));
+ }
+ tree_stmt_iterator iter = tsi_start (stmt_list);
+ while (tsi_stmt (iter) != *body_p)
+ tsi_next (&iter);
+ *body_p = tsi_split_stmt_list (input_location, iter);
}
/* Finish a goto-statement. */
@@ -1437,14 +1499,13 @@ void
finish_while_stmt (tree while_stmt)
{
end_maybe_infinite_loop (boolean_true_node);
- WHILE_BODY (while_stmt)
- = (WHILE_COND_PREP (while_stmt)
- ? pop_stmt_list (WHILE_BODY (while_stmt))
- : do_poplevel (WHILE_BODY (while_stmt)));
- finish_loop_cond (&WHILE_COND (while_stmt), WHILE_BODY (while_stmt));
if (WHILE_COND_PREP (while_stmt))
- WHILE_COND_PREP (while_stmt) = do_poplevel (WHILE_COND_PREP (while_stmt));
- set_one_cleanup_loc (WHILE_COND_CLEANUP (while_stmt), input_location);
+ finish_loop_cond_prep (&WHILE_BODY (while_stmt),
+ &WHILE_COND_PREP (while_stmt),
+ WHILE_COND_CLEANUP (while_stmt));
+ else
+ WHILE_BODY (while_stmt) = do_poplevel (WHILE_BODY (while_stmt));
+ finish_loop_cond (&WHILE_COND (while_stmt), WHILE_BODY (while_stmt));
}
/* Begin a do-statement. Returns a newly created DO_STMT if
@@ -1709,17 +1770,16 @@ finish_for_stmt (tree for_stmt)
RANGE_FOR_BODY (for_stmt) = do_poplevel (RANGE_FOR_BODY (for_stmt));
else
{
- FOR_BODY (for_stmt)
- = (FOR_COND_PREP (for_stmt)
- ? pop_stmt_list (FOR_BODY (for_stmt))
- : do_poplevel (FOR_BODY (for_stmt)));
+ if (FOR_COND_PREP (for_stmt))
+ finish_loop_cond_prep (&FOR_BODY (for_stmt),
+ &FOR_COND_PREP (for_stmt),
+ FOR_COND_CLEANUP (for_stmt));
+ else
+ FOR_BODY (for_stmt) = do_poplevel (FOR_BODY (for_stmt));
if (FOR_COND (for_stmt))
finish_loop_cond (&FOR_COND (for_stmt),
FOR_EXPR (for_stmt) ? integer_one_node
: FOR_BODY (for_stmt));
- if (FOR_COND_PREP (for_stmt))
- FOR_COND_PREP (for_stmt) = do_poplevel (FOR_COND_PREP (for_stmt));
- set_one_cleanup_loc (FOR_COND_CLEANUP (for_stmt), input_location);
}
/* Pop the scope for the body of the loop. */
diff --git a/gcc/tree-iterator.cc b/gcc/tree-iterator.cc
index db2219c62489..b7e2b421c5ee 100644
--- a/gcc/tree-iterator.cc
+++ b/gcc/tree-iterator.cc
@@ -284,6 +284,28 @@ tsi_delink (tree_stmt_iterator *i)
i->ptr = next;
}
+/* Split a STATEMENT_LIST in I.contrainer into two, all statements
+ from the start until I.ptr inclusive will remain in the original
+ one, all statements after I.ptr are removed from that STATEMENT_LIST
+ and returned as a new STATEMENT_LIST. If I is the last statement,
+ an empty statement with LOC location is returned. */
+
+tree
+tsi_split_stmt_list (location_t loc, tree_stmt_iterator i)
+{
+ if (tsi_one_before_end_p (i))
+ return build_empty_stmt (loc);
+ tsi_next (&i);
+ tree ret = NULL_TREE;
+ while (!tsi_end_p (i))
+ {
+ tree t = tsi_stmt (i);
+ tsi_delink (&i);
+ append_to_statement_list_force (t, &ret);
+ }
+ return ret;
+}
+
/* Return the first expression in a sequence of COMPOUND_EXPRs, or in
a STATEMENT_LIST, disregarding DEBUG_BEGIN_STMTs, recursing into a
STATEMENT_LIST if that's the first non-DEBUG_BEGIN_STMT. */
diff --git a/gcc/tree-iterator.h b/gcc/tree-iterator.h
index 27795e9ee2b8..d1bc9014c65b 100644
--- a/gcc/tree-iterator.h
+++ b/gcc/tree-iterator.h
@@ -138,6 +138,7 @@ extern void tsi_link_after (tree_stmt_iterator *, tree,
enum tsi_iterator_update);
extern void tsi_delink (tree_stmt_iterator *);
+extern tree tsi_split_stmt_list (location_t, tree_stmt_iterator);
extern tree alloc_stmt_list (void);
extern void free_stmt_list (tree);
--
2.43.5

View File

@ -0,0 +1,65 @@
# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
TOOLCHAIN_PATCH_DEV="sam"
TOOLCHAIN_HAS_TESTS=1
PATCH_GCC_VER="12.4.0"
PATCH_VER="2"
MUSL_VER="1"
MUSL_GCC_VER="12.4.0"
PYTHON_COMPAT=( python3_{10..12} )
if [[ ${PV} == *.9999 ]] ; then
MY_PV_2=$(ver_cut 2)
MY_PV_3=1
if [[ ${MY_PV_2} == 0 ]] ; then
MY_PV_2=0
MY_PV_3=0
else
MY_PV_2=$((${MY_PV_2} - 1))
fi
# e.g. 12.2.9999 -> 12.1.1
TOOLCHAIN_GCC_PV=$(ver_cut 1).${MY_PV_2}.${MY_PV_3}
elif [[ -n ${TOOLCHAIN_GCC_RC} ]] ; then
# Cheesy hack for RCs
MY_PV=$(ver_cut 1).$((($(ver_cut 2) + 1))).$((($(ver_cut 3) - 1)))-RC-$(ver_cut 5)
MY_P=${PN}-${MY_PV}
GCC_TARBALL_SRC_URI="mirror://gcc/snapshots/${MY_PV}/${MY_P}.tar.xz"
TOOLCHAIN_SET_S=no
S="${WORKDIR}"/${MY_P}
fi
inherit toolchain
if tc_is_live ; then
# Needs to be after inherit (for now?), bug #830908
EGIT_BRANCH=releases/gcc-$(ver_cut 1)
elif [[ -z ${TOOLCHAIN_USE_GIT_PATCHES} ]] ; then
# Don't keyword live ebuilds
#KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
:;
fi
if [[ ${CATEGORY} != cross-* ]] ; then
# Technically only if USE=hardened *too* right now, but no point in complicating it further.
# If GCC is enabling CET by default, we need glibc to be built with support for it.
# bug #830454
RDEPEND="elibc_glibc? ( sys-libs/glibc[cet(-)?] )"
DEPEND="${RDEPEND}"
fi
src_prepare() {
local p upstreamed_patches=(
# add them here
)
for p in "${upstreamed_patches[@]}"; do
rm -v "${WORKDIR}/patch/${p}" || die
done
toolchain_src_prepare
eapply_user
}

View File

@ -0,0 +1,66 @@
# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
TOOLCHAIN_PATCH_DEV="sam"
TOOLCHAIN_HAS_TESTS=1
PATCH_GCC_VER="13.3.0"
MUSL_GCC_VER="13.2.0"
PATCH_VER="2"
MUSL_VER="2"
PYTHON_COMPAT=( python3_{10..12} )
if [[ ${PV} == *.9999 ]] ; then
MY_PV_2=$(ver_cut 2)
MY_PV_3=1
if [[ ${MY_PV_2} == 0 ]] ; then
MY_PV_2=0
MY_PV_3=0
else
MY_PV_2=$((${MY_PV_2} - 1))
fi
# e.g. 12.2.9999 -> 12.1.1
TOOLCHAIN_GCC_PV=$(ver_cut 1).${MY_PV_2}.${MY_PV_3}
elif [[ -n ${TOOLCHAIN_GCC_RC} ]] ; then
# Cheesy hack for RCs
MY_PV=$(ver_cut 1).$((($(ver_cut 2) + 1))).$((($(ver_cut 3) - 1)))-RC-$(ver_cut 5)
MY_P=${PN}-${MY_PV}
GCC_TARBALL_SRC_URI="mirror://gcc/snapshots/${MY_PV}/${MY_P}.tar.xz"
TOOLCHAIN_SET_S=no
S="${WORKDIR}"/${MY_P}
fi
inherit toolchain
if tc_is_live ; then
# Needs to be after inherit (for now?), bug #830908
EGIT_BRANCH=releases/gcc-$(ver_cut 1)
elif [[ -z ${TOOLCHAIN_USE_GIT_PATCHES} ]] ; then
# Don't keyword live ebuilds
#KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
:;
fi
if [[ ${CATEGORY} != cross-* ]] ; then
# Technically only if USE=hardened *too* right now, but no point in complicating it further.
# If GCC is enabling CET by default, we need glibc to be built with support for it.
# bug #830454
RDEPEND="elibc_glibc? ( sys-libs/glibc[cet(-)?] )"
DEPEND="${RDEPEND}"
fi
src_prepare() {
local p upstreamed_patches=(
# add them here
)
for p in "${upstreamed_patches[@]}"; do
rm -v "${WORKDIR}/patch/${p}" || die
done
toolchain_src_prepare
eapply "${FILESDIR}"/${PN}-13-fix-cross-fixincludes.patch
eapply_user
}

View File

@ -0,0 +1,54 @@
# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
TOOLCHAIN_PATCH_DEV="sam"
TOOLCHAIN_HAS_TESTS=1
PATCH_GCC_VER="14.2.0"
PATCH_VER="8"
MUSL_VER="1"
MUSL_GCC_VER="14.1.0"
PYTHON_COMPAT=( python3_{10..12} )
if [[ -n ${TOOLCHAIN_GCC_RC} ]] ; then
# Cheesy hack for RCs
MY_PV=$(ver_cut 1).$((($(ver_cut 2) + 1))).$((($(ver_cut 3) - 1)))-RC-$(ver_cut 5)
MY_P=${PN}-${MY_PV}
GCC_TARBALL_SRC_URI="mirror://gcc/snapshots/${MY_PV}/${MY_P}.tar.xz"
TOOLCHAIN_SET_S=no
S="${WORKDIR}"/${MY_P}
fi
inherit toolchain
if tc_is_live ; then
# Needs to be after inherit (for now?), bug #830908
EGIT_BRANCH=releases/gcc-$(ver_cut 1)
elif [[ -z ${TOOLCHAIN_USE_GIT_PATCHES} ]] ; then
# m68k doesnt build (ICE, bug 932733)
#KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
:;
fi
if [[ ${CATEGORY} != cross-* ]] ; then
# Technically only if USE=hardened *too* right now, but no point in complicating it further.
# If GCC is enabling CET by default, we need glibc to be built with support for it.
# bug #830454
RDEPEND="elibc_glibc? ( sys-libs/glibc[cet(-)?] )"
DEPEND="${RDEPEND}"
fi
src_prepare() {
local p upstreamed_patches=(
# add them here
)
for p in "${upstreamed_patches[@]}"; do
rm -v "${WORKDIR}/patch/${p}" || die
done
toolchain_src_prepare
eapply "${FILESDIR}"/${PN}-13-fix-cross-fixincludes.patch
eapply_user
}

View File

@ -0,0 +1,55 @@
# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
TOOLCHAIN_PATCH_DEV="sam"
TOOLCHAIN_HAS_TESTS=1
PATCH_GCC_VER="15.0.0"
PATCH_VER="45"
MUSL_VER="2"
MUSL_GCC_VER="15.0.0"
PYTHON_COMPAT=( python3_{10..12} )
if [[ -n ${TOOLCHAIN_GCC_RC} ]] ; then
# Cheesy hack for RCs
MY_PV=$(ver_cut 1).$((($(ver_cut 2) + 1))).$((($(ver_cut 3) - 1)))-RC-$(ver_cut 5)
MY_P=${PN}-${MY_PV}
GCC_TARBALL_SRC_URI="mirror://gcc/snapshots/${MY_PV}/${MY_P}.tar.xz"
TOOLCHAIN_SET_S=no
S="${WORKDIR}"/${MY_P}
fi
inherit toolchain
if tc_is_live ; then
# Needs to be after inherit (for now?), bug #830908
EGIT_BRANCH=master
elif [[ -z ${TOOLCHAIN_USE_GIT_PATCHES} ]] ; then
# Don't keyword live ebuilds
#KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
:;
fi
if [[ ${CATEGORY} != cross-* ]] ; then
# Technically only if USE=hardened *too* right now, but no point in complicating it further.
# If GCC is enabling CET by default, we need glibc to be built with support for it.
# bug #830454
RDEPEND="elibc_glibc? ( sys-libs/glibc[cet(-)?] )"
DEPEND="${RDEPEND}"
fi
src_prepare() {
local p upstreamed_patches=(
# add them here
)
for p in "${upstreamed_patches[@]}"; do
rm -v "${WORKDIR}/patch/${p}" || die
done
toolchain_src_prepare
eapply_user
eapply "${FILESDIR}"/${P}-coro.patch
eapply "${FILESDIR}"/${P}-range-for-mariadb.patch
}

View File

@ -6,7 +6,7 @@ EAPI=8
TOOLCHAIN_PATCH_DEV="sam"
TOOLCHAIN_HAS_TESTS=1
PATCH_GCC_VER="15.0.0"
PATCH_VER="45"
PATCH_VER="46"
MUSL_VER="2"
MUSL_GCC_VER="15.0.0"
PYTHON_COMPAT=( python3_{10..12} )