]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
58 min agoa68: Minor typo fix in doc master trunk
Marc Poulhiès [Fri, 30 Jan 2026 11:52:16 +0000 (12:52 +0100)] 
a68: Minor typo fix in doc

gcc/algol68/ChangeLog:
* ga68-coding-guidelines.texi: Typo fix.

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
66 min agoAdd missing PR reference
Eric Botcazou [Fri, 30 Jan 2026 11:43:53 +0000 (12:43 +0100)] 
Add missing PR reference

108 min agoAda: Fix spurious visibility error from limited_with clause in hierarchy
Eric Botcazou [Fri, 30 Jan 2026 10:58:58 +0000 (11:58 +0100)] 
Ada: Fix spurious visibility error from limited_with clause in hierarchy

The problem is that the compiler installs the limited view of a package that
is already installed by the virtue of being an ancestor of the main unit.

gcc/ada/
PR ada/123867
* sem_ch10.adb (Analyze_Compilation_Unit): Output info message
when -gnatdi is specified.
(Install_Parents): Likewise.  Set the Is_Visible_Lib_Unit flag
on the unit.
(Install_Private_With_Clauses): Do not output info message here.
(Remove_Parents): Output info message when -gnatdi is specified
and clear the Is_Visible_Lib_Unit flag on the unit.

gcc/testsuite/
* gnat.dg/specs/limited_with3.ads: New test.
* gnat.dg/specs/limited_with3-child.ads: New helper.
* gnat.dg/specs/limited_with3-child-grandchild.ads: Likewise.
* gnat.dg/specs/limited_with3-child-grandchild-grandgrandchild.ads:
Likewise.

112 min agodebug/110885 - fix split-dwarf / debug-types interaction
Richard Biener [Fri, 30 Jan 2026 08:55:38 +0000 (09:55 +0100)] 
debug/110885 - fix split-dwarf / debug-types interaction

The following fixes a link failure due to missing skeleton
ancestors.

PR debug/110885
* dwarf2out.cc (generate_skeleton_bottom_up): Generate the
skeleton ancestor tree when moving a new child to the parent
even for template instantiations.

* g++.dg/debug/dwarf2/pr110885.C: New testcase.

2 hours agolibatomic: Don't install libatomic_asneeded.{so,a} if corresponding libatomic.{so...
Jakub Jelinek [Fri, 30 Jan 2026 10:43:49 +0000 (11:43 +0100)] 
libatomic: Don't install libatomic_asneeded.{so,a} if corresponding libatomic.{so,a} wasn't installed

Filip complained on IRC that libatomic_asneeded.a is installed as
stale symlink in --disable-static build.

The following patch makes sure to install the libatomic_asneeded.{so,a}
script and/or symlink only if the corresponding libatomic.{so,a} has been
installed.

2026-01-30  Jakub Jelinek  <jakub@redhat.com>

* Makefile.am (all-local, install-asneeded): Only create
libatomic_asneeded.so script if libatomic.so exist, only
create libatomic_asneeded.a symlink if libatomic.a exist.
* Makefile.in: Regenerate.

2 hours agomatch.pd: Fix up __imag__ .MUL_OVERFLOW simplification [PR123864]
Jakub Jelinek [Fri, 30 Jan 2026 10:42:41 +0000 (11:42 +0100)] 
match.pd: Fix up __imag__ .MUL_OVERFLOW simplification [PR123864]

The integer_minus_onep case is really meant for multiplication by
-1, not by (unsigned char)0xff or (unsigned short)0xffff or 0xffffffffU etc.
We've already tested that the first operand is signed (otherwise the
earlier case is used) and also that int_fits_type_p (@1, TREE_TYPE (@0)),
but if @0 is signed and @1 is unsigned all ones with smaller precision
than that, it fits into @0's type, integer_minus_onep will be true
and it still should be handled through the ranges, not as @0 == min.

2026-01-30  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/123864
* match.pd (__builtin_mul_overflow_p (x, cst, (stype) 0) ->
x > stype_max / cst || x < stype_min / cst): Only check
integer_minus_onep for signed types.

* gcc.c-torture/execute/pr123864.c: New test.
* gcc.dg/torture/pr123864.c: New test.

2 hours agofold-const: Fix implicit cast to nullptr_t typedef [PR123790]
Jakub Jelinek [Fri, 30 Jan 2026 10:40:17 +0000 (11:40 +0100)] 
fold-const: Fix implicit cast to nullptr_t typedef [PR123790]

The following testcase is incorrectly rejected, because since r15-6744
it adds build_nop to preserve the exact typedef type and
cxx_eval_constant_expression can't fold NOP_EXPR from integer_zerop of one
NULLPTR_TYPE to another NULLPTR_TYPE, while cxx_eval_constant_expression
relies on fold to do such folding.

I see 3 options to fix that, one is deal with this in the r15-6744 spot
and special case NULLPTR_TYPE there and build_zero_cst instead of build_nop
(with similar condition like in the patch below), another possibility is
special case this in cxx_eval_constant_expression, and
another one (done in this patch) is to handle this in fold-const.cc -
fold_convert_loc and also in fold_convert_const.

2026-01-30  Jakub Jelinek  <jakub@redhat.com>

PR c++/123790
* fold-const.cc (fold_convert_const): Handle conversion of
integer_zerop to NULLPTR_TYPE.
(fold_convert_loc): Likewise.

* g++.dg/cpp0x/nullptr47.C: New test.

2 hours agod: Merge upstream dmd, druntime 1017635a96, phobos 5a142da0a
Iain Buclaw [Fri, 30 Jan 2026 09:25:49 +0000 (10:25 +0100)] 
d: Merge upstream dmd, druntime 1017635a96, phobos 5a142da0a

D front-end changes:

- Import dmd v2.112.0-beta.1.

D runtime changes:

- Import druntime v2.112.0-beta.1.
- Added 64-bit `mul' and `udivmod' overloads to `core.int128'.

Phobos changes:

- Added `lazyCache' to `std.algorithm.iteration'.
- Added `writeText', `writeWText', and `writeDText' to
  `std.conv'.

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd 1017635a96.
* dmd/VERSION: Bump version to v2.112.0-beta.1.
* decl.cc (DeclVisitor::finish_vtable): Update for new front-end
interface.
(DeclVisitor::visit): Likewise.
* typeinfo.cc (TypeInfoVisitor::visit): Likewise.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime 1017635a96.
* libdruntime/Makefile.am (DRUNTIME_DSOURCES_LINUX): Add
core/sys/linux/sys/syscall.d, core/sys/linux/syscall.d.
* libdruntime/Makefile.in: Regenerate.
* src/MERGE: Merge upstream phobos 5a142da0a.
* src/Makefile.am (PHOBOS_DSOURCES): Remove
std/internal/windows/bcrypt.d.
* src/Makefile.in: Regenerate.

gcc/testsuite/ChangeLog:

* gdc.dg/asm1.d: Adjust test.

2 hours agoPermit const counters in flush_on_edges [PR123855]
Jørgen Kvalsvik [Wed, 28 Jan 2026 19:33:21 +0000 (20:33 +0100)] 
Permit const counters in flush_on_edges [PR123855]

Relax the (accidental) requirement and permit that function-local
counters don't have SSA names.  We really only look up the def
statement to check if it is a phi node, in which case we need to
resolve the counter from there.  This obviously doesn't apply when it
is a constant.

PR gcov-profile/123855

gcc/ChangeLog:

* path-coverage.cc (flush_on_edges): Only look up SSA name def
stmt when counter is non-const.

gcc/testsuite/ChangeLog:

* gcc.misc-tests/gcov-pr123855.c: New test.

2 hours agogcov-dump: Print PATHS tag
Jørgen Kvalsvik [Mon, 3 Nov 2025 23:05:04 +0000 (00:05 +0100)] 
gcov-dump: Print PATHS tag

Print the record associated with the PATHS tag.  While it just prints
the number of prime paths for the function, this is more useful than
the UNKNOWN it would otherwise print.

Before:
...
demo.gcno:    01450000:  31:LINES
demo.gcno:                  block 6:`demo.c':13
demo.gcno:    01490000:   4:UNKNOWN

After:
...
demo.gcno:    01450000:  31:LINES
demo.gcno:                  block 6:`demo.c':13
demo.gcno:    01490000:   4:PATHS 5 paths

gcc/ChangeLog:

* gcov-dump.cc (tag_paths): New function.

2 hours agogcc: -f*-coverage implies -ftest-coverage
Jørgen Kvalsvik [Mon, 3 Nov 2025 22:48:25 +0000 (23:48 +0100)] 
gcc: -f*-coverage implies -ftest-coverage

The --coverage flag is a useful alias for -fprofile-arcs
-ftest-coverage where the latter makes gcc output the .gcno file.
While it makes sense to use -fprofile-arcs without a .gcno file (pgo,
maybe more), it never really makes sense to request -fpath-coverage or
-fcondition-coverage without also wanting the .gcno to interpret the
results.

gcc/ChangeLog:

* common.opt: ftest-coverage enabled by fpath-coverage or
fcondition-coverage

gcc/testsuite/ChangeLog:

* g++.dg/gcov/gcov-18.C: Remove --coverage.
* g++.dg/gcov/gcov-22.C: Likewise.
* gcc.misc-tests/gcov-19.c: Remove -ftest-coverage.
* gcc.misc-tests/gcov-29.c: Likewise.

2 hours agogcov-dump: Print start-position for conditions
Jørgen Kvalsvik [Tue, 14 Oct 2025 08:52:54 +0000 (10:52 +0200)] 
gcov-dump: Print start-position for conditions

The printed position should be the start of the record, as is the case
with lines.

Before:
ex.gcno:  795:    01470000:  16:CONDITIONS 2 conditions
ex.gcno:  811:                  block 2: 1
ex.gcno:  819:                  block 5: 1
ex.gcno:  819:    01000000:  50:FUNCTION ... `main' ...

