]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
2 months agolibstdc++: Implement std::layout_right_padded [PR110352].
Luc Grosheintz [Mon, 29 Sep 2025 06:00:19 +0000 (08:00 +0200)] 
libstdc++: Implement std::layout_right_padded [PR110352].

This commit adds the right padded layout as described in N5014, with
LWG4372 (dynamic padding value) and LWG4314 (move in operator()).

PR libstdc++/110352

libstdc++-v3/ChangeLog:

* include/std/mdspan (_RightPaddedIndices): Traits for right
padded layouts.
(layout_right::mapping::mapping) New overload for right padded
layouts.
(layout_right_padded): Add implementation.
* src/c++23/std.cc.in (layout_right_padded): Add.
* testsuite/23_containers/mdspan/layouts/ctors.cc: Update
test for right padded layouts.
* testsuite/23_containers/mdspan/layouts/empty.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/mapping.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/padded.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/padded_neg.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/padded_traits.h: Ditto.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
2 months agolibstdc++: Implement std::layout_left_padded [PR110352].
Luc Grosheintz [Mon, 29 Sep 2025 06:00:18 +0000 (08:00 +0200)] 
libstdc++: Implement std::layout_left_padded [PR110352].

This commit adds a new layout layout_left_padded as standardized in
N5014. It adds a purely internal feature testing macro padded_layouts
and registers layout_left_padded in the std module.

This commit implements LWG4372, because without it's not possible
to properly test padded layouts with a dynamic padding value. It also
implements LWG4314, for consistency with prior layouts.

The implementation uses a _PaddedStorage to deduplicate most of the code
shared between left- and right-padded layouts. It's implemented through
aggregation rather than inheritence, because of a bug related to
inheriting conditionally explicit ctors.

The tests are written such that the canonical version works for
layout_left_padded. A version for layout_right_padded is derived
essentially by reversing the order of the extents.

PR libstdc++/110352

libstdc++-v3/ChangeLog:

* include/bits/version.def (padded_layouts): Add new internal
feature testing macro.
* include/bits/version.h: Regenerate.
* include/std/mdspan (__fwd_prod): New overload.
(layout_left_padded): Add declaration and implementation.
(layout_right_padded): Add declaration only.
(layout_left::mapping::mapping): New overload for left
padded mappings.
(__index_type_cast): New function that performs a checked cast
to index_type.
(__is_left_padded_mapping): New concept.
(__is_right_padded_mapping): Ditto.
(__standardized_mapping): Recognize left and right padded
mappings.
(_LeftPaddedIndices): Traits for left padded details.
(_PaddedStorage): New class for implementing padded layouts.
* src/c++23/std.cc.in (layout_left_padded): Add.
* testsuite/23_containers/mdspan/layouts/class_mandate_neg.cc:
Refactor and add tests for layout_left_padded.
* testsuite/23_containers/mdspan/layouts/ctors.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/empty.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/mapping.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/padded.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/padded_neg.cc: Ditto.
* testsuite/23_containers/mdspan/layouts/padded_traits.h: New
traits.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Signed-off-by: Luc Grosheintz <luc.grosheintz@gmail.com>
2 months agoAdd missing menu item for JIT Language and ABI
Richard Biener [Wed, 8 Oct 2025 09:13:15 +0000 (11:13 +0200)] 
Add missing menu item for JIT Language and ABI

Build of gccint.texi is currently broken, the following fixes it.

* doc/tm.texi.in (JIT Language and ABI): Add menu item.
* doc/tm.texi: Re-generate.

2 months agoc: Fix i386 target attribute regression [PR 122180]
Alfie Richards [Tue, 7 Oct 2025 09:34:48 +0000 (09:34 +0000)] 
c: Fix i386 target attribute regression [PR 122180]

My patch (r16-4182-g73888cefe6da65) broke another target (i386), which this
patch fixes.

The issue was the target_version code was incorrectly being triggered on
targets that do not support target_version semantics (i386).

PR target/122180

gcc/c/ChangeLog:

* c-decl.cc (pushdecl): Add TARGET_HAS_FMV_TARGET_ATTRIBUTE check.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr122180.c: New test.

2 months agogimplify: Fix up __builtin_c[lt]zg gimplification [PR122188]
Jakub Jelinek [Wed, 8 Oct 2025 07:58:41 +0000 (09:58 +0200)] 
gimplify: Fix up __builtin_c[lt]zg gimplification [PR122188]

The following testcase ICEs during gimplification.
The problem is that save_expr sometimes doesn't create a SAVE_EXPR but
returns the original complex tree (COND_EXPR) and the code then uses that
tree in 2 different spots without unsharing.  As this is done during
gimplification it wasn't unshared when whole body is unshared and because
gimplification is destructive, the first time we gimplify it we destruct it
and second time we try to gimplify it we ICE on it.
Now, we could replace one a use with unshare_expr (a), but because this
is a gimplification hook, I think easier than trying to create a save_expr
is just gimplify the argument, then we know it is is_gimple_val and so
something without side-effects and can safely use it twice.  That argument
would be the first thing to gimplify after return GS_OK anyway, so it
doesn't change argument sequencing etc.

2025-10-08  Jakub Jelinek  <jakub@redhat.com>

PR c/122188
* c-gimplify.cc (c_gimplify_expr): Gimplify CALL_EXPR_ARG (*expr_p, 0)
instead of calling save_expr on it.

* c-c++-common/pr122188.c: New test.

2 months agotestsuite: Fix up pr121987.c testcase for ilp32 [PR121206]
Jakub Jelinek [Wed, 8 Oct 2025 07:49:25 +0000 (09:49 +0200)] 
testsuite: Fix up pr121987.c testcase for ilp32 [PR121206]

The test FAILs on ilp32 targets with
pr121987.c:5:21: warning: unsigned conversion from 'long long int' to 'long unsigned int' changes value from '10000000000' to '1410065408' [-Woverflow]
excess error.  Fixed by using unsigned long long instead of unsigned and
using a suffix on the constant.
Tested on x86_64-linux with -m32/-m64, additionally tested with older cc1
where it ICEd in both cases in upper_bound.

2025-10-08  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/121206
* gcc.dg/pr121987.c (main): Use unsigned long long type for e instead
of unsigned long and use ULL suffix on the initializer.

2 months agoFortran: Fix PDT parameter substitution [PR93175,PR102240,PR102686]
Paul Thomas [Wed, 8 Oct 2025 07:17:10 +0000 (08:17 +0100)] 
Fortran: Fix PDT parameter substitution [PR93175,PR102240,PR102686]

2025-10-08  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/93175
PR fortran/102240
PR fortran/102686
* array.cc (match_array_element_spec): For pdt templates, call
gfc_correct_parm_expr to elimante extraneous symbols from the
bound expressions.
* decl.cc (correct_parm_expr, gfc_correct_parm_expr): New fcns
that remove symbols that are not PDT parameters from the type
specification expressions.
(insert_parameter_exprs): Process function symbols as if they
are variables in the substitution with parameter expressions.
(gfc_get_pdt_instance): Make sure that the parameter list of
PDT components is updated as the instance is built. Move the
construction of pdt_strings down a bit in the function and
remove the tie up with pdt_arrays.
* gfortran.h: Add prototype for gfc_correct_parm_expr.
* resolve.cc (resolve_component): Skip testing for constant
specification expressions in pdt_template component string
lengths and pdt_strings.
* trans-array.cc (structure_alloc_comps): Remove testing for
deferred parameters and instead make sure that components of
PDT type have parameters substituted with the parameter exprs
of the enclosing PDT.

gcc/testsuite/
PR fortran/93175
PR fortran/102240
PR fortran/102686
* gfortran.dg/pdt_55.f03: New test.

2 months agoFixup store bool pattern
Richard Biener [Tue, 7 Oct 2025 13:32:45 +0000 (15:32 +0200)] 
Fixup store bool pattern

I think the bool pattern recognition for a store from a bool we
decided to represent with a mask type is a bit confused.  The
following streamlines it by using the mask to create a data 0/1
and first possibly converting the mask according to the vector
data type we produce (that was missing and is noticable in PR110223).

This alone doesn't fix the 2nd testcase from the PR, but is required.

PR tree-optimization/110223
* tree-vect-patterns.cc (vect_recog_bool_pattern): Fix
mistakes in the store-from-mask bool pattern.  Add
required mask conversions.

2 months agotree-optimization/105490 - improve COND_EXPR bool pattern
Richard Biener [Tue, 7 Oct 2025 12:31:18 +0000 (14:31 +0200)] 
tree-optimization/105490 - improve COND_EXPR bool pattern

We miss to add a mask conversion from the mask producer to the
appropriate mask for the condition operation.  The following moves
required helpers and adds the missing part of the pattern.  That's
required both for the case we have different mask element sizes
and for the case we have a different number of elements because
cond expression vectorization doesn't handle the mask having
different nunits than the data vector.

PR tree-optimization/105490
* tree-vect-patterns.cc (build_mask_conversion): Move earlier.
(vect_convert_mask_for_vectype): Likewise.
(vect_recog_bool_pattern): Remove redundant truth type
construction.  Add missing possibly required mask conversion.

* gcc.dg/vect/vect-cond-14.c: New testcase.

2 months agolibgccjit: Add ability to get CPU features
Antoni Boucher [Fri, 21 Mar 2025 17:13:41 +0000 (13:13 -0400)] 
libgccjit: Add ability to get CPU features

gcc/ChangeLog:
PR jit/112466
* Makefile.in (tm_jit_file_list, tm_jit_include_list, TM_JIT_H,
JIT_TARGET_DEF, JIT_TARGET_H, JIT_TARGET_OBJS): New variables.
(tm_jit.h, cs-tm_jit.h, jit/jit-target-hooks-def.h,
s-jit-target-hooks-def-h, default-jit.o): New rules.
(s-tm-texi): Also check timestamp on jit-target.def.
(generated_files): Add TM_JIT_H and jit/jit-target-hooks-def.h.
(build/genhooks.o): Also depend on JIT_TARGET_DEF.
* config.gcc (tm_jit_file, jit_target_objs, target_has_targetjitm):
New variables.
* config/i386/t-i386 (i386-jit.o): New rule.
* configure: Regenerate.
* configure.ac (tm_jit_file_list, tm_jit_include_list,
jit_target_objs): Add substitutes.
* doc/tm.texi: Regenerate.
* doc/tm.texi.in (targetjitm): Document.
(target_has_targetjitm): Document.
* genhooks.cc: Include jit/jit-target.def.
* config/default-jit.cc: New file.
* config/i386/i386-jit.cc: New file.
* config/i386/i386-jit.h: New file.

gcc/jit/ChangeLog:
PR jit/112466
* Make-lang.in (JIT_OBJS): New variable.
* jit-playback.cc (replay): Include jit-target.h and initialize
target.
* jit-playback.h (class populate_target_info): New class.
* jit-recording.cc (recording::context::populate_target_info): New
method.
* jit-recording.h (recording::context::populate_target_info): New
method.
(recording::context::m_populated_target_info): New field.
* libgccjit.cc: Include jit-target.h.
(struct gcc_jit_target_info): New struct.
(gcc_jit_context_get_target_info, gcc_jit_target_info_release,
gcc_jit_target_info_cpu_supports, gcc_jit_target_info_arch,
gcc_jit_target_info_supports_target_dependent_type): New functions.
* libgccjit.h (gcc_jit_context_get_target_info,
gcc_jit_target_info_release, gcc_jit_target_info_cpu_supports,
gcc_jit_target_info_arch,
gcc_jit_target_info_supports_target_dependent_type):
New functions.
* libgccjit.map (LIBGCCJIT_ABI_35): New ABI tag.
* docs/topics/compilation.rst: Add documentation for the
functions gcc_jit_context_get_target_info, gcc_jit_target_info_release,
gcc_jit_target_info_cpu_supports, gcc_jit_target_info_arch,
gcc_jit_target_info_supports_target_dependent_type.
* docs/topics/compatibility.rst (LIBGCCJIT_ABI_35): New ABI tag.
* jit-target-def.h: New file.
* jit-target.cc: New file.
* jit-target.def: New file.
* jit-target.h: New file.

gcc/testsuite/ChangeLog:
PR jit/112466
* jit.dg/all-non-failing-tests.h: Mention
test-target-info.c.
* jit.dg/test-target-info.c: New test.
* jit.dg/test-error-target-info.c: New test.

2 months agoDaily bump.
GCC Administrator [Wed, 8 Oct 2025 00:20:55 +0000 (00:20 +0000)] 
Daily bump.

2 months agoc: Implement C2y handling of incomplete tentative definitions [PR26581]
Joseph Myers [Tue, 7 Oct 2025 23:04:54 +0000 (23:04 +0000)] 
c: Implement C2y handling of incomplete tentative definitions [PR26581]

Before C2y, a tentative definition (file-scope, not extern, no
initializer) with internal linkage and incomplete type was undefined
behavior ("shall" outside Constraints violated).  In C2y, this has
changed to a constraint violation if the type has not been completed
by the end of the translation unit, and is valid if the type has been
completed by the end of the translation unit.  This change originates
from N3347 but the wording accepted into C2y was that from reflector
message 26758.

In GCC, the case of incomplete array types was a hard error with
-pedantic, rather than a pedwarn, contrary to how -pedantic is
supposed to behave; bug 26581 requested a change to allow this case
with -pedantic (i.e. the change made in C2y).  For incomplete structs
and unions, GCC only diagnoses them if the type remains incomplete at
the end of the translation unit; bug 88727 (*not* fixed here) requests
the case where the type gets completed should also be diagnosed as a
quality of implementation matter (and that bug is still applicable for
pre-C2y langauge versions and -Wc23-c2y-compat).

Change the handling of arrays following C2y; the previous error
becomes a pedwarn_c23 while there is a new error at the end of the
translation unit if the type remains incomplete there in C2y mode.

There is an ambiguity in the wording in C2y for the case where the
type gets completed only in an inner scope; I've raised that in
reflector message 34118.

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

PR c/26581

gcc/c/
* c-decl.cc (c_finish_incomplete_decl): Give error for tentative
definition of incomplete array for C2y with internal linkage.
(finish_decl): Do not set DO_DEFAULT based on -pedantic.  Use
pedwarn_c23 for missing array sizes for internal linkage.

gcc/testsuite/
* gcc.dg/c23-incomplete-2.c, gcc.dg/c23-incomplete-3.c,
gcc.dg/c23-incomplete-4.c, gcc.dg/c2y-incomplete-4.c,
gcc.dg/c2y-incomplete-5.c: New tests.
* gcc.dg/c23-thread-local-2.c, gcc.dg/c2y-incomplete-1.c: Update
expected errors.

2 months agolibbid: Set rounding mode to round-to-nearest for _Decimal128 arithmetic
H.J. Lu [Sat, 30 Aug 2025 18:46:31 +0000 (11:46 -0700)] 
libbid: Set rounding mode to round-to-nearest for _Decimal128 arithmetic

