]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
13 hours 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>
13 hours 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>
13 hours 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>
14 hours 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.

15 hours 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.

15 hours 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.

15 hours 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.

31 hours 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.

31 hours 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>
31 hours 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>
32 hours 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.

33 hours 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.

33 hours 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.

33 hours 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.

33 hours 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.

38 hours 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.

39 hours 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.

40 hours 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.

40 hours 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.

43 hours 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 days 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 days 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 days 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 days 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 days 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 days 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 days 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 days 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 days 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 days 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 days 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 days 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 days 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 days 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 days 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 days 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.

3 days 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>
3 days 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.

3 days 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.

3 days 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>
3 days 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>
3 days agoDisallow mask reduction vectorization
Richard Biener [Thu, 2 Oct 2025 12:41:01 +0000 (14:41 +0200)] 
Disallow mask reduction vectorization

When you trick bool pattern recognition to use a mask type for a
reduction PHI you'll figure we're not ready to handle this because
epilogue creation isn't expecting this yet.  The following reverts
part of the last change and makes this explicit.

* tree-vect-loop.cc (vectorizable_reduction): Do not allow
mask reductions.

3 days agoPR modula2/122009: Rename local variables to avoid warnings and add const char
Gaius Mulley [Thu, 2 Oct 2025 13:36:42 +0000 (14:36 +0100)] 
PR modula2/122009: Rename local variables to avoid warnings and add const char

This patch renames local variables in M2WIDESET.mod to avoid compile time
warnings.  It also fixes the parameter declaration in BuildEnumerator to
include the const modifier.

gcc/m2/ChangeLog:

PR modula2/122009
* gm2-compiler/M2GCCDeclare.mod (PrintKnown): Remove.
* gm2-gcc/m2type.cc (m2type_BuildEnumerator): Add const modifier.
* gm2-gcc/m2type.def (BuildEnumerator): Use ConstCharStar type.
* gm2-gcc/m2type.h (m2type_BuildEnumerator): Add const modifier.
* gm2-libs/M2WIDESET.mod (ShiftLeftByteBit): Rename variable to
as toIdx.
Rename variable from as fromIdx.
(ShiftRightByteBit): Rename variable to as toIdx.
Rename variable from as fromIdx.
(RotateLeft): Rename variable to as toIdx.
Rename variable from as fromIdx.
(ArithShiftLeftBit): Rename set to setb.
(ArithShiftRightBit): Rename set to setb.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
3 days agoFix handling of uninitialized counts in merge_blocks
Jan Hubicka [Thu, 2 Oct 2025 13:25:08 +0000 (15:25 +0200)] 
Fix handling of uninitialized counts in merge_blocks

gcc/ChangeLog:

* cfghooks.cc (merge_blocks): Fix typo in the previous change.

Co-authored-by: H.J. Lu <hjl.tools@gmail.com>
3 days ago[RISC-V][PR target/122051] Fix pmode_reg_or_uimm5_operand for thead vector
Jeff Law [Thu, 2 Oct 2025 12:25:47 +0000 (06:25 -0600)] 
[RISC-V][PR target/122051] Fix pmode_reg_or_uimm5_operand for thead vector

For this bug we're failing during vsetvl insertion, but the real problem
happens earlier.

Basically the slide instructions are using pmode_reg_or_uimm5_operand which has
an implementation that was appropriate when we integrated RVV, but which is
bogus once thead vector was added.  It was just a thin wrapper around
vector_length_operand.

vector_length_operand rejects most constants when thead vector is enabled.  LRA
saw the rK constraint, so it figured the (const_int 1) was a sensible
substitution for the relevant operand.  It was only during vsetvl insertion
that we made another change to the insn and tried to recognize it and boom
things blew up.

This patch makes pmode_reg_or_uimm5_operand independent of
vector_length_operand and everything is happy again.

Tested on riscv32-elf (verifying the selector properly skips the test) and
riscv64-elf where the ICE could be seen.  Bootstrap on the Pioneer and BPI just
started a short while ago, so no data for another 7/24 hours respectively, but
not expecting issues.

PR target/122051
gcc/
* config/riscv/predicates.md (pmode_reg_or_uimm5_operand): Implement
directly rather than using vector_length_operand.

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

3 days agoc: fmv: Prevent FMV being combined with other cloning/renaming extensions.
Alfie Richards [Tue, 30 Sep 2025 12:25:25 +0000 (12:25 +0000)] 
c: fmv: Prevent FMV being combined with other cloning/renaming extensions.

This patch adds exclusions and diagnostics to prevent function multi-versioning
being used with omp simd pragmas and renaming extensions.

This behaviour is forbidden by the ACLE as the expected behaviour is not clear.

gcc/c-family/ChangeLog:

* c-attribs.cc (attr_target_clones_exclusions): Add simd and omp
exclusions.
(attr_target_version_exclusions): New definition with simd and omp
exclusions.
(attr_omp_declare_simd_exclusions): New definition with target_version
and clones exclusions.
(attr_simd_exclusions): Ditto.
(c_common_gnu_attributes): Add new target_version, simd, and omp
declare simd variables.

gcc/c/ChangeLog:

* c-decl.cc (maybe_mark_function_versioned): Add diagnostic.
* c-parser.cc (c_finish_omp_declare_simd): Add diagnostic.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/mv-error11.c: New test.
* gcc.target/aarch64/mv-error12.c: New test.

3 days agoc: aarch64: Add FMV diagnostic tests.
Alfie Richards [Wed, 2 Apr 2025 14:24:00 +0000 (14:24 +0000)] 
c: aarch64: Add FMV diagnostic tests.

Adds c fmv diagnostic tests for aarch64.

This mostly tests c front end code, but has to be target specific as FMV
requires specifying target extensions.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/mv-and-mvc-error1.c: New test.
* gcc.target/aarch64/mv-and-mvc-error2.c: New test.
* gcc.target/aarch64/mv-and-mvc-error3.c: New test.
* gcc.target/aarch64/mv-error1.c: New test.
* gcc.target/aarch64/mv-error2.c: New test.
* gcc.target/aarch64/mv-error3.c: New test.
* gcc.target/aarch64/mv-error4.c: New test.
* gcc.target/aarch64/mv-error5.c: New test.
* gcc.target/aarch64/mv-error6.c: New test.
* gcc.target/aarch64/mv-error7.c: New test.
* gcc.target/aarch64/mv-error8.c: New test.
* gcc.target/aarch64/mv-error9.c: New test.
* gcc.target/aarch64/mv-error10.c: New test.
* gcc.target/aarch64/mvc-error1.c: New test.
* gcc.target/aarch64/mvc-error2.c: New test.
* gcc.target/aarch64/mvc-warning1.c: New test.

3 days agoc: Add target_version attribute support.
Alfie Richards [Wed, 2 Apr 2025 13:37:02 +0000 (13:37 +0000)] 
c: Add target_version attribute support.

This commit introduces support for the target_version attribute in the c
frontend, following the behavior defined in the Arm C Language Extension.

Key changes include:

- During pushdecl, the compiler now checks whether the current symbol is
  part of a multiversioned set.
  - New versions are added to the function multiversioning (FMV) set, and the
    symbol binding is updated to include the default version (if present).
    This means the binding for a multiversioned symbol will always reference
    the default version (if present), as it defines the scope and signature
    for the entire set.
  - Pre-existing versions are merged with their previous version (or diagnosed).
- Lookup logic is adjusted to prevent resolving non-default versions.
- start_decl and start_function are updated to handle marking and mangling of
  versioned functions.