After:
ex.gcno:  795:    01470000:  16:CONDITIONS 2 conditions
ex.gcno:  803:                  block 2: 1
ex.gcno:  811:                  block 5: 1
ex.gcno:  819:    01000000:  50:FUNCTION ... `main' ...

gcc/ChangeLog:

* gcov-dump.cc (tag_conditions):  Read position before blocks,
terms.

2 hours agoUpdate expected number of prime paths in test case
Jørgen Kvalsvik [Wed, 5 Nov 2025 19:48:29 +0000 (20:48 +0100)] 
Update expected number of prime paths in test case

This test has been failing since this commit which introduces an extra
block in the loop, increasing the number of prime paths:

FAIL: gcc.misc-tests/gcov-29.c line 826: expected 0/5 covered paths, was 0/6

commit 385d9937f0e23cbf9c62f0b2553a33ff70e56ecf
Author: Jan Hubicka <hubicka@ucw.cz>
Date:   Fri Jul 11 13:01:13 2025 +0200
    Rewrite assign_discriminators

I have looked at the CFGs of this function before and after Jan's
patch and both cases are fine, this test breaking is not a real
regression.

gcc/testsuite/ChangeLog:

* gcc.misc-tests/gcov-29.c: Expect 6 prime paths in test.
* gcc.misc-tests/gcov-30.c: Likewise.

2 hours agogcov: Only consider pure locations in line mapping
Jørgen Kvalsvik [Wed, 5 Nov 2025 19:15:50 +0000 (20:15 +0100)] 
gcov: Only consider pure locations in line mapping

Fixes a regression introduced I bisected to this commit:

commit 385d9937f0e23cbf9c62f0b2553a33ff70e56ecf
Author: Jan Hubicka <hubicka@ucw.cz>
Date:   Fri Jul 11 13:01:13 2025 +0200
    Rewrite assign_discriminators

That patch adds discriminators to edge->goto_locus which will map to
the right source location, but breaks the equality comparison used in
the hash set.

Fixes these tests:

gcc/testsuite/gcc.misc-tests/gcov-pr83813.c
gcc/testsuite/gcc.misc-tests/gcov-pr84758.c
gcc/testsuite/gcc.misc-tests/gcov-pr85332.c
gcc/testsuite/gcc.misc-tests/gcov-pr85372.c

PR gcov-profile/121084
PR gcov-profile/121123
PR gcov-profile/121409

gcc/ChangeLog:

* profile.cc (branch_prob): Record seen_locations without
discriminators.

2 hours agoopenmp: Handle asm goto in diagnose_sb_2 [PR123876]
Jakub Jelinek [Fri, 30 Jan 2026 10:00:41 +0000 (11:00 +0100)] 
openmp: Handle asm goto in diagnose_sb_2 [PR123876]

We weren't handling asm goto in diagnose_sb_2, so could ICE
on invalid code instead of diagnosing it as invalid.

Note, for C++ the FE already diagnoses that instead of deferring
it will omp-low.cc.

2026-01-30  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/123876
* omp-low.cc (diagnose_sb_2): Handle GIMPLE_ASM.

* gcc.dg/gomp/pr123876.c: New test.

2 hours agolibcpp: Fix up comment handling in -fdirectives-only preprocessing [PR123273]
Jakub Jelinek [Fri, 30 Jan 2026 09:56:10 +0000 (10:56 +0100)] 
libcpp: Fix up comment handling in -fdirectives-only preprocessing [PR123273]

Back in 2020 Nathan rewrote the -E -fdirectives-only preprocessing.
In PR103130 a year and half later I've fixed the handling of comments
so that /* \*/ is considered as full comment even when * is escaped,
to match the normal preprocessing.
The following testcases shows further bugs in the comment handling.
One is that /* *\/ should not be considered as full comment (i.e.
when the / after * is escaped).  And another one is that the code
was treating any number of backslashes as escape, which is wrong,
only a single backslash is an escape, two backslashes preprocess as
one backslash, three as one backslash and one escape, etc.
So, while /* *\
/ is a full comment, /* *\\
/ or /* *\\\\\\\\\\\\\
/ is not.

2026-01-30  Jakub Jelinek  <jakub@redhat.com>

PR preprocessor/123273
* lex.cc (cpp_directive_only_process): Only go to done_comment
for '/' if star is true and esc is false.  When seeing '\\' with
esc set to true, clear esc as well as star instead of keeping esc
set.

* c-c++-common/cpp/dir-only-10.c: New test.
* c-c++-common/cpp/dir-only-11.c: New test.

4 hours agoaarch64: Fix gating of fp8 intrinsics [PR123206]
Alex Coplan [Fri, 19 Dec 2025 13:51:04 +0000 (13:51 +0000)] 
aarch64: Fix gating of fp8 intrinsics [PR123206]

As it stands, there are several intrinsics in
aarch64-simd-pragma-builtins.def which have the following form:

  #define REQUIRED_EXTENSIONS nonstreaming_only (TARGET_SIMD)
  [...]
  #undef REQUIRED_EXTENSIONS

the problem being that nonstreaming_only expects an instance of
aarch64_feature_flags which (statically) describes the required
extensions for the intrinsics.  Instead, we were passing TARGET_SIMD,
which computes a boolean telling us dynamically whether the simd feature
is currently available.

This patch fixes the issue by simply doing
s/TARGET_SIMD/AARCH64_FL_SIMD/ in that file.  We also add a simple test
which checks that we now diagnose the missing extension instead of
ICEing when compiling with +nosimd.

As an additional conservative hardening step (to prevent a similar issue
from re-occurring), this patch adjusts the aarch64_pragma_builtins table
to make it constexpr.  This makes the bug a compile-time error.

The next patch in the series adjusts the ctor of bbitmap to make it
explicit (and deals with the fallout), this patch however is
deliberately a minimal fix which is suitable for backporting.

gcc/ChangeLog:

PR target/123206
* config/aarch64/aarch64-builtins.cc (struct aarch64_pragma_builtins_data):
Declare array as CONSTEXPR.
* config/aarch64/aarch64-simd-pragma-builtins.def: Update
incorrect uses of TARGET_SIMD to use AARCH64_FL_SIMD instead.

gcc/testsuite/ChangeLog:

PR target/123206
* gcc.target/aarch64/pr123206.c: New test.

4 hours agod: Refactor for changes to dmd front-end inteface
Iain Buclaw [Fri, 30 Jan 2026 08:06:39 +0000 (09:06 +0100)] 
d: Refactor for changes to dmd front-end inteface

There are a number of interface changes being made to the dmd front-end
interface. This makes any necessary refactorings ahead of the merge to
reduce the size of the diff.

gcc/d/ChangeLog:

* decl.cc (DeclVisitor::visit (EnumDeclaration *)): Treat sinit member
field as a generic pointer.
(enum_initializer_decl): Likewise.
* expr.cc (ExprVisitor::visit (ArrayLiteralExp *)): Compute static
array length separately from creating type.
* modules.cc (struct module_info): Add ctor_decl, dtor_decl,
sharedctor_decl, shareddtor_decl, standalonector_decl, and
unittest_decl.
(layout_moduleinfo_fields): Add mi argument. Use it to check whether
module helpers have been generated.
(layout_moduleinfo): Likewise.
(build_module_tree): Cache generated module helpers in module_info.
* typeinfo.cc (cpp_type_info_ptrs): New variable.
(get_cpp_typeinfo_decl): Cache generated C++ type_info references in
cpp_type_info_ptrs.
* types.cc (TypeVisitor::visit (TypeEnum *)): Separate getting
front-end member value from building its CST tree.

5 hours agod: Fix ICE in dwarf2out_abstract_function, at dwarf2out.cc:23771 [PR123263]
Iain Buclaw [Fri, 30 Jan 2026 07:14:34 +0000 (08:14 +0100)] 
d: Fix ICE in dwarf2out_abstract_function, at dwarf2out.cc:23771 [PR123263]

Emit artificial functions as being part of the module context, so that
they are unaffected by dwarf early_finish pass removing the parent type
that they were generated for.

PR d/123263

gcc/d/ChangeLog:

* d-codegen.cc (d_decl_context): Set DECL_CONTEXT of compiler
generated functions to that of parent module.

gcc/testsuite/ChangeLog:

* gdc.dg/debug/pr123263.d: New test.

5 hours agotree-optimization/109410 - ICE with noreturn and -g
Richard Biener [Thu, 29 Jan 2026 14:43:01 +0000 (15:43 +0100)] 
tree-optimization/109410 - ICE with noreturn and -g

This fixes the -g variant of the original testcase.

PR tree-optimization/109410
* tree-ssa-reassoc.cc (build_and_add_sum): Use
gsi_start_nondebug_after_labels_bb to look for a possible
returns-twice call.

* gcc.dg/pr109410-2.c: New testcase.

6 hours agod, darwin: Add Apple as a predefined version
Iain Buclaw [Fri, 30 Jan 2026 06:34:04 +0000 (07:34 +0100)] 
d, darwin: Add Apple as a predefined version

This is a new predefined version identifier intended to be turned on if
any of the OSX, iOS, TVOS, WatchOS, or VisionOS versions are predefined.

gcc/ChangeLog:

* config/darwin-d.cc (darwin_d_os_builtins): Add Apple.

6 hours agod: Fix infinite loop in dump_generic_node [PR123264]
Iain Buclaw [Thu, 29 Jan 2026 17:07:57 +0000 (18:07 +0100)] 
d: Fix infinite loop in dump_generic_node [PR123264]

PR d/123264

gcc/d/ChangeLog:

* types.cc (finish_aggregate_type): Propagate struct TYPE_NAME to all
TYPE_NEXT_VARIANT types.

gcc/testsuite/ChangeLog:

* gdc.dg/pr123264.d: New test.

8 hours agoifcvt: Improve noce_can_force_operand in ifcvt [PR122170]
Andrew Pinski [Wed, 28 Jan 2026 20:32:12 +0000 (12:32 -0800)] 
ifcvt: Improve noce_can_force_operand in ifcvt [PR122170]

Currently if the rtl is either an arithmetic or an unary
rtl, noce_can_force_operand checks to see if there is an
optab for that rtl code. This works for more things except
on some targets they have a ss_minus instruction but don't
implement the optab for it. In the case of arm you can
generate a ss_minus with a builtin and then when it comes
to trying to do ifcvt, force_operand fails over.
In this case the optab, sssub was only supported for
fixed-point modes before and it was working as code_to_optab
would return there was not optabs. But after r15-1030-gabe6d39365476e,
the optab will be return. What the backend is doing is correct and will
most likely happen with other rtl codes/optabs later on.

To fix this instead of just returning true if the optab exists, we need
to check if the optab entry for the mode exists.

PR rtl-optimization/122170

gcc/ChangeLog:

* ifcvt.cc (noce_can_force_operand): Don't only check if
there is an optab for the code check the entry for the
mode is non-null. Handle non integral div by checking
optab like force_operand does.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
9 hours agoLoongArch: Remove unused function type.
Lulu Cheng [Tue, 27 Jan 2026 02:31:37 +0000 (10:31 +0800)] 
LoongArch: Remove unused function type.

gcc/ChangeLog:

* config/loongarch/loongarch-ftypes.def: Remove unused type.

9 hours agoLoongArch: Fix bug123766.
Lulu Cheng [Tue, 27 Jan 2026 02:31:36 +0000 (10:31 +0800)] 
LoongArch: Fix bug123766.

The pointer parameter type for the original store class builtin
functions is CVPOINTER (const volatile void *).
Taking the following test as an example:

```
v4i64 v = {0, 0, 0, 0};
void try_store() {
     long r[4];
     __lasx_xvst(v, r, 0);
}
```
At this point, the type of r is CVPOINTER, which means data in memory
can only be read through r.  Therefore, if the array r is not
initialized, an uninitialized warning will be issued.
This patch changes the pointer type of store-class builtin functions
from CVPOINTER to VPOINTER (volatile void *).

PR target/123766

gcc/ChangeLog:

* config/loongarch/loongarch-builtins.cc
(loongarch_build_vpointer_type): New function.  Return a type
for 'volatile void *'.
(LARCH_ATYPE_VPOINTER): New macro.
* config/loongarch/loongarch-ftypes.def: Change the pointer
type of the store class function from CVPOINTER to VPOINTER.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/vector/lasx/pr123766.c: New test.
* gcc.target/loongarch/vector/lsx/pr123766.c: New test.

11 hours agoLoongArch: Fix bug123807.
Lulu Cheng [Mon, 26 Jan 2026 03:38:59 +0000 (11:38 +0800)] 
LoongArch: Fix bug123807.

In the function loongarch_expand_vector_init_same, if same is MEM and
the mode of same does not match imode, it will cause an ICE
in force_reg (imode, same).

PR target/123807

gcc/ChangeLog:

* config/loongarch/loongarch.cc
(loongarch_expand_vector_init_same): When same is MEM and
GET_MODE(same) != imode, first load the data from memory
and then process it further.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/vector/lsx/pr123807.c: New test.

11 hours agoLoongArch: Fix movsf in lp64s abi
mengqinggang [Fri, 23 Jan 2026 07:00:58 +0000 (15:00 +0800)] 
LoongArch: Fix movsf in lp64s abi

When adding LoongArch32 ilp32s abi support, add TARGET_HARD_FLOAT condition for
movsf to prevent matching in target without FPU.
But movsf also needs to be used in lp64s abi, it can expand to some
non float instructions.
Delete TARGET_HARD_FLOAT condition.

gcc/ChangeLog:

* config/loongarch/loongarch.md: Delete movsf TARGET_HARD_FLOAT
condition.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/la64/movsf.c: New test.

12 hours agoDaily bump.
GCC Administrator [Fri, 30 Jan 2026 00:16:31 +0000 (00:16 +0000)] 
Daily bump.

14 hours agooptabs: Fix expansion of abs and neg for Float16 [PR123869]
Andrew Pinski [Thu, 29 Jan 2026 00:50:52 +0000 (16:50 -0800)] 
optabs: Fix expansion of abs and neg for Float16 [PR123869]

The problem here is we try to use the widening type before
doing the bitwise expansion of neg/and for floating point types.
This moves the code around to try the bitwise expansion first.

Note this mostly matters for NaNs where you widening (promotion)
would cause a NaN to be slightly different when doing the rounding
back.

Bootstrapped and tested on x86_64-linux-gnu.

PR middle-end/123869

gcc/ChangeLog:

* optabs.cc (expand_unop): Move the NEG optab
handling before the widening code.
Move the ABS bitwise expansion from expand_abs_nojump
to before the widening code.
(expand_abs_nojump): Remove the bitwise expansion trial
since expand_unop is called right above.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
16 hours agolibstdc++: Make std::expected trivially copy/move assignable (LWG 4026)
Jonathan Wakely [Wed, 28 Jan 2026 12:33:46 +0000 (12:33 +0000)] 
libstdc++: Make std::expected trivially copy/move assignable (LWG 4026)

This is the subject of two NB comments on C++26 which seem likely to be
approved. We're allowed to make this change as QoI anyway, even if it
isn't approved for the standard, and it should apply to C++23 as well to
avoid ABI changes between C++23 and C++26.

As shown in the updates to the test, defaulted special members can have
noexcept(false) even if they would be noexcept(true) by default. The new
defaulted operator= overloads added by this commit have conditional
noexcept-specifiers that match the conditions of the non-trivial
assignments, propagating any noexcept(false) on trivial special members
of the T and E types. We could strengthen the noexcept for the trivial
operators, but propagating the conditions from the underlying types is
probably what users expect, if they've bothered to put noexcept(false)
on their defaulted special members.

libstdc++-v3/ChangeLog:

* include/std/expected (__expected::__trivially_replaceable)
(__expected::__usable_for_assign)
(__expected::__usable_for_trivial_assign)
(__expected::__can_reassign_type): New concepts.
(expected::operator=): Adjust constraints
on existing overloads and add defaulted overload.
(expected<cv void, E>::operator=): Likewise.
* testsuite/20_util/expected/requirements.cc: Check for trivial
and nothrow properties of assignments.

16 hours agotestsuite: Move pr116353.c from being x86 specific to being generic
Andrew Pinski [Wed, 28 Jan 2026 20:16:43 +0000 (12:16 -0800)] 
testsuite: Move pr116353.c from being x86 specific to being generic

While working on ifcvt's noce_can_force_operand, I noticed that
the testcase pr116353.c was added as x86 specific testcase but
it has nothing in it that is x86 specific. It is currently
compiled at -O2 but there is no reason why it can't be compiled
at any other optimization level.
So this moves the testcase to be a torture testcase.

The original issue showed up on x86 with respect to ifcvt
where there was a vec_select which does not have an optab for it
but it might show up on other targets too.

Tested on x86_64-linux-gnu.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr116353.c: Move to...
* gcc.dg/torture/pr116353.c: ...here.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
18 hours agoAllow CONCATs in emit_group_load_1.
Roger Sayle [Thu, 29 Jan 2026 18:48:14 +0000 (18:48 +0000)] 
Allow CONCATs in emit_group_load_1.

This one line patch is a pre-requisite to a solution to PR target/123506;
an effort to improve middle-end code for returning structures.  Currently,
emit_group_load_1 contains code to handle a CONCAT returned by force_reg.
This tweak avoids the call for force_reg if the source is already a CONCAT,
which allows this subroutine to be re-used by target-specific implementations
of emit_group_load.  Many thanks to Jeff Law for cross-platform testing.

2026-01-29  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* expr.cc (emit_group_load_1): Don't call force_reg if orig_src
is already a CONCAT.

19 hours agoAda: Fix internal error on equality test with empty container
Eric Botcazou [Thu, 29 Jan 2026 15:16:08 +0000 (16:16 +0100)] 
Ada: Fix internal error on equality test with empty container

This is a regression present on the mainline and 15 branch, although the
root cause has been present for years: the Sem_Type.Covers predicate
returns true for the type of an aggregate (Any_Composite) and any type
declared with the Aggregate aspect (when invoked in Ada 2022 or later),
but its companion function Sem_Type.Specific_Type punts when it is called
on the same combination.

gcc/ada/
PR ada/123861
* sem_type.adb (Covers): Fix couple of typos in comment.
(Specific_Type): Adjust to Covers' handling of types declared
with the Aggregate aspect in Ada 2022.

gcc/testsuite/
* gnat.dg/specs/aggr11.ads: New test.

19 hours agotestsuite: arm: rework some target-supports checks to use -mfpu=auto
Richard Earnshaw [Thu, 29 Jan 2026 10:25:41 +0000 (10:25 +0000)] 
testsuite: arm: rework some target-supports checks to use -mfpu=auto

Several target-supports checks for Arm are still using the antiquated
-mfpu=... setting rather than picking up FPU extensions via the
architecture specification.  This causes problems when tests are
layered because they do not consistently override each other.

Arguably, that is incorrect anyway: you can't test two sets of flag
combinations independently and then expect to be able to apply both
of them, but this change at least makes this behave in a reasonable
way provided the second set of flags fully overrides the first.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp:
(check_effective_target_arm_v8_3a_complex_neon_ok_nocache):
Split and fill in arm and aarch64 compile options.  Remove the
cpu_unset variable.
(check_effective_target_arm_v8_2a_fp16_neon_ok_nocache): Likewise.
(check_effective_target_arm_v8_3a_fp16_complex_neon_ok_nocache):
Likewise.
(check_effective_target_arm_neon_ok_nocache): Rework to use
-mfpu=auto.
(check_effective_target_arm_neon_fp16_ok_nocache): Likewise.

Co-authored-by: Artemiy Volkov <artemiy.volkov@arm.com>
19 hours agotestsuite: require arm_v8_3a_fp16_complex_neon for complex fp16 tests
Artemiy Volkov [Thu, 8 Jan 2026 11:51:06 +0000 (11:51 +0000)] 
testsuite: require arm_v8_3a_fp16_complex_neon for complex fp16 tests

Changes to target-supports.exp from r16-6519-g56dd47c073cabf introduced
some new failures for complex fp16 tests with some arm-eabi targets
configured with -mfpu=auto.  This patch fixes those by (a) requiring the
full arm_v8_3a_fp16_complex_neon_ok target instead of just float16 in
vect/complex fp16 tests, and (b) simplifying down to one
dg-require-effective-target and one dg-add-options and removing the
explicit -march in advsimd-intrinsics/vector-complex_f16.c.

Regtested on aarch64, and the Linaro CI also delivers a positive verdict
for the relevant cortex-m33/-m3/-m55/-m7 configurations (after the
accompanying patch to target-supports.exp that follows).  Huge thanks to
Christophe for testing this on arm.

gcc/testsuite/ChangeLog:

* gcc.dg/vect/complex/fast-math-bb-slp-complex-add-half-float.c:
Adjust testcase.
* gcc.dg/vect/complex/fast-math-bb-slp-complex-add-pattern-half-float.c:
Likewise.
* gcc.dg/vect/complex/fast-math-bb-slp-complex-mla-half-float.c:
Likewise.
* gcc.dg/vect/complex/fast-math-bb-slp-complex-mls-half-float.c:
Likewise.
* gcc.dg/vect/complex/fast-math-bb-slp-complex-mul-half-float.c:
Likewise.
* gcc.dg/vect/complex/fast-math-complex-add-half-float.c: Likewise.
* gcc.dg/vect/complex/fast-math-complex-add-pattern-half-float.c:
Likewise.
* gcc.dg/vect/complex/fast-math-complex-mla-half-float.c:
Likewise.
* gcc.dg/vect/complex/fast-math-complex-mls-half-float.c:
Likewise.
* gcc.dg/vect/complex/fast-math-complex-mul-half-float.c:
Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vector-complex_f16.c:
Likewise.

19 hours agolibstdc++: Fix use of feature test macro in <source_location>
Jonathan Wakely [Thu, 29 Jan 2026 17:02:43 +0000 (17:02 +0000)] 
libstdc++: Fix use of feature test macro in <source_location>

libstdc++-v3/ChangeLog:

* include/std/source_location: Check __glibcxx_contracts instead
of __cpp_lib_contracts.
* testsuite/18_support/contracts/includes.cc: New test.

19 hours agolibstdc++: fix a wrong export of a contracts facility in std module
vspefs [Thu, 29 Jan 2026 16:58:19 +0000 (16:58 +0000)] 
libstdc++: fix a wrong export of a contracts facility in std module

This patch fixes a wrong export name in std module. std module currently
exports std::contracts::invoke_default_violation_handler, which is wrong.
The correct name is std::contracts::invoke_default_contract_violation_handler.

libstdc++-v3/ChangeLog:

* src/c++23/std.cc.in (invoke_default_violation_handler): Change
to invoke_default_contract_violation_handler.

Signed-off-by: Xie Han <vspefs@protonmail.com>
20 hours agoarm: testsuite: Use test framework to set arch in stack-protector-7
Christopher Bazley [Thu, 29 Jan 2026 15:55:15 +0000 (15:55 +0000)] 
arm: testsuite: Use test framework to set arch in stack-protector-7

This test was trying to set the architecture directly instead of
using the framework. The queried options were previously ignored.

gcc/testsuite/ChangeLog:
* gcc.target/arm/stack-protector-7.c: Fix dgdirectives.

20 hours agodoc: Add "user experience" documentation for options
Sandra Loosemore [Thu, 29 Jan 2026 16:41:07 +0000 (16:41 +0000)] 
doc: Add "user experience" documentation for options

After working through PR122243, it seems appropriate to write down
some guidelines for adding/maintaining options and options
documentation so that we can at least point to procedures to keep
things from getting out of sync again.

Thanks to jemarch@gnu.org and dmalcolm@redhat.com for their suggestions
to improve this patch.

gcc/ChangeLog
* doc/options.texi (Options): Point to the "user experience"
documentation.
* doc/ux.texi (Guidelines for Options): Add some.

20 hours agoRISC-V: Handle VL-setting FoF loads. [PR123806]
Robin Dapp [Mon, 26 Jan 2026 14:24:10 +0000 (15:24 +0100)] 
RISC-V: Handle VL-setting FoF loads. [PR123806]

For PR122869 I thought I fixed the issue of VL-spills clobbering
explicit VL reads after fault-only-first (FoF) loads but it turns
out the fix is insufficient.  Even though it avoided the original
issue, we can still have spills that clobber VL before the read_vl
RTL pattern.  That's mostly due to us hiding the VL data flow from
the optimizers so a regular spill to memory can and will introduce
a VL clobber.  In vsetvl we catch all the regular cases but not the
FoF-load case of PR123806 and PR122869.

This patch adds specific FoF patterns that emit the same instruction but
have a register-setting VL pattern inside the insn's PARALLEL.
It serves as a marker for the vsetvl pass that can recognize that we
clobber VL before reading its value.  In that case we now emit an
explicit csrr ..,vl.

After vsetvl it's safe to emit the read_vls because at that point the
VL dataflow has been established and we can be sure to not clobber VL
anymore.

Thus, the main changes are:
 - Unify read_vl si and di and make it an UNSPEC.  We don't optimize
   it anyway so a unified one is easier to include in the new FoF
   VL-setter variants.
 - Introduce VL-setting variants of FoF loads and handle them like
   read_vl()s in the vsetvl pass.
 - Emit read_vl()s after vsetvl insertion is done.

What this doesn't get rid of is the XFAIL in ff-load-3.c that I
introduced for PR122869.  The code is still "good" at -O1 and
"bad" at -O2 upwards.

PR target/123806

gcc/ChangeLog:

* config/riscv/riscv-string.cc (expand_rawmemchr): Use unified
vl_read.
(expand_strcmp): Ditto.
* config/riscv/riscv-vector-builtins-bases.cc:
* config/riscv/riscv-vector-builtins.cc (function_expander::use_fof_load_insn):
Only emit the store and not the VL read.
* config/riscv/riscv-vsetvl.cc (get_fof_set_vl_reg): New
function.
(init_rtl_ssa): New wrapper.
(finish_rtl_ssa): Ditto.
(emit_fof_read_vls): Emit read_vl after each fault-only-first
load.
(pass_vsetvl::simple_vsetvl): Call emit_fof_read_vls ().
(pass_vsetvl::lazy_vsetvl): Ditto.
* config/riscv/vector-iterators.md: Add read_vl unspec.
* config/riscv/vector.md (read_vlsi): Unify.
(@read_vl<mode>): Ditto.
(read_vldi_zero_extend): Ditto.
(@pred_fault_load_set_vl<V_VLS:mode><P:mode>): New FoF variant
that saves VL in a register.
(@pred_fault_load_set_vl<VT:mode><P:mode>): Ditto.

gcc/testsuite/ChangeLog:

* g++.target/riscv/rvv/base/pr123806.C: New test.
* g++.target/riscv/rvv/base/pr123808.C: New test.
* g++.target/riscv/rvv/base/pr123808-2.C: New test.

20 hours agoRISC-V: testsuite: Add zvl requirement to PR123626.
Robin Dapp [Wed, 28 Jan 2026 16:54:42 +0000 (17:54 +0100)] 
RISC-V: testsuite: Add zvl requirement to PR123626.

This adds a new require-effective-target check to pr123626.c.
As the test is a run test compiled with _zvl256b we need
to ensure the target actually supports 256b vectors.

We can only check for exactly 256b right now
(rvv_zvl256b_ok), i.e. "VLS".  Therefore, the patch also adds
a new target check rvv_zvl_ge_256b_ok where ge means greater
or equal.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp: Add rvv_zvl_ge_256b_ok.
* gcc.target/riscv/rvv/base/pr123626.c: Use new target check.

20 hours agod: Fix Segmentation fault with redeclared symbols [PR123407]
Iain Buclaw [Thu, 29 Jan 2026 15:26:21 +0000 (16:26 +0100)] 
d: Fix Segmentation fault with redeclared symbols [PR123407]

Issue an error if two symbols with the same assembler name have a
mismatched TREE_CODE.

PR d/123407

gcc/d/ChangeLog:

* decl.cc (get_symbol_decl): Handle declarations with matching
assembler names, but different TREE_CODE.

gcc/testsuite/ChangeLog:

* gdc.dg/pr123407a.d: New test.
* gdc.dg/pr123407b.d: New test.

21 hours agopta: Fix comment of intra_create_variable_infos
Filip Kastl [Thu, 29 Jan 2026 15:01:33 +0000 (16:01 +0100)] 
pta: Fix comment of intra_create_variable_infos

The comment says that this function creates varinfos for *all*
variables in a function.  Meanwhile, it only creates varinfos for
parameters, the return value and the static chain.

Commiting as obvious.

gcc/ChangeLog:

* gimple-ssa-pta-constraints.cc (make_param_constraints): Adjust
comment: The function only creates varinfos for the parameters,
the return value and the static chain.

Signed-off-by: Filip Kastl <fkastl@suse.cz>
22 hours agoc++/reflection: add fixed test [PR123871]
Marek Polacek [Thu, 29 Jan 2026 14:39:12 +0000 (09:39 -0500)] 
c++/reflection: add fixed test [PR123871]

Incredibly, a patch that I just pushed (r16-7140-g101f2970adc0a7) fixed
this ICE.

I notice that we don't emit the diag_array_subscript diagnostic because
slice calls fold_non_dependent_expr which calls _eval_outermost with
allow_non_constant=true.  I wonder if we want to change this.

PR c++/123871

gcc/testsuite/ChangeLog:

* g++.dg/reflect/error11.C: New test.

22 hours agod: Fix ICE in gimplify_expr with const ref noreturn parameters [PR123046]
Iain Buclaw [Thu, 29 Jan 2026 13:06:14 +0000 (14:06 +0100)] 
d: Fix ICE in gimplify_expr with const ref noreturn parameters [PR123046]

The ICE was caused by references to const/immutable qualified `noreturn'
declarations that were being leaked to the code generation when they
should have been omitted or replaced with `assert(0)'.

PR d/123046

gcc/d/ChangeLog:

* d-codegen.cc (build_address): Return `null' when generating the
address of a `noreturn' declaration.
(d_build_call): Compare TYPE_MAIN_VARIANT of type with `noreturn'.
* decl.cc (get_fndecl_arguments): Likewise.
* types.cc (finish_aggregate_mode): Likewise.
(TypeVisitor::visit (TypeFunction *)): Likewise.