Since _Decimal128 arithmetic requires the round-to-nearest rounding
mode, define DFP_INIT_ROUNDMODE and DFP_RESTORE_ROUNDMODE, similar to
FP_INIT_ROUNDMODE in sfp-machine.h, to set the rounding mode to
round-to-nearest at _Decimal128 related arithmetic function entrances
and restores it upon return.  This doesn't require linking with libm
when libgcc is used.

libgcc/

PR target/120691
* Makefile.in (DECNUMINC): Add -I$(srcdir)/config/$(cpu_type).
* config/i386/dfp-machine.h: New file.
* config/i386/32/dfp-machine.h: Likewise.
* config/i386/64/dfp-machine.h: Likewise.

libgcc/config/libbid/

PR target/120691
* bid128_div.c: Run DFP_INIT_ROUNDMODE at function entrace and
DFP_RESTORE_ROUNDMODE at function exit.
* bid128_rem.c: Likewise.
* bid128_sqrt.c: Likewise.
* bid64_div.c (bid64_div): Likewise.
* bid64_sqrt.c (bid64_sqrt): Likewise.
* bid_conf.h: Include <dfp-machine.h>.
* dfp-machine.h: New file.

gcc/testsuite/

PR target/120691
* gcc.target/i386/pr120691.c: New test.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2 months agoc++: new-expr clobber of constant-size array
Jason Merrill [Sat, 4 Oct 2025 08:24:29 +0000 (09:24 +0100)] 
c++: new-expr clobber of constant-size array

I previously tried to clobber an array as a whole, but fell back on a loop
due to issues with std::construct_at following the resolution of LWG3436.
But the loop seems to make life hard for the optimizers and it occurs to me
that for a one-element array we can just clobber the element type.

This also fixes some xfails in Warray-bounds-20.C.

gcc/cp/ChangeLog:

* init.cc (build_new_1): Clobber a constant-bound array as a whole.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Warray-bounds-20.C: Remove xfails, add diags.

2 months agodocs: Add documentation for TARGET_HAS_FMV_TARGET_ATTRIBUTE macro
Alfie Richards [Wed, 13 Aug 2025 20:13:28 +0000 (20:13 +0000)] 
docs: Add documentation for TARGET_HAS_FMV_TARGET_ATTRIBUTE macro

Adds documentation for the TARGET_HAS_FMV_TARGET_ATTRIBUTE macro hook.

gcc/ChangeLog:

* doc/tm.texi: Regenerate.
* doc/tm.texi.in: Add documentation for TARGET_HAS_FMV_TARGET_ATTRIBUTE.

2 months agoAVR: target/122187 - Don't clobber recog_data.operand[] in insn out.
Georg-Johann Lay [Tue, 7 Oct 2025 15:50:34 +0000 (17:50 +0200)] 
AVR: target/122187 - Don't clobber recog_data.operand[] in insn out.

avr.cc::avr_out_extr() and avr.cc::avr_out_extr_not()
changed xop for output, which spoiled the operand for
the next invokation, running into an assertion.

This patch makes a local copy of the operands.

PR target/122187
gcc/
* config/avr/avr.cc (avr_out_extr, avr_out_extr_not):
Make a local copy of the passed rtx[] operands.

gcc/testsuite/
* gcc.target/avr/torture/pr122187.c: New test.

2 months agoall: Fix "specifc", "costant" and "constat" typos in comments
Jonathan Wakely [Tue, 7 Oct 2025 14:00:24 +0000 (15:00 +0100)] 
all: Fix "specifc", "costant" and "constat" typos in comments

gcc/ChangeLog:

* config/i386/i386-features.cc
(general_scalar_chain::vector_const_cost): Fix spelling in
comment.
* ipa-prop.h (enum jump_func_type): Likewise.
* tree-vectorizer.cc (try_vectorize_loop_1): Likewise.

gcc/cp/ChangeLog:

* module.cc (trees_out::lang_vals): Fix spelling in comment.

gcc/jit/ChangeLog:

* docs/_build/texinfo/libgccjit.texi: Fix spelling.
* docs/internals/index.rst: Likewise.

libgm2/ChangeLog:

* configure.host: Fix spelling in comment.

libstdc++-v3/ChangeLog:

* configure.host: Fix spelling in comment.

gcc/testsuite/ChangeLog:

* gfortran.dg/dynamic_dispatch_9.f03: Fix spelling in comment.
* gfortran.dg/use_only_3.inc: Likewise

2 months ago[PATCH] RISC-V: Detect wrap in shuffle_series_pattern [PR121845].
Robin Dapp [Tue, 7 Oct 2025 13:18:27 +0000 (07:18 -0600)] 
[PATCH] RISC-V: Detect wrap in shuffle_series_pattern [PR121845].

Hi,

In shuffle_series_pattern we use series_p to determine if the permute
mask is a simple series.  This didn't take into account that series_p
also returns true for e.g. {0, 3, 2, 1} where the step is 3 and the
indices form a series modulo 4.

We emit
 vid + vmul
in order to synthesize a series.  In order to be always correct we would
need a vrem afterwards still which does not seem worth it.

