commit 47dd30079fd532f7c672870d61d3f2ea8cdb1771 Author: Richard Biener Date: Fri Aug 8 09:32:56 2025 +0200 Bump BASE-VER * BASE-VER: Set to 15.2.1. diff --git a/gcc/BASE-VER b/gcc/BASE-VER index 6c43fc8aefc..2054e837bc5 100644 --- a/gcc/BASE-VER +++ b/gcc/BASE-VER @@ -1 +1 @@ -15.2.0 +15.2.1 commit 8193500f4fc97808ded2082428380e4f91d1a44a Author: Jakub Jelinek Date: Sun Aug 3 18:27:42 2025 +0200 libcpp: Fix up cpp_maybe_module_directive [PR120845] My changes for "Module Declarations Shouldn’t be Macros" paper broke the following testcase. The backup handling intentionally tries to drop CPP_PRAGMA_EOL token if things go wrong, which is desirable for the case where we haven't committed to the module preprocessing directive (i.e. changed the first token to the magic one). In that case there is no preprocessing directive start and so CPP_PRAGMA_EOL would be wrong. If there is a premature new-line after we've changed the first token though, we shouldn't drop CPP_PRAGMA_EOL, because otherwise we ICE in the FE. While clang++ and MSVC accept the testcase, in my reading it is incorrect at least in the C++23 and newer wordings and I think the changes have been a DR, https://eel.is/c++draft/cpp.module has no exception for new-lines and https://eel.is/c++draft/cpp.pre#1.sentence-2 says that new-line (unless deleted during phase 2 when after backslash) ends the preprocessing directive. The patch arranges for eol being set only in the not_module case. 2025-08-03 Jakub Jelinek PR c++/120845 libcpp/ * lex.cc (cpp_maybe_module_directive): Move eol variable declaration to the start of the function, initialize to false and only set it to peek->type == CPP_PRAGMA_EOL in the not_module case. Formatting fix. gcc/testsuite/ * g++.dg/modules/cpp-21.C: New test. (cherry picked from commit a68f416a706bc61bb323773295189c4ea413ffd6) diff --git a/gcc/testsuite/g++.dg/modules/cpp-21.C b/gcc/testsuite/g++.dg/modules/cpp-21.C new file mode 100644 index 00000000000..fdd049267e9 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/cpp-21.C @@ -0,0 +1,8 @@ +// PR c++/120845 +// { dg-do compile } +// { dg-additional-options "-fmodules" } + +export module pr120485 + [[foobarbaz]]; +// { dg-error "expected ';' before end of line" "" { target *-*-* } .-2 } +// { dg-warning "attribute ignored" "" { target *-*-* } .-2 } diff --git a/libcpp/lex.cc b/libcpp/lex.cc index 2d02ce6e734..37c301dcd20 100644 --- a/libcpp/lex.cc +++ b/libcpp/lex.cc @@ -3504,6 +3504,7 @@ cpp_maybe_module_directive (cpp_reader *pfile, cpp_token *result) cpp_token *keyword = peek; cpp_hashnode *(&n_modules)[spec_nodes::M_HWM][2] = pfile->spec_nodes.n_modules; int header_count = 0; + bool eol = false; /* Make sure the incoming state is as we expect it. This way we can restore it using constants. */ @@ -3563,10 +3564,10 @@ cpp_maybe_module_directive (cpp_reader *pfile, cpp_token *result) tokens. C++ keywords are not yet relevant. */ if (peek->type == CPP_NAME || peek->type == CPP_COLON - || (header_count - ? (peek->type == CPP_LESS - || (peek->type == CPP_STRING && peek->val.str.text[0] != 'R') - || peek->type == CPP_HEADER_NAME) + || (header_count + ? (peek->type == CPP_LESS + || (peek->type == CPP_STRING && peek->val.str.text[0] != 'R') + || peek->type == CPP_HEADER_NAME) : peek->type == CPP_SEMICOLON)) { pfile->state.pragma_allow_expansion = !CPP_OPTION (pfile, preprocessed); @@ -3688,22 +3689,19 @@ cpp_maybe_module_directive (cpp_reader *pfile, cpp_token *result) pfile->state.in_deferred_pragma = false; /* Do not let this remain on. */ pfile->state.angled_headers = false; + /* If we saw EOL, we should drop it, because this isn't a module + control-line after all. */ + eol = peek->type == CPP_PRAGMA_EOL; } /* In either case we want to backup the peeked tokens. */ - if (backup) + if (backup && (!eol || backup > 1)) { - /* If we saw EOL, we should drop it, because this isn't a module - control-line after all. */ - bool eol = peek->type == CPP_PRAGMA_EOL; - if (!eol || backup > 1) - { - /* Put put the peeked tokens back */ - _cpp_backup_tokens_direct (pfile, backup); - /* But if the last one was an EOL, forget it. */ - if (eol) - pfile->lookaheads--; - } + /* Put the peeked tokens back. */ + _cpp_backup_tokens_direct (pfile, backup); + /* But if the last one was an EOL in the not_module case, forget it. */ + if (eol) + pfile->lookaheads--; } } commit a88f4ef1c79a42be8d3c394a1af0f949898b4216 Author: Jakub Jelinek Date: Mon Aug 4 17:12:55 2025 +0200 libstdc++: Add various missing exports [PR121373] On Sat, Aug 02, 2025 at 09:05:07PM +0200, Jakub Jelinek wrote: > Wonder how to automatically discover other missing exports (like in PR121373 > std::byteswap), maybe one could dig that stuff somehow from the raw > dump (look for identifiers in std namespace (and perhaps inlined namespaces > thereof at least) which don't start with underscore. To answer that question, I wrote a simple plugin which just dumps the names (which do not start with underscore) in std namespace (and its inlined namespaces) and for non-inline namespaces in there which do not start with underscore also recurses on those namespaces. Plugin source in https://gcc.gnu.org/pipermail/libstdc++/2025-August/062859.html I went through it all now, using cppreference as a quick check for stuff removed in C++17/C++20 and for everything added verified it is in corresponding eel.is/c++-draft/*.syn etc. and looked it up in the libstdc++ headers for guarding macros. 2025-08-04 Jakub Jelinek hexne PR libstdc++/121373 * src/c++23/std.cc.in (std::ranges::shift_left, std::ranges::shift_right): Only export for C++23 and later. (std::ranges::fold_left_first_with_iter_result, std::ranges::fold_left_with_iter_result): Export. (std::byteswap): Export for C++23 and later. (std::ranges::iter_move, std::ranges::iter_swap): Export. (std::projected_value_t): Export for C++26 and later. (std::out_ptr_t, std::inout_ptr_t): Export. (std::ranges::iota_result): Export. (std::regex_constants): Export a lot of constants. (std::is_scoped_enum, std::is_scoped_enum_v): Export. (cherry picked from commit 490c2c885ee5de1659d8339ea6bedd908acfacea) diff --git a/libstdc++-v3/src/c++23/std.cc.in b/libstdc++-v3/src/c++23/std.cc.in index de34e649bba..5df25bb646a 100644 --- a/libstdc++-v3/src/c++23/std.cc.in +++ b/libstdc++-v3/src/c++23/std.cc.in @@ -496,7 +496,9 @@ export namespace std using ranges::fold_left; using ranges::fold_left_first; using ranges::fold_left_first_with_iter; + using ranges::fold_left_first_with_iter_result; using ranges::fold_left_with_iter; + using ranges::fold_left_with_iter_result; using ranges::fold_right; using ranges::fold_right_last; using ranges::in_value_result; @@ -666,6 +668,9 @@ export namespace std using std::popcount; using std::rotl; using std::rotr; +#if __cpp_lib_byteswap // >= C++23 + using std::byteswap; +#endif } // 22.9 @@ -1726,6 +1731,9 @@ export namespace std using std::make_const_iterator; using std::make_const_sentinel; #endif +#if __glibcxx_algorithm_default_value_type // >= C++26 + using std::projected_value_t; +#endif } // FIXME these should be friends of __normal_iterator to avoid exporting // __gnu_cxx. @@ -1946,6 +1954,8 @@ export namespace std #if __cpp_lib_out_ptr using std::out_ptr; using std::inout_ptr; + using std::out_ptr_t; + using std::inout_ptr_t; #endif } @@ -2062,7 +2072,11 @@ export namespace std using std::lcm; using std::midpoint; #if __cpp_lib_ranges_iota - namespace ranges { using ranges::iota; } + namespace ranges + { + using ranges::iota; + using ranges::iota_result; + } #endif #if __cpp_lib_saturation_arithmetic using std::add_sat; @@ -2473,6 +2487,43 @@ export namespace std using std::regex_constants::operator|; using std::regex_constants::operator|=; using std::regex_constants::operator~; + using std::regex_constants::awk; + using std::regex_constants::basic; + using std::regex_constants::collate; + using std::regex_constants::ECMAScript; + using std::regex_constants::egrep; + using std::regex_constants::extended; + using std::regex_constants::grep; + using std::regex_constants::icase; + using std::regex_constants::multiline; + using std::regex_constants::nosubs; + using std::regex_constants::optimize; + using std::regex_constants::format_default; + using std::regex_constants::format_first_only; + using std::regex_constants::format_no_copy; + using std::regex_constants::format_sed; + using std::regex_constants::match_any; + using std::regex_constants::match_continuous; + using std::regex_constants::match_default; + using std::regex_constants::match_not_bol; + using std::regex_constants::match_not_bow; + using std::regex_constants::match_not_eol; + using std::regex_constants::match_not_eow; + using std::regex_constants::match_not_null; + using std::regex_constants::match_prev_avail; + using std::regex_constants::error_backref; + using std::regex_constants::error_badbrace; + using std::regex_constants::error_badrepeat; + using std::regex_constants::error_brace; + using std::regex_constants::error_brack; + using std::regex_constants::error_collate; + using std::regex_constants::error_complexity; + using std::regex_constants::error_ctype; + using std::regex_constants::error_escape; + using std::regex_constants::error_paren; + using std::regex_constants::error_range; + using std::regex_constants::error_space; + using std::regex_constants::error_stack; } using std::basic_regex; using std::csub_match; @@ -3114,6 +3165,10 @@ export namespace std using std::is_pointer_interconvertible_base_of_v; using std::is_pointer_interconvertible_with_class; #endif +#if __cpp_lib_is_scoped_enum + using std::is_scoped_enum; + using std::is_scoped_enum_v; +#endif } // commit 332e891a8a42a9ba971174c8282864fbc1976b7f Author: Jakub Jelinek Date: Wed Aug 6 11:28:37 2025 +0200 bitint: Fix up handling of uninitialized mul/div/float cast operands [PR121127] handle_operand_addr (used for the cases where we use libgcc APIs, so multiplication, division, modulo, casts of _BitInt to float/dfp) when it sees default definition of an SSA_NAME which is not PARM_DECL (i.e. uninitialized one) just allocates single uninitialized limb, there is no need to waste more memory on it, it can just tell libgcc that it has 64-bit precision, not say 1024 bit etc. Unfortunately, doing this runs into some asserts when we have a narrowing cast of the uninitialized SSA_NAME (but still large/huge _BitInt). The following patch fixes that by using a magic value in *prec_stored for the uninitialized cases (0) and just don't do any *prec tweaks for narrowing casts from that. precs still needs to be maintained as before, that one is used for big endian adjustment. 2025-08-06 Jakub Jelinek PR tree-optimization/121127 * gimple-lower-bitint.cc (bitint_large_huge::handle_operand_addr): For uninitialized SSA_NAME, set *prec_stored to 0 rather than *prec. Handle that case in narrowing casts. If prec_stored is non-NULL, set *prec_stored to prec_stored_val. * gcc.dg/bitint-125.c: New test. (cherry picked from commit d175a6b119b8ab177ab9d9fb81dcac1794d18ad6) diff --git a/gcc/gimple-lower-bitint.cc b/gcc/gimple-lower-bitint.cc index 6fefc834762..23f3162e1d9 100644 --- a/gcc/gimple-lower-bitint.cc +++ b/gcc/gimple-lower-bitint.cc @@ -2213,7 +2213,7 @@ range_to_prec (tree op, gimple *stmt) from that precision, if it is negative, the operand is sign-extended from -*PREC. If PREC_STORED is NULL, it is the toplevel call, otherwise *PREC_STORED is prec from the innermost call without - range optimizations. */ + range optimizations (0 for uninitialized SSA_NAME). */ tree bitint_large_huge::handle_operand_addr (tree op, gimple *stmt, @@ -2318,7 +2318,7 @@ bitint_large_huge::handle_operand_addr (tree op, gimple *stmt, { *prec = TYPE_UNSIGNED (TREE_TYPE (op)) ? limb_prec : -limb_prec; if (prec_stored) - *prec_stored = *prec; + *prec_stored = 0; tree var = create_tmp_var (m_limb_type); TREE_ADDRESSABLE (var) = 1; ret = build_fold_addr_expr (var); @@ -2346,6 +2346,8 @@ bitint_large_huge::handle_operand_addr (tree op, gimple *stmt, tree rhs_type = TREE_TYPE (rhs1); int prec_stored_val = 0; ret = handle_operand_addr (rhs1, g, &prec_stored_val, prec); + if (prec_stored) + *prec_stored = prec_stored_val; if (TYPE_PRECISION (lhs_type) > TYPE_PRECISION (rhs_type)) { if (TYPE_UNSIGNED (lhs_type) @@ -2354,7 +2356,9 @@ bitint_large_huge::handle_operand_addr (tree op, gimple *stmt, } else { - if (*prec > 0 && *prec < TYPE_PRECISION (lhs_type)) + if (prec_stored_val == 0) + /* Non-widening cast of uninitialized value. */; + else if (*prec > 0 && *prec < TYPE_PRECISION (lhs_type)) ; else if (TYPE_UNSIGNED (lhs_type)) { diff --git a/gcc/testsuite/gcc.dg/bitint-125.c b/gcc/testsuite/gcc.dg/bitint-125.c new file mode 100644 index 00000000000..5ef0e327d54 --- /dev/null +++ b/gcc/testsuite/gcc.dg/bitint-125.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/121127 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-O2 -w" } */ + +#if __BITINT_MAXWIDTH__ >= 576 +_BitInt(575) +foo (void) +{ + _BitInt(576) d; + _BitInt(575) e = d * 42wb; + return e; +} +#else +int i; +#endif commit d43ece39b709992681d92b17c1e58b5f152ff247 Author: Jakub Jelinek Date: Wed Aug 6 11:30:08 2025 +0200 bitint: Fix up INTEGER_CST PHI handling [PR121413] The following testcase is miscompiled on aarch64-linux. The problem is in the optimization to shorten large constants in PHI arguments. In a couple of places during bitint lowering we compute minimal precision of constant and if it is significantly smaller than the precision of the type, store smaller constant in memory and extend it at runtime (zero or all ones). Now, in most places that works fine, we handle the stored number of limbs by loading them from memory and then the rest is extended. In the PHI INTEGER_CST argument handling we do it differently, we don't form there any loops (because we insert stmt sequences on the edges). The problem is that we copy the whole _BitInt variable from memory to the PHI VAR_DECL + initialize the rest to = {} or memset to -1. It has min_prec = CEIL (min_prec, limb_prec) * limb_prec; precision, so e.g. on x86_64 there is no padding and it works just fine. But on aarch64 which has abi_limb_mode TImode and limb_mode DImode it doesn't in some cases. In the testcase the constant has 408 bits min precision, rounded up to limb_prec (64) is 448, i.e. 7 limbs. But aarch64 with TImode abi_limb_mode will actually allocate 8 limbs and the most significant limb is solely padding. As we want to extend the constant with all ones, copying the padding (from memory, so 0s) will result in 64 0 bits where 1 bits were needed. The following patch fixes it by detecting this case and setting min_prec to a multiple of abi limb precision so that it has no padding. 2025-08-06 Jakub Jelinek PR tree-optimization/121413 * gimple-lower-bitint.cc (abi_limb_prec): New variable (bitint_precision_kind): Initialize it. (gimple_lower_bitint): Clear it at the start. For min_prec > limb_prec descreased precision vars for INTEGER_CST PHI arguments ensure min_prec is either prec or multiple of abi_limb_prec. * gcc.dg/torture/bitint-85.c: New test. (cherry picked from commit 70aff5112ec25f2391d8048d8c7994160d3cb008) diff --git a/gcc/gimple-lower-bitint.cc b/gcc/gimple-lower-bitint.cc index 23f3162e1d9..6e83367ff41 100644 --- a/gcc/gimple-lower-bitint.cc +++ b/gcc/gimple-lower-bitint.cc @@ -76,7 +76,7 @@ enum bitint_prec_kind { /* Caches to speed up bitint_precision_kind. */ static int small_max_prec, mid_min_prec, large_min_prec, huge_min_prec; -static int limb_prec; +static int limb_prec, abi_limb_prec; /* Categorize _BitInt(PREC) as small, middle, large or huge. */ @@ -106,6 +106,9 @@ bitint_precision_kind (int prec) large_min_prec = MAX_FIXED_MODE_SIZE + 1; if (!limb_prec) limb_prec = GET_MODE_PRECISION (limb_mode); + if (!abi_limb_prec) + abi_limb_prec + = GET_MODE_PRECISION (as_a (info.abi_limb_mode)); if (!huge_min_prec) { if (4 * limb_prec >= MAX_FIXED_MODE_SIZE) @@ -6075,7 +6078,7 @@ static unsigned int gimple_lower_bitint (void) { small_max_prec = mid_min_prec = large_min_prec = huge_min_prec = 0; - limb_prec = 0; + limb_prec = abi_limb_prec = 0; unsigned int i; for (i = 0; i < num_ssa_names; ++i) @@ -7036,7 +7039,20 @@ gimple_lower_bitint (void) from smaller number. */ min_prec = prec; else - min_prec = CEIL (min_prec, limb_prec) * limb_prec; + { + min_prec = CEIL (min_prec, limb_prec) * limb_prec; + if (min_prec > (unsigned) limb_prec + && abi_limb_prec > limb_prec) + { + /* For targets with ABI limb precision higher than + limb precision round to ABI limb precision, + otherwise c can contain padding bits. */ + min_prec + = CEIL (min_prec, abi_limb_prec) * abi_limb_prec; + if (min_prec > prec - rem - 2 * limb_prec) + min_prec = prec; + } + } if (min_prec == 0) c = NULL_TREE; else if (min_prec == prec) diff --git a/gcc/testsuite/gcc.dg/torture/bitint-85.c b/gcc/testsuite/gcc.dg/torture/bitint-85.c new file mode 100644 index 00000000000..43eb6ffc0b6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/bitint-85.c @@ -0,0 +1,34 @@ +/* { dg-do run { target bitint } } */ +/* { dg-options "-std=c23 -pedantic-errors" } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "*" } { "-O0" "-O2" } } */ +/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */ + +#if __BITINT_MAXWIDTH__ >= 1024 +constexpr _BitInt(1024) d = -541140097068598424394740839221562143161511518875518765552323978870598341733206554363735813878577506997168480201818027232521wb; +int c; + +static inline void +foo (_BitInt(1024) b, _BitInt(1024) *r) +{ + if (c) + b = 0; + *r = b; +} + +[[gnu::noipa]] void +bar (_BitInt(1024) y) +{ + if (y != d) + __builtin_abort (); +} +#endif + +int +main () +{ +#if __BITINT_MAXWIDTH__ >= 1024 + _BitInt(1024) x; + foo (d, &x); + bar (x); +#endif +} commit d3c5366520e52057bed5b3ba6898366c79687c34 Author: Jakub Jelinek Date: Fri Aug 8 09:20:51 2025 +0200 tailc: Handle other forms of finally_tmp.N conditional cleanups after musttail [PR121389] My earlier r16-1886 PR120608 change incorrectly assumed that the finally_tmp.N vars introduced by eh pass will be only initialized to values 0 and 1 and there will be only EQ_EXPR/NE_EXPR comparisons of those. The following testcases show that is a bad assumption, the eh pass sets finally_tmp.N vars to 0 up to some highest index depending on hoiw many different exits there are from the finally region. And it emits then switch (finally_tmp.N) statement for all the different cases. So, if it uses more than 0/1 indexes, the lowering of the switch can turn it into a series of GIMPLE_CONDs, if (finally_tmp.N_M > 15) goto ... else goto ... if (finally_tmp.N_M > 7) goto ... else goto ... etc. (and that also means no longer single uses). And if unlucky, we can see a non-lowered GIMPLE_SWITCH as well. So, the following patch removes the assumption that it has to be 0/1 and EQ_EXPR/NE_EXPR, allows all the normal integral comparisons and handles GIMPLE_SWITCH too. 2025-08-08 Jakub Jelinek PR middle-end/121389 * tree-tailcall.cc (find_tail_calls): For finally_tmp.N handle not just GIMPLE_CONDs with EQ_EXPR/NE_EXPR and only values 0 and 1, but arbitrary non-negative values, arbitrary comparisons in conditions and also GIMPLE_SWITCH next to GIMPLE_CONDs. * c-c++-common/asan/pr121389-1.c: New test. * c-c++-common/asan/pr121389-2.c: New test. * c-c++-common/asan/pr121389-3.c: New test. * c-c++-common/asan/pr121389-4.c: New test. (cherry picked from commit 18c32a391685256d2fbd6e3e6b2f7f93200bb912) diff --git a/gcc/testsuite/c-c++-common/asan/pr121389-1.c b/gcc/testsuite/c-c++-common/asan/pr121389-1.c new file mode 100644 index 00000000000..0116d7a2d73 --- /dev/null +++ b/gcc/testsuite/c-c++-common/asan/pr121389-1.c @@ -0,0 +1,23 @@ +// PR middle-end/121389 +// { dg-do compile { target musttail } } +// { dg-options "-fsanitize=address" } + +int foo (void); +int bar (void); +int baz (unsigned *); + +int +bar (void) +{ + do + { + unsigned t; + int u = baz (&t); + if (u == 42) + [[gnu::musttail]] return foo (); + if (u == -42) + break; + } + while (1); + return 42; +} diff --git a/gcc/testsuite/c-c++-common/asan/pr121389-2.c b/gcc/testsuite/c-c++-common/asan/pr121389-2.c new file mode 100644 index 00000000000..02914f88542 --- /dev/null +++ b/gcc/testsuite/c-c++-common/asan/pr121389-2.c @@ -0,0 +1,37 @@ +// PR middle-end/121389 +// { dg-do compile { target musttail } } +// { dg-options "-fsanitize=address" } + +int foo (void); +int bar (void); +int baz (unsigned *); + +int +bar (void) +{ + for (int a = 0; a < 420; ++a) + { + for (int b = 0; b < 420; ++b) + { + for (int c = 0; c < 420; ++c) + { + unsigned t; + int u = baz (&t); + if (u == 42) + [[gnu::musttail]] return foo (); + if (u == -42) + break; + if (u == 16) + goto l1; + if (u == 18) + goto l2; + if (u == 20) + goto l3; + } + l3:; + } + l2:; + } + l1:; + return 42; +} diff --git a/gcc/testsuite/c-c++-common/asan/pr121389-3.c b/gcc/testsuite/c-c++-common/asan/pr121389-3.c new file mode 100644 index 00000000000..5f71e06e39c --- /dev/null +++ b/gcc/testsuite/c-c++-common/asan/pr121389-3.c @@ -0,0 +1,130 @@ +// PR middle-end/121389 +// { dg-do compile { target musttail } } +// { dg-options "-fsanitize=address" } + +int foo (void); +int bar (void); +int baz (unsigned *); + +int +bar (void) +{ + for (int a = 0; a < 420; ++a) + { + for (int b = 0; b < 420; ++b) + { + for (int c = 0; c < 420; ++c) + { + unsigned t; + int u = baz (&t); + if (u == 42) + [[gnu::musttail]] return foo (); + if (u == -42) + break; + if (u == 16) + goto l1; + if (u == 18) + goto l2; + if (u == 20) + goto l3; + switch (u) + { + case 100: goto l100; + case 101: goto l101; + case 102: goto l102; + case 103: goto l103; + case 104: goto l104; + case 105: goto l105; + case 106: goto l106; + case 107: goto l107; + case 108: goto l108; + case 109: goto l109; + case 110: goto l110; + case 111: goto l111; + case 112: goto l112; + case 113: goto l113; + case 114: goto l114; + case 115: goto l115; + case 116: goto l116; + case 117: goto l117; + case 118: goto l118; + case 119: goto l119; + case 120: goto l120; + case 121: goto l121; + case 122: goto l122; + case 123: goto l123; + case 124: goto l124; + case 125: goto l125; + case 126: goto l126; + case 127: goto l127; + case 128: goto l128; + case 129: goto l129; + } + } + l3:; + foo (); + l100: + foo (); + l101: + foo (); + l102: + foo (); + l103: + foo (); + l104: + foo (); + l105: + foo (); + l106: + foo (); + l107: + foo (); + l108: + foo (); + l109:; + } + l2:; + foo (); + l110: + foo (); + l111: + foo (); + l112: + foo (); + l113: + foo (); + l114: + foo (); + l115: + foo (); + l116: + foo (); + l117: + foo (); + l118: + foo (); + l119:; + } + l1:; + foo (); + l120: + foo (); + l121: + foo (); + l122: + foo (); + l123: + foo (); + l124: + foo (); + l125: + foo (); + l126: + foo (); + l127: + foo (); + l128: + foo (); + l129:; + return 42; +} diff --git a/gcc/testsuite/c-c++-common/asan/pr121389-4.c b/gcc/testsuite/c-c++-common/asan/pr121389-4.c new file mode 100644 index 00000000000..2f7b410a1f4 --- /dev/null +++ b/gcc/testsuite/c-c++-common/asan/pr121389-4.c @@ -0,0 +1,6 @@ +// PR middle-end/121389 +// { dg-do compile { target musttail } } +// { dg-options "-fsanitize=address -fdisable-tree-switchlower_O0" } +// { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } + +#include "pr121389-3.c" diff --git a/gcc/tree-tailcall.cc b/gcc/tree-tailcall.cc index e8fd7a0df22..7240a3eef87 100644 --- a/gcc/tree-tailcall.cc +++ b/gcc/tree-tailcall.cc @@ -605,6 +605,12 @@ find_tail_calls (basic_block bb, edge esucc, struct tailcall **ret, && (stmt = last_nondebug_stmt (bb)) && gimple_code (stmt) == GIMPLE_COND) ; + else if (esucc + && cfun->has_musttail + && diag_musttail + && (stmt = last_nondebug_stmt (bb)) + && gimple_code (stmt) == GIMPLE_SWITCH) + ; /* If there is an abnormal edge assume it's the only extra one. Tolerate that case so that we can give better error messages for musttail later. */ @@ -668,7 +674,7 @@ find_tail_calls (basic_block bb, edge esucc, struct tailcall **ret, else goto ; [INV] When walking backwards, ESUCC is the edge we are coming from, - depending on its EDGE_TRUE_FLAG, == vs. != for the comparison + depending on its EDGE_TRUE_FLAG, comparison code and value compared against try to find out through which edge we need to go and which edge should be ignored. The code handles both INTEGER_CST PHI arguments and SSA_NAMEs set to constants @@ -677,19 +683,16 @@ find_tail_calls (basic_block bb, edge esucc, struct tailcall **ret, && diag_musttail && esucc && gimple_code (stmt) == GIMPLE_COND - && (gimple_cond_code (stmt) == EQ_EXPR - || gimple_cond_code (stmt) == NE_EXPR) && TREE_CODE (gimple_cond_lhs (stmt)) == SSA_NAME && TREE_CODE (gimple_cond_rhs (stmt)) == INTEGER_CST && INTEGRAL_TYPE_P (TREE_TYPE (gimple_cond_lhs (stmt))) - && (integer_zerop (gimple_cond_rhs (stmt)) - || integer_onep (gimple_cond_rhs (stmt)))) + && tree_int_cst_sgn (gimple_cond_rhs (stmt)) >= 0) { tree lhs = gimple_cond_lhs (stmt); - bool rhsv = integer_onep (gimple_cond_rhs (stmt)); - if (((esucc->flags & EDGE_TRUE_VALUE) != 0) - ^ (gimple_cond_code (stmt) == EQ_EXPR)) - rhsv = !rhsv; + tree_code ccode = gimple_cond_code (stmt); + tree rhsv = gimple_cond_rhs (stmt); + if ((esucc->flags & EDGE_FALSE_VALUE) != 0) + ccode = invert_tree_comparison (ccode, false); if (!ignored_edges) { ignored_edges = new hash_set; @@ -700,8 +703,10 @@ find_tail_calls (basic_block bb, edge esucc, struct tailcall **ret, && (gimple_assign_rhs_code (SSA_NAME_DEF_STMT (lhs)) == INTEGER_CST)) { - tree rhs = gimple_assign_rhs1 (SSA_NAME_DEF_STMT (lhs)); - if (rhsv ? integer_onep (rhs) : integer_zerop (rhs)) + tree lhsv = gimple_assign_rhs1 (SSA_NAME_DEF_STMT (lhs)); + + if (const_binop (ccode, boolean_type_node, lhsv, rhsv) + == boolean_true_node) continue; } else if (gimple_code (SSA_NAME_DEF_STMT (lhs)) == GIMPLE_PHI) @@ -712,15 +717,62 @@ find_tail_calls (basic_block bb, edge esucc, struct tailcall **ret, edge_iterator ei; FOR_EACH_EDGE (e, ei, pbb->preds) { - tree rhs = gimple_phi_arg_def_from_edge (phi, e); - if (TREE_CODE (rhs) == SSA_NAME - && is_gimple_assign (SSA_NAME_DEF_STMT (rhs)) - && (gimple_assign_rhs_code (SSA_NAME_DEF_STMT (rhs)) + tree lhsv = gimple_phi_arg_def_from_edge (phi, e); + if (TREE_CODE (lhsv) == SSA_NAME + && is_gimple_assign (SSA_NAME_DEF_STMT (lhsv)) + && (gimple_assign_rhs_code (SSA_NAME_DEF_STMT (lhsv)) == INTEGER_CST)) - rhs = gimple_assign_rhs1 (SSA_NAME_DEF_STMT (rhs)); - if (!(rhsv ? integer_onep (rhs) : integer_zerop (rhs))) + lhsv = gimple_assign_rhs1 (SSA_NAME_DEF_STMT (lhsv)); + if (TREE_CODE (lhsv) != INTEGER_CST + || const_binop (ccode, boolean_type_node, + lhsv, rhsv) != boolean_true_node) ignored_edges->add (e); } + continue; + } + } + if (cfun->has_musttail + && diag_musttail + && esucc + && gimple_code (stmt) == GIMPLE_SWITCH + && (TREE_CODE (gimple_switch_index (as_a (stmt))) + == SSA_NAME)) + { + gswitch *swtch = as_a (stmt); + tree idx = gimple_switch_index (swtch); + if (!ignored_edges) + { + ignored_edges = new hash_set; + must_see_bbs = new hash_set; + delete_ignored_edges = true; + } + if (is_gimple_assign (SSA_NAME_DEF_STMT (idx)) + && (gimple_assign_rhs_code (SSA_NAME_DEF_STMT (idx)) + == INTEGER_CST)) + { + tree val = gimple_assign_rhs1 (SSA_NAME_DEF_STMT (idx)); + if (find_taken_edge_switch_expr (swtch, val) == esucc) + continue; + } + else if (gimple_code (SSA_NAME_DEF_STMT (idx)) == GIMPLE_PHI) + { + gimple *phi = SSA_NAME_DEF_STMT (idx); + basic_block pbb = gimple_bb (phi); + must_see_bbs->add (pbb); + edge_iterator ei; + FOR_EACH_EDGE (e, ei, pbb->preds) + { + tree val = gimple_phi_arg_def_from_edge (phi, e); + if (TREE_CODE (val) == SSA_NAME + && is_gimple_assign (SSA_NAME_DEF_STMT (val)) + && (gimple_assign_rhs_code (SSA_NAME_DEF_STMT (val)) + == INTEGER_CST)) + val = gimple_assign_rhs1 (SSA_NAME_DEF_STMT (val)); + if (TREE_CODE (val) != INTEGER_CST + || find_taken_edge_switch_expr (swtch, val) != esucc) + ignored_edges->add (e); + } + continue; } } @@ -1139,47 +1191,67 @@ find_tail_calls (basic_block bb, edge esucc, struct tailcall **ret, if (ignored_edges) { if (is_gimple_assign (stmt) - && gimple_assign_rhs_code (stmt) == INTEGER_CST) + && gimple_assign_rhs_code (stmt) == INTEGER_CST + && tree_int_cst_sgn (gimple_assign_rhs1 (stmt)) >= 0) { use_operand_p use_p; - gimple *use_stmt; - if ((integer_zerop (gimple_assign_rhs1 (stmt)) - || integer_onep (gimple_assign_rhs1 (stmt))) - && single_imm_use (gimple_assign_lhs (stmt), &use_p, - &use_stmt)) + imm_use_iterator imm_iter; + bool bad_p = false; + FOR_EACH_IMM_USE_FAST (use_p, imm_iter, + gimple_assign_lhs (stmt)) { - if (gimple_code (use_stmt) == GIMPLE_COND) - continue; - if (gimple_code (use_stmt) == GIMPLE_PHI - && single_imm_use (gimple_phi_result (use_stmt), - &use_p, &use_stmt) - && gimple_code (use_stmt) == GIMPLE_COND) + gimple *use_stmt = USE_STMT (use_p); + if (is_gimple_debug (use_stmt) + || gimple_code (use_stmt) == GIMPLE_COND + || gimple_code (use_stmt) == GIMPLE_SWITCH) continue; + if (gimple_code (use_stmt) == GIMPLE_PHI) + { + use_operand_p use_p2; + imm_use_iterator imm_iter2; + FOR_EACH_IMM_USE_FAST (use_p2, imm_iter2, + gimple_phi_result (use_stmt)) + { + gimple *use_stmt2 = USE_STMT (use_p2); + if (is_gimple_debug (use_stmt2) + || gimple_code (use_stmt2) == GIMPLE_COND + || gimple_code (use_stmt2) == GIMPLE_SWITCH) + continue; + bad_p = true; + break; + } + if (bad_p) + break; + } + else + { + bad_p = true; + break; + } } + if (!bad_p) + continue; } if (gimple_code (stmt) == GIMPLE_COND - && (gimple_cond_code (stmt) == EQ_EXPR - || gimple_cond_code (stmt) == NE_EXPR) && TREE_CODE (gimple_cond_lhs (stmt)) == SSA_NAME && TREE_CODE (gimple_cond_rhs (stmt)) == INTEGER_CST && INTEGRAL_TYPE_P (TREE_TYPE (gimple_cond_lhs (stmt))) - && (integer_zerop (gimple_cond_rhs (stmt)) - || integer_onep (gimple_cond_rhs (stmt)))) + && tree_int_cst_sgn (gimple_cond_rhs (stmt)) >= 0) { edge e = NULL, et, ef; + enum tree_code ccode = gimple_cond_code (stmt); tree lhs = gimple_cond_lhs (stmt); - bool rhsv = integer_onep (gimple_cond_rhs (stmt)); - if (gimple_cond_code (stmt) == NE_EXPR) - rhsv = !rhsv; + tree rhsv = gimple_cond_rhs (stmt); extract_true_false_edges_from_block (gimple_bb (stmt), &et, &ef); if (is_gimple_assign (SSA_NAME_DEF_STMT (lhs)) && (gimple_assign_rhs_code (SSA_NAME_DEF_STMT (lhs)) == INTEGER_CST)) { - tree rhs = gimple_assign_rhs1 (SSA_NAME_DEF_STMT (lhs)); - if (rhsv ? integer_onep (rhs) : integer_zerop (rhs)) + tree lhsv = gimple_assign_rhs1 (SSA_NAME_DEF_STMT (lhs)); + tree r = const_binop (ccode, boolean_type_node, lhsv, rhsv); + if (r == boolean_true_node) e = et; - else if (rhsv ? integer_zerop (rhs) : integer_onep (rhs)) + else if (r == boolean_false_node) e = ef; } else if (gimple_code (SSA_NAME_DEF_STMT (lhs)) == GIMPLE_PHI) @@ -1189,16 +1261,17 @@ find_tail_calls (basic_block bb, edge esucc, struct tailcall **ret, for (edge e2 : edges) if (e2->dest == pbb) { - tree rhs = gimple_phi_arg_def_from_edge (phi, e2); - if (TREE_CODE (rhs) == SSA_NAME) - if (gimple *g = SSA_NAME_DEF_STMT (rhs)) + tree lhsv = gimple_phi_arg_def_from_edge (phi, e2); + if (TREE_CODE (lhsv) == SSA_NAME) + if (gimple *g = SSA_NAME_DEF_STMT (lhsv)) if (is_gimple_assign (g) && gimple_assign_rhs_code (g) == INTEGER_CST) - rhs = gimple_assign_rhs1 (g); - if (rhsv ? integer_onep (rhs) : integer_zerop (rhs)) + lhsv = gimple_assign_rhs1 (g); + tree r = const_binop (ccode, boolean_type_node, + lhsv, rhsv); + if (r == boolean_true_node) e = et; - else if (rhsv ? integer_zerop (rhs) - : integer_onep (rhs)) + else if (r == boolean_false_node) e = ef; break; } @@ -1213,6 +1286,48 @@ find_tail_calls (basic_block bb, edge esucc, struct tailcall **ret, goto new_bb; } } + if (gimple_code (stmt) == GIMPLE_SWITCH + && (TREE_CODE (gimple_switch_index (as_a (stmt))) + == SSA_NAME)) + { + edge e = NULL; + gswitch *swtch = as_a (stmt); + tree idx = gimple_switch_index (swtch); + if (is_gimple_assign (SSA_NAME_DEF_STMT (idx)) + && (gimple_assign_rhs_code (SSA_NAME_DEF_STMT (idx)) + == INTEGER_CST)) + { + tree val = gimple_assign_rhs1 (SSA_NAME_DEF_STMT (idx)); + e = find_taken_edge_switch_expr (swtch, val); + } + else if (gimple_code (SSA_NAME_DEF_STMT (idx)) == GIMPLE_PHI) + { + gimple *phi = SSA_NAME_DEF_STMT (idx); + basic_block pbb = gimple_bb (phi); + for (edge e2 : edges) + if (e2->dest == pbb) + { + tree val = gimple_phi_arg_def_from_edge (phi, e2); + if (TREE_CODE (val) == SSA_NAME) + if (gimple *g = SSA_NAME_DEF_STMT (val)) + if (is_gimple_assign (g) + && gimple_assign_rhs_code (g) == INTEGER_CST) + val = gimple_assign_rhs1 (g); + if (TREE_CODE (val) == INTEGER_CST) + e = find_taken_edge_switch_expr (swtch, val); + break; + } + } + if (e) + { + ass_var = propagate_through_phis (ass_var, e); + if (!ass_var || ignored_edges) + edges.safe_push (e); + abb = e->dest; + agsi = gsi_start_bb (abb); + goto new_bb; + } + } } if (gimple_code (stmt) != GIMPLE_ASSIGN) commit b3893433abd8d3a4096f8c51d028115d461fe6aa Author: Patrick Palka Date: Mon Aug 4 16:43:33 2025 -0400 c++: constexpr evaluation of abi::__dynamic_cast [PR120620] r13-3299 changed our internal declaration of __dynamic_cast to reside inside the abi/__cxxabiv1:: namespace instead of the global namespace, matching the real declaration. This inadvertently made us now attempt constexpr evaluation of user-written calls to abi::__dynamic_cast since cxx_dynamic_cast_fn_p now also returns true for them, but we're not prepared to handle arbitrary calls to __dynamic_cast, and therefore ICE. This patch restores cxx_dynamic_cast_fn_p to return true only for synthesized calls to __dynamic_cast, which can be distinguished by DECL_ARTIFICIAL, since apparently the synthesized declaration of __dynamic_cast doesn't get merged with the actual declaration. PR c++/120620 gcc/cp/ChangeLog: * constexpr.cc (cxx_dynamic_cast_fn_p): Return true only for synthesized __dynamic_cast. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/constexpr-dynamic19.C: New test. * g++.dg/cpp2a/constexpr-dynamic1a.C: New test. Reviewed-by: Jason Merrill (cherry picked from commit b51ca7d2f548ffdad03fa779e3ff7bcc3441ff03) diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc index f6b9a808825..0751490cc71 100644 --- a/gcc/cp/constexpr.cc +++ b/gcc/cp/constexpr.cc @@ -2459,7 +2459,11 @@ cxx_dynamic_cast_fn_p (tree fndecl) { return (cxx_dialect >= cxx20 && id_equal (DECL_NAME (fndecl), "__dynamic_cast") - && CP_DECL_CONTEXT (fndecl) == abi_node); + && CP_DECL_CONTEXT (fndecl) == abi_node + /* Only consider implementation-detail __dynamic_cast calls that + correspond to a dynamic_cast, and ignore direct calls to + abi::__dynamic_cast. */ + && DECL_ARTIFICIAL (fndecl)); } /* Often, we have an expression in the form of address + offset, e.g. diff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic19.C b/gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic19.C new file mode 100644 index 00000000000..27d167cebc3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic19.C @@ -0,0 +1,10 @@ +// PR c++/120620 +// { dg-do compile } + +#include + +struct A* a; + +void f() { + void* const p = abi::__dynamic_cast(&a, 0, 0, 42); +} diff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic1a.C b/gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic1a.C new file mode 100644 index 00000000000..4077a47055c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic1a.C @@ -0,0 +1,6 @@ +// Test that including , whence the actual abi:__dynamic_cast +// is declared, doesn't affect our constexpr dynamic_cast handling. +// { dg-do compile { target c++20 } } + +#include +#include "constexpr-dynamic1.C" commit 9faa21a4de2b88366e363b6817ee751ea8d13f53 Author: Patrick Palka Date: Mon Aug 4 16:51:00 2025 -0400 c++: constrained memfn vs corresponding using [PR121351] The b.f(42) calls in the below testcases started to get rejected as ambiguous after r15-3740 which corrected our inheritedness tiebreaker to only apply to constructors (and not all member functions) as per CWG2273. But arguably these calls should still be valid regardless of the tiebreaker because B::f corresponds to and therefore hides A::f, so there should only be a single candidate in the first place. This doesn't happen because when determining correspondence we compare the members' uninstantiated constraints instead of their partially substituted constraints as in other declaration matching situations. It doesn't really make sense to compare uninstantiated constraints from two different template contexts. This patch fixes this by substituting in outer template arguments before comparing constraints of two potentially corresponding member functions. PR c++/121351 PR c++/119859 gcc/cp/ChangeLog: * class.cc (add_method): Substitute outer template arguments into constraints before comparing them if the declarations are from different classes. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-using5.C: New test. * g++.dg/cpp2a/concepts-using5a.C: New test. Reviewed-by: Jason Merrill (cherry picked from commit b9f1cc4e119da9205cb8438f0132c62a19afe4ae) diff --git a/gcc/cp/class.cc b/gcc/cp/class.cc index 93ad9d6fd0b..54ccd93b899 100644 --- a/gcc/cp/class.cc +++ b/gcc/cp/class.cc @@ -1351,7 +1351,30 @@ add_method (tree type, tree method, bool via_using) if (!compparms (parms1, parms2)) continue; - if (!equivalently_constrained (fn, method)) + tree fn_constraints = get_constraints (fn); + tree method_constraints = get_constraints (method); + + if (fn_constraints && method_constraints + && DECL_CONTEXT (fn) != type + && !processing_template_decl) + { + if (TREE_CODE (fn) == TEMPLATE_DECL) + ++processing_template_decl; + if (tree ti = CLASSTYPE_TEMPLATE_INFO (DECL_CONTEXT (fn))) + fn_constraints = tsubst_constraint_info (fn_constraints, + TI_ARGS (ti), + tf_warning_or_error, + fn); + if (tree ti = CLASSTYPE_TEMPLATE_INFO (DECL_CONTEXT (method))) + method_constraints = tsubst_constraint_info (method_constraints, + TI_ARGS (ti), + tf_warning_or_error, + method); + if (TREE_CODE (fn) == TEMPLATE_DECL) + --processing_template_decl; + } + + if (!equivalent_constraints (fn_constraints, method_constraints)) { if (processing_template_decl) /* We can't check satisfaction in dependent context, wait until diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-using5.C b/gcc/testsuite/g++.dg/cpp2a/concepts-using5.C new file mode 100644 index 00000000000..d42b8a0167b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-using5.C @@ -0,0 +1,19 @@ +// PR c++/121351 +// { dg-do compile { target c++20 } } + +template concept C = true; + +template +struct A { + template void f(U) requires C = delete; // #1 +}; + +struct B : A { + using A::f; + template void f(U) requires C; // #2 +}; + +int main() { + B b; + b.f(42); // OK, #2 corresponds to and therefore hides #1 +} diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-using5a.C b/gcc/testsuite/g++.dg/cpp2a/concepts-using5a.C new file mode 100644 index 00000000000..5d319481b48 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-using5a.C @@ -0,0 +1,20 @@ +// PR c++/121351 +// { dg-do compile { target c++20 } } +// A version of concepts-using5a.C where B instead of A is a template. + +template concept C = true; + +struct A { + template void f(U) requires C = delete; // #1 +}; + +template +struct B : A { + using A::f; + template void f(U) requires C; // #2 +}; + +int main() { + B b; + b.f(42); // OK, #2 corresponds to and therefore hides #1 +} commit 929da38d40817975265fbcfe7a3373f536b3383a Author: GCC Administrator Date: Sat Aug 9 00:25:34 2025 +0000 Daily bump. diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 29e90b6fcc5..a508ab1acb7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,39 @@ +2025-08-08 Jakub Jelinek + + Backported from master: + 2025-08-08 Jakub Jelinek + + PR middle-end/121389 + * tree-tailcall.cc (find_tail_calls): For finally_tmp.N + handle not just GIMPLE_CONDs with EQ_EXPR/NE_EXPR and only + values 0 and 1, but arbitrary non-negative values, arbitrary + comparisons in conditions and also GIMPLE_SWITCH next to + GIMPLE_CONDs. + +2025-08-08 Jakub Jelinek + + Backported from master: + 2025-08-06 Jakub Jelinek + + PR tree-optimization/121413 + * gimple-lower-bitint.cc (abi_limb_prec): New variable + (bitint_precision_kind): Initialize it. + (gimple_lower_bitint): Clear it at the start. For + min_prec > limb_prec descreased precision vars for + INTEGER_CST PHI arguments ensure min_prec is either + prec or multiple of abi_limb_prec. + +2025-08-08 Jakub Jelinek + + Backported from master: + 2025-08-06 Jakub Jelinek + + PR tree-optimization/121127 + * gimple-lower-bitint.cc (bitint_large_huge::handle_operand_addr): For + uninitialized SSA_NAME, set *prec_stored to 0 rather than *prec. + Handle that case in narrowing casts. If prec_stored is non-NULL, + set *prec_stored to prec_stored_val. + 2025-08-08 Release Manager * GCC 15.2.0 released. diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP index 1f2f1bb8fcd..db3c83932b6 100644 --- a/gcc/DATESTAMP +++ b/gcc/DATESTAMP @@ -1 +1 @@ -20250808 +20250809 diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a0edb117739..7b57ad68169 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,23 @@ +2025-08-08 Patrick Palka + + Backported from master: + 2025-08-04 Patrick Palka + + PR c++/121351 + PR c++/119859 + * class.cc (add_method): Substitute outer template arguments + into constraints before comparing them if the declarations are + from different classes. + +2025-08-08 Patrick Palka + + Backported from master: + 2025-08-04 Patrick Palka + + PR c++/120620 + * constexpr.cc (cxx_dynamic_cast_fn_p): Return true only + for synthesized __dynamic_cast. + 2025-08-08 Release Manager * GCC 15.2.0 released. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 309c2797d23..9d65eabeea9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,57 @@ +2025-08-08 Patrick Palka + + Backported from master: + 2025-08-04 Patrick Palka + + PR c++/121351 + PR c++/119859 + * g++.dg/cpp2a/concepts-using5.C: New test. + * g++.dg/cpp2a/concepts-using5a.C: New test. + +2025-08-08 Patrick Palka + + Backported from master: + 2025-08-04 Patrick Palka + + PR c++/120620 + * g++.dg/cpp2a/constexpr-dynamic19.C: New test. + * g++.dg/cpp2a/constexpr-dynamic1a.C: New test. + +2025-08-08 Jakub Jelinek + + Backported from master: + 2025-08-08 Jakub Jelinek + + PR middle-end/121389 + * c-c++-common/asan/pr121389-1.c: New test. + * c-c++-common/asan/pr121389-2.c: New test. + * c-c++-common/asan/pr121389-3.c: New test. + * c-c++-common/asan/pr121389-4.c: New test. + +2025-08-08 Jakub Jelinek + + Backported from master: + 2025-08-06 Jakub Jelinek + + PR tree-optimization/121413 + * gcc.dg/torture/bitint-85.c: New test. + +2025-08-08 Jakub Jelinek + + Backported from master: + 2025-08-06 Jakub Jelinek + + PR tree-optimization/121127 + * gcc.dg/bitint-125.c: New test. + +2025-08-08 Jakub Jelinek + + Backported from master: + 2025-08-03 Jakub Jelinek + + PR c++/120845 + * g++.dg/modules/cpp-21.C: New test. + 2025-08-08 Release Manager * GCC 15.2.0 released. diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index af431f54e0a..2c2abc2d4b7 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,13 @@ +2025-08-08 Jakub Jelinek + + Backported from master: + 2025-08-03 Jakub Jelinek + + PR c++/120845 + * lex.cc (cpp_maybe_module_directive): Move eol variable declaration + to the start of the function, initialize to false and only set it to + peek->type == CPP_PRAGMA_EOL in the not_module case. Formatting fix. + 2025-08-08 Release Manager * GCC 15.2.0 released. diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index aaacab71aff..caf4d288881 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,22 @@ +2025-08-08 Jakub Jelinek + + Backported from master: + 2025-08-04 Jakub Jelinek + hexne + + PR libstdc++/121373 + * src/c++23/std.cc.in (std::ranges::shift_left, + std::ranges::shift_right): Only export for C++23 and later. + (std::ranges::fold_left_first_with_iter_result, + std::ranges::fold_left_with_iter_result): Export. + (std::byteswap): Export for C++23 and later. + (std::ranges::iter_move, std::ranges::iter_swap): Export. + (std::projected_value_t): Export for C++26 and later. + (std::out_ptr_t, std::inout_ptr_t): Export. + (std::ranges::iota_result): Export. + (std::regex_constants): Export a lot of constants. + (std::is_scoped_enum, std::is_scoped_enum_v): Export. + 2025-08-08 Release Manager * GCC 15.2.0 released. commit 917956fe7d8918791a18a3ef83f71b67563d939d Author: GCC Administrator Date: Sun Aug 10 00:24:41 2025 +0000 Daily bump. diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP index db3c83932b6..c740198fdd2 100644 --- a/gcc/DATESTAMP +++ b/gcc/DATESTAMP @@ -1 +1 @@ -20250809 +20250810 commit 06f43dfbbf314bbe6d0b905fc8780e525ef6e72a Author: Xi Ruoyao Date: Tue Jul 8 14:07:21 2025 +0800 testsuite: Enable the PR 87600 tests for LoongArch I'm going to refine a part of the PR 87600 fix which seems triggering PR 120983 that LoongArch is particularly suffering. Enable the PR 87600 tests so I'll not regress PR 87600. gcc/testsuite/ChangeLog: PR rtl-optimization/87600 PR rtl-optimization/120983 * gcc.dg/pr87600.h [__loongarch__]: Define REG0 and REG1. * gcc.dg/pr87600-1.c (dg-do): Add loongarch. * gcc.dg/pr87600-2.c (dg-do): Likewise. (cherry picked from commit 651845ceaae26a1b2c03f215e16e7e711dcea2cc) diff --git a/gcc/testsuite/gcc.dg/pr87600-1.c b/gcc/testsuite/gcc.dg/pr87600-1.c index 351795756a3..9d74cadb011 100644 --- a/gcc/testsuite/gcc.dg/pr87600-1.c +++ b/gcc/testsuite/gcc.dg/pr87600-1.c @@ -1,5 +1,5 @@ /* PR rtl-optimization/87600 */ -/* { dg-do compile { target aarch64*-*-* arm*-*-* i?86-*-* powerpc*-*-* s390*-*-* x86_64-*-* } } */ +/* { dg-do compile { target aarch64*-*-* arm*-*-* i?86-*-* loongarch*-*-* powerpc*-*-* s390*-*-* x86_64-*-* } } */ /* { dg-options "-O2" } */ #include "pr87600.h" diff --git a/gcc/testsuite/gcc.dg/pr87600-2.c b/gcc/testsuite/gcc.dg/pr87600-2.c index e8a9f194b73..808ebe18507 100644 --- a/gcc/testsuite/gcc.dg/pr87600-2.c +++ b/gcc/testsuite/gcc.dg/pr87600-2.c @@ -1,5 +1,5 @@ /* PR rtl-optimization/87600 */ -/* { dg-do compile { target aarch64*-*-* arm*-*-* i?86-*-* powerpc*-*-* s390*-*-* x86_64-*-* } } */ +/* { dg-do compile { target aarch64*-*-* arm*-*-* i?86-*-* loongarch*-*-* powerpc*-*-* s390*-*-* x86_64-*-* } } */ /* { dg-options "-O2" } */ #include "pr87600.h" diff --git a/gcc/testsuite/gcc.dg/pr87600.h b/gcc/testsuite/gcc.dg/pr87600.h index af91f6345cd..9c0b383947a 100644 --- a/gcc/testsuite/gcc.dg/pr87600.h +++ b/gcc/testsuite/gcc.dg/pr87600.h @@ -7,6 +7,9 @@ #elif defined (__i386__) # define REG1 "%eax" # define REG2 "%edx" +#elif defined (__loongarch__) +# define REG1 "$t0" +# define REG2 "$t1" #elif defined (__powerpc__) || defined (__POWERPC__) # define REG1 "r3" # define REG2 "r4" commit 21a87ad785fe1e7c6504c3cf7984e74fe5a5067a Author: Xi Ruoyao Date: Tue Jul 8 14:39:11 2025 +0800 lra: Reallow reloading user hard registers if the insn is not asm [PR 120983] The PR 87600 fix has disallowed reloading user hard registers to resolve earlyclobber-induced conflict. However before reload, recog completely ignores the constraints of insns, so the RTL passes may produce insns where some user hard registers violate an earlyclobber. Then we'll get an ICE without reloading them, like what we are recently encountering in LoongArch test suite. IIUC "recog does not look at constraints until reload" has been a well-established rule in GCC for years and I don't have enough skill to challange it. So reallow reloading user hard registers (but still disallow doing so for asm) to fix the ICE. gcc/ChangeLog: PR rtl-optimization/120983 * lra-constraints.cc (process_alt_operands): Allow reloading user hard registers unless the insn is an asm. (cherry picked from commit e6d3c88e7bb07f94308074f9751e4384a191e022) diff --git a/gcc/lra-constraints.cc b/gcc/lra-constraints.cc index 7dbc7fe1e00..535991dad06 100644 --- a/gcc/lra-constraints.cc +++ b/gcc/lra-constraints.cc @@ -2423,14 +2423,15 @@ process_alt_operands (int only_alternative) if (curr_static_id->operand[nop].type == OP_INOUT || curr_static_id->operand[m].type == OP_INOUT) break; - /* Operands don't match. If the operands are - different user defined explicit hard + /* Operands don't match. For asm if the operands + are different user defined explicit hard registers, then we cannot make them match when one is early clobber operand. */ if ((REG_P (*curr_id->operand_loc[nop]) || SUBREG_P (*curr_id->operand_loc[nop])) && (REG_P (*curr_id->operand_loc[m]) - || SUBREG_P (*curr_id->operand_loc[m]))) + || SUBREG_P (*curr_id->operand_loc[m])) + && INSN_CODE (curr_insn) < 0) { rtx nop_reg = *curr_id->operand_loc[nop]; if (SUBREG_P (nop_reg)) @@ -3335,19 +3336,15 @@ process_alt_operands (int only_alternative) first_conflict_j = j; last_conflict_j = j; /* Both the earlyclobber operand and conflicting operand - cannot both be user defined hard registers. */ + cannot both be user defined hard registers for asm. + Let curr_insn_transform diagnose it. */ if (HARD_REGISTER_P (operand_reg[i]) && REG_USERVAR_P (operand_reg[i]) && operand_reg[j] != NULL_RTX && HARD_REGISTER_P (operand_reg[j]) - && REG_USERVAR_P (operand_reg[j])) - { - /* For asm, let curr_insn_transform diagnose it. */ - if (INSN_CODE (curr_insn) < 0) + && REG_USERVAR_P (operand_reg[j]) + && INSN_CODE (curr_insn) < 0) return false; - fatal_insn ("unable to generate reloads for " - "impossible constraints:", curr_insn); - } } if (last_conflict_j < 0) continue; commit 45212364fd812be21b98768a5bb3ed67487f59d8 Author: Torbjörn SVENSSON Date: Thu Jul 17 14:27:08 2025 +0200 testsuite: handle-multiline-outputs must allow both cc1 and cc1.exe Prior to 14-2027-g985d6480fe5, the input text had the file extensions pruned. In 14-2027-g985d6480fe5, due to the move of the call, the pruning is never done. This change restores the pruning of the file extension to allow multiline test to pass on both Windows and other platforms like Linux. gcc/testsuite/ChangeLog: * lib/multiline.exp: Added pruning of .exe. Signed-off-by: Torbjörn SVENSSON (cherry picked from commit 7494e197e442dcb0fd6aceacdaee732e62b2c5d7) diff --git a/gcc/testsuite/lib/multiline.exp b/gcc/testsuite/lib/multiline.exp index 08fd9691a4a..686504773ef 100644 --- a/gcc/testsuite/lib/multiline.exp +++ b/gcc/testsuite/lib/multiline.exp @@ -153,6 +153,9 @@ proc handle-multiline-outputs { text } { # If dg-enable-nn-line-numbers was provided, then obscure source-margin # line numbers by converting them to "NN" form. set text [maybe-handle-nn-line-numbers $text] + + # Remove Windows .exe suffix + regsub -all "(as|cc1|cc1plus|collect2|f951|ld|lto-wrapper)\.exe?:" $text {\1:} text set index 0 foreach entry $multiline_expected_outputs {