gcc/testsuite/ChangeLog:

* gdc.dg/pr123046.d: New test.

22 hours agotree-optimization/122537 - do not elide maybe_zero condition for wrapping IV
Richard Biener [Thu, 29 Jan 2026 12:56:11 +0000 (13:56 +0100)] 
tree-optimization/122537 - do not elide maybe_zero condition for wrapping IV

The following removes the optimization eliding the maybe_zero condition
from number_of_iterations_lt_to_ne when the IV can overflow since the
IV delta input is not accurately reflecting this.

PR tree-optimization/122537
* tree-ssa-loop-niter.cc (number_of_iterations_lt_to_ne): Register
may_be_zero condition when the IV may overflow.

* gcc.dg/torture/pr122537.c: New testcase.

23 hours agoc++/reflection: tweak for eval_has_template_arguments
Marek Polacek [Wed, 28 Jan 2026 20:43:35 +0000 (15:43 -0500)] 
c++/reflection: tweak for eval_has_template_arguments

As discussed in
<https://gcc.gnu.org/pipermail/gcc-patches/2026-January/705756.html>:

> For reflection it's probably best to go with
>
> if (TYPE_P (r) && typedef_variant_p (r))
>   return alias_template_specialization_p (r, nt_opaque);
>
> and not get into primary_template_specialization_p at all.

Here in a patch form.

gcc/cp/ChangeLog:

* reflect.cc (eval_has_template_arguments): Return immediately after
checking alias_template_specialization_p.

Reviewed-by: Jason Merrill <jason@redhat.com>
23 hours agoc++/reflection: add assert to eval_type_trait
Marek Polacek [Wed, 28 Jan 2026 21:26:35 +0000 (16:26 -0500)] 
c++/reflection: add assert to eval_type_trait

As discussed in
<https://gcc.gnu.org/pipermail/gcc-patches/2026-January/705756.html>.