- c_parse_final_cleanups now includes a call to process_same_body_aliases.
  This has no functional impact other than setting cpp_implicit_aliases_done
  on all nodes, which is necessary for certain shared FMV logic.

gcc/c/ChangeLog:

* c-decl.cc (maybe_mark_function_versioned): New function.
(merge_decls): Preserve DECL_FUNCTION_VERSIONED in merging.
(duplicate_decls): Add check and diagnostic for unmergable version decls.
(pushdecl): Add FMV target_version logic.
(lookup_name): Don't resolve non-default versions.
(start_decl): Mark and mangle versioned functions.
(start_function): Mark and mangle versioned functions.
(c_parse_final_cleanups): Add call to process_same_body_aliases.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/mv-1.c: New test.
* gcc.target/aarch64/mv-and-mvc1.c: New test.
* gcc.target/aarch64/mv-and-mvc2.c: New test.
* gcc.target/aarch64/mv-and-mvc3.c: New test.
* gcc.target/aarch64/mv-and-mvc4.c: New test.
* gcc.target/aarch64/mv-symbols1.c: New test.
* gcc.target/aarch64/mv-symbols10.c: New test.
* gcc.target/aarch64/mv-symbols11.c: New test.
* gcc.target/aarch64/mv-symbols12.c: New test.
* gcc.target/aarch64/mv-symbols13.c: New test.
* gcc.target/aarch64/mv-symbols14.c: New test.
* gcc.target/aarch64/mv-symbols2.c: New test.
* gcc.target/aarch64/mv-symbols3.c: New test.
* gcc.target/aarch64/mv-symbols4.c: New test.
* gcc.target/aarch64/mv-symbols5.c: New test.
* gcc.target/aarch64/mv-symbols6.c: New test.
* gcc.target/aarch64/mv-symbols7.c: New test.
* gcc.target/aarch64/mv-symbols8.c: New test.
* gcc.target/aarch64/mv-symbols9.c: New test.
* gcc.target/aarch64/mvc-symbols1.c: New test.
* gcc.target/aarch64/mvc-symbols2.c: New test.
* gcc.target/aarch64/mvc-symbols3.c: New test.
* gcc.target/aarch64/mvc-symbols4.c: New test.

3 days agoRegenerate aclocal.m4/configure/Makefile.in
H.J. Lu [Thu, 2 Oct 2025 07:36:51 +0000 (15:36 +0800)] 
Regenerate aclocal.m4/configure/Makefile.in

Regenerate aclocal.m4/configure/Makefile.in for

commit 6051a849aa1e8ed444ee71161d90fd800469121d
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Oct 2 08:08:09 2025 +0800

    Sync toplevel files from binutils-gdb

gcc/

* aclocal.m4: Regenerated.
* configure: Likewise.

libcc1/

* Makefile.in: Regenerated.
* aclocal.m4: Likewise.
* configure: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
3 days agotree-optimization/122079 - PRE antic compute doesn't converge
Richard Biener [Wed, 1 Oct 2025 12:55:17 +0000 (14:55 +0200)] 
tree-optimization/122079 - PRE antic compute doesn't converge

The following re-instantiates the pruning of the ANTIC_IN value set
by the previous iterations one by reverting part of
r16-3945-gc30f58c3f7ec25.  The earlier fixes made sure the initial
value set is appropriately big to not cause this to lose optimizations.
But it seems to be still required for correctness given iteration
order means we combine ANTIC_IN sets from different generations which
can be prone to oscillations in CFG cycles.

PR tree-optimization/122079
* tree-ssa-pre.cc (compute_antic_aux): Re-instantiate
ANTIC_IN value pruning by the old solution.

* gcc.dg/torture/pr122079-2.c: New testcase.
* gcc.dg/torture/pr122079-3.c: Likewise.

3 days agotree-optimization/122079 - PRE antic_compute doesn't converge
Richard Biener [Wed, 1 Oct 2025 12:16:50 +0000 (14:16 +0200)] 
tree-optimization/122079 - PRE antic_compute doesn't converge

The following fixes another case of us pruning from the value set
based on the expression set after expression removal when the
maximum expression set is involved.

PR tree-optimization/122079
* tree-ssa-pre.cc (prune_clobbered_mems): Do not prune
values when the maximum expression set is involved.

* gcc.dg/torture/pr122079-1.c: New testcase.

3 days agoSync toplevel files from binutils-gdb
H.J. Lu [Thu, 2 Oct 2025 00:08:09 +0000 (08:08 +0800)] 
Sync toplevel files from binutils-gdb

commit aef88b83384976e96a8fb287a001588a2277ecd5
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Oct 2 08:53:45 2025 +0800

    binutils/GCC: Quote ${COMPILER_FOR_TARGET}

    Replace

    if test x${COMPILER_FOR_TARGET} = x"\$(CC)"; then

    with

    if test x"${COMPILER_FOR_TARGET}" = x"\$(CC)"; then

    since COMPILER_FOR_TARGET may contain spaces when configuring GCC.

commit 76a693c087c30e8108852928c717399011c6166d
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Sep 30 11:23:58 2025 +0800

    binutils: Use AC_TRY_COMPILE to check target clang/gcc

    Use AC_TRY_COMPILE to check for the working target clang and gcc when
    configuring for cross tools.

commit 77c74294bfc5005204a2de3cc64bbdb2f877be29
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Sep 26 08:03:01 2025 +0800

    binutils: Pass target plugin file to target ar/nm/ranlib

    There are 2 kinds of binutils tests:

    1. Tests of binutils object files and libraries using the build tools,
    like CC, AR, NM and RANLIB.
    2. Tests of binutils programs as the target tools, like CC_FOR_TARGET,
    AR_FOR_TARGET, NM_FOR_TARGET and RANLIB_FOR_TARGET.

    Set AR_PLUGIN_OPTION_FOR_TARGET, NM_PLUGIN_OPTION_FOR_TARGET and
    RANLIB_PLUGIN_OPTION_FOR_TARGET to the target compiler plugin file for
    target ar/nm/ranlib.

commit 10deea6e2fc1b9ec5818b5fa1bc510c63ff5b2e2
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Sep 23 04:24:00 2025 +0800

    Binutils/GCC: Add clang LTO support to AR, NM and RANLIB

    Add CLANG_PLUGIN_FILE to find the clang plugin file and pass it to
    --plugin for ar, nm and ranlib so that binutils can be built with
    clang LTO.  Run CLANG_PLUGIN_FILE before GCC_PLUGIN_OPTION since
    GCC_PLUGIN_OPTION may return the wrong PLUGIN_OPTION with clang.

commit 1fcb94ed750db2ac30d0f0ecc04fa0c7833dd10f
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date:   Thu Sep 18 16:17:14 2025 +0200

    Remove remnants of Solaris/PowerPC support

    When removing Solaris/PowerPC support, I missed a couple of references.
    This patch removes them.

    Tested with crosses to ppc-unknown-linux-gnu and powerpc-ibm-aix7.

ChangeLog:

* Makefile.in: Regenerated.
* configure: Likewise.
* Makefile.tpl: Synced from binutils-gdb.
* configure.ac: Likewise.
* libtool.m4: Likewise.

config/ChangeLog:

* clang-plugin.m4: Synced from binutils-gdb.
* gcc-plugin.m4: Likewise.

libbacktrace/ChangeLog:

* Makefile.in: Regenerated.
* aclocal.m4: Likewise.
* configure: Likewise.

libiberty/ChangeLog:

* aclocal.m4: Regenerated.
* configure: Likewise.
* configure.ac: Synced from binutils-gdb.

zlib/ChangeLog:

* Makefile.in: Regenerated.
* aclocal.m4: Likewise.
* configure: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
3 days agoSync toplevel files from binutils-gdb
H.J. Lu [Wed, 1 Oct 2025 22:13:41 +0000 (06:13 +0800)] 
Sync toplevel files from binutils-gdb

commit 28ea7ae220a0343ff7fe531ec761bd77d00dcb1c
Author: Matthieu Longo <matthieu.longo@arm.com>
Date:   Tue May 28 10:49:45 2024 +0100

    autoupdate: replace old version of AC_INIT by the new one

    - old AC_INIT by AC_INIT + AC_CONFIG_SRC_DIR
      https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.72/autoconf.html#index-AC_005fINIT-3

commit 29496481662736f0a24bfc1daf31dbfc9d2bb7ee
Author: Matthieu Longo <matthieu.longo@arm.com>
Date:   Tue May 28 10:49:43 2024 +0100

    autoupdate: replace obsolete macros AC_CANONICAL_SYSTEM

    - AC_CANONICAL_SYSTEM by:
        * AC_CANONICAL_HOST where host, and host_alias are needed
        * AC_CANONICAL_TARGET where target_alias is needed
      https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.72/autoconf.html#index-AC_005fCANONICAL_005fTARGET-1

commit d9639e091c77689b10363ecb197466deaa161ade
Author: Maciej W. Rozycki <macro@redhat.com>
Date:   Mon Apr 28 18:53:30 2025 +0100

    Fix 64-bit BFD detection causing build failures

    We have a discrepancy with 64-bit BFD handling across our component
    subdirectories leading to link failures such as:

    ld: ../opcodes/.libs/libopcodes.a(disassemble.o): in function `disassembler': disassemble.c:(.text+0x65): undefined reference to `print_insn_alpha'
    ld: disassemble.c:(.text+0x105): undefined reference to `print_insn_ia64'
    ld: disassemble.c:(.text+0x11d): undefined reference to `print_insn_loongarch'
    ld: disassemble.c:(.text+0x1a1): undefined reference to `print_insn_big_mips'
    [...]

    with some configurations having a 32-bit host and 64-bit BFD, such as:
    `--host=i386-linux-gnu --target=riscv64-linux-gnu --enable-targets=all'.
    This is ultimately due to how 64-bit BFD is enabled for bfd/ itself and
    other subdirectorses and has been a regression from commit 1d5269c994bf
    ("unify 64-bit bfd checks").

    For bfd/ the BFD_64_BIT autoconf macro from config/bfd64.m4 is used
    combined with this logic in bfd/configure.ac:

    case ${host64}-${target64}-${want64} in
      *true*)
        wordsize=64
        bfd64_libs='$(BFD64_LIBS)'
        all_backends='$(BFD64_BACKENDS) $(BFD32_BACKENDS)'
        [...]
        ;;
      false-false-false)
        wordsize=32
        all_backends='$(BFD32_BACKENDS)'
        ;;
    esac

    where the value of ${wordsize} switches between 32-bit and 64-bit BFD
    via these pieces:

    #define BFD_ARCH_SIZE @wordsize@

    and:

    #if BFD_ARCH_SIZE >= 64
    #define BFD64
    #endif

    in bfd/bfd-in.h, which ultimately becomes a part of "bfd.h".

    Then ${host64} is determined in bfd/configure.ac from the host's word
    size, via the host's pointer size:

    if test "x${ac_cv_sizeof_void_p}" = "x8"; then
      host64=true
    fi

    And ${target64} is determined in bfd/configure.ac from the target's word
    size:

        if test ${target_size} = 64; then
            target64=true
        fi

    Where multiple targets have been requested with `--enable-targets=all'
    the presence of any 64-bit target will set "true" here.

    Finally ${want64} is set according to `--enable-64-bit-bfd' user option
    with an arrangement involving BFD_64_BIT:

    BFD_64_BIT
    if test $enable_64_bit_bfd = yes ; then
      want64=true
    else
      want64=false
    fi

    which also, redundantly, checks and sets its result upon the host's word
    size.  Lastly ${want64} is also selectively set by target fragments in
    bfd/config.bfd, which mostly if not completely overlaps with ${target64}
    setting as described above.

    Conversely other subdirectories only rely on BFD_64_BIT, so they fail to
    notice that BFD is 64-bit and do not enable their 64-bit handling where
    the host requested is 32-bit and 64-bit BFD has been enabled other than
    with `--enable-64-bit-bfd'.  One consequence is opcodes/disassemble.c
    enables calls to its numerous own 64-bit backends by checking the BFD64
    macro from "bfd.h", however does not actually enable said backends in
    its Makefile.  Hence the link errors quoted above.

    Address the problem then by moving the `--enable-64-bit-bfd' option back
    to bfd/configure.ac and remove the call to BFD_64_BIT from there and
    then rewrite the macro in terms of checking for the presence of BFD64
    macro in "bfd.h", which is the canonical way of determining whether BFD
    is 64-bit or not.

    Rather than running `grep' directly on ../bfd/bfd-in3.h as the opcodes/
    fragment used to before the problematic commit:

        if grep '#define BFD_ARCH_SIZE 64' ../bfd/bfd-in3.h > /dev/null; then

    run the preprocessor on "bfd.h", which allows to invoke the macro from
    configure.ac files placed in subdirectories located at deeper levels, by
    relying on the preprocessor's search path.

    This requires however that the invokers rely on `all-bfd' rather than
    `configure-bfd' for their `configure' invocation stage, because "bfd.h"
    is made by `make all' rather than `configure' in bfd/.

    Do not cache the result of this check however, as reconfiguring a tree
    such as to flip `--enable-64-bit-bfd' on or to change a secondary target
    may affect BFD64 and we have no access to information about secondary
    targets in BFD_64_BIT.

    Also remove the ENABLE_BFD_64_BIT automake conditional, as it's not used
    anywhere.

    Last but not least remove the hack from gdb/configure.ac to fail builds
    for `mips*-*-*' hosts where `--enable-targets=all' has been requested,
    but `--enable-64-bit-bfd' has not as it's no longer needed.  Such builds
    complete successfully now, having enabled 64-bit BFD implicitly.

Tested-By: Guinevere Larsen <guinevere@redhat.com>
Tested-By: Luis Machado <luis.machado@arm.com>
Approved-By: Alan Modra <amodra@gmail.com>
Approved-By: Luis Machado <luis.machado@arm.com>
* Makefile.def: Synced from binutils-gdb.
* Makefile.in: Regenerated.

commit 319719bb2921e978738acd408e6b16dabf0e7f5e
Author: Tom Tromey <tom@tromey.com>
Date:   Thu Mar 21 17:12:23 2024 -0600

    Revert "Pass GUILE down to subdirectories"

    This reverts commit b7e5a29602143b53267efcd9c8d5ecc78cd5a62f.

    This patch caused problems for some users when building gdb, because
    it would cause 'guild' to be invoked with the wrong versin of guile.
    On the whole it seems simpler to just back this out.

    I'm checking this in to the binutils-gdb repository in the interest of
    fixing the build for Andrew.  No one has responded to the identical
    patch sent to gcc-patches, but I will ping it there.

commit da48217f315084097ef25226c0acab3bbd55ebd3
Author: Simon Marchi <simon.marchi@efficios.com>
Date:   Thu Mar 14 13:39:18 2024 -0400

    gdbserver/linux: probe for libiconv in configure

    Make gdbserver's build system locate libiconv when building for Linux.

    Commit 07b3255c3bae ("Filter invalid encodings from Linux thread names")
    make libiconv madantory for building gdbserver on Linux.

    While trying to cross-compile gdb for xtensa-fsf-linux-uclibc (with a
    toolchain generated with crosstool-ng), I got:

        /home/smarchi/src/binutils-gdb/gdbserver/linux-low.cc:48:10: fatal error: iconv.h: No such file or directory
           48 | #include <iconv.h>
              |          ^~~~~~~~~

    I downloaded GNU libiconv, built it for that host, and installed it in
    an arbitrary directory.  I had to modify the gdbserver build system to
    locate libiconv and use it, the result is this patch.

    I eventually found that crosstool-ng has a config option to make uclibc
    provide an implementation of iconv, which is of course much easier.  But
    given that this patch is now written, I think it would be worth merging
    it, it could help some people who do not have iconv built-in their libc
    in the future (and may not have the luxury of rebuilding their libc like
    I do).

    Using AM_ICONV in configure.ac adds these options for configure (the
    same we have for gdb):

        --with-libiconv-prefix[=DIR]  search for libiconv in DIR/include and DIR/lib
        --without-libiconv-prefix     don't search for libiconv in includedir and libdir
        --with-libiconv-type=TYPE     type of library to search for (auto/static/shared)

    It sets the `LIBICONV` variable with whatever is needed to link with
    libiconv, and adds the necessary `-I` flag to `CPPFLAGS`.

    To avoid unnecessarily linking against libiconv on hosts that don't need
    it, set `MAYBE_LIBICONV` with the contents of `LIBICONV` only if the
    host is Linux, and use `MAYBE_LIBICONV` in `Makefile.in`.

    Since libiconv is a hard requirement for Linux hosts, error out if it is
    not found.

    The bits in acinclude.m4 are similar to what we have in
    gdb/acinclude.m4.

    Update the top-level build system to support building against an in-tree
    libiconv (I did not test this part though).  Something tells me that the
    all-gdbserver dependency on all-libiconv is unnecessary, since there is
    already a dependency of configure-gdbserver on all-libiconv (and
    all-gdbserver surely depends on configure-gdbserver).  I just copied
    what's done for GDB though.

* Makefile.def: Synced from binutils-gdb.
* Makefile.tpl: Likewise.
* configure.ac: Likewise.
* Makefile.in: Regenerated.
* configure: Likewise.

config/

* acx.m4: Synced from binutils-gdb.
* lthostflags.m4: Likewise.

libbacktrace/

* configure.ac: Synced from binutils-gdb.
* configure: Regenerated.

zlib/
* configure.ac: Synced from binutils-gdb.
* configure: Regenerated.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
4 days agoDaily bump.
GCC Administrator [Thu, 2 Oct 2025 00:19:36 +0000 (00:19 +0000)] 
Daily bump.

4 days agoPR modula2/122009: ldtoa_ldtoa correct parameter type from int to bool
Gaius Mulley [Wed, 1 Oct 2025 22:04:56 +0000 (23:04 +0100)] 
PR modula2/122009: ldtoa_ldtoa correct parameter type from int to bool

This is an obvious fix which corrects a parameter type so that it matches
the prototype.

gcc/m2/ChangeLog:

PR modula2/122009
* pge-boot/Gldtoa.cc (ldtoa_ldtoa): Change int to bool for
parameter sign.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
4 days agoc++, contracts: Abstract interfaces to constexpr [NFC].
Iain Sandoe [Wed, 17 Sep 2025 15:28:41 +0000 (16:28 +0100)] 
c++, contracts: Abstract interfaces to constexpr [NFC].

We want to move to having different representations of the contract
semantic for C++26, since that wants values outside the range that
can be accommodated using the cxx2a mechanisms.  First part, abstract
the interfaces to constexpr, so that they do not see the underlying
source of data.

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_constant_expression): Use revised
interfaces to determine if contracts are ignored and, if not,
whether they are evaluated.
* contracts.h (contract_ignored_p, contract_evaluated_p): New.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
4 days ago[RISC-V][PR target/122106] Add missing predicate on crc expanders
Jeff Law [Wed, 1 Oct 2025 21:12:49 +0000 (15:12 -0600)] 
[RISC-V][PR target/122106] Add missing predicate on crc expanders

This is a minor bug in the CRC code for RISC-V.

Essentially in the expander we have an operand without a predicate.  So it
matches anything.  But that operand really has to be a CONST_INT.  So this
patch adds the missing predicate.  I noticed we had constraints on our
define_expand.  It doesn't hurt anything, but they're never used and can easily
get out of date, so this removes the unnecessary constraints.

Tested on riscv32-elf and riscv64-elf.  Bootstrap & regression test on the
Pioneer is in flight and should finish in the next few hours.

Pushing to the trunk once CI confirms it's OK.

PR target/122106
gcc/
* config/riscv/bitmanip.md (crc expanders): Add predicate for
polynomial argument.  Drop unnecessary constraints.

gcc/testsuite/

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

4 days agolibstdc++: Avoid _GLIBCXX20_CONSTEXPR in C++ >= 20 code sections
François Dumont [Wed, 1 Oct 2025 05:09:36 +0000 (07:09 +0200)] 
libstdc++: Avoid _GLIBCXX20_CONSTEXPR in C++ >= 20 code sections

libstdc++-v3/ChangeLog:

* include/std/vector (std::erase_if, std::erase): Replace _GLIBCXX20_CONSTEXPR
with 'constexpr' and remove implied 'inline' keyword.
* include/std/string (std::erase_if, std::erase): Likewise.

4 days agoFortran: UBSAN uninitialized stride for missing optional argument [PR122080]
Harald Anlauf [Tue, 30 Sep 2025 19:14:12 +0000 (21:14 +0200)] 
Fortran: UBSAN uninitialized stride for missing optional argument [PR122080]

PR fortran/122080

gcc/fortran/ChangeLog:

* trans-array.cc (gfc_conv_array_parameter): Wrap the derivation of
bounds and strides for the descriptor of an optional dummy array
argument by a test on argument presence when it is supposed to be
passed to an optional argument.

gcc/testsuite/ChangeLog:

* gfortran.dg/ubsan/missing_optional_dummy_9.f90: New test.

4 days agom68k: fix adddi3/subdi3 with POST_INC/PRE_DEC destination
Andreas Schwab [Mon, 29 Sep 2025 16:46:45 +0000 (18:46 +0200)] 
m68k: fix adddi3/subdi3 with POST_INC/PRE_DEC destination

This part has never been exercised until r15-1579-g792f97b44ffc5e.

PR target/122066
* config/m68k/m68k.md (adddi3, subdi3): Strip POST_INC and PRE_DEC
when generating high part of the destination operand.

* gcc.c-torture/compile/pr122066.c: New test.

4 days agoImprove dumps of afdo_calculate_branch_prob
Jan Hubicka [Wed, 1 Oct 2025 16:14:48 +0000 (18:14 +0200)] 
Improve dumps of afdo_calculate_branch_prob

gcc/ChangeLog:

* auto-profile.cc (afdo_calculate_branch_prob): Improve dump file.

4 days agoAdd --parm auto-profile-bbs
Jan Hubicka [Wed, 1 Oct 2025 15:58:00 +0000 (17:58 +0200)] 
Add --parm auto-profile-bbs

This patch adds a parameter that controls whether BB profile is read from auto-profile
or we just scale guessed profile according to known counts.  This is mostly useful as
a first aid when auto-profile goes wrong.  Once we fix enough bugs I think it may be
removed but so far it is quite useful, so I decided to push it.

gcc/ChangeLog:

* auto-profile.cc (determine_scale): Break out from ...
(afdo_adjust_guessed_profile): ... here.
(scale_bb_profile): New function.
(afdo_annotate_cfg): Use it.
* params.opt (auto-profile-bbs): New parmaeter.
* doc/invoke.texi (auto-profile-bbs): Document.

4 days agoFix handling of goto locuses and phi args in auto-profile
Jan Hubicka [Wed, 1 Oct 2025 15:18:44 +0000 (17:18 +0200)] 
Fix handling of goto locuses and phi args in auto-profile

afdo_set_bb_count had code that, only if no count was determined in the BB itself,
looked into its outgoing edges and tried to determine counts based on location of
phi args.  This is not quite correct, since value detemrined is the count of edge
which may be lower than count of BB.

This patchs moves the logic into afdo_unscaled_edge_count and extends it to
also use goto_locus.  BB profile is infered only if BB has single successor and
otherwise the edge counts are stored into correct location in
afdo_calculate_branch_prob.

gcc/ChangeLog:

* auto-profile.cc (afdo_unscaled_edge_count): New function based on
part of ...
(afdo_set_bb_count): ... this function; use it here.
(afdo_calculate_branch_prob): Try to determine edge counts using
phi args and goto locuses.

4 days agomake autprofiledbootstrap with LTO meaningful
Jan Hubicka [Wed, 1 Oct 2025 15:06:41 +0000 (17:06 +0200)] 
make autprofiledbootstrap with LTO meaningful

currently autoprofiled bootstrap produces auto-profiles for cc1 and cc1plus
binaries.  Those are used to build respective frontend files.  For backend
cc1plus.fda is used.   This does not work well with LTO bootstrap where cc1plus
backend is untrained since it is used only for parsing and ealry opts. As a
result all binaries gets most of the backend optimized for size rather then
speed.

This patch adds lto1.fda and then combines all of cc1, cc1plus and lto1 into
all.fda that is used compiling common modules.  This is more or less equivalent
to what -fprofile-use effectively uses modulo that with -fprofile-use we know
number of runs of evety object file and scale accordingly at LTO time.

gcc/ChangeLog:

* Makefile.in (ALL_FDAS): New variable.
(ALL_HOST_BACKEND_OBJ): Use all.fda instead of cc1plus.fda
(all.fda): New target

gcc/c/ChangeLog:

* Make-lang.in: Add c_FDAS
(create_fdas_for_cc1): Be sure that build fails if create_gcov fails.

gcc/cp/ChangeLog:

* Make-lang.in: Add c++_FDAS
(create_fdas_for_cc1plus): Be sure that build fails if create_gcov fails.

gcc/lto/ChangeLog:

* Make-lang.in: Add lto_FDAS; enable FDA collection
(create_fdas_for_lto1): Be sure that build fails if create_gcov fails.

4 days agoImprove profile update in merge_blocks
Jan Hubicka [Wed, 1 Oct 2025 14:56:15 +0000 (16:56 +0200)] 
Improve profile update in merge_blocks

When merging blocks we currently alway use count of the first basic block.
In some cases we merge block containing call to cold noreturn function (thus
having count 0 (reliable)) with earlier block with weaker form of profile.
In this case we can still preserve reliable count of 0.

The patch also makes block merging to pick higher of the counts if quality
is the same.  This should reduce chances of losing track of hot code in broken
profiles.

gcc/ChangeLog:

* cfghooks.cc (merge_blocks): Choose more reliable or higher BB
count.

4 days agoPropagate unlikely executed BBs even on measured profiles
Jan Hubicka [Wed, 1 Oct 2025 14:51:26 +0000 (16:51 +0200)] 
Propagate unlikely executed BBs even on measured profiles

While looking into AutoFDO porfiles I noticed that sometimes we lost
precise zero counts due to inlining and merging basic blocks.  Propagating
precise zero counts should be safe even for measured profiles and thus
this patch enables it.

gcc/ChangeLog:

* predict.cc (unlikely_executed_stmt_p): Remove redundant check.
(rebuild_frequencies): Also recompute unlikely bbs when profile is
present or consistent.

4 days agotoplevel: unify the GCC and GDB/binutils .editorconfig files
Richard Earnshaw [Tue, 23 Sep 2025 16:36:20 +0000 (17:36 +0100)] 
toplevel: unify the GCC and GDB/binutils .editorconfig files

Both GCC and GDB/binutils now have root editorconfig files.  It would
make sense to unify them as this sets the general tone for these
projects.

ChangeLog:
* .editorconfig: Unify the GCC and GDB/binutils root config.

4 days agolibstdc++: Fix sizeof(wide-string)-1 bug in std::regex test
Jonathan Wakely [Wed, 1 Oct 2025 12:11:38 +0000 (13:11 +0100)] 
libstdc++: Fix sizeof(wide-string)-1 bug in std::regex test

This uses sizeof on a wide string to get the length, which is wrong
because each wchar_t is more than one byte. This was presumably copied
from a narrow char test.

libstdc++-v3/ChangeLog:

* testsuite/28_regex/basic_regex/assign/wchar_t/pstring.cc: Use
wcslen(cs) instead of sizeof(cs)-1.

Reviewed-by: Tomasz KamiƄski <tkaminsk@redhat.com>
4 days agoFix off by one in range_from_loop_direction.
Andrew MacLeod [Tue, 30 Sep 2025 19:59:38 +0000 (15:59 -0400)] 
Fix off by one in range_from_loop_direction.

When bounds_of_var_in_loop was converted to range_from_loop_direction,
the final check returned FALSE when the beginning and end bounds were
the same...  The new code was using wi::gt_p, when it should have been
wi::ge_p when checking for the fail condition.

PR tree-optimization/120560
gcc/
* vr-values.cc (range_from_loop_direction): Use wi::ge_p rather
than wi::gt_p.

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

4 days agolibstdc++: Fix -Wmismatched-delete bug in std::unique_ptr test
Jonathan Wakely [Tue, 30 Sep 2025 11:10:15 +0000 (12:10 +0100)] 
libstdc++: Fix -Wmismatched-delete bug in std::unique_ptr test

libstdc++-v3/ChangeLog:

* testsuite/20_util/unique_ptr/modifiers/93562.cc: Define a
separate deleter for array cases.

Reviewed-by: Tomasz KamiƄski <tkaminsk@redhat.com>
4 days agolibstdc++: Fix incorrect overriders in filebuf tests
Jonathan Wakely [Tue, 30 Sep 2025 16:13:03 +0000 (17:13 +0100)] 
libstdc++: Fix incorrect overriders in filebuf tests

These test facets were failing to override the members in the
std::codecvt base class.

libstdc++-v3/ChangeLog:

* testsuite/27_io/basic_filebuf/seekoff/wchar_t/9875_seekoff.cc
(Cvt::do_length): Fix signature to override virtual function in
base.
* testsuite/27_io/basic_filebuf/seekpos/wchar_t/9875_seekpos.cc:
(Cvt::do_length): Likewise.
* testsuite/27_io/basic_filebuf/underflow/char/1.cc
(NoconvCvt::do_in): Likewise.
* testsuite/27_io/basic_filebuf/underflow/wchar_t/11603.cc
(checksumcvt::do_length): Likewise.

Reviewed-by: Tomasz KamiƄski <tkaminsk@redhat.com>
4 days agolibstdc++: Add missing parentheses to tests with wrong precedence
Jonathan Wakely [Tue, 30 Sep 2025 16:10:42 +0000 (17:10 +0100)] 
libstdc++: Add missing parentheses to tests with wrong precedence

These tests are currently evaluated as (err == failbit)|eofbit which is
not what we want. It should be err == (failbit|eofbit).

libstdc++-v3/ChangeLog:

* testsuite/22_locale/time_get/get/char/3.cc: Add parentheses to
x == y|z expression.
* testsuite/22_locale/time_get/get/wchar_t/3.cc: Likewise.
* testsuite/28_regex/algorithms/regex_match/multiline.cc:
Likewise.

Reviewed-by: Tomasz KamiƄski <tkaminsk@redhat.com>
4 days agolibstdc++: Suppress -Wclass-memaccess warnings in bits/stl_uninitialized.h
Jonathan Wakely [Tue, 30 Sep 2025 09:49:08 +0000 (10:49 +0100)] 
libstdc++: Suppress -Wclass-memaccess warnings in bits/stl_uninitialized.h

Running the testsuite with warnings enabled gives:

FAIL: 20_util/specialized_algorithms/uninitialized_copy/58982.cc  -std=gnu++26 (test for excess errors)
Excess errors:
.../libstdc++-v3/include/bits/stl_uninitialized.h:293: warning: 'void* __builtin_memcpy(void*, const void*, long unsigned int)' writing to an object of type 'struct T' with no trivial copy-assignment; use copy-initialization instead [-Wclass-memaccess]

This is because -Wclass-memaccess warns about using memcpy on types
which have a deleted assignment, even though those can be trivially
copyable and so using memcpy on them is technically valid. Where these
warnings occur in bits/stl_uninitialized.h we're only using memcpy after
checking for trivially copyable (and any other relevant conditions) so
we can be confident that we're using it safely. We also don't actually
care about assignment here because we're only constructing new objects,
not copying over existing ones (which is what std::copy does, but not
std::uninitialized_copy).

Uses of memcpy in the C++98 code don't need to have -Wclass-memaccess
suppressed, because there are no deleted functions in C++98 so there are
no types which are trivially copyable but trigger the warning.

libstdc++-v3/ChangeLog:

* include/bits/stl_uninitialized.h (uninitialized_copy)
(uninitialized_fill, uninitialized_fill_n): Use pragmas to
suppress -Wclass-memaccess warnings.

Reviewed-by: Tomasz KamiƄski <tkaminsk@redhat.com>
4 days agotree-optimization/122110 - do not reject all bit-precision reductions
Richard Biener [Wed, 1 Oct 2025 09:26:45 +0000 (11:26 +0200)] 
tree-optimization/122110 - do not reject all bit-precision reductions

We can handle bitwise-operation reductions and reductions on mask
vectors just fine.

PR tree-optimization/122110
* tree-vect-loop.cc (vectorizable_reduction): Relax restriction
to mode-precision operations.

4 days agoc: Regenerate c.opt.urls
Alejandro Colomar [Sat, 27 Sep 2025 08:20:44 +0000 (10:20 +0200)] 
c: Regenerate c.opt.urls

This was regenerated with (slightly simplified):

$ make bootstrap && make html && cd gcc && make regenerate-opt-urls;

Fixes: 33c35b7f4c18 (2025-09-26; "c, objc: Add -Wmultiple-parameter-fwd-decl-lists")
gcc/c-family/ChangeLog:

* c.opt.urls: Regenerate

Signed-off-by: Alejandro Colomar <alx@kernel.org>
4 days agolibstdc++: Fix spelling of "Polymorphic" in a test
Jonathan Wakely [Wed, 1 Oct 2025 10:58:38 +0000 (11:58 +0100)] 
libstdc++: Fix spelling of "Polymorphic" in a test

libstdc++-v3/ChangeLog:

* testsuite/std/memory/polymorphic/copy.cc: Fix spelling of
typedef.

4 days agoFortran: Generic interface checking with use associated PDTs [PR122089]
Paul Thomas [Wed, 1 Oct 2025 07:14:00 +0000 (08:14 +0100)] 
Fortran: Generic interface checking with use associated PDTs [PR122089]

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

gcc/fortran
PR fortran/122089
* decl.cc (gfc_get_pdt_instance): If the pdt_template is use
associated, 'module' field should be copied to this instance.

gcc/testsuite/
PR fortran/122089
* gfortran.dg/pdt_51.f03: New test.

5 days agoDaily bump.
GCC Administrator [Wed, 1 Oct 2025 00:20:51 +0000 (00:20 +0000)] 
Daily bump.

5 days agotestsuite: remove redundant import in sarif.py
David Malcolm [Tue, 30 Sep 2025 21:23:32 +0000 (17:23 -0400)] 
testsuite: remove redundant import in sarif.py

I believe I stopped using this in r16-2211-ga5d9debedd2f46.

gcc/testsuite/ChangeLog:
* lib/sarif.py: Remove import of ET.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
5 days agodiagnostics::output_spec: fix "color" in "text" output scheme
David Malcolm [Tue, 30 Sep 2025 21:23:32 +0000 (17:23 -0400)] 
diagnostics::output_spec: fix "color" in "text" output scheme

The previous refactoring highlighted that we were ignoring the "color"
key within the "text" output scheme for diagnostics.

Fixed thusly.

gcc/ChangeLog:
* diagnostics/output-spec.cc (text_scheme_handler::make_sink): Use
the value of the "color" to determine if the sink's printer is
colorized.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
5 days agodiagnostics::output_spec: refactor per-sink key-value handling
David Malcolm [Tue, 30 Sep 2025 21:23:31 +0000 (17:23 -0400)] 
diagnostics::output_spec: refactor per-sink key-value handling

No functional change intended.

gcc/ChangeLog:
* diagnostics/output-spec.cc: Add comments.  Introduce a
"struct decoded_args" within each scheme_handler subclass,
and split out per-scheme key-value parsing from each make_sink
implementation into new per-scheme decode_kv member functions.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
5 days agodiagnostics::output_spec: move class scheme_handler
David Malcolm [Tue, 30 Sep 2025 21:23:31 +0000 (17:23 -0400)] 
diagnostics::output_spec: move class scheme_handler

Simplification; no functional change intended.

gcc/ChangeLog:
* diagnostics/output-spec.cc: Move class scheme_handler out from
inside class output_factory.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
5 days agodiagnostics: simplifying output-spec.cc
David Malcolm [Tue, 30 Sep 2025 21:23:31 +0000 (17:23 -0400)] 
diagnostics: simplifying output-spec.cc

No functional change intended.

gcc/ChangeLog:
* diagnostics/output-spec.cc: Rename "parsed_arg" to
"scheme_and_kvs" throughout.  Rename "unparsed_arg" to
"unparsed_spec" throughout, and make a member of
output_spec::context rather than passing it around.
* diagnostics/output-spec.h: Likewise.
* libgdiagnostics.cc: Likewise.
* opts-diagnostic.cc: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
5 days agoc: Fix regression related to DECL_NONLOCAL on aarch64 [PR121933]
Martin Uecker [Sat, 13 Sep 2025 06:37:32 +0000 (08:37 +0200)] 
c: Fix regression related to DECL_NONLOCAL on aarch64 [PR121933]

The recent patch r16-3747-gafa74d37e81 to detect the use of non-local
context by nested functions caused regressions on aarch64, because
DECL_NONLOCAL was set on labels.  Fix this by setting it only to
the same types of decls as before.

PR target/121933

gcc/c/ChangeLog:
* c-typeck.cc (mark_decl_used): Set DECL_NONLOCAL
only for VAR_DECL, FUNC_DECL, PARM_DECL.

5 days agolibstdc++: std::inplace_vector implementation cleaup
François Dumont [Mon, 22 Sep 2025 16:54:46 +0000 (18:54 +0200)] 
libstdc++: std::inplace_vector implementation cleaup

Remove duplicated std::swap implementation.

libstdc++-v3/ChangeLog

* include/std/inplace_vector:
(std::swap(inplace_vector<>&, inplace_vector<>&)): Remove the duplicated
implementation at std namespace level. Keep the friend inline one.
(inplace_vector<Tp, 0>::assign(initializer_list<>)): Add missing return
statement.

5 days agofmv: Redirect to specific target
Alfie Richards [Mon, 14 Apr 2025 14:11:29 +0000 (14:11 +0000)] 
fmv: Redirect to specific target

Adds an optimisation in FMV to redirect to a specific target if possible.

A call is redirected to a specific target if both:
- the caller can always call the callee version
- and, it is possible to rule out all higher priority versions of the callee
  fmv set. That is estabilished either by the callee being the highest priority
  version, or each higher priority version of the callee implying that, were it
  resolved, a higher priority version of the caller would have been selected.

For this logic, introduces the new TARGET_OPTION_FUNCTIONS_B_RESOLVABLE_FROM_A
hook. Adds a full implementation for Aarch64, and a weaker default version
for other targets.

This allows the target to replace the previous optimisation as the new one is
able to cover the same case where two function sets implement the same versions.

gcc/ChangeLog:

* config/aarch64/aarch64.cc (aarch64_functions_b_resolvable_from_a): New
function.
(TARGET_OPTION_FUNCTIONS_B_RESOLVABLE_FROM_A): New define.
* doc/tm.texi: Regenerate.
* doc/tm.texi.in: Add documentation for
TARGET_OPTION_FUNCTIONS_B_RESOLVABLE_FROM_A.
* multiple_target.cc (redirect_to_specific_clone): Add new optimisation
logic.
(ipa_target_clone): Remove check for TARGET_HAS_FMV_TARGET_ATTRIBUTE.
* target.def: Document new hook..
* attribs.cc: (functions_b_resolvable_from_a) New function.
* attribs.h: (functions_b_resolvable_from_a) New function.

gcc/testsuite/ChangeLog:

* g++.target/aarch64/fmv-selection1.C: New test.
* g++.target/aarch64/fmv-selection2.C: New test.
* g++.target/aarch64/fmv-selection3.C: New test.
* g++.target/aarch64/fmv-selection4.C: New test.
* g++.target/aarch64/fmv-selection5.C: New test.
* g++.target/aarch64/fmv-selection6.C: New test.
* g++.target/aarch64/fmv-selection7.C: New test.

5 days agoFix various comment typos
Jakub Jelinek [Tue, 30 Sep 2025 14:11:56 +0000 (16:11 +0200)] 
Fix various comment typos

The following patch fixes various comment typos.

2025-09-30  Jakub Jelinek  <jakub@redhat.com>

gcc/
* auto-profile.h (maybe_hot_afdo_count_p): Fix comment typos,
possiby -> possibly and ture -> true.
* gimplify.cc (build_asan_poison_call_expr): Change "of a for"
to "memory of the" in a comment.
* ipa-devirt.cc (add_type_duplicate): Fix comment typo,
mangles -> mangled.
* auto-profile.cc: Fix comment typo, -fauto-profile-inlinig
-> -fauto-profile-inlining.
(maybe_hot_afdo_count_p): Fix comment typos, possiby -> possibly
and ture -> true.
(function_instance::removed_icall_target): Fix comment typo,
Reutrn -> Return.
(function_instance::in_worklist_): Fix comment typo, Ture -> True.
(function_instance::offline): Fix comment typo, tolevel -> toplevel.
(function_instance::match): Fix comment typo, craeate_gcov ->
create_gcov.
(autofdo_source_profile::offline_external_functions): Fix comment
typos, tolevel -> toplevel and porfile -> profile.
(autofdo_source_profile::get_function_instance_by_inline_stack): Fix
comment typo, chekcing -> checking.
(struct scale): Fix comment typo, scalle -> scale.
* gimple.h (currently_expanding_gimple_stmt): Fix comment typo,
comminucating -> communicating.
* tree.h (canonical_type_used_p): Fix comment typo, ture -> true.
* tree-ssa-alias.cc (types_equal_for_same_type_for_tbaa_p): Likewise.
* ipa-profile.cc (contains_hot_call_p): Likewise.
* cfgexpand.cc (add_scope_conflicts_2): Fix comment typos,
Querry -> Query, referendd -> referenced and Querrying -> Querying.
* ipa-param-manipulation.cc (currently_expanding_gimple_stmt): Fix
comment typo, comminucating -> communicating.
* ipa-prop.cc (ipa_cst_ref_desc::refcount): Fix comment typo,
if -> is.
* tree-if-conv.cc (version_loop_for_if_conversion): Fix comment typos,
porfile -> profile and confistency -> consistency.
* fold-const.cc: Change size_int_wide in comment to size_int as
size_int_wide doesn't exit for 21 years.
gcc/testsuite/
* gcc.dg/vect/tsvc/vect-tsvc-s1244.c (s1244): Fix comment typo,
ture -> true.
* gcc.dg/vect/tsvc/vect-tsvc-s2244.c (s2244): Likewise.

5 days agoFix discriminators of gimple PHI arguments
Jan Hubicka [Tue, 30 Sep 2025 12:51:39 +0000 (14:51 +0200)] 
Fix discriminators of gimple PHI arguments

while gimple PHI itself does not have locations, the arguments does and they
can be used to determine count of edges in CFG.  Assign_discriminators already
knows how to handle goto_locus and PHI args should be handled same way as
done by this patch.

Bootstrapped/regtested x86_64-linux, comitted.

gcc/ChangeLog:

* auto-profile.cc (function_instance::match): Sanity check
that gimple PHI has no location.
* tree-cfg.cc (assign_discriminators): Also remap locations
of gimple PHI arguments.

5 days agoFix overflow in ipa_profile_generate_summary
Jan Hubicka [Tue, 30 Sep 2025 11:07:53 +0000 (13:07 +0200)] 
Fix overflow in ipa_profile_generate_summary

With profile count scaling we now get overflow in ipa_profile_generate_summary
which uses old macro GCOV_COMPUTE_SCALE that is not ready for very large
counts.  This patch replaces remaining two uses of it by (somewhat elaborate)
profile-count based equivalent which is overflow safe.

gcc/ChangeLog:

* basic-block.h (GCOV_COMPUTE_SCALE): Remove.
* ipa-profile.cc (ipa_profile_generate_summary): Use
profile-count scaling.
* sched-rgn.cc (compute_trg_info): Likewise.

5 days agoRestrict what kind of statements are used for auto-profile
Jan Hubicka [Mon, 29 Sep 2025 22:22:48 +0000 (00:22 +0200)] 
Restrict what kind of statements are used for auto-profile

When building profile of walk_tree_1 during autoprofiledbootstrap we produce
non-zero counts to call of tree_check_failed because location of INLINE_ENTRY
debug statement is misplaced.  Auto-profile already knows it should skip
clobbers since their locations will never go into debug info.  This patch extend
it to all kind of debug statement except for DEBUG_BEGIN_STMT, nops, labels
and predict.

autoprofilebootstrapped/regtested x86_64-linux.

gcc/ChangeLog:

* auto-profile.cc (stmt_loc_used_by_debug_info): New function.
(autofdo_source_profile::get_count_info): Use it.
(afdo_set_bb_count): Likewise.
(afdo_vpt_for_early_inline): Likewise.

5 days agoAda: Fix internal error on ill-formed Reduce attribute in Ada 2022
Eric Botcazou [Tue, 30 Sep 2025 09:55:18 +0000 (11:55 +0200)] 
Ada: Fix internal error on ill-formed Reduce attribute in Ada 2022

This is an internal error on the new Reduce attribute of Ada 2022 when the
programmer swaps its arguments(!)  The change makes it so that the compiler
gives an error message instead.

gcc/ada/
PR ada/117517
* sem_attr.adb (Resolve_Attribute) <Attribute_Reduce>: Try to
resolve the reducer first.  Fix casing of error message.

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

5 days agolibgcc, bitint: do not use softfp_wrap for bitint and add build option
Andre Vieira [Tue, 30 Sep 2025 09:57:58 +0000 (10:57 +0100)] 
libgcc, bitint: do not use softfp_wrap for bitint and add build option

This patch circumvents the softfp_wrap for bitint functions in libgcc as certain
ports, like arm, can use softfp_wrap to distinquigh between targets they want to
use specialized assembly functions for and targets that they use the soft-fp
C implementations for.  This is an orthogonal choice to the use of the soft-fp
C implementations for bitint conversions.

This patch also adds extra options to build bitint soft-fp functions, this is
needed by the arm port to build HF bitint conversion functions.

libgcc/ChangeLog:

* config/t-softfp: Don't use softfp_wrap for bitint functions.
(softfp_cflags): New parameter that is passed to the building of bitint
functions.

5 days agobitint: fix inconsistency in bitint_precision_kind
Andre Vieira [Tue, 30 Sep 2025 09:57:46 +0000 (10:57 +0100)] 
bitint: fix inconsistency in bitint_precision_kind

This patch fixes an issue where the first call to bitint_precision_kind would
return the bitint kind, which was also inconsistent with subsequent calls with
the same bitint size.

gcc/ChangeLog:

* gimple-lower-bitint.cc (bitint_precision_kind): Fix inconsistency in
results between first and consecutive calls to this function.

5 days agoFortran: ICE in derived type with a PDT component [PR102241,PR105380]
Paul Thomas [Tue, 30 Sep 2025 08:24:11 +0000 (09:24 +0100)] 
Fortran: ICE in derived type with a PDT component [PR102241,PR105380]

2025-09-30  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/102241
* gfortran.h: Add symbol attribute 'pdt_comp'.
* module.cc : Add 'pdt_comp' to 'ab_attribute' and 'attr_bits'.
(mio_symbol_attribute): Set 'pdt_comp'.
* resolve.cc (resolve_component): If a PDT component is found
in a non-PDT type, generate the PDT instance, if necessary, and
set the 'pdt_comp' attribute. Fix some whitespace issues.
* trans-decl.cc (gfc_get_symbol_decl, gfc_trans_deferred_vars):
If 'pdt_comp' set, initialize the PDT components.
* trans-stmt.cc (gfc_trans_deallocate): Verify that a typespec
parameter list is available for PDT components of ordinary
derived types.

gcc/testsuite/
PR fortran/105380
* gfortran.dg/pdt_49.f03: New test.

PR fortran/102241
* gfortran.dg/pdt_11.f03: Deallocate 'o_fdef'.
* gfortran.dg/pdt_15.f03: Reinstate final 'pop_8' and update
the tree dump counts.
* gfortran.dg/pdt_20.f03: Deallocate 'x'.
* gfortran.dg/pdt_23.f03: Deallocate 'x'.
* gfortran.dg/pdt_3.f03: Eliminate the temporary 'matrix' and
use w%d directly in the allocation. Change the TODO comment and
comment on memory leak in allocation.
* gfortran.dg/pdt_39.f03: Comments on memory leaks.
* gfortran.dg/pdt_40.f03: Deallocate 'foo' and bar%x.
* gfortran.dg/pdt_50.f03: New test.

6 days agoDaily bump.
GCC Administrator [Tue, 30 Sep 2025 00:21:09 +0000 (00:21 +0000)] 
Daily bump.

6 days agoada: Remove references to ASIS, explain PolyORB status.
Tonu Naks [Thu, 18 Sep 2025 09:24:47 +0000 (09:24 +0000)] 
ada: Remove references to ASIS, explain PolyORB status.

gcc/ada/ChangeLog:

* doc/gnat_rm/implementation_advice.rst: PolyORB
* doc/gnat_rm/implementation_defined_characteristics.rst: PolyORB
* doc/gnat_rm/implementation_defined_pragmas.rst: ASIS
* doc/gnat_rm/obsolescent_features.rst: PolyORB
* doc/gnat_rm/specialized_needs_annexes.rst: PolyORB
* doc/gnat_rm/the_gnat_library.rst: PolyORB
* doc/gnat_ugn/building_executable_programs_with_gnat.rst: ASIS
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.

6 days agoada: Improve error for pre/post on generic formal subprogram in Ada 2012 mode
Piotr Trojanek [Thu, 24 Jul 2025 08:20:40 +0000 (10:20 +0200)] 
ada: Improve error for pre/post on generic formal subprogram in Ada 2012 mode

Instead of saying that pragma placement is illegal, we now say that it
would be legal in Ada 2022.

gcc/ada/ChangeLog:

* sem_prag.adb (Analyze_Pre_Post_Condition): Handle contracts on
generic formal subprograms like on declarations of access-to-subprogram
types.

6 days agoada: Add special-case for 'Constrained on stand-alone objects in SPARK
Piotr Trojanek [Tue, 15 Jul 2025 13:18:26 +0000 (15:18 +0200)] 
ada: Add special-case for 'Constrained on stand-alone objects in SPARK

GNAT relies on standalone objects of indefinite, non-class-wide types getting a
constrained itypes; GNATprove relies on the same objects keeping their nominal,
unconstrained types. None of that can be simply changed, so instead we carry
this different handling to routine which provides the value of attribute
Constrained.

gcc/ada/ChangeLog:

* exp_util.adb (Attribute_Constrained_Static_Value): Special case
stand-alone objects for GNATprove.

6 days agoada: Fix error message about limited extensions
Ronan Desplanques [Tue, 16 Sep 2025 08:12:29 +0000 (10:12 +0200)] 
ada: Fix error message about limited extensions

Consider the following package:

    package P is
       type T1 is tagged limited null record;

       type T2 is new T1 with private;
    private

       type T2 is limited new T1 with null record;
    end P;

It should be rejected because of ARM 7.3 (10.1/3). Before this patch,
GNAT did reject it, with the following error message:

    full view of non-limited extension cannot be limited

This message is not right because the partial view of T2 here *is*
limited even if it doesn't have an explicit limited keyword in its
declaration. This patch changes the error message to something that's a
better match for ARM 7.3 (10.1/3).

This patch also tweaks another related error message and substitutes
a mention of ARM 7.3 (10.1/3) for the Ada Issue it originated from in a
comment.

gcc/ada/ChangeLog:

* sem_ch3.adb (Process_Full_View): Fix error message.

6 days agoada: Unsigned_Base_Range aspect (part 4)
Javier Miranda [Tue, 16 Sep 2025 10:50:45 +0000 (10:50 +0000)] 
ada: Unsigned_Base_Range aspect (part 4)

Disable this feature; more work needed.

gcc/ada/ChangeLog:

* aspects.adb (Get_Aspect_Id): Return No_Aspect for Unsigned_Base_Range
name.
* sem_prag.adb (Analyze_Pragma): Disable pragma Unsigned_Base_Range.
* par-ch4.adb (Scan_Apostrophe): Disable attribute Unsigned_Base_Range.
* doc/gnat_rm/gnat_language_extensions.rst: Remove documentation
of aspect unsigned base range.
* gnat_rm.texi: Regenerate.