This patch adds the modulo for VLA permutes and punts if we wrap around
for VLS permutes.  I'm not really certain whether we'll really see a wrapping
VLA series (certainly we haven't so far in the test suite) but as we observed
a VLS one here now it appears conservatively correct to module the indices.

Regtested on rv64gcv_zvl512b.

Regards
 Robin

PR target/121845

gcc/ChangeLog:

* config/riscv/riscv-v.cc (shuffle_series_patterns):
Modulo indices for VLA and punt when wrapping for VLS.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/pr121845.c: New test.

2 months ago[PATCH] RISC-V: Fix slide pattern recognition [PR122124]
Raphael Moreira Zinsly [Tue, 7 Oct 2025 13:14:01 +0000 (07:14 -0600)] 
[PATCH] RISC-V: Fix slide pattern recognition [PR122124]

Ensure the second pivot is really a pivot and it's not in OP1.

PR target/122124
gcc/ChangeLog:
* config/riscv/riscv-v.cc (shuffle_slide_patterns): Check if
the second pivot is in OP1 and improve comments.

gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/pr122124.c: New test.

2 months agoFortran: Fix ICE in pdt_1[3-5].f03 with -fcheck=all [PR102901]
Paul Thomas [Tue, 7 Oct 2025 12:30:43 +0000 (13:30 +0100)] 
Fortran: Fix ICE in pdt_1[3-5].f03 with -fcheck=all [PR102901]

2025-10-07  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/102901
* trans-array.cc (structure_alloc_comps): Do not use
gfc_check_pdt_dummy with pointer or allocatable components.

gcc/testsuite/
PR fortran/102901
* gfortran.dg/pdt_56.f03: Copy of pdt_13.f03 compiled with
-fcheck=all.

2 months agolibstdc++: Initialize local variable in __gnu_cxx::rope
Jonathan Wakely [Wed, 1 Oct 2025 14:12:35 +0000 (15:12 +0100)] 
libstdc++: Initialize local variable in __gnu_cxx::rope

This avoids -Wmaybe-uninitialized warnings.

libstdc++-v3/ChangeLog:

* include/ext/ropeimpl.h (rope::_S_fetch): Initialize variable.

2 months agolibstdc++: Fix -Wparentheses warning in std::mul_sat
Jonathan Wakely [Wed, 1 Oct 2025 12:53:14 +0000 (13:53 +0100)] 
libstdc++: Fix -Wparentheses warning in std::mul_sat

libstdc++-v3/ChangeLog:

* include/bits/sat_arith.h (mul_sat): Add parentheses around
operands.

2 months agolibstdc++: Fix -Wmaybe-uninitialized warning in another test
Jonathan Wakely [Wed, 1 Oct 2025 12:51:55 +0000 (13:51 +0100)] 
libstdc++: Fix -Wmaybe-uninitialized warning in another test

Like r16-4120-ge1b9ccaa10df01 this is a false positive, but we can just
initialize the variable.

libstdc++-v3/ChangeLog:

* testsuite/std/time/parse/parse.cc: Initialize variable.

2 months agolibstdc++: Suppress -Wpessimizing-move warnings in shared_ptr tests
Jonathan Wakely [Thu, 2 Oct 2025 15:37:33 +0000 (16:37 +0100)] 
libstdc++: Suppress -Wpessimizing-move warnings in shared_ptr tests

libstdc++-v3/ChangeLog:

* testsuite/20_util/shared_ptr/cons/move.cc: Add comment and
dg-prune-output for -Wpessimizing-move warning.
* testsuite/experimental/memory/shared_ptr/cons/move_ctor.cc:
Likewise.

2 months agolibstdc++: Fix -Wreorder warning in std::philox_engine
Jonathan Wakely [Wed, 1 Oct 2025 12:48:18 +0000 (13:48 +0100)] 
libstdc++: Fix -Wreorder warning in std::philox_engine

libstdc++-v3/ChangeLog:

* include/bits/random.h (philox_engine(result_type)): Reorder
ctor-initializer-list to match declaration order.

2 months agolibstdc++: Fix -Wformat warning in std::string
Jonathan Wakely [Wed, 1 Oct 2025 12:31:59 +0000 (13:31 +0100)] 
libstdc++: Fix -Wformat warning in std::string

The __throw_out_of_range_fmt function works like fprintf and so the
arguments corresponding to %zu specifiers need to be size_t. The
std::basic_string<C,T,A>::size_type type is A::size_type which is not
necessarily size_t. Add explicit casts to avoid a -Wformat warning with
-Wsystem-headers.

libstdc++-v3/ChangeLog:

* include/bits/basic_string.h (basic_string::_M_check): Cast
size_type arguments to size_t.

2 months agoRevert "Ada: Remove useless Makefile variable"
Eric Botcazou [Tue, 7 Oct 2025 07:51:37 +0000 (09:51 +0200)] 
Revert "Ada: Remove useless Makefile variable"

This reverts commit 49aed8ceb5d3ee8af96ebd7edd5d250b682697cd.

2 months agomatch: Extend `-(a ptrdiff b)` pattern by allowing a nop conversion between the neg...
Andrew Pinski [Sun, 5 Oct 2025 16:08:15 +0000 (09:08 -0700)] 
match: Extend `-(a ptrdiff b)` pattern by allowing a nop conversion between the neg and ptrdiff [PR121921]

When I tried to fix this before I didn't realize there was already a pattern for
`-(a ptrdiff b) -> (b ptrdiff a)`, I had added a complex pattern to match `ptr0 - (ptr0 - ptr1)`.
But with there being a pattern for `-(a ptrdiff b)`, we just need to extend the pattern
to support a nop conversion inbetween the negative and the ptrdiff.
Also the check for TYPE_OVERFLOW_UNDEFINED was wrong, in the case of `-(a - b) -> (b - a)`, the check
is !TYPE_OVERFLOW_SANITIZED so this pattern should use the same check.

Bootstrapped and tested on x86_64-linux-gnu.

Changes since v1:
* v2: Use the old type of the pointer_diff rather than ssizetype.

PR tree-optimization/121921

gcc/ChangeLog:

* match.pd (`-(a ptrdiff b)`): Extend for a nop_convert
between the neg and ptrdiff.

gcc/testsuite/ChangeLog:

* gcc.dg/pr121921-1.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 months agophiopt/cselim: Improve cselim-limited to commonalize all stores [PR122083]
Andrew Pinski [Sat, 4 Oct 2025 03:18:07 +0000 (20:18 -0700)] 
phiopt/cselim: Improve cselim-limited to commonalize all stores [PR122083]

cselim (and the phiopt's cselim-limited) can commonalize a single
store which makes this too limited in some/many cases. Instead let's
commonalize all trailing stores as much as possible (only in the same
order).
The change is smallish, basically the restriction on being the only store
is removed from single_trailing_store_in_bb (renamed too). And also
looping to remove all of the trailing stores instead of just doing one for
the pass.

Note sink will do the same optimization so doing it earlier seems like a good
idea because it improve change inlining size estimates.
For an example with this change, early inlining can happen for min_cmp<long int>
in g++.dg/opt/pr122083-1.C now; that avoids a -Wnonnull warning as the memcmp with
the null argument is optimized early. It can also catch some min in phiopt1 in some
cases.

Bootstrapped and tested on x86_64-linux-gnu.

Changes since v1:
* v2: For !flag_expensive_optimizations, handle the only store rather than just the last
      store.

PR tree-optimization/122083

gcc/ChangeLog:

* tree-ssa-phiopt.cc (single_trailing_store_in_bb): Rename to ...
(trailing_store_in_bb): This and take new argument to check for
only store.
(cond_if_else_store_replacement_limited): Update to use
trailing_store_in_bb.
(cond_if_else_store_replacement): Loop until
cond_if_else_store_replacement_limited returns false.
(pass_phiopt::execute): Instead of calling cond_if_else_store_replacement_limited
once, also loop on it.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/ssa-pre-19.c: Disable phiopt and cselim.
* g++.dg/opt/pr122083-1.C: New test.
* gcc.dg/tree-ssa/cselim-1.c: New test.
* gcc.dg/tree-ssa/cselim-2.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 months agox86: Swap %edx/%rdx with %eax/%rax for PR middle-end/122122
H.J. Lu [Tue, 7 Oct 2025 00:28:04 +0000 (08:28 +0800)] 
x86: Swap %edx/%rdx with %eax/%rax for PR middle-end/122122

Swap %edx/%rdx with %eax/%rax after

commit r16-4255-g075310d3a3ef1a8b483b62d9535887b37f291ee4
Author: Jan Hubicka <hubicka@ucw.cz>
Date:   Mon Oct 6 21:35:22 2025 +0200

    Update profile in tree-ssa-dce

commit 8498ef3d0758012bf3e355a61a0f89aff7513851
Author: Jan Hubicka <hubicka@ucw.cz>
Date:   Wed Oct 1 16:56:15 2025 +0200

    Improve profile update in merge_blocks

PR middle-end/122122
* gcc.target/i386/memcpy-pr120683-2.c: Swap %edx/%rdx with
%eax/%rax after
* gcc.target/i386/memcpy-pr120683-3.c: Likewise.
* gcc.target/i386/memcpy-pr120683-4.c: Likewise.
* gcc.target/i386/memcpy-pr120683-5.c: Likewise.
* gcc.target/i386/memcpy-pr120683-6.c: Likewise.
* gcc.target/i386/memcpy-pr120683-7.c: Likewise.
* gcc.target/i386/pr111657-1.c: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2 months agoDaily bump.
GCC Administrator [Tue, 7 Oct 2025 00:21:28 +0000 (00:21 +0000)] 
Daily bump.

2 months agocselim: Don't create a phi node if the rhs side are the same [PR122155]
Andrew Pinski [Sat, 4 Oct 2025 17:16:20 +0000 (10:16 -0700)] 
cselim: Don't create a phi node if the rhs side are the same [PR122155]

This is a small compile time optimization where if commonalizing stores
that have the same rhs, a phi node does not need to be created.
This uses the same code as what was added for the `= {};` case.
The reason why it is a compile time optimization is that Copy prop
later on will do the same thing so not creating a new phi and a new
ssa name will have a small compile time improvement.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/122155

gcc/ChangeLog:

* tree-ssa-phiopt.cc (cond_if_else_store_replacement_1): Don't
create a phi if the 2 rhs are the same.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/cselim-3.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 months agoAVR/LibF7: Implement sincos.
Georg-Johann Lay [Mon, 6 Oct 2025 19:31:46 +0000 (21:31 +0200)] 
AVR/LibF7: Implement sincos.

libgcc/config/avr/libf7/
* libf7-common.mk (F7_ASM_PARTS): Add D_sincos.
* libf7-asm.sx: (D_sincos): New module implements sincos / sincosl.

gcc/testsuite/
* gcc.target/avr/sincos-1.c: New test.

2 months agoUpdate profile in tree-ssa-dce
Jan Hubicka [Mon, 6 Oct 2025 19:35:22 +0000 (21:35 +0200)] 
Update profile in tree-ssa-dce

The profile mismatches uncovered by my merge_blocks change are actually caused
by tree-ssa-dce not updating profile of blocks with no statements for whose it
optimized away control dependencies.  In most cases those basic blocks are
merged or skipped as forwarders.  I tried to simply set their count as
uninitialized but that upsets verifier since in some cases we keep the block
around (for example, when it is header of a loop).

In all cases I debugged we optimized away an unnecesary loop and while merging
old code picked porfile of loop preheader, while we now pick loop header.  This
is however not guaranteed and we may process blocks in different order and pick
wrong profile.

Since regions of dead basic blocks must be acyclic it is easy to propagate the
frequencies as implemented by this patch.

Bootstrapped/regtested x86_64-linux. Comitted

gcc/ChangeLog:

PR middle-end/122122
* tree-cfgcleanup.cc (tree_forwarder_block_p): Cleanup.
* tree-ssa-dce.cc (propagate_counts): New function.
(eliminate_unnecessary_stmts): Use it.

2 months agoFix description of --param auto-profile-bbs
Jan Hubicka [Thu, 2 Oct 2025 10:12:05 +0000 (12:12 +0200)] 
Fix description of --param auto-profile-bbs

gcc/ChangeLog:

* params.opt (-param=auto-profile-bbs=): Add missing full stop after
description.

2 months agoIf a range's bitmask changes, reflect it in the bounds.
Andrew MacLeod [Thu, 2 Oct 2025 15:51:01 +0000 (11:51 -0400)] 
If a range's bitmask changes, reflect it in the bounds.

Rather than trying to be smart, if the bitmask changes, adjust all range
bounds to satisfy the bitmask requirements.

PR tree-optimization/121206
gcc/
* value-range.cc (irange::intersect_bitmask): Always call
set_range_from_bitmask if the bitmask changes.

gcc/testsuite
* gcc.dg/pr121987.c: New.

2 months agodoc: mention STAGE1_CFLAGS
Sam James [Wed, 14 Aug 2024 12:15:30 +0000 (13:15 +0100)] 
doc: mention STAGE1_CFLAGS

STAGE1_CFLAGS can be used to accelerate the just-built stage1 compiler
which especially improves its performance on some of the large generated
files during bootstrap. It defaults to nothing (i.e. -O0).

The downside is that if the native compiler is buggy, there's a greater
risk of a failed bootstrap. Those with a modern native compiler, ideally
a recent version of GCC, should be able to use -O1 or -O2 without issue
to get a faster build.

PR rtl-optimization/111619
* doc/install.texi (Building a native compiler): Discuss STAGE1_CFLAGS.

2 months agoAVR/LibF7: target/122177 - fix fmin / fmax return value for one NaN arg.
Georg-Johann Lay [Sun, 5 Oct 2025 18:56:56 +0000 (20:56 +0200)] 
AVR/LibF7: target/122177 - fix fmin / fmax return value for one NaN arg.

fmin and fmax should return the non-NaN argument in the case where
exactly one argument is a NaN.

Moreover, IEEE double fmin and fmax can be performed without
first converting the args to the internal representation and
then converting back again.

PR target/122177
libgcc/config/avr/libf7/
* libf7-common.mk (m_ddd): Remove: fmin, fmax.
(F7_ASM_PARTS): Add: D_fminfmax.
* libf7-asm.sx (D_fmanfmax): New module.
* f7-wraps.h: Rebuild.

gcc/testsuite/
* gcc.target/avr/fminfmax-1.c: New test.

2 months agoAVR: Speed up IEEE double comparisons.
Georg-Johann Lay [Sun, 5 Oct 2025 18:56:56 +0000 (20:56 +0200)] 
AVR: Speed up IEEE double comparisons.

IEEE double can be compared without first converting them to
the internal representation.

libgcc/config/avr/libf7/
* libf7-common.mk (g_xdd_cmp): Remove le, lt, ge, gt, ne, eq, unord.
(F7_ASM_PARTS): Add D_cmp, D_eq, D_ne, D_ge, D_gt, D_le, D_lt, D_unord.
* libf7-asm.sx (D_cmp, D_eq, D_ne, D_ge, D_gt, D_le, D_lt, D_unord):
New modules.
* f7-wraps.h: Rebuild.

gcc/testsuite/
* gcc.target/avr/cmpdi-1.c: New test.

2 months agoaarch64: Fix ICE when op2 is zero for SVE2 saturating add intrinsics.
Jennifer Schmitz [Thu, 21 Aug 2025 17:01:49 +0000 (10:01 -0700)] 
aarch64: Fix ICE when op2 is zero for SVE2 saturating add intrinsics.

When op2 in SVE2 saturating add intrinsics (svuqadd, svsqadd) is a zero
vector and predication is _z, an ICE in vregs occurs, e.g. for

svuint8_t foo (svbool_t pg, svuint8_t op1)
{
    return svsqadd_u8_z (pg, op1, svdup_s8 (0));
}

The insn failed to match the pattern (aarch64-sve2.md):

;; Predicated binary operations with no reverse form, merging with zero.
;; At present we don't generate these patterns via a cond_* optab,
;; so there's no correctness requirement to handle merging with an
;; independent value.
(define_insn_and_rewrite "*cond_<sve_int_op><mode>_z"
  [(set (match_operand:SVE_FULL_I 0 "register_operand")
(unspec:SVE_FULL_I
  [(match_operand:<VPRED> 1 "register_operand")
   (unspec:SVE_FULL_I
     [(match_operand 5)
      (unspec:SVE_FULL_I
[(match_operand:SVE_FULL_I 2 "register_operand")
 (match_operand:SVE_FULL_I 3 "register_operand")]
SVE2_COND_INT_BINARY_NOREV)]
     UNSPEC_PRED_X)
   (match_operand:SVE_FULL_I 4 "aarch64_simd_imm_zero")]
  UNSPEC_SEL))]
  "TARGET_SVE2"
  {@ [ cons: =0 , 1   , 2 , 3  ]
     [ &w       , Upl , 0 , w  ] movprfx\t%0.<Vetype>, %1/z, %0.<Vetype>\;<sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
     [ &w       , Upl , w , w  ] movprfx\t%0.<Vetype>, %1/z, %2.<Vetype>\;<sve_int_op>\t%0.<Vetype>, %1/m, %0.<Vetype>, %3.<Vetype>
  }
  "&& !CONSTANT_P (operands[5])"
  {
    operands[5] = CONSTM1_RTX (<VPRED>mode);
  }
  [(set_attr "movprfx" "yes")]
)

because operands[3] and operands[4] were both expanded into the same register
operand containing a zero vector by define_expand "@cond_<sve_int_op><mode>".

This patch fixes the ICE by making a case distinction in
function_expander::use_cond_insn that uses add_fixed_operand if
fallback_arg == CONST0_RTX (mode), and otherwise add_input_operand (which was
previously the default and allowed the expansion of the zero-vector
fallback_arg to a register operand).

The patch was bootstrapped and tested on aarch64-linux-gnu, no regression.
OK for trunk?

Alex Coplan pointed out in the bugzilla ticket that this ICE goes back
to GCC 10. Shall we backport?

Signed-off-by: Jennifer Schmitz <jschmitz@nvidia.com>
Co-authored by: Richard Sandiford <rdsandiford@googlemail.com>

gcc/
PR target/121599
* config/aarch64/aarch64-sve-builtins.cc
(function_expander::use_cond_insn): Use add_fixed_operand if
fallback_arg == CONST0_RTX (mode).

gcc/testsuite/
PR target/121599
* gcc.target/aarch64/sve2/pr121599.c: New test.

2 months agotree-optimization/122131 - do not use re-align load for gathers
Richard Biener [Mon, 6 Oct 2025 07:53:07 +0000 (09:53 +0200)] 
tree-optimization/122131 - do not use re-align load for gathers

As we now ask vect_supportable_dr_alignment for gathers avoid using
(optimized) re-align instructions for them.

PR tree-optimization/122131
* tree-vect-data-refs.cc (vect_supportable_dr_alignment): Do
not use re-align loads for gathers.

* gcc.target/powerpc/altivec-39.c: New testcase.

2 months agoada: Fix handling of Extended_Access with array subtype
Marc Poulhiès [Mon, 22 Sep 2025 08:57:13 +0000 (10:57 +0200)] 
ada: Fix handling of Extended_Access with array subtype

For array subtypes, return the extended types corresponding to the array
type.

gcc/ada/ChangeLog:

* gcc-interface/decl.cc (get_extended_unconstrained_array): Handle
array subtype.

Co-authored-by: Éric Botcazou <botcazou@adacore.com>
2 months agoada: Implement proper upcasting in more cases
Eric Botcazou [Wed, 24 Sep 2025 17:02:34 +0000 (19:02 +0200)] 
ada: Implement proper upcasting in more cases

Upcasting (conversion from a tagged type extension to one of its parents)
is represented as a simple N_Type_Conversion node in the expanded code,
but translating it into a VIEW_CONVERT_EXPR is a bit problematic because
source and target types of the GCC node are supposed to have the same size
(at least in "non-pathological" cases).

That's why Gigi attempts to build an explicit chain of references to the
appropriate _Parent (sub)component instead, but it currently does that
only for simple (i.e. non-discriminated) tagged types.  This can be easily
extended to discriminated tagged types in not-too-dynamic cases (an example
is the ACATS c391002 test).

gcc/ada/ChangeLog:

* gcc-interface/utils.cc (convert): Also extract the _Parent field
to implement upcasting in the case where only the sizes match.

2 months agoada: Fix extended access and memory pool explicit deref
Marc Poulhiès [Tue, 16 Sep 2025 13:07:29 +0000 (15:07 +0200)] 
ada: Fix extended access and memory pool explicit deref

Explicit dereference of an extended access with data allocation in a
memory pool would crash the compiler.

gcc/ada/ChangeLog:

* gcc-interface/trans.cc (Attribute_to_gnu)<Attr_Pool_Address>: Handle
extended access.

2 months agoada: Fix usage of Table.Table in Fmap
Ronan Desplanques [Thu, 25 Sep 2025 07:53:35 +0000 (09:53 +0200)] 
ada: Fix usage of Table.Table in Fmap

Table.Table can be instantiated to use either 0-based or 1-based
indexing, which can cause some confusion and make 0-based instances get
used as 1-based ones.

This was the case for two tables in Fmap before this patch. That did not
cause any bugs but allocated an extra cell in the arrays that went
unused.

This patch also replaces Increment_Last-and-assignment combos with
equivalent calls to Append.

gcc/ada/ChangeLog:

* fmap.adb (File_Mapping, Path_Mapping): Fix instantiations.
(Add_To_File_Map): Use Table.Table.Append.

2 months agoada: Remove obsolete code
Ronan Desplanques [Wed, 24 Sep 2025 12:53:18 +0000 (14:53 +0200)] 
ada: Remove obsolete code

This patch removes code that has been unused since the project manager
infrastructure was retired.

gcc/ada/ChangeLog:

* fmap.ads (Add_Forbidden_File_Name): Remove obsolete code.
* fmap.adb (Forbidden_Names, Add_Forbidden_File_Name,
Mapped_Path_Name, Reset_Tables): Remove obsolete code.

2 months agoada: Refine documentation of -gnatwr
Tonu Naks [Thu, 18 Sep 2025 07:18:08 +0000 (10:18 +0300)] 
ada: Refine documentation of -gnatwr

gcc/ada/ChangeLog:

* doc/gnat_ugn/building_executable_programs_with_gnat.rst: refine
description of -gnatwr
* gnat_ugn.texi: Regenerate.

2 months agotree-optimization/122158 - vector reduction epilog for bit-precision result
Richard Biener [Mon, 6 Oct 2025 07:06:45 +0000 (09:06 +0200)] 
tree-optimization/122158 - vector reduction epilog for bit-precision result

The following makes sure to perform the vector element extraction
using the element type and convert to the original, possibly
bit-precision, result afterwards.  I've also used gimple_build
for the BIT_FIELD_REF since that simplifies the code.

PR tree-optimization/122158
* tree-vect-loop.cc (vect_create_epilog_for_reduction): Handle
bit-precision result.

* gcc.dg/vect/pr122158.c: New testcase.

2 months agostmt: Handle %cc[name] in resolve_asm_operand_names [PR122133]
Jakub Jelinek [Mon, 6 Oct 2025 07:46:48 +0000 (09:46 +0200)] 
stmt: Handle %cc[name] in resolve_asm_operand_names [PR122133]

Last year I've extended the asm template syntax in inline asm to support
%cc0 etc., apparently the first 2 letter generic operand modifier.
As the following testcase shows, I forgot to tweak the [foo] handling
for it though.  As final.cc will error on any % ISALPHA not followed by
digit (with the exception of % c c digit), I think we can safely handle
this for any 2 letters in between % and [, instead of hardcoding it for
now only for %cc[ and changing it again next time we add something
two-letter.

2025-10-06  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/122133
* stmt.cc (resolve_asm_operand_names): Handle % and 2 letters followed
by open square.

* c-c++-common/toplevel-asm-9.c: New test.

2 months agoIntroduce fold_before_rtl_expansion_p [PR122142]
Andrew Pinski [Fri, 3 Oct 2025 16:54:45 +0000 (09:54 -0700)] 
Introduce fold_before_rtl_expansion_p [PR122142]

As requested in https://inbox.sourceware.org/gcc-patches/CAFiYyc1jzZSZNhTas-DdMBFOzH1p96oGN=OVj6fyjt8HzDUyCA@mail.gmail.com/T/#u.
This introduces fold_before_rtl_expansion_p to replace
`(cfun->curr_properties & PROP_last_full_fold) != 0`.
I am not a fan of include tree-pass.h in gimple-fold.h but that was the
only way to reduce the number of changes.

Bootrapped and tested on x86_64-linux-gnu.

PR tree-optimization/122142
gcc/ChangeLog:

* generic-match-head.cc: Include gimple-iterator.h
and gimple-fold.h.
* gimple-fold.cc (gimple_fold_builtin_constant_p): Use
fold_before_rtl_expansion_p.
(gimple_fold_builtin_assume_aligned): Likewise.
(gimple_fold_builtin_stdarg): Likewise.
(gimple_fold_call): Likewise.
* gimple-fold.h: Include "tree-pass.h".
(fold_before_rtl_expansion_p): New function.
* match.pd: Use fold_before_rtl_expansion_p
instead of `cfun->curr_properties & PROP_last_full_fold`.
* tree-ssa-forwprop.cc (simplify_builtin_memcmp): Likewise.
(optimize_stack_restore): Likewise.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 months agoDaily bump.
GCC Administrator [Mon, 6 Oct 2025 00:17:42 +0000 (00:17 +0000)] 
Daily bump.

2 months agox86: Handle small OP size in setmem_epilogue_gen_val
H.J. Lu [Fri, 3 Oct 2025 23:02:20 +0000 (07:02 +0800)] 
x86: Handle small OP size in setmem_epilogue_gen_val

Since OP size passed to setmem_epilogue_gen_val may be smaller than the
required vector size, duplicate it first before setting vector.

gcc/

PR target/122150
* config/i386/i386-expand.cc (setmem_epilogue_gen_val): Duplicate
OP if its size is smaller than MODE size.

gcc/testsuite/

PR target/122150
* gcc.target/i386/pr122150.c: New test.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2 months agoDisable some testcase for -Og
Andrew Pinski [Sun, 5 Oct 2025 20:30:49 +0000 (13:30 -0700)] 
Disable some testcase for -Og

Running the testsuite with ADDITIONAL_TORTURE_OPTIONS set include "-Og -g",
there are a few extra failures in the torture testsuite. These 2 failures
are expected so let's skip them in the same way for -O0.

asm-inline.c is because inlining does not happen as much at -Og.
restrict-8.c fails due to not building the points to aliasing info at -Og.

gcc/testsuite/ChangeLog:

* c-c++-common/torture/asm-inline.c: Disable at -Og.
* gcc.dg/torture/restrict-8.c: Likewise.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 months agohppa: Fix over alignment of 64-bit functions
John David Anglin [Sun, 5 Oct 2025 16:52:28 +0000 (12:52 -0400)] 
hppa: Fix over alignment of 64-bit functions

Both 32 and 64-bit assembly code needs 32-bit alignment.

2025-10-05  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

* config/pa/pa.h (FUNCTION_BOUNDARY): Set to 32.

2 months agoDaily bump.
GCC Administrator [Sun, 5 Oct 2025 16:50:51 +0000 (16:50 +0000)] 
Daily bump.

2 months agocontrib: Ignore commit b40ef6e9dc09 Sync toplevel files from binutils-gdb
Mark Wielaard [Sun, 5 Oct 2025 16:26:43 +0000 (18:26 +0200)] 
contrib: Ignore commit b40ef6e9dc09 Sync toplevel files from binutils-gdb

contrib/ChangeLog:

* gcc-changelog/git_update_version.py (ignored_commits): Add
commit b40ef6e9dc096c8c19399e94947a1965258a6942.

2 months ago*: regenerate autotools
Sam James [Sun, 5 Oct 2025 16:12:21 +0000 (17:12 +0100)] 
*: regenerate autotools

libatomic/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* testsuite/Makefile.in: Regenerate.

libcc1/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.

libffi/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* include/Makefile.in: Regenerate.
* man/Makefile.in: Regenerate.
* testsuite/Makefile.in: Regenerate.

libgcobol/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.

libgfortran/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.

libgm2/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* libm2cor/Makefile.in: Regenerate.
* libm2iso/Makefile.in: Regenerate.
* libm2log/Makefile.in: Regenerate.
* libm2min/Makefile.in: Regenerate.
* libm2pim/Makefile.in: Regenerate.

libgomp/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* testsuite/Makefile.in: Regenerate.

libgrust/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* libformat_parser/Makefile.in: Regenerate.
* libproc_macro_internal/Makefile.in: Regenerate.

libitm/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* testsuite/Makefile.in: Regenerate.

libobjc/ChangeLog:

* aclocal.m4: Regenerate.
* configure: Regenerate.

libphobos/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* libdruntime/Makefile.in: Regenerate.
* src/Makefile.in: Regenerate.
* testsuite/Makefile.in: Regenerate.

libquadmath/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.

libsanitizer/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* asan/Makefile.in: Regenerate.
* configure: Regenerate.
* hwasan/Makefile.in: Regenerate.
* interception/Makefile.in: Regenerate.
* libbacktrace/Makefile.in: Regenerate.
* lsan/Makefile.in: Regenerate.
* sanitizer_common/Makefile.in: Regenerate.
* tsan/Makefile.in: Regenerate.
* ubsan/Makefile.in: Regenerate.

libssp/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.

libstdc++-v3/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* doc/Makefile.in: Regenerate.
* include/Makefile.in: Regenerate.
* libsupc++/Makefile.in: Regenerate.
* po/Makefile.in: Regenerate.
* python/Makefile.in: Regenerate.
* src/Makefile.in: Regenerate.
* src/c++11/Makefile.in: Regenerate.
* src/c++17/Makefile.in: Regenerate.
* src/c++20/Makefile.in: Regenerate.
* src/c++23/Makefile.in: Regenerate.
* src/c++26/Makefile.in: Regenerate.
* src/c++98/Makefile.in: Regenerate.
* src/experimental/Makefile.in: Regenerate.
* src/filesystem/Makefile.in: Regenerate.
* src/libbacktrace/Makefile.in: Regenerate.
* testsuite/Makefile.in: Regenerate.

libvtv/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* testsuite/Makefile.in: Regenerate.

lto-plugin/ChangeLog:

* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* configure: Regenerate.

2 months agoRISC-V: Combine vec_duplicate + vwaddu.wv to vwaddu.wx on GR2VR cost
Pan Li [Fri, 26 Sep 2025 15:08:20 +0000 (23:08 +0800)] 
RISC-V: Combine vec_duplicate + vwaddu.wv to vwaddu.wx on GR2VR cost

This patch would like to combine the vec_duplicate + vwaddu.wv to the
vwaddu.wx.  From example as below code.  The related pattern will depend
on the cost of vec_duplicate from GR2VR.  Then the late-combine will
take action if the cost of GR2VR is zero, and reject the combination
if the GR2VR cost is greater than zero.

Assume we have asm code like below, GR2VR cost is 0.

Before this patch:
  11       beq a3,zero,.L8
  12       vsetvli a5,zero,e32,m1,ta,ma
  13       vmv.v.x v2,a2
  ...
  16   .L3:
  17       vsetvli a5,a3,e32,m1,ta,ma
  ...
  22       vwaddu.wv v1,v2,v3
  ...
  25       bne a3,zero,.L3

After this patch:
  11       beq a3,zero,.L8
  ...
  14    .L3:
  15       vsetvli a5,a3,e32,m1,ta,ma
  ...
  20       vwaddu.wx v1,a2,v3
  ...
  23       bne a3,zero,.L3

Unfortunately, and similar as vwaddu.vv, only widening from uint32_t to
uint64_t has the necessary zero-extend during combine, we loss the extend
op after expand for any other types.

gcc/ChangeLog:

* config/riscv/autovec-opt.md (*widen_waddu_wx_<mode>): Add new
pattern to match vwaddu.wx.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 months agoMatch: Refactor unsigned SAT_MUL form 1 mul and widen-mul by for [NFC]
Pan Li [Thu, 25 Sep 2025 04:59:07 +0000 (12:59 +0800)] 
Match: Refactor unsigned SAT_MUL form 1 mul and widen-mul by for [NFC]

Inspired by the previous patch, the form 1 of unsigned SAT_MUL
can be mul or widen-mul based.  So we can leverage the keyword
for to group it, and avoid the pattern duplication.

The below test suites are passed for this patch:
1. The rv64gcv fully regression tests.
2. The x86 bootstrap tests.
3. The x86 fully regression tests.

gcc/ChangeLog:

* match.pd: Refactor the form 1 of SAT_MUL by keyword for.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 months agoISC-V: Add test for vec_duplicate + vwaddu.wv signed combine with GR2VR cost 0, 1...
Pan Li [Fri, 26 Sep 2025 15:12:27 +0000 (23:12 +0800)] 
ISC-V: Add test for vec_duplicate + vwaddu.wv signed combine with GR2VR cost 0, 1 and 15

Add asm dump check and run test for vec_duplicate + vwaddu.wv
combine to vwaddu.wx, with the GR2VR cost is 0, 2 and 15.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u16.c: Add asm check
for vwaddu.wx.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_widen.h: Add test helper
macros.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_widen_data.h: Add test
helper macros and data.
* gcc.target/riscv/rvv/autovec/vx_vf/vx_widen_wx_run.h: New test.
* gcc.target/riscv/rvv/autovec/vx_vf/wx_vwaddu-run-1-u64.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
2 months agoc++/modules: Avoid ICE when redefining a type reachable via import [PR122053]
Nathaniel Shead [Fri, 26 Sep 2025 12:10:15 +0000 (22:10 +1000)] 
c++/modules: Avoid ICE when redefining a type reachable via import [PR122053]

This shouldn't be an error (see PR c++/99000), but we can at least avoid
the ICE by ensuring that we load any pending type definition before
calling pushdecl, so that we error before committing to filling in the
class definition.

Something like this will probably still be helpful even for implementing
textual deduplication as we now at least ensure check_module_override is
called for this case.

PR c++/122053

gcc/cp/ChangeLog:

* name-lookup.cc (pushtag): Load any imported definition of type
before calling pushdecl.

gcc/testsuite/ChangeLog:

* g++.dg/modules/pr122053_a.C: New test.
* g++.dg/modules/pr122053_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
2 months agoc++/modules: Also check conflicting internal-linkage entities
Nathaniel Shead [Fri, 26 Sep 2025 12:03:24 +0000 (22:03 +1000)] 
c++/modules: Also check conflicting internal-linkage entities

While investigating another issue I noticed that the condition in
check_module_override seems incorrect: the wording in [basic.link] p11
has no exceptions for internal-linkage entities.

gcc/cp/ChangeLog:

* name-lookup.cc (check_module_override): Remove check for
TREE_PUBLIC when checking mergeable entities.

gcc/testsuite/ChangeLog:

* g++.dg/modules/namespace-1_c.C: Adjust to expect errors.
* g++.dg/modules/namespace-2_b.C: Likewise.
* g++.dg/modules/namespace-3_a.C: Removed.
* g++.dg/modules/namespace-3_b.C: Removed.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
2 months agoAda: Fix assertion failure on allocators for discriminated type with default
Franck Behaghel [Sun, 5 Oct 2025 10:17:10 +0000 (12:17 +0200)] 
Ada: Fix assertion failure on allocators for discriminated type with default

This is an incorrect node sharing for allocators built for a discriminated
type with default values.

gcc/ada/
PR ada/110314
* sem_ch4.adb (Analyze_Allocator): Add call to New_Copy_Tree.

gcc/testsuite/
* gnat.dg/allocator3.adb: New test.

2 months agoAda: Report that -gnatyz is included in -gnatyg
Eric Botcazou [Sun, 5 Oct 2025 09:10:17 +0000 (11:10 +0200)] 
Ada: Report that -gnatyz is included in -gnatyg

gcc/ada/
PR ada/112446
* usage.adb (Usage): Add 'z' to the list of 'g' style.

2 months agoAdd testcase for PR ada/113536
Eric Botcazou [Sun, 5 Oct 2025 08:42:25 +0000 (10:42 +0200)] 
Add testcase for PR ada/113536

gcc/testsuite/
PR ada/113536
* gnat.dg/reduce2.adb: New test.

2 months agoAda: Remove useless Makefile variable
Eric Botcazou [Sun, 5 Oct 2025 08:25:14 +0000 (10:25 +0200)] 
Ada: Remove useless Makefile variable

gcc/ada
PR ada/118343
* Makefile.rtl (LLVM_BUILD): Delete.

2 months agoFortran: fix issue with I/O of array pointer [PR107968]
Harald Anlauf [Fri, 3 Oct 2025 19:16:19 +0000 (21:16 +0200)] 
Fortran: fix issue with I/O of array pointer [PR107968]

PR fortran/107968

gcc/fortran/ChangeLog:

* trans-io.cc (gfc_trans_transfer): Also scalarize I/O of section
of an array pointer.

gcc/testsuite/ChangeLog:

* gfortran.dg/implied_do_io_9.f90: New test.

2 months agoforwprop: Refine when TODO_update_address_taken is set [PR122143]
Andrew Pinski [Sat, 4 Oct 2025 00:51:33 +0000 (17:51 -0700)] 
forwprop: Refine when TODO_update_address_taken is set [PR122143]

As requested in https://inbox.sourceware.org/gcc-patches/CAFiYyc162F+i=majzQqutFcq1y=DtRoJVC4z+V3gP8N7uTnFLA@mail.gmail.com/T/#u.
This refines when TODO_update_address_taken is set so it only set when folding of a call.
This should speed up compile time slightly if we don't fold a call during the last forwprop.

Boostrapped and tested on x86_64-linux-gnu.

PR tree-optimization/122143
gcc/ChangeLog:

* tree-ssa-forwprop.cc (pass_forwprop::execute): Restrict setting
TODO_update_address_taken only when the statement was a call before fold_stmt.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 months agophiopt: allow store placement of `= {}` [PR122153]
Andrew Pinski [Fri, 3 Oct 2025 21:09:57 +0000 (14:09 -0700)] 
phiopt: allow store placement of `= {}` [PR122153]

Currently cselim and cselim-limited are able to
handle stores which have a rhs of a ssa name or a constant.
This extends that support to also allow `= {}`.
The sink pass will also commonalize the store but in some
cases this is too late in the pipeline. Doing it in phiopt1
allows for better inlining estimates too.

This is also the first step in improving/fixing PR 122083
such that we do an early inlining which is now not happening
for GCC 15+.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/122153

gcc/ChangeLog:

* tree-ssa-phiopt.cc (cond_if_else_store_replacement_1): Handle
stores of empty constructors too.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/pr122153-1.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 months ago[PATCH][PR tree-optimization/117760] `a != b` implies that a or b is also non-zero
Matteo Nicoli [Sat, 4 Oct 2025 15:22:54 +0000 (09:22 -0600)] 
[PATCH][PR tree-optimization/117760] `a != b` implies that a or b is also non-zero

Implements a match.pd pattern to optimize the cases found in PR 117760.

PR tree-optimization/117760
gcc/
* match.pd: Add simplifications that exploit implied values after
logical tests.

gcc/testsuite
* gcc.dg/int-bwise-opt-1.c: New test.
* gcc.dg/int-bwise-opt-2.c: New test.

2 months agowidening_mul: Reset flow sensitive info in maybe_optimize_guarding_check [PR122104]
Jakub Jelinek [Sat, 4 Oct 2025 15:06:16 +0000 (17:06 +0200)] 
widening_mul: Reset flow sensitive info in maybe_optimize_guarding_check [PR122104]

In PR95852 I've added an optimization where next to just pattern
recognizing r = x * y; r / x != y or r = x * y; r / x == y
as .MUL_OVERFLOW or negation thereof it also recognizes
r = x * y; x && (r / x != y) or r = x * y; !x || (r / x == y)
by optimizing the guarding condition to always true/false.

The problem with that is that some value ranges recorded for
the SSA_NAMEs in the formerly conditional, now unconditional
basic block can be invalid.

This patch fixes it by calling reset_flow_sensitive_info_in_bb
if we optimize the guarding condition.

2025-10-04  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/122104
* tree-ssa-math-opts.cc (maybe_optimize_guarding_check): Call
reset_flow_sensitive_info_in_bb on bb when optimizing out the
guarding condition.

* gcc.target/i386/pr122104.c: New test.

2 months ago[PATCH v2] RISC-V: Fix type of CFA during stack probe [PR122114]
Raphael Moreira Zinsly [Sat, 4 Oct 2025 14:36:48 +0000 (08:36 -0600)] 
[PATCH v2] RISC-V: Fix type of CFA during stack probe [PR122114]

Changes since v1:
- Limit test to rv64.

-->8--

frame.total_size may not be a constant, this patch changes the type of
the stored cfa offset to avoid errors trying to convert the frame size.

PR target/122114
gcc/ChangeLog:
* config/riscv/riscv.cc
(riscv_allocate_and_probe_stack_space): Change initial_cfa_offset
type.

gcc/testsuite/ChangeLog:
* gcc.target/riscv/pr122114.c: New test.

2 months ago[RISC-V][PR target/122147] Avoid creating (subreg (mem)) in RISC-V port
Jeff Law [Sat, 4 Oct 2025 14:33:19 +0000 (08:33 -0600)] 
[RISC-V][PR target/122147] Avoid creating (subreg (mem)) in RISC-V port

So another fun bug.  Utterly amazed we didn't trip over this in some form or
another until now.

We're generating a (subreg (mem)) expression during combine because
"move_operand" accepts it as a valid operand.  We've discouraged those kinds of
expressions for a long time, even though they're generally expected to act like
registers due to reloading.

In this case reloading just goes into an infinite loop 🙁   Rather than
try to fix this in LRA, let's just avoiding creating the problematical subreg
to begin with.  That's accomplished by being a bit more selective in what
move_operand allows.  I'm not particularly happy with what I saw in
move_operand, but I'm inclined to let it be right now.

Tested on rv32 and rv64.  Bootstraps on the Pioneer and BPI will run later
today.  I'll push once the pre-commit CI system has done its thing.

PR target/122147
gcc/
* config/riscv/predicates.md (move_operand): Only allow a REG as the
operand of a SUBREG.

gcc/testsuite/

* gcc.target/riscv/pr122147.c: New test.

2 months ago[PR target/118945][PATCH v3] RISC-V: Add 'prefer_agnostic' tune parameter for vector...
Zhongyao Chen [Sat, 4 Oct 2025 14:29:32 +0000 (08:29 -0600)] 
[PR target/118945][PATCH v3] RISC-V: Add 'prefer_agnostic' tune parameter for vector policies

Improve RISC-V vector code generation by preferring tail-agnostic (ta) and
mask-agnostic (ma) policies for vector instructions when merge operands
are undefined. This optimization, controlled by a uarch-specific `prefer_agnostic`
tuning parameter, reduces `vsetvl` instructions and avoids conservative
undisturbed policy selections, addressing PR target/118945.

Changes from v2:
        - more detailed comment.
        - refine the test to check for vsetvli ta/tu number explicitly.

PR target/118945
gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_prefer_agnostic_p): New function.
(riscv_tune_param): Add prefer_agnostic member.
(various tune info structures): Initialize prefer_agnostic.
* config/riscv/riscv-protos.h (riscv_prefer_agnostic_p): Add
prototype.
* config/riscv/riscv-v.cc (get_prefer_tail_policy,
get_prefer_mask_policy): Use riscv_prefer_agnostic_p.
* config/riscv/riscv-vsetvl.cc (vsetvl_info::get_demand_flags):
demand policy for agnostic when prefer_agnostic is true.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/pr118945-1.c: New file.
* gcc.target/riscv/rvv/autovec/pr118945-2.c: New file.

2 months agoAda: Fix ineffective "use all" clause for type declared in nested package
Eric Botcazou [Sat, 4 Oct 2025 09:28:27 +0000 (11:28 +0200)] 
Ada: Fix ineffective "use all" clause for type declared in nested package

This is an issue reported 10 years ago for a new feature introduced in the
language 20 years ago (Ada 2005): primitive subprograms of a type named in
an use-all-type clause are not seen as (potentially) use-visible if the type
is declared in a nested package, except in the specific case of enumeration
literals; the fix just extends the processing done for enumeration literals.

gcc/ada/
PR ada/64869
* sem_ch7.adb (Install_Private_Declarations): Also propagate the
Current_Use_Clause from partial to full view.
(Uninstall_Declarations): Extend implementation of RM 8.4(8.1/3)
subclause to all primitive subprograms.

gcc/testsuite/
* gnat.dg/use_type1.adb: New test.
* gnat.dg/use_type2.adb: Likewise.

2 months agotestsuite: Add 2 new tests
Jakub Jelinek [Sat, 4 Oct 2025 09:19:30 +0000 (11:19 +0200)] 
testsuite: Add 2 new tests

The following patch adds a variant of constexpr-new23.C and
constexpr-new4.C tests which are or could be affected by some of
the discussed changes in new expression clobbers.

2025-10-04  Jakub Jelinek  <jakub@redhat.com>

* g++.dg/cpp2a/constexpr-new28.C: New test.
* g++.dg/cpp2a/constexpr-new29.C: New test.

2 months agoc++, gimplify: Implement C++26 P2795R5 - Erroneous behavior for uninitialized reads...
Jakub Jelinek [Sat, 4 Oct 2025 07:50:39 +0000 (09:50 +0200)] 
c++, gimplify: Implement C++26 P2795R5 - Erroneous behavior for uninitialized reads [PR114457]

The following patch implements the C++26 P2795R5 paper by enabling something
like -ftrivial-auto-var-init=zero by default for -std=c++26/-std=gnu++26.
There is an important difference between explicit -ftrivial-auto-var-init=zero
and the implicitly enabled one, in particular the explicit one will try to
clear padding bits on vars with explicit initializers, while the default
C++26 mode does not - C++26 says that using the padding bits for anything
but copying structures around is still undefined behavior rather than
erroneous behavior.

Users can still override the default C++26 behavior in both directions,
with -ftrivial-auto-var-init=uninitialized even C++26 will act as C++23
with treating all uninitialized var reads (except for copying) as UB rather
than EB, with -ftrivial-auto-var-init=zero it will also clear padding bits
on explicit initialization and with -ftrivial-auto-var-init=pattern it will
initialize to pattern with clearing padding bits in between.

There are other changes that had to be implemented.  First of all, we need
to magicly preinitialize also temporary objects; this is implemented for
both the C++26 implicit mode and explicit
-ftrivial-auto-var-init={zero,pattern} by emitting .DEFERRED_INIT before
construction of TARGET_EXPR temporaries (if they have void type initializers,
i.e. are initialized by code rather than some value).

Second needed change is dropping *this ={v} {CLOBBER(bob)}; statements
at the start of the constructors for -flifetime-dse=2, that says the old
content of *this is irrelevant, which is not true anymore for C++26,
where we want to treat it like that for -W*uninitialized purposes, but
at runtime actually initialize the values.  Instead for -flifetime-dse=2
we emit such {CLOBBER(bob)} before calling whole object constructor
(on TARGET_EXPR with void type initializer or on DECL_EXPR).
And a separate patch added and another one will be adding more {CLOBBER(bob)}
to new expressions.

The third needed change is about gotos and switches across vacuous
initialization.  C++26 says those are still valid, but don't make an
exception for those in the EB rules.
The patch now includes redirecting of forward/backward gotos
which cross vacuous initializations for -std=c++26 and
-ftrivial-auto-var-init={zero,pattern} by adding an artificial
if (0) { lab1: v1 = .DEFERRED_INIT (...); lab2: v2 = .DEFERRED_INIT (...); }
etc. hunk before the user label (or for case labels moving the case
label into it).  Only one per adjacent set of labels, with perhaps
multiple artificial labels in it.  I believe (and testing seems to
confirm that) that one only needs one set of such initialized vars
per the adjacent label group, if some forward or backward jump
crosses more vacuous inits, it will always cross a subset or superset
of the others and when the vars are ordered right, it can jump into
different positions in the same if (0).
Furthermore, -Wimplicit-fallthrough and -Wswitch-unreachable warnings
have been adjusted to deal with that.
These changes mean that -Wtrivial-auto-var-init warning now doesn't
make sense for C++, as there is nothing to warn about, all the switches
and all the gotos are handled right for -ftrivial-auto-var-init= and
are handled that way both for the implicit C++26 mode and for explicit
-ftrivial-auto-var-init= options.

The fourth change is to avoid regressions for code like
struct A
{
  int f, g;
  A () { f = g; // { dg-warning "g. is used uninitialized" } }
} a;
where with -flifetime-dse=2 -Wuninitialized we were able to warn
about bugs like this because of the *this ={v} {CLOBBER(bob)};
statements at the start of the constructors, but with their removal
wouldn't warn about it.  Instead we now add a magic "clobber *this"
attribute to the this PARM_DECL and use it in -W*uninitialized handling
only as an implicit *this ={v} {CLOBBER(bob)}; at the start of the
function.  If a function is inlined, this disappears, but that shouldn't
be a problem, either it is inlined into another constructor and that
should have "clobber *this" for its this argument or it is inlined into
whole object construction spot and there should be an explicit
{CLOBBER(bob)} for the variable or temporary object.

The fifth change is adding [[indeterminate]] attribute support and
using it to avoid .DEFERRED_INIT calls (like [[gnu::uninitialized]]
is handled).

Some regressions caused by this patch had bugs filed (but for cases
where those already didn't work before with explicit
-ftrivial-auto-var-init=zero), those have been xfailed for now.
See PR121975 and PR122044.

2025-10-04  Jakub Jelinek  <jakub@redhat.com>

PR c++/114457
gcc/
* flag-types.h (enum auto_init_type): Add AUTO_INIT_CXX26.
* tree.h (VACUOUS_INIT_LABEL_P): Define.
* gimplify.cc (is_var_need_auto_init): Renamed to ...
(var_needs_auto_init_p): ... this.  Don't return true for
vars with "indeterminate" attribute.  Formatting fixes.
(gimplify_decl_expr): Use var_needs_auto_init_p instead of
is_var_need_auto_init.
(emit_warn_switch_unreachable): Remove the flag_auto_var_init
special cases.
(warn_switch_unreachable_and_auto_init_r): Handle them here
by doing just returning NULL.
(last_stmt_in_scope): Don't skip just debug stmts to find
the last stmt in seq, skip for
flag_auto_var_init > AUTO_INIT_UNINITIALIZED also IFN_DEFERRED_INIT
calls.
(collect_fallthrough_labels): For
flag_auto_var_init > AUTO_INIT_UNINITIALIZED ignore
IFN_DEFERRED_INIT calls and GIMPLE_GOTOs to
VACUOUS_INIT_LABEL_P.
(should_warn_for_implicit_fallthrough): For
flag_auto_var_init > AUTO_INIT_UNINITIALIZED also skip over
IFN_DEFERRED_INIT calls.
(expand_FALLTHROUGH_r): Likewise, and handle GIMPLE_GOTOs
to VACUOUS_INIT_LABEL_P.
(gimplify_init_constructor): Use var_needs_auto_init_p instead
of is_var_need_auto_init and for flag_auto_var_init
AUTO_INIT_CXX26 don't call gimple_add_padding_init_for_auto_var.
(gimplify_target_expr): If var_needs_auto_init_p and init has
void type, call gimple_add_init_for_auto_var and for
AUTO_INIT_PATTERN also gimple_add_padding_init_for_auto_var.
* tree-ssa-uninit.cc (maybe_warn_operand): Handle loads from *this
at the start of the function with "clobber *this" attribute on the
PARM_DECL.
* ipa-split.cc (split_function): Remove "clobber *this" attribute
from the first PARM_DECL (if any).
* doc/invoke.texi (ftrivial-auto-var-init=): Adjust documentation.
gcc/c-family/
* c-opts.cc (c_common_post_options): For C++26 set
flag_auto_var_init to AUTO_INIT_CXX26 if not specified explicitly.
For C++ disable warn_trivial_auto_var_init.
gcc/cp/
* cp-tree.h: Implement C++26 P2795R5 - Erroneous behavior for
uninitialized reads.
(IF_STMT_VACUOUS_INIT_P): Define.
(check_goto): Change argument type from tree to tree *.
* call.cc (build_over_call): Add indeterminate attribute to
TARGET_EXPR slots for indeterminate parameters.
* constexpr.cc (cxx_eval_internal_function): Handle IFN_DEFERRED_INIT.
(cxx_eval_store_expression): Temporarily work around PR121965 bug.
* cp-gimplify.cc (genericize_if_stmt): Handle IF_STMT_VACUOUS_INIT_P.
(maybe_emit_clobber_object_begin): New function.
(cp_gimplify_expr): Call it for DECL_EXPRs and TARGET_EXPRs with
void type non-NULL TARGET_EXPR_INITIAL.
* decl.cc (struct named_label_fwd_direct_goto,
struct named_label_bck_direct_goto): New types.
(struct named_label_use_entry): Add direct_goto member.  Formatting
fix.
(struct named_label_entry): Add direct_goto member.  Turn bool members
into bool : 1.  Add has_bad_decls bitfield.
(adjust_backward_gotos): New function.
(pop_labels): For flag_auto_var_init > AUTO_INIT_UNINITIALIZED
call adjust_backward_gotos if needed.
(poplevel_named_label_1): For decl_jump_unsafe also set
ent->has_bad_decls, and for decl_instrument_init_bypass_p decls
push them into ent->bad_decls vector too.
(duplicate_decls): Complain if indeterminate attribute on function
parameter isn't present on the first function declaration.
(decl_instrument_init_bypass_p): New function.
(build_deferred_init_call): Likewise.
(maybe_add_deferred_init_calls): Likewise.
(adjust_backward_goto): Likewise.
(check_previous_goto_1): Add direct_goto and case_label arguments.
For decl_instrument_init_bypass_p decls seen if
direct_goto || case_label move case label if needed, call
maybe_add_deferred_init_calls and adjust GOTO_EXPR operands remembered
in direct_goto.  Change return type from bool to int, return 0 on
error, 1 for success with no need to adjust vacuous inits and 2 for
success with need to adjust those.
(check_previous_goto): Adjust check_previous_goto_1 call, vec_free
direct_goto vector.
(check_switch_goto): Add case_label argument, adjust
check_previous_goto_1 call.  Change return type from bool to int.
(check_goto_1): Remove computed argument, add declp argument.  Don't
reuse previous ent->uses if
ent->binding_level != current_binding_level.  Push declp into
direct_goto vectors if needed.
(check_goto): Remove decl argument, add declp argument.  Adjust
check_goto_1 calls.
(finish_case_label): Call check_switch_goto up to twice, first time
to detect errors and find out if second call will be needed, and
after c_add_case_label second time if needed.  In the first case
pass NULL_TREE as new argument to it, in the second case r.
(start_preparsed_function): Don't emit CLOBBER_OBJECT_BEGIN here
for -flifetime-dse=2, instead add "clobber *this" attribute to
current_class_ptr.
* parser.cc (cp_parser_asm_label_list): Call check_goto only
after the TREE_LIST is created and pass address of its TREE_VALUE to
it instead of the label.
* semantics.cc (finish_goto_stmt): Call check_goto only after
build_stmt has been called and pass it address of its first operand
rather than destination.
* tree.cc (handle_indeterminate_attribute): New function.
(cxx_gnu_attributes): Add entry for indeterminate attribute.
gcc/testsuite/
* g++.dg/cpp1y/vla-initlist1.C: Remove dg-skip-if for powerpc.
Initialize i to 43 for ctor from initializer_list and expect value
43 instead of 42.
* g++.dg/cpp26/attr-indeterminate1.C: New test.
* g++.dg/cpp26/attr-indeterminate2.C: New test.
* g++.dg/cpp26/attr-indeterminate3.C: New test.
* g++.dg/cpp26/attr-indeterminate4.C: New test.
* g++.dg/cpp26/erroneous1.C: New test.
* g++.dg/cpp26/erroneous2.C: New test.
* g++.dg/cpp26/erroneous3.C: New test.
* g++.dg/cpp26/erroneous4.C: New test.
* g++.dg/opt/store-merging-1.C: Add
-ftrivial-auto-var-init=uninitialized to dg-options.
* g++.dg/uninit-pred-loop-1_b.C: Expect a warning for C++26.
* g++.dg/warn/Wuninitialized-13.C: Expect warning on a different
line.
* c-c++-common/ubsan/vla-1.c: Add
-ftrivial-auto-var-init=uninitialized to dg-options.
* c-c++-common/uninit-17.c: For c++26 expect warning on a different
line.
* g++.dg/warn/Warray-bounds-20.C: Expect warning on a different line.
* c-c++-common/analyzer/invalid-shift-1.c: Xfail for c++26 until
PR122044 is fixed.
* g++.dg/analyzer/exception-value-2.C: Skip for c++26 until PR122044
is fixed.
* c-c++-common/goacc-gomp/nesting-1.c: Skip for c++26 until PR121975
is fixed.
* c-c++-common/goacc/kernels-decompose-2.c: Likewise.
* c-c++-common/goacc/kernels-decompose-pr100400-1-1.c: Likewise.
* c-c++-common/goacc/kernels-decompose-pr100400-1-3.c: Likewise.
* c-c++-common/goacc/kernels-decompose-pr104061-1-1.c: Likewise.
* c-c++-common/goacc/kernels-decompose-pr104061-1-3.c: Likewise.
* c-c++-common/goacc/kernels-decompose-pr104061-1-4.c: Likewise.
* c-c++-common/goacc/kernels-decompose-pr104132-1.c: Likewise.
* c-c++-common/goacc/kernels-decompose-pr104133-1.c: Likewise.
* c-c++-common/goacc/kernels-decompose-pr104774-1.c: Likewise.
* c-c++-common/goacc/mdc-1.c: Likewise.

2 months agoc++: concepts and conversions, take 2 [PR122127]
Jason Merrill [Fri, 3 Oct 2025 17:10:36 +0000 (18:10 +0100)] 
c++: concepts and conversions, take 2 [PR122127]

My r16-4115 changed convert_template_argument (when called from
instantiate_alias_template) to take the maybe_convert_nontype_argument path
rather than convert_nontype_argument for this testcase.  This meant not
folding the use of the by-ref capture in the template argument to constant
1.  When we come back to convert_template_argument again when substituting
into resize<_Np> we strip the IMPLICIT_CONV_EXPR (since the types are the
same) and take the convert_nontype_argument path, but at this point we've
pushed into the alias template context and trying to fold away the capture
fails because current_lambda_expr() is now null.

Taking the convert_nontype_argument path in the same-type case where we
would later strip an IMPLICIT_CONV_EXPR fixes the problem.  Note that
maybe_convert_nontype_argument already shares the same-type check with the
stripping, but that isn't enough; it still doesn't fold away the capture
proxy.

PR c++/122127
PR c++/112632

gcc/cp/ChangeLog:

* pt.cc (convert_template_argument): Don't add redundant
IMPLICIT_CONV_EXPR.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/lambda/lambda-template18.C: New test.

2 months agoc++/modules: Handle naming external TU-local entities in ADL
Nathaniel Shead [Sat, 20 Sep 2025 13:12:17 +0000 (23:12 +1000)] 
c++/modules: Handle naming external TU-local entities in ADL

This finishes the reworking of ADL handling for modules for PR117658.
[basic.link] p18 says that we should diagnose any references to a
TU-local entity from a different TU; with our fixed handling of ADL this
is now possible to occur.

To do this we need to generate fake bindings for these decls on
stream-out so that importers know that we have a visible name in this
namespace.  We don't actually need (or want) to provide full DECLs
though, as that could potentially involve streaming other TU-local
entities, so we just build a TU_LOCAL_ENTITY for the decl on receipt.
The patch also uses 'decl_as_string' to give a more descriptive name for
these decls when erroring.

We also need somewhere to store these decls.  We only actually need the
decls for diagnostics; for correctness we only need to know whether any
such decls existed, so to not mess with the existing packing of bindings
or usages of the OVERLOADs this patch adds a new map to the binding
vector that can be looked up when diagnostics need to be generated.

Finally, as specified this diagnostic is a pretty broad hammer, as any
internal-linkage purview function will stop ADL in exported templates
from working with that name.  So this patch just makes it a pedwarn and
provides an option to disable if needed.

PR c++/117658

gcc/c-family/ChangeLog:

* c.opt: New flag '-Wexternal-tu-local'.
* c.opt.urls: Regenerate.

gcc/cp/ChangeLog:

* cp-tree.h (TU_LOCAL_ENTITY_NAME): Clarify meaning.
* module.cc (depset::entity_kind): New enumerator, assert that
we have enough bits reserved.
(depset::disc_bits): Assert the discriminator has enough bits.
(depset::entity_kind_name): Add 'tu-local' case, assert we
have an entry for all relevant entry_kinds.
(name_for_tu_local_decl): New function.
(trees_out::tree_node): Use it.
(depset::hash::make_dependency): Validate EK_TU_LOCAL.
(depset::hash::add_binding_entity): Generate bindings for
internal purview functions.
(enum ct_bind_flags): New enum for TU-local decls.
(depset::hash::find_dependencies): Handle EK_TU_LOCAL entities.
(binding_cmp): Likewise.
(sort_cluster): Likewise.
(module_state::write_cluster): Likewise.
(module_state::read_cluster): Likewise.
* name-lookup.cc (append_imported_binding_slot): Propagate
internal decl list when growing binding vector.
(name_lookup::adl_namespace_fns): Diagnose if naming a TU-local
entity from a different TU.
(set_module_binding): Include any internal decls in binding.
* name-lookup.h (struct module_tree_map_traits): New type.
(struct tree_binding_vec): Add member 'internal_decls'.
(BINDING_VECTOR_INTERNAL_DECLS): New getter.
(MODULE_BINDING_INTERNAL_DECLS_P): New flag.
(set_module_binding): Add parameter.

gcc/ChangeLog:

* doc/invoke.texi: Document '-Wno-external-tu-local'.

gcc/testsuite/ChangeLog:

* g++.dg/modules/adl-6_c.C: Adjust diagnostics.
* g++.dg/modules/internal-14_c.C: Likewise.
* g++.dg/modules/internal-15_a.C: New test.
* g++.dg/modules/internal-15_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
2 months agoc++: Fix ICE with struct in function parameter containing auto [PR122112]
Egas Ribeiro [Fri, 3 Oct 2025 00:56:52 +0000 (01:56 +0100)] 
c++: Fix ICE with struct in function parameter containing auto [PR122112]

When parsing function parameters containing a struct declaration,
initially auto_is_implicit_function_template_parm_p is set to true by
cp_parser_parameter_declaration_clause. However, later when we enter
class scope and scope_kind becomes sk_class, we don't set it to false, so
cp_parser_simple_type_specifier will call
synthesize_implicit_template_parm, which expects that
current_binding_level->kind == sk_function_parms, triggering a failed
assertion. This fix ensures that auto_is_implicit_function_template_parm_p
isn't set when parsing a struct body definition.

gcc/cp/ChangeLog:

PR c++/122112
* parser.cc (cp_parser_parameter_declaration_clause): Don't
enable auto_is_implicit_function_template_parm_p when entering
class scope.

gcc/testsuite/ChangeLog:

PR c++/122112
* g++.dg/parse/auto-struct-param.C: New test.

Signed-off-by: Egas Ribeiro <egas.g.ribeiro@tecnico.ulisboa.pt>
2 months agoRevert: r16-4193 ("diagnostics: generalize state graph code to use json::property...
David Malcolm [Fri, 3 Oct 2025 15:04:53 +0000 (11:04 -0400)] 
Revert: r16-4193 ("diagnostics: generalize state graph code to use json::property instances")

This reverts commit e4ab1f87805a6555bc327538d67067f3a690eddc.

Patch r16-4193-ge4ab1f87805a65 seems to have broken the build with
GCC 5.5 (PR bootstrap/122151).  Sorry about this.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 months ago[RISC-V][PR rtl-optimization/121937] Don't call neg_poly_int_rtx with a vector mode
Jeff Law [Fri, 3 Oct 2025 14:41:53 +0000 (08:41 -0600)] 
[RISC-V][PR rtl-optimization/121937] Don't call neg_poly_int_rtx with a vector mode

Fun little bug.

We're asked to simplify this:

(vec_select:HI (if_then_else:V2HI (unspec:V2BI [
                (const_vector:V2BI [
                        (const_int 0 [0])
                        (const_int 1 [0x1])
                    ])
                (const_int 2 [0x2])
                (const_int 0 [0]) repeated x3
                (reg:SI 66 vl)
                (reg:SI 67 vtype)
            ] UNSPEC_VPREDICATE)
        (const_vector:V2HI [
                (const_int 0 [0])
                (const_int -1 [0xffffffffffffffff])
            ])
        (const_vector:V2HI [
                (const_int -1 [0xffffffffffffffff])
                (const_int 0 [0])
            ]))
    (parallel [
            (const_int 0 [0])
        ]))

That triggers some fairly obscure code in combine which realizes the arms are
STORE_FLAG_VALUE computabble.  So we ask for a simplified conditional of the
condition against (const_int 0):

3610      return simplify_context ().simplify_gen_relational (code, mode, op_mode,
(gdb) p debug_rtx (op0)
(unspec:V2BI [
        (const_vector:V2BI [
                (const_int 0 [0])
                (const_int 1 [0x1])
            ])
        (const_int 2 [0x2])
        (const_int 0 [0]) repeated x3
        (reg:SI 66 vl)
        (reg:SI 67 vtype)
    ] UNSPEC_VPREDICATE)
$50 = void
(gdb) p debug_rtx (op1)
(const_int 0 [0])

CODE will be EQ.  So that eventually we'll try that as a simplification using
MINUS with those two operands.

That ultimately lands us in simplify_binary_operation_1 which (of course) tries
to simplify x - 0 to x.  But that fails because we test (const_int 0) against
CONST0_RTX (V2BI) which, of course, false.

We then stumble down into this code:

      /* Don't let a relocatable value get a negative coeff.  */
      if (poly_int_rtx_p (op1) && GET_MODE (op0) != VOIDmode)
        return simplify_gen_binary (PLUS, mode,
                                    op0,
                                    neg_poly_int_rtx (mode, op1));

Where MODE is V2BI.  That's not a scalar mode and we try to get the precision
of V2BI in the bowels of neg_poly_int_rtx, which looks like:

return GET_MODE_PRECISION (as_a <scalar_mode> (x.second));

Where x.second is the mode, V2BI.  Since V2BI is not a scalar mode it blows up
as seen in the BZ.

The immediate and direct fix is to guard that code with a check that we've got
a scalar mode.

I looked at passing a more suitable zero node as well as improving the checks
to simplify x - 0 -> x for this case.  While the RTL does simplify in the
expected ways, nothing really comes out of the RTL simplification (ie, the
final assembly code is the same).  So I decided against including those hacks
(they really didn't feel all that clean to me).  There's just not a compelling
reason for them.

Anyway, bootstrapped and regression tested on x86_64.  Verified it fixes the
riscv fault and doesn't regress riscv64-elf and riscv32-elf. Bootstrap on riscv
native targets will fire up overnight.

PR rtl-optimization/121937

gcc/
* simplify-rtx.cc (simplify_context::simplify_binary_operation_1): Make
sure we've got a scalar_int_mode before calling neg_poly_int_rtx.

gcc/testsuite/
* gcc.target/riscv/pr121937.c: New test.

2 months agoRemove fold_builtin pass [PR121762]
Andrew Pinski [Wed, 24 Sep 2025 04:36:00 +0000 (21:36 -0700)] 
Remove fold_builtin pass [PR121762]

After moving the last optimization out of fab, we can
finally remove this pass.
For -Og, we remove this pass and also swaps out the copy_prop
for a forwprop (which does an integrated copy prop too).

A few testcases needed to be updated.
Most is just s/fab1/optimized/ except for pr79691.c which
needed a slight change in the scaning of the optimized dump;
to find `return 9;` instead of `= 9;`.

Bootstrappd and tested on x86_64-linux-gnu.

PR tree-optimization/121762
gcc/ChangeLog:

* passes.def: Remove both pass_fold_builtin.
Swap out pass_copy_prop for pass_forwprop with
full_walk = false and last=true.
* tree-pass.h (make_pass_fold_builtins): Remove.
* tree-ssa-ccp.cc (class pass_fold_builtins): Delete.
(pass_fold_builtins::execute): Delete.
(make_pass_fold_builtins): Remove.
* doc/passes.texi (Folding built-in functions): Remove.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/builtin-fprintf-1.c: Update to scan optimized.
* gcc.dg/tree-ssa/builtin-fprintf-chk-1.c: Likewise.
* gcc.dg/tree-ssa/builtin-printf-1.c: Likewise.
* gcc.dg/tree-ssa/builtin-printf-chk-1.c: Likewise.
* gcc.dg/tree-ssa/builtin-vfprintf-1.c: Likewise.
* gcc.dg/tree-ssa/builtin-vfprintf-chk-1.c: Likewise.
* gcc.dg/tree-ssa/builtin-vprintf-1.c: Likewise.
* gcc.dg/tree-ssa/builtin-vprintf-chk-1.c: Likewise.
* gcc.dg/tree-ssa/ssa-ccp-10.c: Likewise.
* gcc.dg/builtin-unreachable-5.c: Likewise.
* gcc.dg/builtin-unreachable-6.c: Likewise.
* gcc.dg/builtin-unreachable-6a.c: Likewise.
* gcc.dg/builtin-unreachable-7.c: Likewise.
* gcc.dg/pr78408-2.c: Change fab1 to forwprop1 as that
optimization was moved there a while back.
* gcc.dg/tree-ssa/pr79691.c: Udpate scanning for 9
constant to return.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 months agofab/isel: Move atomic optimizations to isel from fab [PR121762]
Andrew Pinski [Wed, 24 Sep 2025 04:08:24 +0000 (21:08 -0700)] 
fab/isel: Move atomic optimizations to isel from fab [PR121762]

These atomic optimizations that are currently in fab are really an
instruction selection like optimizations so let's move them to gimple-isel.cc.

Note since this is the last manual optimization left in fab, I have simplified
the code to only fold internal and normal builtins. The next patch will remove all
of fab.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/121762
gcc/ChangeLog:

* gimple-isel.cc (gimple_nop_atomic_bit_test_and_p): New decl.
(gimple_nop_convert): Likewise.
(convert_atomic_bit_not): Moved from tree-ssa-ccp.cc.
(optimize_atomic_bit_test_and): Likewise.
(optimize_atomic_op_fetch_cmp_0): Likewise.
(gimple_isel_builtin_call): New function.
(CASE_ATOMIC): Moved from tree-ssa-ccp.cc.
(CASE_ATOMIC_CMP0): Likewise.
(CASE_ATOMIC_BIT_TEST_AND): Likewise.
(pass_gimple_isel::execute): For calls just call gimple_isel_builtin_call.
* tree-ssa-ccp.cc (convert_atomic_bit_not): Move to gimple-isel.cc.
(gimple_nop_atomic_bit_test_and_p): Likewise.
(gimple_nop_convert): Likewise.
(optimize_atomic_bit_test_and): Likewise.
(optimize_atomic_op_fetch_cmp_0): Likewise.
(pass_fold_builtins::execute): Just call fold_stmt for internal
or normal bultin calls.
(CASE_ATOMIC): Move to gimple-isel.cc.
(CASE_ATOMIC_CMP0): Likewise.
(CASE_ATOMIC_BIT_TEST_AND): Likewise.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 months agofab: Use a macro for the atomic/sync builtins case
Andrew Pinski [Tue, 23 Sep 2025 23:43:36 +0000 (16:43 -0700)] 
fab: Use a macro for the atomic/sync builtins case

This is a small cleanup to make it easier to move this part of fab to
somewhere else. And it makes it easier to understand which builtins are being
used here and also less repeated code.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* tree-ssa-ccp.cc (CASE_ATOMIC): New defined.
(CASE_ATOMIC_CMP0): New define.
(CASE_ATOMIC_BIT_TEST_AND): New defined.
(pass_fold_builtins::execute): Use CASE_ATOMIC, CASE_ATOMIC_CMP0,
and CASE_ATOMIC_BIT_TEST_AND.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 months agofab/gimple-fold/forwprop: Move va_args folding to gimple_fold [PR121762]
Andrew Pinski [Tue, 23 Sep 2025 19:58:37 +0000 (12:58 -0700)] 
fab/gimple-fold/forwprop: Move va_args folding to gimple_fold [PR121762]

This moves the va_args functions folding to gimple-fold. Right now this is still
kept for the last folding but later it can move sometime after stdargs pass is run by
checking PROP_gimple_lva instead.
Also for forwprop, if a folding happens for the last folding we need to maybe update the
variables as non-addressable like what is done in fab. It was originally added in fab for
__builtin_sincos->__builtin_cexpi folding (PR39643). After the removal of fab, this will
also be the last pass which updates address taken too.

PR tree-optimization/121762
gcc/ChangeLog:

* gimple-fold.cc (gimple_fold_builtin_stdarg): New function,
moved from tree-ssa-ccp.cc (optimize_stdarg_builtin).
(gimple_fold_builtin): Call gimple_fold_builtin_stdarg for
va_start, va_copy and va_end.
* tree-ssa-ccp.cc (optimize_stdarg_builtin): Remove.
(pass_fold_builtins::execute): Remove handling of
va_start, va_copy and va_end.
* tree-ssa-forwprop.cc (pass_forwprop::execute): Update
todos if fold_stmt return true if last forwprop to include
TODO_update_address_taken.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 months agofab/forwprop: Move optimize_unreachable to forwprop [PR121762]
Andrew Pinski [Tue, 23 Sep 2025 19:14:47 +0000 (12:14 -0700)] 
fab/forwprop: Move optimize_unreachable to forwprop [PR121762]

This moves the optimize_unreachable to forwprop from fab.
There is a slightly optimization here in that the first
statement is checked and outside of the main fold loop. And if
the statement is __builtin_unreachable, then call optimize_unreachable.

Changes since v1:
* v2: simplified the check for BUILT_IN_UNREACHABLE to just use gimple_call_builtin_p.
      Move the code after checking for not executable blocks.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/121762
gcc/ChangeLog:

* tree-ssa-ccp.cc (optimize_unreachable): Move to tree-ssa-forwprop.cc
(pass_fold_builtins::execute): Remove handling of __builtin_unreachable.
* tree-ssa-forwprop.cc (optimize_unreachable): New function from
tree-ssa-ccp.cc. Change argument to bb. Remove check on first statement
being the __builtin_unreachable since it is handled already.
(pass_forwprop::execute): Handle first statement as being __builtin_unreachable
by calling optimize_unreachable.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 months agofab/forwprop: Move optimize stack restore to forwprop [PR121762]
Andrew Pinski [Tue, 23 Sep 2025 18:37:35 +0000 (11:37 -0700)] 
fab/forwprop: Move optimize stack restore to forwprop [PR121762]

This moves the removal of redundant stack restore from fab to forwprop.
There is a possibility of removing some of the redundant stack restores
before the last folding but that is for a different patch.

Changes since v1:
* v2: the additional comment change.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/121762
gcc/ChangeLog:

* tree-ssa-ccp.cc (optimize_stack_restore): Move to tree-ssa-forwprop.cc.
(pass_fold_builtins::execute): Don't call optimize_stack_restore.
* tree-ssa-forwprop.cc (optimize_stack_restore): New function from
tree-ssa-ccp.cc. Return bool instead of value, use replace_call_with_value
istead of returning integer_zero_node.
(simplify_builtin_call): Call optimize_stack_restore.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 months agofab: rewrite optimize_stack_restore call check [PR122033]
Andrew Pinski [Mon, 22 Sep 2025 22:26:00 +0000 (15:26 -0700)] 
fab: rewrite optimize_stack_restore call check [PR122033]

The call check in optimize_stack_restore is not the same as
what is described in the comment before the function. It has never
been the same even. It has always allowed all nromal builtins but not
target builtins while the comment says no calls.

This rewrites it to allow the following.
* a restore right before a noreturn is fine to be removed as the noreturn
  function will do the restore (or exit the program).
* Internal functions are ok because they will turn into an instruction or 2
* Still specifically reject alloca and __scrub_leave
* simple or inexpensive builtins (including target builtins)

This will both reject some more locations but also accepts more locations due
to the internal and target and noreturn function calls checks.

Bootstrapped and tested on x86_64-linux-gnu.

Changes since v1:
* v2: Add comment about why restoring before calls is important.

PR tree-optimization/122033
gcc/ChangeLog:

* tree-ssa-ccp.cc (optimize_stack_restore): Rewrite the call check.
Update comment in the front to new rules on calls.
* tree.h (fndecl_builtin_alloc_p): New function.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/pr122033-1.c: New test.
* gcc.dg/tree-ssa/pr122033-2.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 months agofab/gimple-fold: Move removal of ASSUME internal function to gimple fold [PR121762]
Andrew Pinski [Tue, 23 Sep 2025 05:25:29 +0000 (22:25 -0700)] 
fab/gimple-fold: Move removal of ASSUME internal function to gimple fold [PR121762]

This moves the removal of the ASSUME internal function to gimple fold.
The only thing is fab for -Og support until fab is removed either needs to stay
or changed over to a fold_stmt. I decided to change over to a fold_stmt for
internal function calls. I am almost positive this won't change much either way.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/121762
gcc/ChangeLog:

* gimple-fold.cc (gimple_fold_call): Remove ASSUME internal function
calls when PROP_last_full_fold is set.
* tree-ssa-ccp.cc (pass_fold_builtins::execute): Handling folding
of all internal functions.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 months agofab: Manaully build gimple rather than depend on gimplifier for stdarg functions
Andrew Pinski [Mon, 22 Sep 2025 05:30:18 +0000 (22:30 -0700)] 
fab: Manaully build gimple rather than depend on gimplifier for stdarg functions

This code dates before gimple tuples was around. So it uses both MODIFY_EXPR and
INDIRECT_REF :).
For `__builtin_va_start(ptr, 0)` it exands into:
```
_t = __builtin_next_arg (0);
*ptr = _t;
```
We need to get a new VDEF for the next arg call so we don't need to do a
ssa update too.

For `__builtin_va_copy(ptr, b)`, it expands into:
```
*ptr = b;
```
Which is still a store.

For `__builtin_va_end(ptr)`, we change it into a GIMPLE_NOP.

Before optimize_stdarg_builtin would return a tree and then
pass_fold_builtins::execute would set todo to include
TODO_update_address_taken for a non-null result.
Since now optimize_stdarg_builtin returns a bool, the path that had
set the todo is no longer taken (the result variable is still NULL).
Setting the todo to include TODO_update_address_taken when the call to
optimize_stdarg_builtin succeeds to be able to get the same effect as
before.

That is:
before we had:
```
result = optimize_stdarg_builtin(...);
...
if (!result) continue;
todo |= TODO_update_address_taken;
```
Now after this change we have:
result = NULL_TREE;
...
if (optimize_stdarg_builtin(...))
  todo |= TODO_update_address_taken;
if (!result) continue;
```
Also since optimize_stdarg_builtin will remove the part of taking an
address of a local variable and in this case fab is the last pass
where this happens, TODO_update_address_taken is needed to change the
va args in some cases to not forced to memory variables.

Note this code will be moved into gimple_fold later on. This is part of the
reason for updating this code. The other side is this simplifies the code
too.

Changes since v1:
* v2: expand commit message.

gcc/ChangeLog:

* tree-ssa-ccp.cc (optimize_stdarg_builtin): Mannually create the
gimple statements instead of depending on the gimplifier.
(pass_fold_builtins::execute): Handle updated call to optimize_stdarg_builtin.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 months agofab/forwprop: Move memcmp->memcmp_eq to forwprop
Andrew Pinski [Sat, 20 Sep 2025 06:02:35 +0000 (23:02 -0700)] 
fab/forwprop: Move memcmp->memcmp_eq to forwprop

This moves from the memcmp->memcmp_eq to forwprop by
checking PROP_last_full_fold.

Note this means at -Og, we no longer optimize some
memcmp. That will be fixed when I exchange fab/copyprop
for a (late) forwprop.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* tree-ssa-ccp.cc (optimize_memcmp_eq): Remove.
(pass_fold_builtins::execute): Remove handling of memcmp.
* tree-ssa-forwprop.cc (simplify_builtin_memcmp): Add folding
of memcmp to memcmp_eq for PROP_last_full_fold.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 months agoaarch64: testsuite: fix several duplicate test names
Richard Earnshaw [Wed, 1 Oct 2025 13:48:44 +0000 (14:48 +0100)] 
aarch64: testsuite: fix several duplicate test names

This patch fixes many, though not all, of the aarch64-specific
duplicate testnames.  Similarly to the arm port, most of these are a
mix of duplicate scan-assembler tests that have been addressed by
converting the code to use check-function-bodies, or outright bugs in
the test.

There are a couple of files that still contain duplicates
gcc/testsuite/ChangeLog:

* gcc.target/aarch64/asm-flag-1.c: Scan for lt.
* gcc.target/aarch64/vector-compare-5.c: Use scan-tree-dump-times.
* gcc.target/aarch64/simd/fold_to_highpart_5.c: Scan for sabal2
and uabal2.
* gcc.target/aarch64/sve/mixed_size_6.c: Scan for absence of
index with 2.
* gcc.target/aarch64/declare-simd-2.c: Scan for _ZGVnM4ul2v_f05
and_ZGVnN8ul2v_f05

* gcc.target/aarch64/sve/arith_1.c: Remove duplicate
scan-assembler patterns.
* gcc.target/aarch64/sve/cond_fmaxnm_1.c: Likewise.
* gcc.target/aarch64/sve/cond_fmaxnm_5.c: Likewise.
* gcc.target/aarch64/sve/cond_fminnm_1.c: Likewise.
* gcc.target/aarch64/sve/cond_fminnm_5.c: Likewise
* gcc.target/aarch64/sve/pcs/annotate_1.c: Likewise.
* gcc.target/aarch64/sve/uzp1_1.c: Likewise.
* gcc.target/aarch64/sve/uzp2_1.c: Likewise.

* gcc.target/aarch64/scalar_intrinsics.c: Scan for ursra.
* gcc.target/aarch64/singleton_intrinsics_1.c: Likewise.

* gcc.target/aarch64/sve/cond_fmaxnm_3.c: Fix register modifiers in
scan patterns.
* gcc.target/aarch64/sve/cond_fmaxnm_7.c: Likewise.
* gcc.target/aarch64/sve/cond_fminnm_3.c: Likewise.
* gcc.target/aarch64/sve/cond_fminnm_7.c: Likewise.
* gcc.target/aarch64/sve/cond_fmul_3.c: Likewise.
* gcc.target/aarch64/sve/cond_fsubr_3.c: Likewise.

* gcc.target/aarch64/ldp_stp_18.c: Fix typos in scan patterns.
* gcc.target/aarch64/sve/pcs/return_6.c: Likewise.

* gcc.target/aarch64/ror_2.c: Adjust constants to ensure
scan-assembler patterns are unique.
* gcc.target/aarch64/sve/struct_move_3.c: Likewise.
* gcc.target/aarch64/sve/struct_move_6.c: Likewise.

* gcc.target/aarch64/builtin_pld_pli.c: Use check-function-bodies
* gcc.target/aarch64/csinc-1.c: Likewise.
* gcc.target/aarch64/csneg-1.c: Likewise.
* gcc.target/aarch64/flt_mov_immediate_1.c: Likewise.
* gcc.target/aarch64/scalar_shift_1.c: Likewise.

2 months agolibstdc++: Add C++2020 Implementation status table.
Tomasz Kamiński [Wed, 1 Oct 2025 11:47:25 +0000 (13:47 +0200)] 
libstdc++: Add C++2020 Implementation status table.

This is derived from Table of Content of the ISO/IEC 14882:2020.
Section are included up to depth limit of 3 in majority of the cases.

libstdc++-v3/ChangeLog:

* doc/html/manual/index.html: Regenerated.
* doc/html/manual/status.html: Regenerated.
* doc/xml/manual/status_cxx2020.xml: Added status table.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2 months agoFortran: Error in nested PDTs with undefined KIND exprs. [122109]
Paul Thomas [Fri, 3 Oct 2025 06:29:50 +0000 (07:29 +0100)] 
Fortran: Error in nested PDTs with undefined KIND exprs. [122109]

2025-10-03  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/122089
* decl.cc (gfc_get_pdt_instance): If gfc_extract_int is true an
error has occurred because the kind expr was not provided. Use
the template in this case and return MATCH_YES.

gcc/testsuite/
PR fortran/122089
* gfortran.dg/pdt_52.f03: New test.
* gfortran.dg/pdt_53.f03: New test.
* gfortran.dg/pdt_54.f03: New test.

2 months agodiagnostics: generalize state graph code to use json::property instances
David Malcolm [Thu, 2 Oct 2025 22:19:13 +0000 (18:19 -0400)] 
diagnostics: generalize state graph code to use json::property instances

In r16-1631-g2334d30cd8feac I added support for capturing state
information from -fanalyzer in the form of embedded XML strings
in SARIF output.

In r16-2211-ga5d9debedd2f46 I rewrote this so the state was captured in
the form of a SARIF directed graph, using various custom types.

I want to add the ability to capture other kinds of graph in our SARIF
output (e.g. inheritance hierarchies, CFGs, etc), so  the following patch
reworks the state graph handling code to minimize the use of custom types.
Instead, the patch introduces various json::property types, and
describes the state graph serialization in terms of instances of these
properties, rather than hardcoding string attribute names in readers and
writers.  The custom SARIF properties live in a new
"gcc/custom-sarif-properties/" directory.

The "experimental-html" scheme keys "show-state-diagrams-dot-src" and
"show-state-diagrams-sarif" become "show-graph-dot-src" and
"show-graph-dot-src" in preparation for new kinds of graph in the output.

contrib/ChangeLog:
* gcc.doxy (INPUT): Add gcc/custom-sarif-properties

gcc/ChangeLog:
* Makefile.in (OBJS-libcommon): Add
custom-sarif-properties/digraphs.o and
custom-sarif-properties/state-graphs.o.  Remove
diagnostics/state-graphs.o.
* configure: Regenerate.
* configure.ac: Add custom-sarif-properties to subdir iteration.
* custom-sarif-properties/digraphs.cc: New file.
* custom-sarif-properties/digraphs.h: New file.
* custom-sarif-properties/state-graphs.cc: New file.
* custom-sarif-properties/state-graphs.h: New file.
* diagnostics/diagnostics-selftests.cc
(run_diagnostics_selftests): Drop call of state_graphs_cc_tests.
* diagnostics/diagnostics-selftests.h (state_graphs_cc_tests):
Delete decl.
* diagnostics/digraphs.cc: Include
"custom-sarif-properties/digraphs.h".  Move include of
"selftest.h" to within CHECKING_P section.
(using digraph_object): New.
(namespace properties): New.
(diagnostics::digraphs::object::get_attr): Delete.
(diagnostics::digraphs::object::set_attr): Delete.
(diagnostics::digraphs::object::set_json_attr): Delete.
(digraph_object::get_property): New definitions, for various
property types.
(digraph_object::set_property): Likewise.
(digraph_object::maybe_get_property): New.
(digraph_object::get_property_as_tristate): New.
(digraph_object::ensure_property_bag): New.
(digraph::get_graph_kind): New.
(digraph::set_graph_kind): New.
Add include of "custom-sarif-properties/state-graphs.h".
(selftest::test_simple_graph): Rewrite to use json::property
instances rather than string attribute names.
(selftest::test_property_objects): New test.
(selftest::digraphs_cc_tests): Call it.
* diagnostics/digraphs.h: Include "tristate.h".
(object::get_attr): Delete.
(object::set_attr): Delete.
(object::get_property): New decls.
(object::set_property): New decls.
(object::maybe_get_property): New.
(object::get_property_as_tristate): New.
(object::set_json_attr): Delete.
(object::ensure_property_bag): New.
(graph::get_graph_kind): New.
(graph::set_graph_kind): New.
* diagnostics/html-sink.cc
(html_generation_options::html_generation_options): Update for
field renamings.
(html_generation_options::dump): Likewise.
(html_builder::maybe_make_state_diagram): Likewise.
(html_builder::add_graph): Show SARIF and .dot src inline, if
requested.
* diagnostics/html-sink.h
(html_generation_options::m_show_state_diagrams_sarif): Rename
to...
(html_generation_options::m_show_graph_sarif): ...this.
(html_generation_options::m_show_state_diagrams_dot_src): Rename
to...
(html_generation_options::m_show_graph_dot_src0): ...this.
* diagnostics/output-spec.cc
(html_scheme_handler::maybe_handle_kv): Rename keys.
(html_scheme_handler::get_keys): Likewise.
* diagnostics/state-graphs-to-dot.cc: : Reimplement throughout to
use json::property instances found within custom_sarif_properties
throughout, rather than types in diagnostics::state_graphs.
* diagnostics/state-graphs.cc: Deleted file.
* diagnostics/state-graphs.h: Delete almost all, except decl of
diagnostics::state_graphs::make_dot_graph.
* doc/invoke.texi: Update for changes to "experimental-html" sink
keys.
* json.cc (json::object::set_string): New.
(json::object::set_integer): New.
(json::object::set_bool): New.
(json::object::set_array_of_string): New.
* json.h: Include "label-text.h".
(struct json::property): New template.
(json::string_property): New.
(json::integer_property): New.
(json::bool_property): New.
(json::json_property): New.
(using json::array_of_string_property): New.
(struct json::enum_traits): New.
(enum_json::property): New.
(json::value::dyn_cast_array): New vfunc.
(json::value::dyn_cast_integer_number): New vfunc.
(json::value::set_string): New.
(json::value::set_integer): New.
(json::value::set_bool): New.
(json::value::set_array_of_string): New.
(json::value::maybe_get_enum): New.
(json::value::set_enum): New.
(json::array::dyn_cast_array): New.
(json::integer_number::dyn_cast_integer_number): New.
(object::maybe_get_enum): New.
(object::set_enum): New.

gcc/analyzer/ChangeLog:
* ana-state-to-diagnostic-state.cc: Reimplement throughout to use
json::property instances found within custom_sarif_properties
throughout, rather than types in diagnostics::state_graphs.
* ana-state-to-diagnostic-state.h: Likewise.
* checker-event.cc: Likewise.
* sm-malloc.cc: Likewise.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/diagnostic_plugin_test_graphs.cc
(report_diag_with_graphs): Port from set_attr to set_property.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 months agoc: Add more C2y tests of initializer constraints
Joseph Myers [Thu, 2 Oct 2025 18:06:03 +0000 (18:06 +0000)] 
c: Add more C2y tests of initializer constraints

Add further tests of C2y requirements on initializers that became
constraints (so requiring diagnostics rather than violations being
undefined behavior) in N3346.

(Some of the tests for invalid string initializers might not cover all
theoretically possible cases, e.g. where char is 64-bit, but should
work on all currently supported targets.)

Tested for x86_64-pc-linux-gnu.

* gcc.dg/c2y-init-2.c, gcc.dg/c2y-init-3.c: New tests.

2 months ago[PATCH v2] RISC-V: fix __builtin_round NaN handling [PR target/121652]
Aurelien Jarno [Thu, 2 Oct 2025 15:05:34 +0000 (09:05 -0600)] 
[PATCH v2] RISC-V: fix __builtin_round NaN handling [PR target/121652]

__builtin_round() fails to correctly generate invalid exceptions for NaN
inputs when -ftrapping-math is used (which is the default). According to
the specification, an invalid exception should be raised for sNaN, but
not for qNaN.

Commit f12a27216952 ("RISC-V: fix __builtin_round clobbering FP...")
attempted to avoid raising an invalid exception for qNaN by saving and
restoring the FP exception flags. However this inadvertently suppressed
the invalid exception for sNaN as well.

Instead of saving/restoring fflags, this patch uses the same approach
than the well tested GLIBC round implementation. When flag_trapping_math
is enabled, it first checks whether the input is a NaN using feq.s/d. In
that case it adds the input value with itself to possibly convert sNaN
into qNaN. With this change, the glibc testsuite passes again.

The generated code with -ftrapping-math now looks like:

convert_float_to_float_round
  feq.s       a5,fa0,fa0
  beqz        a5,.L6
  auipc       a5,0x0
  flw         fa4,42(a5)
  fabs.s      fa5,fa0
  flt.s       a5,fa5,fa4
  beqz        a5,.L5
  fcvt.w.s    a5,fa0,rmm
  fcvt.s.w    fa5,a5
  fsgnj.s     fa0,fa5,fa0
  ret
.L6:
  fadd.s      fa0,fa0,fa0
.L5:
  ret

With -fno-trapping-math, the additional checks are omitted so the
resulting code is unchanged.

In addition this fixes the following failures:
FAIL: gcc.target/riscv/rvv/autovec/vls/math-nearbyint-1.c -O3 -ftree-vectorize -mrvv-vector-bits=scalable  scan-assembler-times frflags\\s+[atx][0-9]+ 32
FAIL: gcc.target/riscv/rvv/autovec/vls/math-nearbyint-1.c -O3 -ftree-vectorize -mrvv-vector-bits=scalable  scan-assembler-times fsflags\\s+[atx][0-9]+ 32

Fixes: f652a35877e3 ("This is almost exclusively Jivan's work....")
Fixes: f12a27216952 ("RISC-V: fix __builtin_round clobbering FP...")
PR target/121652

gcc/ChangeLog:

* config/riscv/riscv.md (round_pattern): special case NaN input
instead of saving/restoring fflags.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vls/math-nearbyint-1.c: Adjust
scan pattern for fewer instances of frflags/fsrflags.

2 months agodiagnostics::output_spec: support client-specific keys
David Malcolm [Thu, 2 Oct 2025 14:44:54 +0000 (10:44 -0400)] 
diagnostics::output_spec: support client-specific keys

This patch adds the ability for users of diagnostics::output_spec to
add custom key/values pairs to
  -fdiagnostics-{add,set}-output=SCHEME:KEY=VALUE

The intent is for allow e.g. capturing compiler-specific information in
SARIF sinks (CFGs, inheritance hierarchies, etc)

gcc/ChangeLog:
* diagnostics/output-spec.cc: (scheme_handler::parse_bool_value):
Convert to...
(key_handler::parse_bool_value): ...this.
(scheme_handler::parse_enum_value): Convert to...
(key_handler::parse_enum_value): ...this.
(struct text_scheme_handler::decoded_args): Eliminate, moving
fields into class text_scheme_handler.
(text_scheme_handler::text_scheme_handler): Initialize the new
fields.
Add a "dc" param and use it to initialize m_show_color.
(struct sarif_scheme_handler::decoded_args): Eliminate, moving
fields into class sarif_scheme_handler.
(sarif_scheme_handler::sarif_scheme_handler): Initialize the new
fields.
(struct html_scheme_handler::decoded_args): Eliminate, moving
fields into class html_scheme_handler.
(html_scheme_handler::html_scheme_handler): Initialize the new
fields.
(context::report_unknown_key): Get keys from scheme rather than
passing them in.  Support client keys.
(context::parse_and_make_sink): Pass dc to output_factory ctor.
(output_factory::output_factory): Pass dc to text_scheme_handler.
(output_factory::get_scheme_handler): Make return non-const.
(output_factory::make_sink): Move key-handling here, rather than
in individual sinks.
(context::handle_kv): New.
(text_scheme_handler::make_sink): Eliminate key decoding.
(text_scheme_handler::decode_kv): Convert to...
(text_scheme_handler::maybe_handle_kv): ...this...
(text_scheme_handler::get_keys): ...and this.
(sarif_scheme_handler::make_sink): Eliminate key decoding.
(sarif_scheme_handler::decode_kv): Convert to...
(sarif_scheme_handler::maybe_handle_kv): ...this...
(sarif_scheme_handler::get_keys): ...and this.
(html_scheme_handler::make_sink): Eliminate key decoding.
(html_scheme_handler::decode_kv): Convert to...
(html_scheme_handler::maybe_handle_kv): ...this...
(html_scheme_handler::get_keys): ...and this.
(struct selftest::parser_test): Add "client_keys" arg, and update
for new param ordering.
(selftest::parser_test::parse_and_make_sink): New.
(selftest::test_output_arg_parsing): Move auto-fixes to caller.
(class selftest::test_key_handler): New.
(selftest::test_client_arg_parsing): New test.
(selftest::output_spec_cc_tests): Call it.
* diagnostics/output-spec.h (class key_handler): New.
(class scheme_handler): Move here from output-spec.cc.
(context::report_unknown_key): Simplify params.
(context::handle_kv): Update params.
(context::context): Add "client_keys" param.
(context::m_client_keys): New field.
(struct dc_spec_context): Update order of params.  Add
"client_keys" param.
* libgdiagnostics.cc (spec_context::spec_context): Pass nullptr
for client keys.
* opts-diagnostic.cc (opt_spec_context::opt_spec_context):
Likewise.  Update for new param ordering.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 months agotestsuite: fix typo in comment in gcc.dg/plugin/start_unit_plugin.cc
David Malcolm [Thu, 2 Oct 2025 14:44:54 +0000 (10:44 -0400)] 
testsuite: fix typo in comment in gcc.dg/plugin/start_unit_plugin.cc

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/start_unit_plugin.cc: Fix typo in comment.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>