Since we check eval_is_type in process_metafunction:

  if (eval_is_type (ht) != boolean_true_node)
     return throw_exception_nontype (loc, ctx, fun, non_constant_p,
     jump_target);

finish_trait_expr should never return error_mark_node.  We can ensure
that it's so by adding an assert.

gcc/cp/ChangeLog:

* reflect.cc (eval_type_trait): Assert that finish_trait_expr didn't
return error_mark_node.

Reviewed-by: Jason Merrill <jason@redhat.com>
23 hours agoc++/reflection: enhance splice error checking
Marek Polacek [Wed, 28 Jan 2026 22:30:06 +0000 (17:30 -0500)] 
c++/reflection: enhance splice error checking

As discussed in
<https://gcc.gnu.org/pipermail/gcc-patches/2026-January/705756.html>:

> Absolutely, I mean anything other than REFLECT_EXPR or error_mark_node
> should be an error.

I'm not giving another error for error_mark_node since we've already
complained (but make sure we have).

gcc/cp/ChangeLog:

* reflect.cc (class_members_of): Adjust comment.
(splice): Give an error if the expression doesn't evaluate to
a REFLECT_EXPR_P.

Reviewed-by: Jason Merrill <jason@redhat.com>
23 hours agoFix AIX build break in gcc/diagnostics/sarif-sink.cc.
Sangamesh Mallayya [Thu, 29 Jan 2026 13:04:40 +0000 (07:04 -0600)] 
Fix AIX build break in gcc/diagnostics/sarif-sink.cc.

In AIX, build fails while trying to compile gcc/diagnostics/sarif-sink.cc.
Here is the snapshot of the error we are getting.

In file included from /opt/freeware/src/packages/BUILD/gcc/gcc/system.h:46,
                 from /opt/freeware/src/packages/BUILD/gcc/gcc/diagnostics/sarif-sink.cc:34:
/opt/freeware/lib/gcc/powerpc-ibm-aix7.3.0.0/13/include-fixed/stdio.h:593:12: error: conflicting declaration of C function 'int fgetpos64(FILE*, fpos64_t*)'
  593 | extern int fgetpos64(FILE *, fpos64_t *);
      |            ^~~~~~~~~

This happens when we include sys/types.h before defining _LARGE_FILES.
We can see similar errors with this sample program.

#include <sys/types.h>
#define _LARGE_FILES 1
#include <stdio.h>
int main()
{
   return 0;
}

In gcc/diagnostics/sarif-sink.cc we are including config.h after #include <sys/un.h> which intern
 including sys/types.h and causing the conflicting errors.
Including config.h before including sys/un.h should solve this error.

The patch is to fix the build break on AIX.

gcc/ChangeLog:
* diagnostics/sarif-sink.cc: Move config.h at the begining.

24 hours agod: Fix buffer overflow detected with -defaultlib= and -debuglib= [PR123349]
Iain Buclaw [Thu, 29 Jan 2026 09:11:43 +0000 (10:11 +0100)] 
d: Fix buffer overflow detected with -defaultlib= and -debuglib= [PR123349]

PR d/123349

gcc/d/ChangeLog:

* d-spec.cc (lang_specific_driver): Use xstrdup to copy -defaultlib
and -debuglib argument, and unconditionally free the old value.

gcc/testsuite/ChangeLog:

* gdc.dg/driver_debuglib.d: New test.
* gdc.dg/driver_defaultlib.d: New test.

24 hours agolibstdc++: Fix non-ASCII characters in <contracts> header
Jonathan Wakely [Thu, 29 Jan 2026 12:12:45 +0000 (12:12 +0000)] 
libstdc++: Fix non-ASCII characters in <contracts> header

This fixes:
FAIL: 17_intro/headers/c++1998/charset.cc  -std=gnu++26 (test for excess errors)

libstdc++-v3/ChangeLog:

* include/std/contracts: Replace non-ASCII characters.

25 hours agotree-optimization/123596 - fix partial virtual SSA update in eh_cleanup
Richard Biener [Thu, 29 Jan 2026 09:41:16 +0000 (10:41 +0100)] 
tree-optimization/123596 - fix partial virtual SSA update in eh_cleanup

The following replaces the not quite correct use of
mark_virtual_operand_for_renaming by an appropriate way of dealing
with a possibly partially up-to-date virtual SSA form.  Namely
when we just move stmts and not remove a VDEF we should arrange
for missing virtual PHIs to be created and just queue its arguments
for possible renaming.  For the testcase at hand there's no renaming
necessary in the end when done this way.

PR tree-optimization/123596
* tree-eh.cc (sink_clobbers): Create a virtual PHI when
one is required but not present, queuing arguments
for renaming.

* g++.dg/torture/pr123596.C: New testcase.

25 hours agotree-optimization/116747 - ICE in cselim due to duplicate sinking
Richard Biener [Thu, 29 Jan 2026 07:47:44 +0000 (08:47 +0100)] 
tree-optimization/116747 - ICE in cselim due to duplicate sinking

The following avoids queueing duplicate stmts in the set of sinkings
to consider as well as pick candidates in an order that ensures
we don't unnecessarily re-order stores.  While we currently only can
trigger the ICE with out-of-bound accesses future enhancements
to how we deal with dependence analysis in this pass could expose
the issue to a wider range of testcases, so this makes it future-proof.

PR tree-optimization/116747
* tree-ssa-phiopt.cc (cond_if_else_store_replacement): Avoid
duplicate stmts in the set of store pairs to process.

* gcc.dg/tree-ssa/cselim-4.c: New testcase.

25 hours agoc++: Fix ICE in eval_annotations_of [PR123866]
Jakub Jelinek [Thu, 29 Jan 2026 11:34:59 +0000 (12:34 +0100)] 
c++: Fix ICE in eval_annotations_of [PR123866]

eval_annotations_of throws if the passed in reflection handle is not
eval_is_function (and various others).  Now, eval_is_function uses
maybe_get_first_fn to look through BASELINK/OVERLOAD etc., but
eval_annotations_of wasn't doing that and ICEd on
  else if (TYPE_P (r))
    r = TYPE_ATTRIBUTES (r);
  else if (DECL_P (r))
    r = DECL_ATTRIBUTES (r);
  else
    gcc_unreachable ();
because r isn't a decl nor type (nor REFLECT_BASE earlier).

2026-01-29  Jakub Jelinek  <jakub@redhat.com>

PR c++/123866
* reflect.cc (eval_annotations_of): Use maybe_get_first_fn.

* g++.dg/reflect/annotations10.C: New test.

25 hours agoa68: implement GNU68-2026-001-short-of-symbol
Jose E. Marchesi [Thu, 29 Jan 2026 02:33:17 +0000 (03:33 +0100)] 
a68: implement GNU68-2026-001-short-of-symbol

This patch implements the GNU extension:

  GNU68-2026-001-brief-selection - Brief style for selection

which adds the preferred brief style for selection recommended by
Hansen in "ALGOL 68 Hardware Represenatation Recommendations"
published in the Algol Bulletin issue 42.

This extension is already listed in https://algol68-lang.org.

Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
gcc/algol68/ChangeLog

* ga68.vw: Update formal grammar to express the GNU extension.
* a68-parser.cc (a68_dont_mark_here): Likewise.
* a68-parser-scanner.cc (SINGLE_QUOTE_CHAR): Define.
(get_next_token): Recognize ' as QUOTE_SYMBOL.
(tokenise_source): Acknowledge QUOTE_SYMBOL.
* a68-parser-keywords.cc (a68_set_up_tables): Likewise.
* a68-parser-bottom-up.cc (reduce_primary_parts): Adjust parser to
brief form of selection.
* a68-parser-attrs.def (QUOTE_SYMBOL): New attribute.
* ga68.texi (Brief selection): New section.

gcc/testsuite/ChangeLog

* algol68/compile/error-selector-1.a68: New test.
* algol68/execute/selection-2.a68: Update test.
* algol68/execute/selection-5.a68: Likewise.

28 hours agoc++: Implement CWG3131 - Value categories and types for the range in iterable expansi...
Jakub Jelinek [Thu, 29 Jan 2026 08:49:51 +0000 (09:49 +0100)] 
c++: Implement CWG3131 - Value categories and types for the range in iterable expansion statements

For the https://gcc.gnu.org/pipermail/gcc/2025-November/246977.html
issues I've filed https://github.com/cplusplus/CWG/issues/805
which resulted in two CWG issues,
https://cplusplus.github.io/CWG/issues/3131.html
and
https://cplusplus.github.io/CWG/issues/3140.html
This patch implements the former, changing
the iterating expansion statement http://eel.is/c++draft/stmt.expand#5.2
line from
constexpr auto&& range = expansion-initializer;
to
constexpr decltype(auto) range = (expansion-initializer);
(for our partly pre-CWG3044 implementation with static before it).

2026-01-29  Jakub Jelinek  <jakub@redhat.com>

* cp-tree.h (build_range_temp): Implement CWG3131 - Value
categories and types for the range in iterable expansion statements.
Add bool argument defaulted to false.
* parser.cc (build_range_temp): Add expansion_stmt_p argument,
if true build const decltype(auto) __for_range = range_expr instead of
auto &&__for_range = range_expr.
(cp_build_range_for_decls): For expansion stmts build __for_range as
static constexpr decltype(auto) __for_range = (range_expr);
rather than static constexpr auto &&__for_range = range_expr;.

* g++.dg/cpp26/expansion-stmt1.C (N::begin, N::end, O::begin,
O::end): Change argument type from B & to const B & or from
D & to const D &.
* g++.dg/cpp26/expansion-stmt2.C (N::begin, N::end, O::begin,
O::end): Likewise.
* g++.dg/cpp26/expansion-stmt3.C (N::begin, N::end, O::begin,
O::end): Likewise.
* g++.dg/cpp26/expansion-stmt16.C: Expect different diagnostics
for C++11.
* g++.dg/cpp26/expansion-stmt18.C (N::begin, N::end): Change
argument type from B & to const B &.
* g++.dg/cpp26/expansion-stmt25.C (N::begin, N::end): Likewise.
* g++.dg/cpp26/expansion-stmt26.C: New test.
* g++.dg/reflect/p3491-2.C (baz): Move workaround to a new
function garply, use the previously #if 0 guarded implementation.
(garply): New function.

35 hours agolibffi: Remove more unneeded files when merging
Pietro Monteiro [Thu, 29 Jan 2026 01:16:04 +0000 (20:16 -0500)] 
libffi: Remove more unneeded files when merging

Delete .allow-ai-service and .gail-labels which are present in newer
versions of libffi.

libffi/ChangeLog:
PR libffi/117635
* merge.sh: Delete .allow-ai-service and .gail-labels when
merging new upstream versions.

Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
35 hours agolibffi: Add missing GCC patches to LOCAL_PATCHES
Pietro Monteiro [Thu, 29 Jan 2026 01:16:04 +0000 (20:16 -0500)] 
libffi: Add missing GCC patches to LOCAL_PATCHES

Add all the patches to GCC's copy of libffi to LOCAL_PATCHES.  I
skipped patches that only regenerate the configure script because it
doesn't come from upstream.

libffi/ChangeLog:
PR libffi/117635
* LOCAL_PATCHES: Add missing patches.

Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
36 hours agoa68: support FFI with C via formal holes
Jose E. Marchesi [Sat, 24 Jan 2026 19:10:10 +0000 (20:10 +0100)] 
a68: support FFI with C via formal holes

This commit adds FFI support to access C variables and call C
functions from Algol 68, using the construct specified by the Modules
and Separated compilation facilities intended to that effect: formal
holes (`nest' constructs).

Briefly put, an `int foo' C variable can be accessed from Algol 68
like:

  int foo = nest C "foo";
  if foo > 10 then ... fi;

A ref to a C variable `int counter', that allows to modify it as well
as read it:

  ref int counter = nest C "&counter";
  counter +:= 1;

The address stored in an `int *ptr' variable, as an Algol 68
reference:

  ref int ptr = nest C "ptr";
  ptr := 100; { Changes the integer pointed by the C ptr }

Calling the standard C `random' function:

  proc long int random = nest C "random";
  if random < 100 then ... fi;

Some tests and an sketchy section in the manual are also included.

Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
gcc/algol68/ChangeLog

* ga68.vw: Fix grammar for formal holes.
* ga68.texi (Particular programs): New section.
(Comments): Likewise.
* a68.h: Prototypes for a68_is_c_mode, a68_make_fomal_hole_decl,
a68_lower_formal_hole.
* a68-parser-attrs.def (FORMAL_HOLE): New attribute.
(LANGUAGE_INDICANT): Likewise.
* a68-parser-extract.cc (a68_elaborate_bold_tags): Elaborate
language indicants.
* a68-parser-moids-check.cc (mode_check_unit): Check mode in
formal holes.
* a68-low-units.cc (a68_lower_formal_hole): New function.
* a68-low.cc (a68_make_formal_hole_decl): Likewise.
* a68-moids-misc.cc (a68_is_c_mode): Likewise.
* a68-parser-bottom-up.cc (reduce_formal_holes): Likewise.

gcc/testsuite/ChangeLog

* algol68/compile/error-nest-1.a68: New test.
* algol68/compile/nest-c-1.a68: Likewise.
* algol68/compile/error-nest-5.a68: Likewise.
* algol68/compile/error-nest-4.a68: Likewise.
* algol68/compile/error-nest-3.a68: Likewise.
* algol68/compile/error-nest-2.a68: Likewise.

36 hours agoDaily bump.
GCC Administrator [Thu, 29 Jan 2026 00:16:45 +0000 (00:16 +0000)] 
Daily bump.

37 hours agoAda: Fix crash on Unchecked_Union parameter with -gnateV -gnata
Eric Botcazou [Wed, 28 Jan 2026 22:52:41 +0000 (23:52 +0100)] 
Ada: Fix crash on Unchecked_Union parameter with -gnateV -gnata

The problem is that the compiler generates 'Valid_Scalars for a formal
parameter of an Unchecked_Union type, which cannot work because it is not
possible to find out where the scalars are in it, given that the parameter
does not contain the discriminants of its Unchecked_Union type.  This also
changes -gnateV to work without the need for -gnata, as there is no mention
of this dependence in the documentation.

gcc/ada/
PR ada/123857
* checks.adb (Apply_Parameter_Validity_Checks.Add_Validity_Check):
Set Is_Checked on the generated {Pre,Post}_Condition pragma and
bail out if the parameter is of an Unchecked_Union type.

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

37 hours agoAda: Fix stack corruption with concatenation and 'Image of composite type
Eric Botcazou [Wed, 28 Jan 2026 22:31:49 +0000 (23:31 +0100)] 
Ada: Fix stack corruption with concatenation and 'Image of composite type

The issue is that the expansion of 'Image for composite types is heavyweight
and involves a mix of Expression_With_Actions and controlled object that
does not work properly when it is the argument of a call to a subprogram,
so this replaces it by the canonical scheme used for controlled temporaries.

gcc/ada/
PR ada/123832
* exp_imgv.adb: Add with and use clauses for Exp_Ch7.
(Expand_Image_Attribute): Establish a transient scope before
rewriting the attribute as a call to Put_Image.
(Expand_Wide_Image_Attribute): Likewise.
(Expand_Wide_Wide_Image_Attribute): Likewise.
* exp_put_image.ads (Build_Image_Call): Add note about the
need for a transient scope when the function is invoked.
* exp_put_image.adb (Build_Image_Call): Call Insert_Actions
to immediately insert the actions instead of wrapping them
in an Expression_With_Actions node.

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

38 hours agod: Fix ICE in ExprVisitor::visit, at d/expr.cc:2224 [PR123419]
Iain Buclaw [Wed, 28 Jan 2026 22:06:23 +0000 (23:06 +0100)] 
d: Fix ICE in ExprVisitor::visit, at d/expr.cc:2224 [PR123419]

The original assert expected the type of `__traits(initSymbol)' to be
exactly `const(void[])', but because D strips const from arrays to allow
passing slices as mutable ranges to template functions, so it got turned
into `const(void)[]'.

PR d/123419

gcc/d/ChangeLog:

* expr.cc (ExprVisitor::visit (VarExp *)): Adjust assertion.

gcc/testsuite/ChangeLog:

* gdc.dg/pr123419.d: New test.

39 hours agod: Fix ICE: in output_constructor_regular_field, at varasm.cc:5500 [PR123798]
Iain Buclaw [Wed, 28 Jan 2026 21:09:37 +0000 (22:09 +0100)] 
d: Fix ICE: in output_constructor_regular_field, at varasm.cc:5500 [PR123798]

PR d/123798

gcc/d/ChangeLog:

* types.cc (insert_aggregate_bitfield): Set DECL_NONADDRESSABLE_P and
DECL_PADDING_P on bit-field decls.
(finish_aggregate_type): Pass the aligned bit offset to layout_decl.

gcc/testsuite/ChangeLog:

* gdc.dg/pr123798.d: New test.

39 hours agoi386: Use x >> ~y for x >> 31-y [PR36503]
Uros Bizjak [Wed, 28 Jan 2026 20:57:47 +0000 (21:57 +0100)] 
i386: Use x >> ~y for x >> 31-y [PR36503]

x86 targets mask 32-bit shifts with a 5-bit mask (and 64-bit with 6-bit mask),
so they can use x >> ~y instead of x >> 31-y.

The optimization converts:

movl    $31, %ecx
        subl    %esi, %ecx
        sall    %cl, %eax

to:
        notl    %ecx
        sall    %cl, %eax

PR target/36503

gcc/ChangeLog:

* config/i386/i386.md (*<insn:any_shift><mode:SWI48>3_sub):
Also allow operands[3] & (<mode_bitsize>-1) == (<mode_bitsize>-1)
in insn condition. Emit NOT RTX instead of NEG RTX in this case.
(*<insn:any_shift><mode:SWI48>3_sub_1): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr36503-5.c: New test.
* gcc.target/i386/pr36503-6.c: New test.

41 hours agoRISC-V: Fix ABI vector passing on stack and GPR [PR123824].
Robin Dapp [Mon, 26 Jan 2026 16:59:58 +0000 (17:59 +0100)] 
RISC-V: Fix ABI vector passing on stack and GPR [PR123824].

Krister reported that we violate the psABI when one vector argument
halfway fits into a register:

"Aggregates whose total size is no more than 2×XLEN bits are passed in a
pair of registers; if only one register is available, the first XLEN
bits are passed in a register and the remaining bits are passed on the
stack. If no registers are available, the aggregate is passed on the
stack."

This patch fixes this oversight and adds a few tests.

Regtested on rv64gcv_zvl512b.

PR target/123824

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_vls_mode_fits_in_gprs_p): New
helper.
(riscv_pass_vls_aggregate_in_gpr): Use helper and distribute
half-fitting vector to GPR and stack.
(riscv_pass_aggregate_in_vr): Reformat comment.
(riscv_get_arg_info): Use helper.
(riscv_pass_by_reference): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/abi/vls-gpr-1.c: New test.
* gcc.target/riscv/abi/vls-gpr-10.c: New test.
* gcc.target/riscv/abi/vls-gpr-11.c: New test.
* gcc.target/riscv/abi/vls-gpr-12.c: New test.
* gcc.target/riscv/abi/vls-gpr-13.c: New test.
* gcc.target/riscv/abi/vls-gpr-14.c: New test.
* gcc.target/riscv/abi/vls-gpr-2.c: New test.
* gcc.target/riscv/abi/vls-gpr-3.c: New test.
* gcc.target/riscv/abi/vls-gpr-4.c: New test.
* gcc.target/riscv/abi/vls-gpr-5.c: New test.
* gcc.target/riscv/abi/vls-gpr-6.c: New test.
* gcc.target/riscv/abi/vls-gpr-7.c: New test.
* gcc.target/riscv/abi/vls-gpr-8.c: New test.
* gcc.target/riscv/abi/vls-gpr-9.c: New test.

42 hours agoC/C++: Better notification if misused a function like macro [PR102846]
Andrew Pinski [Wed, 15 Oct 2025 00:50:13 +0000 (17:50 -0700)] 
C/C++: Better notification if misused a function like macro [PR102846]

Currently if assert is misused, e.g. like passing to a function like a
function pointer, GCC suggests to include assert.h/cassert. But since
it is already included that is just a bogus suggestion. Instead we should
see if a function-like macro is that same name (in the case of assert it will be),
and inform the user that it is being mis-used.

PR c++/102846
PR c/102846

gcc/c-family/ChangeLog:

* known-headers.cc (macro_like_function_used::macro_like_function_used): New.
(macro_like_function_used::~macro_like_function_used): New.
* known-headers.h (class macro_like_function_used): New class.

gcc/c/ChangeLog:

* c-decl.cc (lookup_name_fuzzy): Lookup function-like macro and
notify of misuse there.

gcc/cp/ChangeLog:

* name-lookup.cc (lookup_name_fuzzy): Lookup function-like macro and
notify of misuse there.

gcc/testsuite/ChangeLog:

* c-c++-common/function-like-macro-1.c: New test.
* c-c++-common/function-like-macro-2.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
43 hours agod: Fix ICE: in expand_asm_stmt, at cfgexpand.cc:3445 [PR121477]
Iain Buclaw [Wed, 28 Jan 2026 17:34:21 +0000 (18:34 +0100)] 
d: Fix ICE: in expand_asm_stmt, at cfgexpand.cc:3445 [PR121477]

The d_mark_addressable routine that sets TREE_ADDRESSABLE in the D
front-end did not handle DECL_BIT_FIELD.

PR d/121477

gcc/d/ChangeLog:

* d-codegen.cc (d_mark_addressable): Give an error if taking the
address of a DECL_BIT_FIELD.

gcc/testsuite/ChangeLog:

* gdc.dg/pr121477.d: New test.

44 hours ago[PR121571, LRA]: Reprocess asm insn with different preferences when there are no...
Vladimir N. Makarov [Wed, 28 Jan 2026 15:52:21 +0000 (10:52 -0500)] 
[PR121571, LRA]: Reprocess asm insn with different preferences when there are no enough regs for the asm-insn

The test for the PR contains asm insn requiring 7 general regs but
three operands can be in memory too ('g' constraint).  There are only
6 available general regs.  IRA in the test case assigns a mask reg to
one pseudo.  When LRA reloads the pseudo assigned to mask reg, it
frees general reg assigned to another pseudo in the asm and assigns
mask reg to another pseudo.  After a few iterations, we have asm all
operands of which are reload pseudos assigned to general regs and one
pseudo assigned to mask reg.  After that LRA can do nothing and
reports "not enough regs".  The patch recognizes situation when there
are not enough regs for an asm insn and makes 2nd attempt to find
reloads when memory for operands with 'g' or 'rm' constraint is
preferred.

gcc/ChangeLog:

PR target/121571
* lra-constraints.cc (process_alt_operands): Reprocess asm insn
when there are no enough regs for the asm-insn.

gcc/testsuite/ChangeLog:

PR target/121571
* gcc.target/i386/pr121571.c: New.

46 hours agod: RVO/NRVO not done when returning a copy constructor
Iain Buclaw [Wed, 28 Jan 2026 11:45:26 +0000 (12:45 +0100)] 
d: RVO/NRVO not done when returning a copy constructor

RVO was already being done when returning a constructor call via a
temporary, which in the front-end AST looks like:

    return S.this((__tmp = {}, &__tmp), args...);

But this was not being done for copy construction calls, which instead
looks like:

    return __copytmp = {}, S.this(&__copytmp, V(1).s), __copytmp;

This pattern is now matched and the temporary gets set up as a
DECL_VALUE_EXPR of the RESULT_DECL.

PR d/123422

gcc/d/ChangeLog:

* expr.cc (ExprVisitor::visit (ArrayLiteralExp *)): Don't add
TARGET_EXPR around constructor.
* toir.cc (IRVisitor::visit (ReturnStatement *)): Recognize more
patterns for return value optimization.

gcc/testsuite/ChangeLog:

* gdc.dg/torture/pr123422.d: New test.

46 hours agoc: Fix parser error on address space names [PR 123583]
Senthil Kumar Selvaraj [Wed, 28 Jan 2026 08:29:55 +0000 (13:59 +0530)] 
c: Fix parser error on address space names [PR 123583]

This patch fixes a regression introduced by PR 67784
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67784) - it broke
recognition of named address space qualifiers (such as __memx on
AVR or __seg_gs on x86) after certain statements.

The fix for PR 67784 attempts to reclassify tokens whose
token->id_kind could have been set incorrectly (because of possibly
wrong scope when peeking ahead). c_parser_maybe_reclassify_token
only skips reclassification for C_ID_CLASSNAME though - a token with
id_kind = C_ID_ADDRSPACE ends up getting reclassified as C_ID_ID,
eventually causing a ": error: '<address space name>' undeclared"
error later down the line.

Rather than explicitly excluding C_ID_ADDRSPACE, the patch modifies
the check to reclassify only tokens kinds that could potentially get
incorrectly classified - C_ID_ID and C_ID_TYPENAME.

Bootstrapped and regtested on x86_64-linux.

PR c/123583

gcc/c/ChangeLog:

* c-parser.cc (c_parser_maybe_reclassify_token): Reclassify only
C_ID_ID and C_ID_TYPENAME tokens.

gcc/testsuite/ChangeLog:

* gcc.target/avr/pr123583.c: New test.
* gcc.target/i386/pr123583.c: New test.

46 hours agomiddle-end/123575 - fix ABS_EXPR folding for vectors
Richard Biener [Wed, 28 Jan 2026 12:39:14 +0000 (13:39 +0100)] 
middle-end/123575 - fix ABS_EXPR folding for vectors

Folding away a conversion requires an optab check for vectors.

PR middle-end/123575
* match.pd (abs ((T)x) -> absu (x)): For vector type
arguments require the resulting operation is supported.

* g++.dg/pr123575.C: New testcase.

2 days agolibstdc++: Default to C++20 in src/experimental/Makefile.am
Jonathan Wakely [Wed, 28 Jan 2026 10:27:07 +0000 (10:27 +0000)] 
libstdc++: Default to C++20 in src/experimental/Makefile.am

r16-7089-gfbde291af66e02 had a stray change to the Makefile.in but
actually we probably should change that directory to use C++20, now that
it's the default. So this updates the Makefile.am, and the Makefile.in
doesn't need to be regenerated now.

libstdc++-v3/ChangeLog:

* src/experimental/Makefile.am: Change AM_CXXFLAGS to use C++20
by default.

2 days agolibstdc++: Do not allow contract26.cc to build without -fcontracts
Jonathan Wakely [Wed, 28 Jan 2026 12:17:14 +0000 (12:17 +0000)] 
libstdc++: Do not allow contract26.cc to build without -fcontracts

It seems prefereable to get a hard error if this file is built
incorrectly, rather than failing to define any symbols.

libstdc++-v3/ChangeLog:

* src/experimental/contract26.cc: Use #error if built without
contracts support enabled.
* include/std/source_location: Remove stray whitespace.

2 days agoipa/111036 - strip nop conversions around __builtin_constant_p arguments
Richard Biener [Wed, 28 Jan 2026 09:55:56 +0000 (10:55 +0100)] 
ipa/111036 - strip nop conversions around __builtin_constant_p arguments

The PR is about inconsistent behavior wrt inline predicate analysis
and later folding of __builtin_constant_p which ultimatively results
from fold_builtin_constant_p stripping nops off its argument but
this not being done on GIMPLE.  The following adds a match.pd pattern
for this.

PR ipa/111036
* match.pd (__builtin_constant_p ((T)x)): Strip nop-conversions
from __builtin_constant_p arguments.

* gcc.dg/torture/pr111036.c: New testcase.

2 days agortl-optimization/106859 - fix location dumping from var-tracking
Richard Biener [Wed, 28 Jan 2026 09:16:29 +0000 (10:16 +0100)] 
rtl-optimization/106859 - fix location dumping from var-tracking

We currently ICE when the locations include one without a setting insn.
Looking at cselib this seems to be a supported state so the following
arranges for this and dumps -1 as UID.

PR rtl-optimization/106859
* var-tracking.cc (val_store): Dump -1 as UID if setting_insn
is NULL.

2 days agotree-optimization/123537 - fix too permissive .REDUC_* folding
Richard Biener [Wed, 28 Jan 2026 09:04:45 +0000 (10:04 +0100)] 
tree-optimization/123537 - fix too permissive .REDUC_* folding

The following restricts the allowed conversions to those maintaining
the element type size.

PR tree-optimization/123537
* match.pd (REDUC (@0 & @1) -> @0[I] & @1[I]): Restrict
allowed conversions.

* gcc.dg/pr123537.c: New testcase.

2 days agoaarch64: FEAT_SVE_BFSCALE support
Karl Meakin [Thu, 6 Nov 2025 16:34:06 +0000 (16:34 +0000)] 
aarch64: FEAT_SVE_BFSCALE support

Add support for the `SVE_BFSCALE` architecture extension.

gcc/ChangeLog:

* doc/invoke.texi: Document `+sve-bfscale` flag.
* config/aarch64/aarch64.h (TARGET_SVE_BFSCALE): New macro.
* config/aarch64/aarch64-c.cc (aarch64_update_cpp_builtins):
Define `__AARCH64_FEATURE_SVE_BFSCALE`.
* config/aarch64/aarch64-sve-builtins-base.cc: Skip constant
folding for floating-point or unpredicated multiplications.
* config/aarch64/aarch64-sve-builtins-sve2.def: New `SVE_FUNCTION`s.
* config/aarch64/aarch64-sve.md: Modify insns for
`SVE_COND_FP_BINARY_INT` to handle BF16 modes.
* config/aarch64/aarch64-sve2.md
(@aarch64_sve_<optab><mode>, @aarch64_sve_<optab><mode>_single): New insn for `BFSCALE`.
Modify insns for `UNSPEC_FSCALE` to handle BF16 modes.
* config/aarch64/iterators.md (SVE_FULL_F_SCALAR): Add `VNx8BF` to iterator.
(SVE_FULL_F_BFSCALE): New iterator.
(SVE_Fx24_BFSCALE): New iterator.
(SVE_BFx24): New iterator.
(UNSPEC_FMUL): New unspec.
(V_INT_EQUIV): Add entries for BF16 modes.
(b): Add entries for scalar float modes.
(is_bf16): Add entries for BF16 modes and reformat.
(SVSCALE_SINGLE_INTARG): Likewise.
(SVSCALE_INTARG): Likewise.
(SVE_FP_MULL): New iterator.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp: Add `sve-bfscale` to `sve_exts`.
* gcc.target/aarch64/pragma_cpp_predefs_4.c: Add test for `__ARM_SVE_FEATURE_BFSCALE`.
* gcc.target/aarch64/sme2/acle-asm/mul_bf16_x2.c: New test.
* gcc.target/aarch64/sme2/acle-asm/mul_bf16_x4.c: New test.
* gcc.target/aarch64/sme2/acle-asm/scale_bf16_x2.c: New test.
* gcc.target/aarch64/sme2/acle-asm/scale_bf16_x4.c: New test.
* gcc.target/aarch64/sve/acle/asm/scale_bf16.c: New test.
* gcc.target/aarch64/sve/acle/general-c/bfscale.c: New test.

2 days agoexpand: Increase stack slot alignment for STRICT_ALIGNMENT targets [PR123447]
Pengfei Li [Mon, 26 Jan 2026 16:09:42 +0000 (16:09 +0000)] 
expand: Increase stack slot alignment for STRICT_ALIGNMENT targets [PR123447]

PR123447 reports an ICE on AArch64 with "-O2 -mstrict-align" in subreg
lowering while decomposing the following multiword store RTL:

(insn 12 11 13 2 (set (mem/c:XI (plus:DI (reg/f:DI 64 sfp)
                (const_int -96 [0xffffffffffffffa0])) [0  S64 A8])
        (reg:XI 103)) "a.c":14:6 4861 {*aarch64_movxi}

This RTL originates from expanding the following GIMPLE statement:

_1 = BIT_FIELD_REF <{ 9, -64497, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 256, 0>;

The operand is a constant _Decimal64 vector with BLKmode, so expand has
to materialize it in memory. Current get_object_alignment() returns a
1-byte guaranteed alignment for this VECTOR_CST, as indicated by A8 in
the RTL dump above. However, with "-mstrict-align" enabled, later subreg
lowering pass expects at least 64-bit alignment when it constructs a new
RTX to decompose the store into pieces. Because the original alignment
is too small, simplify_gen_subreg() returns NULL_RTX and an assertion is
hit.

This patch increases the stack slot alignment for STRICT_ALIGNMENT
targets, when the operand is forced into memory. The increased alignment
is capped by MAX_SUPPORTED_STACK_ALIGNMENT so it won't be too large.

Bootstrapped and tested on aarch64-linux-gnu and x86_64-linux-gnu.

gcc/ChangeLog:

PR middle-end/123447
* expr.cc (expand_expr_real_1): Increase stack slot alignment
for STRICT_ALIGNMENT targets.

gcc/testsuite/ChangeLog:

PR middle-end/123447
* gcc.dg/pr123447.c: New test.

2 days agooptions: Fix a missing period on and option message.
Iain Sandoe [Wed, 28 Jan 2026 11:13:56 +0000 (11:13 +0000)] 
options: Fix a missing period on and option message.

As per subject.

gcc/c-family/ChangeLog:

* c.opt: Append a period to the message for
-fcontracts-client-check=.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2 days agovect: reconstruct vectype for non scalar masks
Andre Vieira [Wed, 28 Jan 2026 11:11:14 +0000 (11:11 +0000)] 
vect: reconstruct vectype for non scalar masks

This reconstructs the masks vectype based on the the type set by the backend
for any non scalar masks, which resolves the ICE caused by the sve type
attribute in SVE types used for simdclones.

gcc/ChangeLog:

PR target/123016
* tree-vect-stmts.cc (vectorizable_simd_clone_call): use
'build_truth_vector_type_for_mode' to reconstruct mask's vectype for
non-scalar masks.

gcc/testsuite/ChangeLog:

* gfortran.dg/vect/pr123016.f90: New test.

2 days agolibstdc++: Disable false positive middle end warnings in std::shared_ptr [PR122197]
Jonathan Wakely [Fri, 23 Jan 2026 14:25:03 +0000 (14:25 +0000)] 
libstdc++: Disable false positive middle end warnings in std::shared_ptr [PR122197]

Speculative devirtualization in GCC 16 causes some false positive
warnings for unreachable paths. Use diagnostic pragmas to suppress
those warnings until the regression is fixed.

libstdc++-v3/ChangeLog:

PR tree-optimization/122197
* include/bits/shared_ptr_base.h (~_Sp_counted_deleter): Use
diagnostic pragam to disable -Wfree-nonheap-object false
positive.
(~_Sp_counted_ptr_inplace): Likewise for -Warray-bounds false
positive.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 days agolibstdc++: Avoid -Wtype-limits warnings in locale/gnu/ctype_members.cc
Jonathan Wakely [Fri, 23 Jan 2026 14:04:26 +0000 (14:04 +0000)] 
libstdc++: Avoid -Wtype-limits warnings in locale/gnu/ctype_members.cc

On targets where wchar_t is unsigned we get warnings during the
libstdc++ build:

ctype_members.cc: In member function ‘virtual char std::ctype<wchar_t>::do_narrow(wchar_t, char) const’:
ctype_members.cc:224:14: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
  224 |     if (__wc >= 0 && __wc < 128 && _M_narrow_ok)
      |         ~~~~~^~~~
ctype_members.cc: In member function ‘virtual const wchar_t* std::ctype<wchar_t>::do_narrow(const wchar_t*, const wchar_t*, char, char*) const’:
ctype_members.cc:247:21: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
  247 |           if (*__lo >= 0 && *__lo < 128)
      |               ~~~~~~^~~~

This introduces a helper function that converts the wchar_t to an
unsigned type and then does the comparison. This means the comparison is
not target-dependent, and there's no more warning.

libstdc++-v3/ChangeLog:

* config/locale/gnu/ctype_members.cc (use_table): New function.
(ctype<wchar_t>::do_narrow): Use use_table.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 days agoc++: Implement C++23 P2246R1 - Character encoding of diagnostic text
Jakub Jelinek [Wed, 28 Jan 2026 09:23:20 +0000 (10:23 +0100)] 
c++: Implement C++23 P2246R1 - Character encoding of diagnostic text

The following patch attempts to implement the C++23 P2246R1
Character encoding of diagnostic text paper.
Initially I thought there is nothing to do, but this patch shows
that there is (and I wonder if we shouldn't backport it to release
branches).  Though the patch is on top of the cpp_translate_string
libcpp addition from the reflection patchset (though, that is
quite small change that could be backported too).

We have various different encodings in play in GCC.
There is -finput-charset= defaulting to SOURCE_CHARSET, which is
almost always UTF-8 (but in theory could be UTF-EBCDIC if that really
works).  libcpp converts source from the input charset to SOURCE_CHARSET
initially.  And then we have -fexec-charset=, again defaulting to
SOURCE_CHARSET, -fwide-exec-charset=, then UTF-8, UTF-16 and UTF-32
for u8, u and U string literals and constants and finally user uses
some character set in the terminal in which gcc is running.

Now, I think we mostly just emit diagnostics in SOURCE_CHARSET,
there is identifier_to_locale function which uses UCNs if LC_CTYPE
CODESET is not UTF-8-ish, but I think we don't use it all the time.
Even then, there is really no support for outputing from SOURCE_CHARSET
UTF-8 to non-ASCII compatible terminal charsets.
So for now let's pretend that we are emitting diagnostics to UTF-8
capable terminal.

When reporting errors about identifiers in the source (which are in
SOURCE_CHARSET), we just emit those.  The paper talks about
deprecated & nodiscard attribute msgs, static_assert, #error (and for
C++26 it would talk about #warning, delete (reason) and static_assert
with constexpr user messages).  #error/#warning works fine on UTF-8
terminals, delete (reason) too (we don't translate the string literal
from SOURCE_CHARSET to exec-charset in that case), static_assert
with a string literal too (again, notranslate), __attribute__ form
of deprecated attribute too (again, !parser->translate_strings_p).
What doesn't work properly are C++11 attributes (standard or gnu::),
we do translate those to exec charset, except for C++26
standard deprecated/nodiscard (which aren't translated).  And static_assert
with user messages doesn't work, those really have to be in exec-charset
because we have no control on how user constructs the messages during
constexpr evaluation.

So, this patch for C++11 attributes if they have the first argument
of a CPP_STRING temporarily disables translation of that string, which
fixes [[gnu::deprecated ("foo")]], [[gnu::unavailable ("foo")]]
and for C++ < 26 also [[deprecated ("foo")]] and [[nodiscard ("foo")]].
And another change is convert back from exec-charset to SOURCE_CHARSET
the custom user static_assert messages (and also inline asm strings).
For diagnostics without this patch worst case we show garbage, but
for inline asm we actually then fail to assemble stuff when users
use the constexpr created string views with non-ASCII exec charsets.

2026-01-28  Jakub Jelinek  <jakub@redhat.com>

PR c++/102613
* parser.cc: Implement C++23 P2246R1 - Character encoding of
diagnostic text.
(cp_parser_parenthesized_expression_list): For std attribute
argument where the first argument is CPP_STRING, ensure the
string is not translated.
* semantics.cc: Include c-family/c-pragma.h.
(cexpr_str::extract): Use cpp_translate_string to translate
string from ordinary literal encoding to SOURCE_CHARSET.

* g++.dg/cpp1z/constexpr-asm-6.C: New test.
* g++.dg/cpp23/charset2.C: New test.
* g++.dg/cpp23/charset3.C: New test.
* g++.dg/cpp23/charset4.C: New test.
* g++.dg/cpp23/charset5.C: New test.

2 days agoc++: Implement part of CWG3044
Jakub Jelinek [Wed, 28 Jan 2026 09:08:14 +0000 (10:08 +0100)] 
c++: Implement part of CWG3044

The following patch implements part of CWG3044 resolution.
Small part of it has been implemented already earlier (using ptrdiff_t
as the type of i rather than leaving that unspecified), part of it
can't be implemented until constexpr references are supported
(removal of static keywords), but the final CWG3044 resolution
wording states that it is begin + decltype(begin - begin){i}
rather than just begin + i.

The following patch implements that.

It broke a bunch of tests because I haven't implemented operator -
for those. fixed that too (plus added a testcase expected to fail
now with operator - not implemented).

2026-01-28  Jakub Jelinek  <jakub@redhat.com>

* pt.cc (finish_expansion_stmt): Implement part of CWG3044.
Add to begin decltype(begin - begin){i} with std::ptrdiff_t
i instead of just i.

* g++.dg/cpp26/expansion-stmt1.C (A::operator -, C::operator -): New.
* g++.dg/cpp26/expansion-stmt2.C (A::operator -, C::operator -): New.
* g++.dg/cpp26/expansion-stmt3.C (A::operator -, C::operator -): New.
* g++.dg/cpp26/expansion-stmt18.C  (A::operator -): New.
* g++.dg/cpp26/expansion-stmt25.C: New test.

2 days agoc, c++: Use c*_build_qualified_type instead of build_qualified_type from within build...
Jakub Jelinek [Wed, 28 Jan 2026 08:50:26 +0000 (09:50 +0100)] 
c, c++: Use c*_build_qualified_type instead of build_qualified_type from within build_type_attribute_qual_variant [PR101312]

The following testcases ICE in various ways because of the interaction
between attributes and C/C++ c*_build_qualified_type behavior on array
types and how they affect TYPE_CANONICAL.
For array types, C/C++ moves qualifiers to the element type, but
when a cv qualified array build that way has an attribute applied to it,
we call build_type_attribute_qual_variant and that doesn't have that
handling and builds non-qualified version of the array type with qualified
element type and puts it as TYPE_CANONICAL of the type with attribute
which is a distinct type copy.

The following patch adds a langhook, so that even
build_type_attribute_qual_variant uses for C/C++ for array types
c*_build_qualified_type.
There has been already a related langhook
lang_hooks.types.copy_lang_qualifiers used solely for C++, so instead
of adding another langhook this adds a combined langhook for those two,
where C can handle array types specially and otherwise build_qualified_type,
while C++ ditto + do the function/method type modifiers propagation as
well.

Unfortunately there is a terrible array_as_string hack used by some
of the middle-end warnings which creates some array type with sometimes
an artificial attribute and then has hacks in the c-family type printing
to tweak the printed form, and this hack relies on the previous behavior
of build_type_attribute_qual_variant where it even for C/C++ kept
element type quals unmodified and added normally invalid quals on the
array type itself.  The patch stops using build_type_attribute_qual_variant
for that and instead uses copy_node on the type and adjusts the quals and
adds the attribute to the copy and then ggc_frees it.  Also it renames the
attribute from "array" to "array " to make it clear it is internal
attribute users can't specify even in vendor attributes.

2026-01-28  Jakub Jelinek  <jakub@redhat.com>

PR c/101312
gcc/
* langhooks.h (struct lang_hooks_for_types): Remove
copy_lang_qualifiers.  Add build_lang_qualified_type.
* langhooks.cc (lhd_build_lang_qualified_type): New function.
* langhooks-def.h (lhd_build_lang_qualified_type): Declare.
(LANG_HOOKS_COPY_LANG_QUALIFIERS): Remove.
(LANG_HOOKS_BUILD_LANG_QUALIFIED_TYPE): Add.
(LANG_HOOKS_FOR_TYPES_INITIALIZER): Use
LANG_HOOKS_BUILD_LANG_QUALIFIED_TYPE instead of
LANG_HOOKS_COPY_LANG_QUALIFIERS.
* attribs.cc (build_type_attribute_qual_variant): Use
lang_hooks.types.build_lang_qualified_type instead of
build_qualified_type and/or build_qualified_type with
optional lang_hooks.types.copy_lang_qualifiers call.
(attr_access::array_as_string): Use "array " attribute instead of
"array".  If attribute has been created or intended quals differ
from quals of build_array_type, use copy_node and adjust quals and
attributes on the copy, print and then ggc_free.
gcc/c-family/
* c-pretty-print.cc (c_pretty_printer::direct_abstract_declarator):
Look up "array " attribute instead of "array".
gcc/c/
* c-tree.h (c_build_lang_qualified_type): Declare.
* c-objc-common.h (LANG_HOOKS_BUILD_LANG_QUALIFIED_TYPE): Define.
* c-objc-common.cc (c_build_lang_qualified_type): New function.
gcc/cp/
* cp-tree.h (cxx_build_lang_qualified_type): Declare.
* cp-objcp-common.h (LANG_HOOKS_COPY_LANG_QUALIFIERS): Remove.
(LANG_HOOKS_BUILD_LANG_QUALIFIED_TYPE): Define.
* tree.cc (cxx_build_lang_qualified_type): New function.
gcc/testsuite/
* c-c++-common/pr101312-1.c: New test.
* c-c++-common/pr101312-2.c: New test.

2 days agofree-lang-data: Remove C++ annotations [PR123837]
Jakub Jelinek [Wed, 28 Jan 2026 08:48:10 +0000 (09:48 +0100)] 
free-lang-data: Remove C++ annotations [PR123837]

As mentioned in the PR and reproduced on the testcase, we ICE during
LTO streaming because C++ annotation arguments can contain trees LTO
streaming doesn't handle.
We don't really need annotations when the FE is done with the whole
TU, annotations are always TU local and not exposed to the rest and
used in consteval only stuff, so the following patch just removes
all annotations at free-lang-data time.

2026-01-28  Jakub Jelinek  <jakub@redhat.com>

PR c++/123837
* ipa-free-lang-data.cc (find_decls_types_r): Remove C++ annotations
from {DECL,TYPE}_ATRIBUTES.

* g++.dg/reflect/annotations9.C: New test.

2 days agowaccess: Fix handling of extended builtin types [PR123849]
Andrew Pinski [Wed, 28 Jan 2026 00:55:45 +0000 (16:55 -0800)] 
waccess: Fix handling of extended builtin types [PR123849]

So DEMANGLE_COMPONENT_EXTENDED_BUILTIN_TYPE is not being handled
from the demangler in new_delete_mismatch_p. This adds the handling,
just like DEMANGLE_COMPONENT_BUILTIN_TYPE as there is no simple way
to compare the type you have to call into the demanager to do it
instead.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/123849

gcc/ChangeLog:

* gimple-ssa-warn-access.cc (new_delete_mismatch_p): Handle
DEMANGLE_COMPONENT_EXTENDED_BUILTIN_TYPE like DEMANGLE_COMPONENT_BUILTIN_TYPE.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wmismatched-new-delete-11.C: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 days agotree-optimization/110043 - avoid overflow in pointer-query
Richard Biener [Tue, 27 Jan 2026 14:43:53 +0000 (15:43 +0100)] 
tree-optimization/110043 - avoid overflow in pointer-query

pointer-query is built around using offset_int to avoid needing
to deal with overflow.  This falls apart when trying to analyze
array accesses indexed by __int128.  So don't.

PR tree-optimization/110043
* pointer-query.cc (get_offset_range): Fail for integer
types with precision larger than ptrdiff_type_node.

* gcc.dg/torture/pr110043.c: New testcase.

2 days agoi386: Drop mask subst for define_insn_and_split of extend [PR123779]
Hongyu Wang [Tue, 27 Jan 2026 07:38:12 +0000 (15:38 +0800)] 
i386: Drop mask subst for define_insn_and_split of extend [PR123779]

For define_insn_and_split, the subst applied only for the define_insn
part, not the define_split part. So several define_insn_and_split with
mask_name is actually producing non-splitable insns, resulting ICE in
lra. Separate them to define_insn_and_split for mask/nonmask variants
to generate corresponding splitters.

PR target/123779

gcc/ChangeLog:

* config/i386/sse.md (*sse4_1_<code>v8qiv8hi2<mask_name>_2):
Rename to ...
(*sse4_1_<code>v8qiv8hi2_2): ... this, and drop mask conditions.
(*avx2_<code>v8qiv8si2<mask_name>_2): Rename to ...
(*avx2_<code>v8qiv8si2_2): ... this, and likewise.
(*sse4_1_<code>v4qiv4si2<mask_name>_2): Rename to ...
(*sse4_1_<code>v4qiv4si2_2): ... this, and likewise.
(*sse4_1_<code>v4hiv4si2<mask_name>_2): Rename to ...
(*sse4_1_<code>v4hiv4si2_2): ... this, and likewise.
(*avx2_<code>v4qiv4di2<mask_name>_2): Rename to ...
(*avx2_<code>v4qiv4di2_2): ... this, and likewise.
(*avx2_<code>v4hiv4di2<mask_name>_2): Rename to ...
(*avx2_<code>v4hiv4di2_2): ... this, and likewise.
(*sse4_1_<code>v2hiv2di2<mask_name>_2): Rename to ...
(*sse4_1_<code>v2hiv2di2_2): ... this, and likewise.
(*sse4_1_<code>v2siv2di2<mask_name>_2): Rename to ...
(*sse4_1_<code>v2siv2di2_2): ... this, and likewise.
(*avx512f_<code>v8qiv8di2<mask_name>_2): Rename to ...
(*avx512f_<code>v8qiv8di2_2): ... this.
(*avx512vl_<code>v8qiv8hi2_mask_2): New define_insn_and_split.
(*avx512vl_<code>v8qiv8si2_mask_2): Likewise.
(*avx512vl_<code>v4qiv4si2_mask_2): Likewise.
(*avx512vl_<code>v4hiv4si2_mask_2): Likewise.
(*avx512f_<code>v8qiv8di2_mask_2): Likewise.
(*avx512vl_<code>v4qiv4di2_mask_2): Likewise.
(*avx512vl_<code>v4hiv4di2_mask_2): Likewise.
(*avx512vl_<code>v2hiv2di2_mask_2): Likewise.
(*avx512vl_<code>v2siv2di2_mask_2): Likewise.

gcc/testsuite/ChangeLog:

* g++.target/i386/pr123779.C: New test.

2 days agolibstdc++: Implement std::atomic::fetch_min/max
Soumya AR [Fri, 16 Jan 2026 05:20:50 +0000 (05:20 +0000)] 
libstdc++: Implement std::atomic::fetch_min/max

This patch extends libstdc++ to implement C++26's atomic fetch min/max
operations.

The __atomic_fetch_minmaxable concept checks if __atomic_fetch_min and
__atomic_fetch_max builtins are implemented by the compiler. If not, fall back
to a CAS loop.

This patch was bootstrapped and regtested on aarch64-linux-gnu and
x86_64-linux-gnu, no regression.

Signed-off-by: Soumya AR <soumyaa@nvidia.com>
libstdc++-v3/ChangeLog:

* include/bits/atomic_base.h:
Add fetch_min and fetch_max memberfunctions.
* include/bits/version.def:
Add __cpp_lib_atomic_min_max feature test macro.
* include/bits/version.h (defined): Regenerate.
* include/std/atomic: Extend for fetch_min/max non-member functions.
* src/c++23/std.cc.in: Export atomic_fetch_min, atomic_fetch_max,
atomic_fetch_min_explicit, atomic_fetch_max_explicit.
* testsuite/29_atomics/atomic_integral/nonmembers_fetch_minmax.cc:
New test.
* testsuite/29_atomics/atomic_ref/integral_fetch_minmax.cc: New test.

2 days agoc++: Error diagnostics for pointer-to-member type [PR38612]
Alex Yesmanchyk [Wed, 28 Jan 2026 02:07:07 +0000 (21:07 -0500)] 
c++: Error diagnostics for pointer-to-member type [PR38612]

Consider the following ptrtomem4.C file.

Now for test1 and test3 it produces the following errors:

ptrtomem4.C: In function 'int test1(int Base::*, X*)':
ptrtomem4.C:8:21: error: pointer to member type 'int Base::*' incompatible with incomplete object type 'X'
ptrtomem4.C: In function 'int test3(int Base::*, Y*)':
ptrtomem4.C:22:21: error: pointer to member type 'int Base::*' incompatible with object type 'Y' because 'Y' is not derived from 'Base'

PR c++/38612

gcc/cp/ChangeLog:

* typeck2.cc (build_m_component_ref): Improve class mismatch
diagnostic.

gcc/testsuite/ChangeLog:

* g++.dg/diagnostic/ptrtomem4.C: New test.

Signed-off-by: Alex Yesmanchyk <aliaksandr.yesmanchyk@gmail.com>
Co-authored-by: Jason Merrill <jason@redhat.com>
2 days agoc++/modules: Handle reflection SPLICE_SCOPE tree node
vspefs [Mon, 26 Jan 2026 20:56:52 +0000 (20:56 +0000)] 
c++/modules: Handle reflection SPLICE_SCOPE tree node

This patch adds support for serializing and deserializing SPLICE_SCOPE trees
in C++20 modules implementation. SPLICE_SCOPE is introduced by C++26
reflection, notably used for dependent splice types, thus needing to be
exported/imported as part of the module interface. Not handling SPLICE_SCOPE
leads to ICE.

This patch also includes 2 simple test cases: one for exporting splice scope
types and another for importing them.

gcc/cp/

* module.cc (trees_out::type_node): Add case for SPLICE_SCOPE.
(trees_in::tree_node): Add case for SPLICE_SCOPE.

gcc/testsuite/

* g++.dg/modules/splice-scope-tree_a.C: New test.
* g++.dg/modules/splice-scope-tree_b.C: New test.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
2 days agoc++: Fix false positive with -Wunused [PR114450]
Lucas Chollet [Mon, 26 Jan 2026 10:16:53 +0000 (18:16 +0800)] 
c++: Fix false positive with -Wunused [PR114450]

The patch fixes a bug in the detection of the usage of static variables
inside generic lambdas.  The comment in finish_id_expression_1 already
mentions this case, but the code didn't actually handle it.

PR c++/114450

gcc/cp/ChangeLog:

* lambda.cc (generic_lambda_fn_p): Handle null argument.
* semantics.cc (finish_id_expression_1): Check for generic lambda.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wunused-var-42.C: New test.

Co-authored-by: Jason Merrill <jason@redhat.com>
2 days agoc++: -Wunused-value on ternary indexed by non-constant
Johannes Altmanninger [Mon, 26 Jan 2026 10:16:53 +0000 (18:16 +0800)] 
c++: -Wunused-value on ternary indexed by non-constant

On this expression:

(true ? "a" : "b")[index()]

"g++ -Wunused-value" incorrectly produces

warning: left operand of comma operator has no effect [-Wunused-value]

From the -fdump-tree-original output:

if ((void) SAVE_EXPR <index ()>, 1)
  {
    (void) "a"[SAVE_EXPR <index ()>];
  }
else
  {
    (void) "b"[SAVE_EXPR <index ()>];
  }

Observe that we evaluate index() (and save it) before evaluating the
ternary expression.  Since "(void) SAVE_EXPR <index ()>" is ostensibly
side-effect free, we get this warning.  Since SAVE_EXPR is not useless,
this is a false positive. Also the comma operator compiler-generated,
so warning about it is wrong.

Suppress this warning for this implicit expression. Test that the
warning is gone for "$ternary[index()]" but we still warn on cases like
"$ternary[(1, 0)]".

gcc/cp/ChangeLog:

* typeck.cc (cp_build_array_ref): Suppress unused-value
warning for implicit comma expression.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wunused-value-2.C: New test.

Signed-off-by: Johannes Altmanninger <aclopte@gmail.com>
Co-authored-by: Jason Merrill <jason@redhat.com>
2 days agoc++, contracts: Add caller-side contract checks, and controls.
Nina Ranns [Thu, 28 Aug 2025 16:56:56 +0000 (17:56 +0100)] 
c++, contracts: Add caller-side contract checks, and controls.

This a (currently GCC-only) extension that implements caller-side
checking of pre and post conditions.  It is completely in scope
with the C++26 CDIS wording, but is not mandated.

The implementation here allows applying caller or callee-side
checking independently.

gcc/c-family/ChangeLog:

* c.opt (fcontracts-definition-check=,
fcontracts-client-check=): New.
* c.opt.urls: Regenerate.

gcc/cp/ChangeLog:

* call.cc (build_cxx_call): Where enabled, wrap calls to
functions with contract specifiers.
* contracts.cc (enum contract_match_kind): Move to contracts
header.
(build_contract_condition_function): Copy caller-side wrapper
state.
(set_contract_wrapper_function, get_contract_wrapper_function,
get_orig_func_for_wrapper, contracts_fixup_cdtorname,
build_contract_wrapper_function,
get_or_create_contract_wrapper_function): New.
(start_function_contracts): Handle caller-side wrappers.
(maybe_apply_function_contracts): Likewise.
(copy_and_remap_contracts): Likewise.
(should_contract_wrap_call, maybe_contract_wrap_call,
define_contract_wrapper_func, emit_contract_wrapper_func): New.
(finish_function_contracts): Handle caller-side wrappers.
(get_src_loc_impl_ptr): Likewise.
* contracts.h (DECL_IS_WRAPPER_FN_P): New.
(enum contract_match_kind): Moved from contracts.cc.
(copy_and_remap_contracts): Allow selection on the specific
contract kind.
(maybe_contract_wrap_call, emit_contract_wrapper_func): New.
(set_decl_contracts): Delete dead code.
* cp-tree.h (struct lang_decl_fn): Add wrapper function bit.
(DECL_CONTRACT_WRAPPER): New.
* decl2.cc (c_parse_final_cleanups): Emit wrappers.

gcc/ChangeLog:

* doc/invoke.texi: Document -fcontracts-client-check= and
-fcontracts-definition-check=.

gcc/testsuite/ChangeLog:

* g++.dg/contracts/cpp26/callerside-checks/callerside-checks-all.C: New test.
* g++.dg/contracts/cpp26/callerside-checks/callerside-checks-non-trivial.C: New test.
* g++.dg/contracts/cpp26/callerside-checks/callerside-checks-none.C: New test.
* g++.dg/contracts/cpp26/callerside-checks/callerside-checks-pre.C: New test.
* g++.dg/contracts/cpp26/callerside-checks/ctor.C: New test.
* g++.dg/contracts/cpp26/callerside-checks/freefunc-noexcept-post.C: New test.
* g++.dg/contracts/cpp26/callerside-checks/freefunc-noexcept-pre.C: New test.
* g++.dg/contracts/cpp26/definition-checks/contract-assert-no-def-check.C: New test.
* g++.dg/contracts/cpp26/non-trivial-ice.C: New test.

Co-Authored-by: Iain Sandoe <iain@sandoe.co.uk>
Co-Authored-by: Ville Voutilainen <ville.voutilainen@gmail.com>
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2 days agoc++, contracts: Allow contract checks as outlined functions.
Nina Ranns [Fri, 31 Oct 2025 00:20:43 +0000 (00:20 +0000)] 
c++, contracts: Allow contract checks as outlined functions.

In this variant of the contracts handling, we emit the contract
checks for pre and post conditions into small TU-local functions
that are then called in the relevant positions at the start of
the function and on each return edge (as a try-finally).

The rationale for adding this is that it is possible to treat
these outlined functions specially (for example, with different
(potentially fixed) optimisation settings from the code body.
Doing this can be a mechanism to work around cases where
optimisation of the contract conditions (or some function that
they might call) can lead to the elision of checks.

In order to pass parameters through to these small outlined
functions, we need similar functionality to that used for thunk
calls with respect copies of non-trivial values.  We are calling
this a "thunk-like" call, since none of the adjustments are
relevant here.

gcc/c-family/ChangeLog:

* c.opt (fcontract-checks-outlined,
fcontract-disable-optimized-checks): New.
* c.opt.urls: Regenerate.

gcc/cp/ChangeLog:

* contracts.cc (handle_contracts_p): Check that we are
handling an original function, not an outlined check.
(set_precondition_function, set_postcondition_function,
get_orig_for_outlined, contracts_fixup_name,
build_contract_condition_function,
build_precondition_function, build_postcondition_function,
build_contract_function_decls): New.
(start_function_contracts): Update for the case that we
outline the contract checks.
(build_arg_list, build_thunk_like_call,
add_pre_condition_fn_call,
get_postcondition_result_parameter,
add_post_condition_fn_call): New.
(apply_preconditions): Allow outlined checks.
(apply_postconditions): Likewise.
(get_precondition_function, get_postcondition_function,
set_contract_functions, remap_and_emit_conditions,
finish_function_contracts): New.
(get_src_loc_impl_ptr): Handle outlined checks.
(build_contract_check): Likewise.
* contracts.h (DECL_PRE_FN, DECL_POST_FN,
DECL_IS_PRE_FN_P, DECL_IS_POST_FN_P,
get_precondition_function, get_postcondition_function,
get_orig_for_outlined, finish_function_contracts,
set_contract_functions): New.
* cp-tree.h (enum lang_contract_helper): New.
(struct lang_decl_fn): Add contract helper enum.
(CONTRACT_HELPER): New.
(mangle_decl_string): New.
* decl.cc (finish_function): Emit outlined checks when
in use.
* module.cc (trees_out::fn_parms_init): Stream pre and post
outlined checks.
(trees_in::fn_parms_init): Reload pre and post outlined checks.
(check_mergeable_decl): Handle pre and post outlined functions.
(module_state_config::get_dialect): Add contracts dialect.

gcc/ChangeLog:

* doc/invoke.texi: Document -fcontract-checks-outlined and
-fcontract-disable-optimized-checks.

gcc/testsuite/ChangeLog:

* g++.dg/contracts/cpp26/outline-checks/freefunc-noexcept-post.C: New test.
* g++.dg/contracts/cpp26/outline-checks/freefunc-noexcept-pre.C: New test.
* g++.dg/contracts/cpp26/outline-checks/func-noexcept-assert.C: New test.
* g++.dg/contracts/cpp26/outline-checks/memberfunc-noexcept-post.C: New test.
* g++.dg/contracts/cpp26/outline-checks/memberfunc-noexcept-pre.C: New test.
* g++.dg/contracts/cpp26/empty-nt-param.C: Test with outlined checks.

Co-Authored-by: Iain Sandoe <iain@sandoe.co.uk>
Co-Authored-by: Ville Voutilainen <ville.voutilainen@gmail.com>
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2 days agoc++, contracts: Add tests for C++26 contracts.
Iain Sandoe [Sun, 19 Oct 2025 14:49:31 +0000 (15:49 +0100)] 
c++, contracts: Add tests for C++26 contracts.

This adds in a set of tests for the C++26 contracts, and also ensures that
cases that previously failed with attribute syntax continue to work as
expected with the revised C++26 syntax.

PR c++/113968
PR c++/110871
PR c++/110872

gcc/testsuite/ChangeLog:

* g++.dg/contracts/cpp26/BZ121936-workaround-noipa.C: New test.
* g++.dg/contracts/cpp26/assertion-statement-errors.C: New test.
* g++.dg/contracts/cpp26/assertion-statement.C: New test.
* g++.dg/contracts/cpp26/basic.contract.eval.p11-observe.C: New test.
* g++.dg/contracts/cpp26/basic.contract.eval.p14.C: New test.
* g++.dg/contracts/cpp26/basic.contract.eval.p17-2.C: New test.
* g++.dg/contracts/cpp26/basic.contract.eval.p17-3.C: New test.
* g++.dg/contracts/cpp26/basic.contract.eval.p17-4.C: New test.
* g++.dg/contracts/cpp26/basic.contract.eval.p17-5.C: New test.
* g++.dg/contracts/cpp26/basic.contract.eval.p17-SMF-post.C: New test.
* g++.dg/contracts/cpp26/basic.contract.eval.p17-SMF-pre.C: New test.
* g++.dg/contracts/cpp26/basic.contract.eval.p17-SMF2.C: New test.
* g++.dg/contracts/cpp26/basic.contract.eval.p17-SMF3.C: New test.
* g++.dg/contracts/cpp26/basic.contract.eval.p17-SMF4.C: New test.
* g++.dg/contracts/cpp26/basic.contract.eval.p17.C: New test.
* g++.dg/contracts/cpp26/basic.contract.eval.p4-error.C: New test.
* g++.dg/contracts/cpp26/basic.contract.eval.p4.C: New test.
* g++.dg/contracts/cpp26/basic.contract.eval.p6.C: New test.
* g++.dg/contracts/cpp26/basic.contract.eval.p6.observe.C: New test.
* g++.dg/contracts/cpp26/basic.scope.contract.p1.C: New test.
* g++.dg/contracts/cpp26/basic.scope.contract.p2.1.C: New test.
* g++.dg/contracts/cpp26/contract-assert-run.C: New test.
* g++.dg/contracts/cpp26/contract-assert-warn-attributes.C: New test.
* g++.dg/contracts/cpp26/contract-violation-noexcept.C: New test.
* g++.dg/contracts/cpp26/contract-violation-noexcept2.C: New test.
* g++.dg/contracts/cpp26/contract_genericize.C: New test.
* g++.dg/contracts/cpp26/contracts-friend1.C: New test.
* g++.dg/contracts/cpp26/contracts-nested-class1.C: New test.
* g++.dg/contracts/cpp26/contracts-nested-class2.C: New test.
* g++.dg/contracts/cpp26/contracts-tmpl-spec2.C: New test.
* g++.dg/contracts/cpp26/dcl.contract.func.p4.C: New test.
* g++.dg/contracts/cpp26/dcl.contract.func.p6.C: New test.
* g++.dg/contracts/cpp26/dcl.contract.res.p1-NT.C: New test.
* g++.dg/contracts/cpp26/dcl.contract.res.p1.C: New test.
* g++.dg/contracts/cpp26/dcl.contract.res.p2.C: New test.
* g++.dg/contracts/cpp26/debug-and-opt.C: New test.
* g++.dg/contracts/cpp26/deferred1.C: New test.
* g++.dg/contracts/cpp26/dependent_contract.C: New test.
* g++.dg/contracts/cpp26/empty-nt-param.C: New test.
* g++.dg/contracts/cpp26/function-contract-specifier-seq-error.C: New test.
* g++.dg/contracts/cpp26/function-contract-specifier-seq.C: New test.
* g++.dg/contracts/cpp26/lambda.C: New test.
* g++.dg/contracts/cpp26/name_mangling.C: New test.
* g++.dg/contracts/cpp26/over.call.func.p3.1.C: New test.
* g++.dg/contracts/cpp26/pr113968.C: New test.
* g++.dg/contracts/cpp26/src-loc-0.C: New test.
* g++.dg/contracts/cpp26/src-loc-1.C: New test.
* g++.dg/contracts/cpp26/src-loc-2.C: New test.
* g++.dg/contracts/cpp26/throwing-violation-handler.cc: New test.
* g++.dg/contracts/cpp26/unused_warning.C: New test.
* g++.dg/contracts/cpp26/vaargs.C: New test.
* g++.dg/contracts/cpp2a/check-err.C: New test.
* g++.dg/coroutines/pr110871.C: New test.
* g++.dg/coroutines/pr110872.C: New test.
* g++.dg/contracts/cpp26/basic.contract.eval.p8.C: New test.
* g++.dg/contracts/cpp26/dcl.contract.func.p7.C: New test.
* g++.dg/contracts/cpp26/dcl.contract.res.p1-2.C: New test.
* g++.dg/contracts/cpp26/expr.prim.id.unqual.p7-2.C: New test.
* g++.dg/contracts/cpp26/expr.prim.id.unqual.p7.C: New test.
* g++.dg/contracts/cpp26/basic.contract.eval.p7.3.C: New test.
* g++.dg/contracts/cpp26/intro.compliance.general.p2.3.4.C: New test.

Co-Authored-by: Nina Ranns <dinka.ranns@gmail.com>
Co-Authored-by: Ville Voutilainen <ville.voutilainen@gmail.com>
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2 days agolibstdc++, contracts: Add base P2900R14 contracts support.
Nina Ranns [Sun, 19 Oct 2025 14:55:52 +0000 (15:55 +0100)] 
libstdc++, contracts: Add base P2900R14 contracts support.

What we need to do here (and, of course, in the code synthesis
that produces the objects) needs to be interoperable with other
platforms that share ABI.  For the present, this means Itanium
and to interoperate with clang and libc++.

The model we have followed in the development is essentially the
same as the model used for the C++2a edition.  However there is some
concern that the read-only data footprint of this is potentially
high and alternate schemes are in discussion with the clang folks.

Since the layout of the violation object is ABI let's leave this
in experimental until an agreed solution is fixed.

Remove the cxx2a support at the same time, GCC no longer supports
this mode.

libstdc++-v3/ChangeLog:

* include/Makefile.am: Add contract include.
* include/Makefile.in: Regenerate.
* include/bits/version.def: Add ftm for contracts.
* include/bits/version.h: Regenerate.
* include/precompiled/stdc++.h: Add contracts header.
* include/std/source_location: Befriend the contract_violation
class so that we can initialise a source_location from an
existing __impl *.
* src/c++23/std.cc.in: Add contracts support.
* src/experimental/Makefile.am: Add new contract violation
implementation, remove the old one.
* src/experimental/Makefile.in: Regenerate.
* include/experimental/contract: Removed.
* src/experimental/contract.cc: Removed.
* include/std/contracts: New file.
* src/experimental/contract26.cc: New file.
* testsuite/18_support/contracts/invoke_default_cvh.cc: New test.
* testsuite/18_support/contracts/invoke_default_cvh2.cc: New test.

Co-Authored-by: Iain Sandoe <iain@sandoe.co.uk>
Co-Authored-by: Ville Voutilainen <ville.voutilainen@gmail.com>
Signed-off-by: Nina Ranns <dinka.ranns@gmail.com>