]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
2 months agoa68: Fix ICE in a68_extract_indicants
Iain Buclaw [Tue, 3 Feb 2026 23:21:32 +0000 (00:21 +0100)] 
a68: Fix ICE in a68_extract_indicants

At the time a68_extract_indicants executes nothing guarantees that the
module text following a module symbol is well formed.

gcc/algol68/ChangeLog:

* a68-parser-extract.cc (a68_extract_indicants): Don't call FORWARD if
skip_module_text returns NO_NODE.

gcc/testsuite/ChangeLog:

* algol68/compile/error-module-definition-1.a68: New test.
* algol68/compile/error-module-definition-2.a68: New test.

2 months agod: Merge upstream dmd, druntime 24a41073c2, phobos 24a41073c2.
Iain Buclaw [Sun, 1 Feb 2026 15:02:20 +0000 (16:02 +0100)] 
d: Merge upstream dmd, druntime 24a41073c2, phobos 24a41073c2.

D front-end changes:

- Import dmd v2.112.0.
- Bitfields feature is now enabled by default.
- The compiler now accepts `-std=d2024' and `-std=d202y'.
- An error is now issued for dangling `else' statements.
- `finally' statements are no longer rewritten to a sequence if
  no `Exception' was thrown.
- Some forms of `printf' calls are now treated as `@safe'.
- Implicit integer conversions in `int op= float` assignments
  has been deprecated.

D runtime changes:

- Import druntime v2.112.0.
- Added `filterCaughtThrowable' in `core.thread.ThreadBase'.

Phobos changes:

- Import phobos v2.112.0.

gcc/d/ChangeLog:

* dmd/VERSION: Bump version to v2.112.0.
* dmd/MERGE: Merge upstream dmd 24a41073c2.
* d-attribs.cc (build_attributes): Update for new front-end interface.
* d-builtins.cc (build_frontend_type): Likewise.
(matches_builtin_type): Likewise.
(d_init_versions): Predefine D_Profile when compiling with profile
enabled.
* d-codegen.cc (get_array_length): Update for new front-end interface.
(lower_struct_comparison): Likewise.
(build_array_from_val): Likewise.
(get_function_type): Likewise.
(get_frameinfo): Likewise.
* d-compiler.cc (Compiler::paintAsType): Likewise.
* d-convert.cc (convert_expr): Likewise.
(convert_for_rvalue): Likewise.
(convert_for_assignment): Likewise.
(d_array_convert): Likewise.
* d-diagnostic.cc (verrorReport): Rename to ...
(vreportDiagnostic): ... this.
(verrorReportSupplemental): Rename to ...
(vsupplementalDiagnostic): ... this.
* d-lang.cc (d_handle_option): Handle -std=d2024 and -std=d202y.
(d_parse_file): Update for new front-end interface.
* d-target.cc (Target::fieldalign): Likewise.
(Target::isVectorTypeSupported): Likewise.
(Target::isVectorOpSupported): Likewise.
* decl.cc (get_symbol_decl): Likewise.
(DeclVisitor::visit): Likewise.
(DeclVisitor::visit (FuncDeclaration *)): Do NRVO on `__result' decl.
* expr.cc (needs_postblit): Remove.
(needs_dtor): Remove.
(lvalue_p): Remove.
(ExprVisitor::visit): Update for new front-end interface.
(ExprVisitor::visit (AssignExp *)): Update for front-end lowering
expression using templates.
* imports.cc (ImportVisitor::visit): Update for new front-end
interface.
* intrinsics.def (INTRINSIC_VA_ARG): Update signature.
(INTRINSIC_C_VA_ARG): Update signature.
(INTRINSIC_VASTART): Update signature.
* lang.opt: Add -std=d2024 and -std=d202y.
* toir.cc (IRVisitor::visit): Update for new front-end interface.
* typeinfo.cc (TypeInfoVisitor::visit): Likewise.
(TypeInfoVisitor::visit (TypeInfoStructDeclaration *)): Ensure
semantic is ran on all TypeInfo members.
(base_vtable_offset): Update for new front-end interface.
* types.cc (TypeVisitor::visit): Likewise.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime 24a41073c2.
* libdruntime/__importc_builtins.di: Reimplement.
* src/MERGE: Merge upstream phobos 808314eb2.
* testsuite/libphobos.aa/test_aa.d: Adjust test.
* testsuite/libphobos.gc/forkgc2.d: Removed.
* testsuite/libphobos.thread/filterthrownglobal.d: New test.
* testsuite/libphobos.thread/filterthrownmethod.d: New test.

gcc/testsuite/ChangeLog:

* gdc.dg/pr90601.d: Adjust test.
* lib/gdc-utils.exp: Handle new compiler options.

2 months agolibstdc++, c++/reflection: mark {,de}allocate constexpr
Marek Polacek [Mon, 2 Feb 2026 16:05:16 +0000 (11:05 -0500)] 
libstdc++, c++/reflection: mark {,de}allocate constexpr

[allocator.members] says that allocator::{,de}allocate should be
constexpr but currently we don't mark them as such.  I had to
work around that in the Reflection code, but it would be better to
clean this up.  (I see no allocation_result so I'm not changing that.)

gcc/cp/ChangeLog:

* constexpr.cc (is_std_allocator): Don't check for __new_allocator.
(is_std_allocator_allocate): Make static.
* cp-tree.h (is_std_allocator_allocate): Remove declaration.
* reflect.cc (check_out_of_consteval_use): Don't call
is_std_allocator_allocate.
(check_consteval_only_fn): Likewise.

libstdc++-v3/ChangeLog:

* include/bits/new_allocator.h (__new_allocator::allocate,
__new_allocator::deallocate): Add missing constexpr.

Reviewed-by: Jason Merrill <jason@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2 months agofortran: Fix creation of reference to C_FUNLOC argument [PR117303]
Kirill Chilikin [Sun, 25 Jan 2026 07:43:08 +0000 (14:43 +0700)] 
fortran: Fix creation of reference to C_FUNLOC argument [PR117303]

The reference returned by C_FUNLOC is assigned to a variable. Without that,
no reference from the calling subprogram to the argument of C_FUNLOC
was created in the call graph, resulting in an undefined-reference error
with link-time optimization. Please see PR 117303 for more details.

PR fortran/117303

gcc/fortran/ChangeLog:

* trans-intrinsic.cc (conv_isocbinding_function):
Assign the reference returned by C_FUNLOC to a variable.

gcc/testsuite/ChangeLog:

* gfortran.dg/c_funloc_tests_7.f90:
Updated test due to changed code generation.
* gfortran.dg/c_funloc_tests_9.f90: New test.

Signed-off-by: Kirill Chilikin <chilikin.k@gmail.com>
2 months agobuild: Only use gas_flag/gnu_ld_flag internally [PR123841]
Rainer Orth [Tue, 3 Feb 2026 19:41:40 +0000 (20:41 +0100)] 
build: Only use gas_flag/gnu_ld_flag internally [PR123841]

gcc/acinclude.m4, gcc/config.gcc, and gcc/configure.ac have two
different variables that are checked to determine if GNU as and/or GNU
ld are used.  config.gcc describes them like this:

  gas_flag Either yes or no depending on whether GNU as was
requested.
  gnu_ld_flag Either yes or no depending on whether GNU ld was
requested.

  gas Set to yes or no depending on whether the target
system normally uses GNU as.
  gnu_ld Set to yes or no depending on whether the target
system normally uses GNU ld.

I find this duplication highly confusing: what's the point of what a
target normally uses when it can just be determined at configure time if
the assembler/linker used is gas/gnu_ld?

There are two uses for those variables:

* gas/gnu_ld determine the setting of HAVE_GNU_AS/HAVE_GNU_LD.  In this
  case only, the normally part may be good enough, so this patch doesn't
  touch it.

* However, there are several other places where this isn't good enough:
  when the assembler/linker is invoked at configure time, it's crucial
  that the right options and input syntax are use for the tool in
  question.

Therefore this patch determines gas_flag/gnu_ld_flag at configure time
if they are not yet set otherwise.  All tests that need to know which
tool is used now check gas_flag/gnu_ld_flag only.

Tested on {i386,amd64}-pc-solaris2.11, {i686,x86_64}-pc-linux-gnu,
{i386,x86_64}-apple-darwin, and sparc64-unknown-linux-gnu.

2026-01-30  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc:
PR other/123841
* acinclude.m4 (gcc_GAS_FLAGS): Check $gas_flag, $gnu_ld_flag
instead of $gas, $gnu_ld.
* configure.ac: Likewise.
(gas_flag): Determine if not already set.
(gnu_ld_flag): Likewise.
(ld_32_opt): Only set after gnu_ld_flag is set.
(ld_64_opt): Likewise.
* configure: Regenerate.

2 months agobuild: Use separate options for Darwin as [PR123841]
Rainer Orth [Tue, 3 Feb 2026 19:34:10 +0000 (20:34 +0100)] 
build: Use separate options for Darwin as [PR123841]

Since

commit 5fc4e333b42d12aca71587f83f2d2c5be9633146
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date:   Tue Jan 27 19:15:36 2026 +0100

    build: Unify 32 and 64-bit assembler handling

gcc/acinclude.m4 uses gas-only flags --32/--64 on Darwin/x86 with the
native assembler, which breaks many configure tests.

This patch uses the Darwin as options instead, handling the PowerPC
cases at the same time.

Tested on x86_64-apple-darwin21.6.0 and 386-apple-darwin17.7.0.

2026-01-28  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc:
PR other/123841
* acinclude.m4 (gcc_GAS_FLAGS): Handle Darwin as cases separately.
* configure: Regenerate.

2 months agoSplit gcc.dg/pr123109.c into scalar and vector parts
Pengxuan Zheng [Thu, 15 Jan 2026 21:42:25 +0000 (13:42 -0800)] 
Split gcc.dg/pr123109.c into scalar and vector parts

Split gcc.dg/pr123109.c into scalar and vector parts as suggested by Jakub.

gcc/testsuite/ChangeLog:

* gcc.dg/pr123109.c: Move to...
* gcc.dg/pr123109-vector.c: ...here.
* gcc.dg/pr123109-scalar.c: New test.

Signed-off-by: Pengxuan Zheng <pengxuan.zheng@oss.qualcomm.com>
2 months agoFortran: Fix module proc with array valued dummy procedure [PR123952]
Paul Thomas [Tue, 3 Feb 2026 18:00:54 +0000 (18:00 +0000)] 
Fortran: Fix module proc with array valued dummy procedure [PR123952]

2026-01-14  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/123952
* symbol.cc (gfc_copy_dummy_sym): Ensure that external, array
valued destination symbols have the correct interface so that
conflicts do not arise when adding attributes.

gcc/testsuite
PR fortran/123952
* gfortran.dg/pr123952.f90: New test.

2 months agoPR middle-end/118608: Fix lack of sign extension on MIPS64 with -Os
Roger Sayle [Tue, 3 Feb 2026 17:43:59 +0000 (17:43 +0000)] 
PR middle-end/118608: Fix lack of sign extension on MIPS64 with -Os

Here is a refreshed version of my patch from February 2025, for resolving
PR middle-end/118608, a wrong code on valid regression where the middle-end
is failing to keep values suitably sign-extended (MIPS64 is a rare
targetm.mode_rep_extended target, as well as being BYTES_BIG_ENDIAN).

This fix requires three independent tweaks, one in each source file.
The first tweak is that the logic in my triggering patch for determining
whether store_field updates the most significant bit needs to be updated
to handle BYTES_BIG_ENDIAN.  Of the two insertions in the bugzilla test
case, we were generating the sign extension after the wrong one.
The second tweak was that this explicit sign-extension was then being
eliminated during combine by simplify-rtx that believed the explicit
TRUNCATE wasn't required.  This patch updates truncated_to_mode to
understand that on mode_rep_extended targets, TRUNCATE is used instead
of SUBREG because it isn't a no-op.  Finally, the third tweak is
that the MIPS backend requires a small change to recognize (and split)
*extenddi_truncatesi when TARGET_64BIT and !ISA_HAS_EXTS.

On mips64-elf with -mabi=64 the following are now generated for prepareNeedle:

-O2
        sll     $5,$5,16
        jr      $31
        or      $2,$5,$4

-Os
        dsll    $5,$5,16
        or      $2,$4,$5
        dsll    $2,$2,32
        jr      $31
        dsra    $2,$2,32

-O2 -march=octeon2
        move    $2,$0
        ins     $2,$5,16,16
        jr      $31
        ins     $2,$4,0,16

-Os -march=octeon2
        move    $2,$0
        dins    $2,$4,0,16
        dins    $2,$5,16,16
        jr      $31
        sll     $2,$2,0

Many thanks to Mateusz Marciniec and Jeff Law for additional testing.

gcc/ChangeLog
PR middle-end/118608
* expr.cc (store_field_updates_msb_p): New helper function that
now also handles BYTES_BIG_ENDIAN targets.
(expand_assignment): Use the above function when deciding to emit
a required sign/zero extension.
* rtlanal.cc (truncated_to_mode): Call targetm.mode_rep_extended
to check whether an explicit TRUNCATE is required (i.e. performs
an extension) on this target.
* config/mips/mips.md (*extenddi_truncate<mode>): Handle all
SUBDI modes, not just SHORT modes.

gcc/testsuite/ChangeLog
PR middle-end/118608
* gcc.target/mips/pr118608-1.c: New test case.
* gcc.target/mips/pr118608-2.c: Likewise.
* gcc.target/mips/pr118608-3.c: Likewise.
* gcc.target/mips/pr118608-4.c: Likewise.

2 months agoPR middle-end/123826: __builtin_pow vs. errno.
Roger Sayle [Tue, 3 Feb 2026 17:06:25 +0000 (17:06 +0000)] 
PR middle-end/123826: __builtin_pow vs. errno.

This is my proposed solution to PR middle-end/123826.  Initially
I thought this would be a "one line change", adding a test for
flag_errno_math to gimple_expand_builtin_pow.  Unfortunately
this revealed a second later problem, where pow (with constant
arguments) was still getting evaluated at compile-time, even when
the result is known to overflow.

It's ancient history, but shortly after I added support for pow
as a builtin, I contributed code to evaluate it at compile-time
when the exponent is an integer constant.  Since then we now use
MPFR to evaluate libm math functions at compile-time.  However
the vestigial call to evaluate pow via real_powi still exists,
and gets invoked after do_mpfr_arg2/mpfr_pow correctly determines
that we shouldn't evaluate pow at compile-time.  This patch reorganizes
fold_const_pow paying attention to signaling NaNs (PR 61441)
and flag_errno_math.  Most importantly normal cases like pow(2.0,3.0)
and pow(3.0,0.5) still get evaluated at compile-time.

2026-02-03  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
PR middle-end/123826
* tree-ssa-math-opts.cc (gimple_expand_builtin_pow): Add test
for flag_errno_math.
* fold-const-call.cc (fold_const_pow): Reorganize, eliminating
call to real_powi, and letting do_mpfr_arg2 do all the heavy
lifting.

gcc/testsuite/ChangeLog
PR middle-end/123826
* gcc.dg/errno-2.c: New test case.
* gcc.dg/errno-3.c: Likewise.

2 months agoaarch64: Fix issue with __pld builtin at -O0 [PR 123548]
Alfie Richards [Mon, 19 Jan 2026 11:09:28 +0000 (11:09 +0000)] 
aarch64: Fix issue with __pld builtin at -O0 [PR 123548]

This fixes the issues with __pld by removing it and related prefetch
instrisics from the arm_acle.h and defines the intrinsics directly.

PR target/123548

gcc/ChangeLog:

* config/aarch64/aarch64-builtins.cc
(aarch64_builtins): Rename AARCH64_PL<X> to
AARCH64_PREFETCH_PL<X>.
(aarch64_init_prefetch_builtin): Rename to...
(aarch64_init_prefetch_builtins): ...this and change builtin
names.
(AARCH64_INIT_PREFETCH_BUILTIN): Change to not add
"__builtin_aarch64__" prefix and to register builtins.
(handle_arm_acle_h): Add call to aarch64_init_prefetch_builtins.
(aarch64_init_pcdphint_builtins): Move __pldir code to init
prefetch builtins.
(aarch64_general_init_builtins): Remove call to
aarch64_init_prefetch_builtin.
(aarch64_expand_prefetch_builtin): Update names of PL<X>
builtins.`
* config/aarch64/arm_acle.h
(__pld): Remove
(__pli): Likewise.
(__plix): Likewise.
(__pldx): Likewise.
(__pldir): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/pldir.c: Move to...
* gcc.target/aarch64/acle/pldir.c: ...here.
* gcc.target/aarch64/builtin_pld_pli_illegal.c: Removed.
* gcc.target/aarch64/acle/pld_pli_illegal.c: New test.
* gcc.target/aarch64/builtin_pld_pli.c: Removed.
* gcc.target/aarch64/acle/pld_pli.c: New test.
* gcc.target/aarch64/pr123548.c: New test.

2 months agotestsuite: arm: Make arm_neon_ok_nocache consistent with other effective-targets
Christophe Lyon [Tue, 3 Feb 2026 13:07:10 +0000 (13:07 +0000)] 
testsuite: arm: Make arm_neon_ok_nocache consistent with other effective-targets

A recent patch updated arm_neon_ok_nocache with an improved list of
flags to try, but was not consistent with
arm_v8_3a_complex_neon_ok,_nocache arm_v8_2a_fp16_neon_ok_nocache,
arm_v8_3a_fp16_complex_neon_ok_nocache.

This patch inserts "-mcpu=unset -march=armv7-a+simd -mfpu=auto" before
we try to force -mfloat-abi=softfp and -mfloat-abi=hard.

Tested on aarch64-linux-gnu, arm-linux-gnueabihf and several flavors
of arm-none-eabi with non-default configurations.

2026-02-03  Christophe Lyon  <christophe.lyon@arm.com>

gcc/testsuite/
* lib/target-supports.exp
(check_effective_target_arm_neon_ok_nocache): Add "-mcpu=unset
-march=armv7-a+simd -mfpu=auto" to the list.

2 months ago[RISC-V][PR rtl-optimization/123322] Split general conditional moves into simpler...
Jeff Law [Tue, 3 Feb 2026 14:24:53 +0000 (07:24 -0700)] 
[RISC-V][PR rtl-optimization/123322] Split general conditional moves into simpler sequences

This has gone round and round a few times... But I think we're finally at a
resolution of the regression. There's more work to do for gcc-17 though.

---

At its core this regression is caused by more accurately costing branches
during if-conversion.  The more accurate cost causes the multi-set path during
the first ifcvt pass to (profitably) convert the sequence.  However, it would
have been more profitable to have waited for things to be cleaned up and by the
2nd ifcvt pass we'd be able to convert using the condzero path which is *more*
profitable than the multi-set code (which is what happens in gcc-15).

One possible solution would be to disable the multi-set ifcvt code during its
first pass.  That was evaluated and ultimately rejected because of clear
undesirable impacts.  It may still be a good thing to do, but certainly not at
this stage of gcc-16.

Another path that was considered was recognizing the sign extension in the
if-convertable block and avoiding the multi-set path in that case on the
assumption it'd be cleaned up later and the condzero path would be used.  That
felt way too target specific and optimistic about removal of the sign
extension.

Daniel looked at if-converting these cases during phiopt; that generally looks
like a good thing to do, but had notable undesirable fallout on RISC-V and I
was significantly worried it would re-introduce sequences on x86 and aarch64
that we just fixed.  ie, solving one regression and creating another.  So that
feels like a gcc-17 evaluation.

After much head-banging it occurred to me that we could tackle this in the
target with a tiny bit of help from combine.  These conditional ops are 4
instruction sequences.  The operation, a pair of czeros and an add/ior to
select between the output of the two czeros.  Combine is pretty conservative in
when it chooses to try 4 insn sequences.

So step #1 was to loosen the restrictions on combine a little bit.  If it sees
an IF_THEN_ELSE, then it considers that "good" which in turn allows us to try 4
insn combinations a bit more often.

That exposes the potential for 4 insn combinations and since the IOR/XOR case
is a 4->2 sequence fixing those regressions is just a good define_split.   In
fact, we can use that splitter for any case where the neutral operand is zero
(IOR, XOR, PLUS, MINUS, etc).  We need a second pattern to handle reversed
operands since we're using code iterators and match_dup for the matching
operand rather than something like a matching constraint.

THat still leaves conditional shifts regressing due to the same problem.  For
shifts/rotates, the count is in QImode, so we need a different pattern to
handle those cases, but it has the same basic structure and behavior.

AND was *still* regressing though.  That would require a 4->3 split which isn't
supported by combine.  Given the issues with the other paths attempted, I
ultimately decided on a define_insn_and_split (boo!).  This shouldn't be
happening a ton like mvconst_internal, so not great, but workable.  This also
required recognizing the pattern and giving it a suitable cost (COSTS_N_INSNS
(3)).

That fixes the regressions.  We're still not generating ideal code for rv64
when the operands are 32bit quantities and the architecture provides an
instruction variant that sign extends from 32 to 64 bits (add, subtract, shifts
and rotates).  But the code we generate for gcc-16 is better than we were
generating for gcc-15, it's just not optimal.  So there's a TODO for gcc-17 as
well.

This was bootstrapped and regression tested on x86, alpha, riscv, armv7, hppa,
maybe others, but those definitely for sure.  It was also tested on the various
crosses without regressions.  Waiting on pre-commit testing to render a verdict
before going forward.

PR rtl-optimization/123322
gcc/
* combine.cc (try_combine): Consider an IF_THEN_ELSE "good" when
evaluating if 4 insn combinations should be tried.
* config/riscv/iterators.md (zero_is_neutral_op): New iterator.
(zero_is_neutral_op_c): Likewise.
(any_shift_rotate): Likewise.
* config/riscv/riscv.cc (riscv_rtx_costs): Recognize the conditional
AND RTL and cost is appropriately.
* config/riscv/zicond.md: Add patterns to rewrite general conditional
move sequences into simpler forms.

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

2 months agoc++/reflection: refactor compare_reflections
Marek Polacek [Mon, 2 Feb 2026 23:09:08 +0000 (18:09 -0500)] 
c++/reflection: refactor compare_reflections

In <https://gcc.gnu.org/pipermail/gcc-patches/2026-January/705756.html>
Jason suggested using cp_tree_equal for all exprs in compare_reflections.
This patch does so.  We just have to handle comparing annotations and
types specially, then we can use cp_tree_equal for the rest.  It just
had to be taught not to crash on unequal NAMESPACE_DECLs.

gcc/cp/ChangeLog:

* reflect.cc (compare_reflections): Handle comparing annotations
and types specially, use cp_tree_equal for the rest.
* tree.cc (cp_tree_equal) <case NAMESPACE_DECL>: New.

Reviewed-by: Jason Merrill <jason@redhat.com>
2 months agolibstdc++: Define __cpp_lib_define_static [PR123921]
Jakub Jelinek [Tue, 3 Feb 2026 13:22:46 +0000 (14:22 +0100)] 
libstdc++: Define __cpp_lib_define_static [PR123921]

I've totally missed the P3491R3 paper (define_static_{string,object,array})
comes with its own feature test macro - __cpp_lib_define_static 202506
which should appear in <version> and <meta>.
The paper contains 3 parts, std::is_string_literal,
std::meta::reflect_constant_{string,array} and
std::define_static_{string,object,array}.
The first part is implementable without reflection, the third part in theory
would be also implementable without reflection but usually will be (and in
libstdc++ is) implemented using reflection, and the middle part is really
part of reflection.  So dunno how useful this FTM actually is, maybe just
for cases where some implementation does implement reflection and doesn't
implement this paper for a while.

Anyway, the FTM is in C++26 draft, so this patch adds it, with the same
condition as __cpp_lib_reflection.

2026-02-03  Jakub Jelinek  <jakub@redhat.com>

PR libstdc++/123921
* include/bits/version.def (define_static): New with the
same values as reflection.
* include/bits/version.h: Regenerate.
* include/std/meta: Define also __glibcxx_want_define_static before
including bits/version.h.

* g++.dg/reflect/feat2.C: Add also test for __cpp_lib_define_static.
* g++.dg/reflect/feat3.C: New test.

2 months agolibgomp, amdgcn, nvptx: Improve omp_target_is_accessible [PR121813]
Andrew Stubbs [Mon, 8 Dec 2025 16:18:02 +0000 (16:18 +0000)] 
libgomp, amdgcn, nvptx: Improve omp_target_is_accessible [PR121813]

This patch extends omp_target_is_accessible to check the actual device status
for the memory region, on amdgcn and nvptx devices (rather than just checking
if shared memory is enabled).

In both cases, we check the status of each 4k region within the given memory
range (assuming 4k pages should be safe for all the currently supported hosts)
and returns true if all of the pages report accessible.

The testcases have been modified to check that allocations marked accessible
actually are accessible (inaccessibility can't be checked without invoking
memory faults), and to understand that some parts of an array can be accessible
but other parts not (I have observed this intermittently for the stack memory
on amdgcn using the Fortran testcase, which can have the allocation span pages).

There's also new testcases for the various other memory modes, and for managed
memory.

include/ChangeLog:

* cuda/cuda.h (CUpointer_attribute): New enum.
(cuPointerGetAttribute): New prototype.

libgomp/ChangeLog:

PR libgomp/121813
PR libgomp/113213
* libgomp-plugin.h (GOMP_OFFLOAD_is_accessible_ptr): New prototype.
* libgomp.h
(struct gomp_device_descr): Add GOMP_OFFLOAD_is_accessible_ptr.
* libgomp.texi: Update omp_target_is_accessible docs.
* plugin/cuda-lib.def (cuPointerGetAttribute): New entry.
* plugin/plugin-gcn.c (struct hsa_runtime_fn_info): Add
hsa_amd_svm_attributes_get_fn and hsa_amd_pointer_info_fn.
(init_hsa_runtime_functions): Add hsa_amd_svm_attributes_get and
hsa_amd_pointer_info.
(enum accessible): New enum type.
(host_memory_is_accessible): New function.
(device_memory_is_accessible): New function.
(GOMP_OFFLOAD_is_accessible_ptr): New function.
* plugin/plugin-nvptx.c (GOMP_OFFLOAD_is_accessible_ptr): Likewise.
* target.c (omp_target_is_accessible): Call is_accessible_ptr_func.
(gomp_load_plugin_for_device): Add is_accessible_ptr.
* testsuite/libgomp.c-c++-common/target-is-accessible-1.c: Rework
to match more details of the GPU implementation.
* testsuite/libgomp.fortran/target-is-accessible-1.f90: Likewise.
* testsuite/libgomp.c-c++-common/target-is-accessible-2.c: New test.
* testsuite/libgomp.c-c++-common/target-is-accessible-3.c: New test.
* testsuite/libgomp.c-c++-common/target-is-accessible-4.c: New test.
* testsuite/libgomp.c-c++-common/target-is-accessible-5.c: New test.

2 months agodiagnostics: conditionally include afunix.h
Torbjörn SVENSSON [Thu, 29 Jan 2026 16:44:13 +0000 (17:44 +0100)] 
diagnostics: conditionally include afunix.h

afunix.h was first included in MinGW 10.0.0.  For earlier versions, fall
back to internal definition.

gcc/ChangeLog:

* config.in: Regenerate.
* configure: Regenerate.
* configure.ac (gcc_cv_header_afunix_h): New test.
(HAVE_AFUNIX_H): New AC_DEFINE.
* diagnostics/sarif-sink.cc: Conditionally include afunix.h
if it's available, else fall back to internal definition.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
2 months agogcc: migrate from CONST_CAST2 macro to const_cast<>() [PR123892]
Torbjörn SVENSSON [Fri, 30 Jan 2026 16:07:11 +0000 (17:07 +0100)] 
gcc: migrate from CONST_CAST2 macro to const_cast<>() [PR123892]

Prepare to remove CONST_CAST2 macro from gcc/system.h

gcc/ChangeLog:

PR middle-end/123892
* collect2.cc: Migrate from CONST_CAST2() macro to
const_cast<>() C++ expression.
* config/sparc/driver-sparc.cc: Likewise.
* gcc-ar.cc: Likewise.
* gcc.cc: Likewise.
* toplev.cc: Likewise.
* tree-nested.cc: Likewise.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
2 months agoipa/123416 - fix IPA modref summary merging after inlining
Richard Biener [Tue, 3 Feb 2026 08:26:01 +0000 (09:26 +0100)] 
ipa/123416 - fix IPA modref summary merging after inlining

There's a typo in the condition skipping load collapsing when
there's no callee modref summary.  We do have to collapse loads
for the destination iff the callee performs any loads which includes
when the callee is ECF_PURE.  The LTO summary part already gets
this correct.

PR ipa/123416
* ipa-modref.cc (ipa_merge_modref_summary_after_inlining):
Fix typo in condtion for load merging when no callee summary.

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

2 months agoc++: Fix UB in eval_data_member_spec [PR123920]
Jakub Jelinek [Tue, 3 Feb 2026 08:19:19 +0000 (09:19 +0100)] 
c++: Fix UB in eval_data_member_spec [PR123920]

We can overflow buffer in eval_data_member_spec on some initializers.
The code has 2 loops, one to figure out the needed length
of the buffer and diagnose errors
          unsigned HOST_WIDE_INT l = 0;
          bool ntmbs = false;
          FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (f), k, field, value)
            if (!tree_fits_shwi_p (value))
              goto fail;
            else if (field == NULL_TREE)
              {
                if (integer_zerop (value))
                  {
                    ntmbs = true;
                    break;
                  }
                ++l;
              }
            else if (TREE_CODE (field) == RANGE_EXPR)
              {
                tree lo = TREE_OPERAND (field, 0);
                tree hi = TREE_OPERAND (field, 1);
                if (!tree_fits_uhwi_p (lo) || !tree_fits_uhwi_p (hi))
                  goto fail;
                if (integer_zerop (value))
                  {
                    l = tree_to_uhwi (lo);
                    ntmbs = true;
                    break;
                  }
                l = tree_to_uhwi (hi) + 1;
              }
            else if (tree_fits_uhwi_p (field))
              {
                l = tree_to_uhwi (field);
                if (integer_zerop (value))
                  {
                    ntmbs = true;
                    break;
                  }
                ++l;
              }
            else
              goto fail;
          if (!ntmbs || l > INT_MAX - 1)
            goto fail;
which assumes that if there are designators, they need to be ascending,
so no { [10] = 1, [2] = 3, [6] = 4, [4] = 5 } like in C11 and stops on the
first '\0' seen (but remember in l the index of that.  Here we need the
3 integer_zerop calls because the exact setting of l depends on if it is
an elt without index, or with RANGE_EXPR index, or with normal INTEGER_CST
index.  And then there is a second loop where it just stores the values
into the allocated buffer and does rely on the checking the first loop
did.  Now, for CONSTRUCTORs without indexes or with RANGE_EXPR only it
also correctly stops at '\0', but I forgot to check that in the last
case where index is INTEGER_CST:
          char *namep;
          unsigned len = l;
          if (l < 64)
            namep = XALLOCAVEC (char, l + 1);
          else
            namep = XNEWVEC (char, l + 1);
          memset (namep, 0, l + 1);
          l = 0;
          FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (f), k, field, value)
            if (field == NULL_TREE)
              {
                if (integer_zerop (value))
                  break;
                namep[l] = tree_to_shwi (value);
                ++l;
              }
            else if (TREE_CODE (field) == RANGE_EXPR)
              {
                tree lo = TREE_OPERAND (field, 0);
                tree hi = TREE_OPERAND (field, 1);
                if (integer_zerop (value))
                  break;
                unsigned HOST_WIDE_INT m = tree_to_uhwi (hi);
                for (l = tree_to_uhwi (lo); l <= m; ++l)
                  namep[l] = tree_to_shwi (value);
              }
            else
              {
                l = tree_to_uhwi (field);
                namep[l++] = tree_to_shwi (value);
              }
          namep[len] = '\0';
So, I could add if (integer_zerop (value) break; into the else
block, but then, in this loop there is no reason not to check integer_zerop
(value) first because it is handled in all 3 cases the same.

2026-02-03  Jakub Jelinek  <jakub@redhat.com>

PR c++/123920
* reflect.cc (eval_data_member_spec): Break out of the loop
if value is integer_zerop even in the field
&& TREE_CODE (field) != RANGE_EXPR case and use a single
test for integer_zerop (value) in the whole loop.

2 months agoc++: Don't call cpp_translate_string on NULL string [PR123918]
Jakub Jelinek [Tue, 3 Feb 2026 08:18:34 +0000 (09:18 +0100)] 
c++: Don't call cpp_translate_string on NULL string [PR123918]

My P2246R1 patch caused diagnostics reported by running ubsan
instrumented compiler on cpp26/static_assert1.C - if len is 0,
we don't bother to allocate msg, so it stays NULL, and when I've added
cpp_translate_string call, that can invoke memcpy (something, NULL, 0);
in that case.
While that is no longer UB in C2Y since N3322, libsanitizer doesn't
know that yet and reports it anyway.
While we could just do
      if (len)
        {
...
        }
      else
        msg = "";
there is really no point in trying to translate "" and allocate memory
for that, so the following patch instead by passes that translation for
len == 0.

2026-02-03  Jakub Jelinek  <jakub@redhat.com>

PR c++/123918
* semantics.cc (cexpr_str::extract): Bypass cpp_translate_string
for len == 0.

2 months agoAda: Fix couple of small accessibility glitches
Eric Botcazou [Tue, 3 Feb 2026 07:45:23 +0000 (08:45 +0100)] 
Ada: Fix couple of small accessibility glitches

The first glitch is that the ACATS test c3a0025 does not pass in Ada 2005
because an accessibility check preempts a null access check.  The second
glitch is that there should be no differences in Ada 2012 and later for
the test, in other words there is a missing accessibility check failure.

The second glitch comes from a thinko in the new implementation of the
In_Return_Value predicate, which has incorrectly dropped the handling of
assignments to return objects.

The first glitch is fixed by swapping the order of null access checks and
accessibility checks for conversions, which requires adding a small guard
to Apply_Discriminant_Check.

gcc/ada/
* checks.adb (Apply_Discriminant_Check): Bail out for a source type
that is a class-wide type whose root type has no discriminants.
* exp_ch4.adb (Expand_N_Type_Conversion): If the target type is an
access type, emit null access checks before accessibility checks.
* sem_util.adb (In_Return_Value): Deal again with assignments to
return objects.

2 months agoRevert "LoongArch: Fix PR122097 (2)."
Xi Ruoyao [Sat, 31 Jan 2026 16:04:23 +0000 (00:04 +0800)] 
Revert "LoongArch: Fix PR122097 (2)."

This reverts commit e753fa38bb612a3bebe0fc596a44a104bbd2739b.

The commit is no longer needed with the new copysign/xorsign
implementaton.

2 months agoLoongArch: rework copysign and xorsign implementation
Xi Ruoyao [Thu, 29 Jan 2026 09:08:02 +0000 (17:08 +0800)] 
LoongArch: rework copysign and xorsign implementation

The copysign and xorsign implementation had two significant bugs:

1. The GCC Internal documentation explicitly says the IOR, XOR, and AND
   optabs are only for fixed-point modes, i.e. they cannot be used for
   floating-point modes.
2. The handling of "%V" uses a very nasty way to pun floating-point
   const value to integer representation, invoking undefined behavior on
   32-bit hosts by shifting left a "long" by 32 bits.  In fact
   lowpart_subreg handles punning of const values correctly despite the
   name contains "reg."

Fix the bugs by using lowpart_subreg to pun the modes in the expanders.

gcc/

* config/loongarch/predicates.md (const_vector_neg_fp_operand):
New define_predicate.
(reg_or_vector_neg_fp_operand): New define_predicate.
* config/loongarch/lasx.md (copysign<mode>3): Remove.
(xorsign<mode>3): Remove.
* config/loongarch/lsx.md (copysign<mode>3): Remove.
(@xorsign<mode>3): Remove.
* config/loongarch/simd.md (copysign<mode>3): New define_expand.
(@xorsign<mode>3): New define_expand.
(and<mode>3): Only allow IVEC instead of ALLVEC.
(ior<mode>3): Likewise.
(xor<mode>3): Likewise.
* config/loongarch/loongarch.cc (loongarch_print_operand): No
longer allow floating-point vector constants for %V.
(loongarch_const_vector_bitimm_set_p): Always return false for
floating-point vector constants.
(loongarch_build_signbit_mask): Factor out force_reg.
(loongarch_emit_swrsqrtsf): Use integer vector mode instead of
floating-point vector mode when masking zero inputs.

2 months agoDaily bump.
GCC Administrator [Tue, 3 Feb 2026 00:16:25 +0000 (00:16 +0000)] 
Daily bump.

2 months agodiagnostics: respect dumpdir when outputting SARIF and HTML file [PR110522]
David Malcolm [Mon, 2 Feb 2026 23:14:11 +0000 (18:14 -0500)] 
diagnostics: respect dumpdir when outputting SARIF and HTML file [PR110522]

PR diagnostics/110522 notes that when generating the output path for
diagnostics in SARIF or HTML form, the compiler ignores the path for the
compiler output, leading to race conditions and overwritten SARIF output
when compiling the same source file multiple times in a build.

Given e.g.

  gcc \
    -o build-dir/foo.o \
    -fdiagnostics-add-output=sarif
    foo.c

my intent was for the sarif sink to write to "build-dir/foo.c.sarif",
but in GCC 13 - GCC 15 it writes to "foo.c.sarif" instead.

The driver adds the option "-dumpdir build-dir" when invoking cc1, and
opts.cc's finish_options has the logic to prepend the dump_dir_name to
the dump_base_name, which in theory ought to have affected the name for
SARIF output.  The root cause is that finish_options is called *after*
processing the options for creating the diagnostic sinks, and so the
sarif_sink is created when dump_base_name is "foo.c", and thus
writes to "foo.c.sarif", rather than "build-dir/foo.c.sarif".

This patch introduces a new helper function for accessing the base name
for diagnostic sinks and refactors the prepending logic
in finish_options so that it is also used when creating diagnostic
sinks, so that in the above example the SARIF is written to
"build-dir/foo.c.sarif".

The patch took the number of .sarif files generated by the analyzer
integration tests from 5094 to 11309.  The most extreme example I could
find within them was where we previously got a single .sarif file:
  qemu-7.2.0/build/fpu_softfloat.c.c.sarif
and *with* the patch we get 66 .sarif files:
  qemu-7.2.0/build/libqemu-aarch64-linux-user.fa.p/fpu_softfloat.c.c.sarif
  qemu-7.2.0/build/libqemu-aarch64-softmmu.fa.p/fpu_softfloat.c.c.sarif
  [...snip lots of different architectures...]
  qemu-7.2.0/build/libqemu-xtensaeb-linux-user.fa.p/fpu_softfloat.c.c.sarif
  qemu-7.2.0/build/libqemu-xtensaeb-softmmu.fa.p/fpu_softfloat.c.c.sarif

which presumably were previously all being written to the same place
during the build.  Indeed, the old file is invalid JSON, and appears to
have been truncated.

gcc/ChangeLog:
PR diagnostics/110522
* gcc.cc (driver_handle_option): Use
get_diagnostic_file_output_basename for
OPT_fdiagnostics_format_.
* opts-diagnostic.cc (get_base_filename): Likewise.
(get_diagnostic_file_output_basename): New.
* opts-diagnostic.h (get_diagnostic_file_output_basename): New
decl.
* opts.cc (maybe_prepend_dump_dir_name): New, based on code in
finish_options.
(finish_options): Move code for determining prepended
dump_base_name to maybe_prepend_dump_dir_name and call it.
(common_handle_option): Use get_diagnostic_file_output_basename
for OPT_fdiagnostics_format_.
* opts.h (maybe_prepend_dump_dir_name): New decl.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 months agoc++: update FTM for C++23 inherited CTAD
Patrick Palka [Mon, 2 Feb 2026 20:20:37 +0000 (15:20 -0500)] 
c++: update FTM for C++23 inherited CTAD

We implement inherited CTAD (P2582R1) since GCC 14 but the corresponding
FTM hasn't been updated in the standard until recently[1].

[1]: https://github.com/cplusplus/draft/pull/8450

gcc/c-family/ChangeLog:

* c-cppbuiltin.cc (c_cpp_builtins): Bump __cpp_deduction_guides to
202207L for C++23 and later.

gcc/testsuite/ChangeLog:

* g++.dg/cpp23/feat-cxx2b.C: Adjust expected __cpp_deduction_guides
value.
* g++.dg/cpp26/feat-cxx26.C: Likewise.

Reviewed-by: Jakub Jelinek <jakub@redhat.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
2 months agolibstdc++/regex: Zero-initialize _ExecutorFrame flags
Patrick Palka [Mon, 2 Feb 2026 20:14:20 +0000 (15:14 -0500)] 
libstdc++/regex: Zero-initialize _ExecutorFrame flags

Prevents uninitialized read bugs, and it's also just natural to assume
flags are initially cleared rather than uninitialized.

In passing rename the _M_end flag to _M_subexpr_end to make it distinct
from _Executor::_M_end.

libstdc++-v3/ChangeLog:

* include/bits/regex_executor.tcc (_ExecutorFrameBase):
Zero-initialize _M_byte0.
(_ExecutorFrameBase::_M_end): Rename to ...
(_ExecutorFrameBase::_M_subexpr_end): ... this.
(_Executor::_M_handle_subexpr_begin): Remove now redundant
clearing of _M_subexpr_end.
(_Executor::_M_handle_subexpr_end): Adjust after renaming.
(_Executor::_M_dfs) <case _S_fopcode_restore_cur_results>:
Likewise.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2 months agoAda: Fix profile conformance glitch with limited_with and incomplete type
Eric Botcazou [Mon, 2 Feb 2026 18:40:33 +0000 (19:40 +0100)] 
Ada: Fix profile conformance glitch with limited_with and incomplete type

That's an old issue, but the fix is quite straightforward.

gcc/ada/
PR ada/89159
* sem_ch6.adb (Conforming_Types.Is_Matching_Limited_View): Return
true when the type is an incomplete view of the non-limited view.

gcc/testsuite/
* gnat.dg/limited_with8.adb: New test.
* gnat.dg/limited_with8_pkg1.ads: New helper.
* gnat.dg/limited_with8_pkg2.ads: Likewise.
* gnat.dg/limited_with8_pkg2.adb: Likewise.

2 months agoifcvt: Fix store flag of XImode on aarch64 while ifcvt [PR123294]
Andrew Pinski [Sun, 1 Feb 2026 23:41:52 +0000 (15:41 -0800)] 
ifcvt: Fix store flag of XImode on aarch64 while ifcvt [PR123294]

In the testcase ifcvt is trying to do a emit_store_flag into a XImode.
That will cause an ICE because XImode does not have any arithmetic optabs
associated with it. This is because it is greater than MAX_FIXED_MODE_SIZE
(along other things).
noce_emit_store_flag already has code to reject non-scalar modes, so
this adds a new check for modes that are greater than MAX_FIXED_MODE_SIZE.

Bootstrapped and tested on aarch64-linux-gnu.

PR rtl-optimization/123294

gcc/ChangeLog:

* ifcvt.cc (noce_emit_store_flag): Reject modes
greater than MAX_FIXED_MODE_SIZE.

gcc/testsuite/ChangeLog:

* gcc.dg/pr123294-1.c: New test.
* gcc.target/aarch64/pr123294-1.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 months agoc++/reflection: fix ICE with object_of [PR123695]
Marek Polacek [Sun, 1 Feb 2026 23:06:20 +0000 (18:06 -0500)] 
c++/reflection: fix ICE with object_of [PR123695]

In eval_object_of we are calling cxx_eval_constant_expression on
references to get the referent.  We should check that the type is
non-null before checking TYPE_REF_P, because for invalid arguments
it can be null, as shown in the test.

PR c++/123695

gcc/cp/ChangeLog:

* reflect.cc (eval_object_of): Check type before TYPE_REF_P.

gcc/testsuite/ChangeLog:

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

Co-authored-by: Boris Staletic <boris.staletic@protonmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
2 months agoc++/reflection: wrong error with const meta::info parm [PR123614]
Marek Polacek [Sun, 1 Feb 2026 20:20:55 +0000 (15:20 -0500)] 
c++/reflection: wrong error with const meta::info parm [PR123614]

Here we issue a bogus "not a constant expression" error ultimately
because get_info returns NULL_TREE for the const parameter in Name.
The cxx_eval_constant_expression in get_info produces a NOP_EXPR:

  (info) reflect_expr <int>

which is not REFLECT_EXPR_P.  This isn't caught by the
REFLECTION_TYPE_P && REFLECT_EXPR_P check in _eval_constant_expression
because OP is a NOP_EXPR.  The NOP_EXPR comes from adjust_temp_type.

I suppose I could just add STRIP_NOPS to get_info.  Or I could follow
c++/65695 / r6-41-gfb899e32c16088 and adjust cp_fold_convert to fold
away the conversion.

PR c++/123614

gcc/cp/ChangeLog:

* cvt.cc (cp_fold_convert): Avoid wrapping a REFLECT_EXPR in NOP_EXPR.

gcc/testsuite/ChangeLog:

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

Reviewed-by: Jason Merrill <jason@redhat.com>
2 months agomiddle-end: use destination type when folding addent [PR123897]
Tamar Christina [Mon, 2 Feb 2026 11:03:53 +0000 (11:03 +0000)] 
middle-end: use destination type when folding addent [PR123897]

Previously the types of the 3 operands would always be the same when you get to
convert_mult_to_fma_1.  However now they can differ untill we fold them to be the
same.  Using the type of the final expression is thus incorrect and any
intermediate operations need to happen in the type of the expression being
folded.

gcc/ChangeLog:

PR tree-optimization/123897
* tree-ssa-math-opts.cc (convert_mult_to_fma_1): Use type of variable
being folded.

gcc/testsuite/ChangeLog:

PR tree-optimization/123897
* gcc.target/aarch64/sve/pr123897.c: New test.

2 months agoAArch64: remove setting scalar dup analysis flag back to false [PR121290]
Tamar Christina [Mon, 2 Feb 2026 10:59:11 +0000 (10:59 +0000)] 
AArch64: remove setting scalar dup analysis flag back to false [PR121290]

The final loop in the PR s313 is fixed by removing he else branch that shouldn't
be there now that we look at a ratio of dups instead of a yes/no.

By setting m_loop_fully_scalar_dup the final costing doesn't think there's any
dup at all in the inner loop costing.

This returns the codegen to what it was for GCC 15.  However as the PR mentions
with the broken costing -O3 did improve.  The reason for this was that it was
preventing unrolling at -O3.

The loop generates at -O3:

.L5:
        add     w2, w2, w7
        ld1w    z26.s, p7/z, [x1]
        ld1w    z29.s, p7/z, [x0]
        ld1w    z2.s, p7/z, [x1, #1, mul vl]
        ld1w    z27.s, p7/z, [x0, #1, mul vl]
        ld1w    z1.s, p7/z, [x1, #2, mul vl]
        ld1w    z30.s, p7/z, [x0, #2, mul vl]
        ld1w    z0.s, p7/z, [x1, #3, mul vl]
        ld1w    z28.s, p7/z, [x0, #3, mul vl]
        fmul    z29.s, z26.s, z29.s
        fmul    z27.s, z2.s, z27.s
        fadda   s31, p7, s31, z29.s
        fmul    z30.s, z1.s, z30.s
        fadda   s31, p7, s31, z27.s
        fmul    z28.s, z0.s, z28.s
        fadda   s31, p7, s31, z30.s
        add     x1, x1, x3
        add     x0, x0, x3
        fadda   s31, p7, s31, z28.s
        cmp     w2, w6
        bls     .L5

Which is silly due to the limited throughput of the instructions in this loop.
the left fold reduction is a single cycle reduction since the unrolling needs
the accumulation to happen in the same scalar.

However aarch64_force_single_cycle doesn't detected this and so the costing of
the loop is wrong.  Even fixing that though the cost model does still think it's
beneficial because the throughput restrictions for the reductions aren't modeled
but to get it to reject the unrolling the cost have to be increased
unrealistically.

The better approach I think would be for us to model pipeline restrictions more
such that we have the ability to say that the above is a linear reduction chain.

However since that's not a regression and needs quite a bit of work, punted to
GCC 17.

gcc/ChangeLog:

PR target/121290
* config/aarch64/aarch64.cc (aarch64_vector_costs::add_stmt_cost):
Remove else.

gcc/testsuite/ChangeLog:

PR target/121290
* gcc.target/aarch64/pr121290_3.c: New test.

2 months agowidening_mul: Fix UADDC/USUBC pattern matching [PR121104]
Jakub Jelinek [Mon, 2 Feb 2026 09:07:15 +0000 (10:07 +0100)] 
widening_mul: Fix UADDC/USUBC pattern matching [PR121104]

As the following testcase shows, I've missed a check that element type
of lhs type of ovf1/ovf2 (.ADD_OVERFLOW/.SUB_OVERFLOW) matches type (there
are some casts accepted on the way for the case of values in [0-1] range),
so the following testcase got also matched as .SUBC and we get an ICE on
type mismatch in there.  The other .{ADD,SUB}_OVERFLOW cases already check
even the result type, both
                    if (gimple_call_internal_p (ovf, code == PLUS_EXPR
                                                     ? IFN_ADD_OVERFLOW
                                                     : IFN_SUB_OVERFLOW))
...
                        ovf_lhs = gimple_call_lhs (ovf);
                        tree ovf_lhs_type = TREE_TYPE (TREE_TYPE (ovf_lhs));
                        ovf_arg1 = gimple_call_arg (ovf, 0);
                        ovf_arg2 = gimple_call_arg (ovf, 1);
                        /* In that case we need to punt if the types don't
                           mismatch.  */
                        if (!types_compatible_p (type, ovf_lhs_type)
                            || !types_compatible_p (type, TREE_TYPE (ovf_arg1))
                            || !types_compatible_p (type,
                                                    TREE_TYPE (ovf_arg2)))
                          ovf_lhs = NULL_TREE;
and
          gimple *ovf3
            = SSA_NAME_DEF_STMT (TREE_OPERAND (gimple_assign_rhs1 (im3), 0));
          if (gimple_call_internal_p (ovf3, ifn))
            {
              lhs = gimple_call_lhs (ovf3);
              arg1 = gimple_call_arg (ovf3, 0);
              arg2 = gimple_call_arg (ovf3, 1);
              if (types_compatible_p (type, TREE_TYPE (TREE_TYPE (lhs)))
                  && types_compatible_p (type, TREE_TYPE (arg1))
                  && types_compatible_p (type, TREE_TYPE (arg2)))

2026-02-02  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/121104
* tree-ssa-math-opts.cc (match_uaddc_usubc): Punt if
lhs of ovf1 or ovf2 doesn't have element type compatible with type.

* gcc.dg/pr121104.c: New test.

2 months agoDaily bump.
GCC Administrator [Mon, 2 Feb 2026 00:16:29 +0000 (00:16 +0000)] 
Daily bump.

2 months agoa68: simplify a68_bits_test
Jose E. Marchesi [Sun, 1 Feb 2026 22:27:42 +0000 (23:27 +0100)] 
a68: simplify a68_bits_test

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

* a68-low-bits.cc (a68_bits_test): Do not get a parameter with the
result moid.
* a68.h: Adapt prototype of a68_bits_test accordingly.
* a68-low-prelude.cc (a68_lower_test3): Adjust call accordingly.

2 months agoa68: avoid indirect calls to publicized C functions
Jose E. Marchesi [Sun, 1 Feb 2026 21:49:12 +0000 (22:49 +0100)] 
a68: avoid indirect calls to publicized C functions

Publicized identifiers of proc modes with the form:

  pub proc(int)int fclose = nest C "_libga68_posixclose"

currently results in a export like:

  iden extract: POSIX_fclose [*.LMD11] variable=0 inproc=0

Note how the "inproc" export flag is not set.  This causes the
resulting applied identifier in calls to fclose to be lowered to a
VAR_DECL rather than a FUNCTION_DECL, resulting in an indirect call.

This patch makes the parser to mark identity declarations of proc
modes whose actual parameters are formal holes as "inproc".

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

* a68.h: Prototype for a68_make_proc_formal_hole_decl.
* a68-parser-extract.cc (extract_identities): Mark identity
declarations of proc modes whose actual parameter is a formal hole
as "inproc".
* a68-low.cc (a68_make_proc_formal_hole_decl): New function.
* a68-low-units.cc (a68_lower_formal_hole): Call
a68_make_proc_formal_hole_decl whenever necessary.

2 months agoAda: Fix prefixed-view notation rejected for discriminated private type
Eric Botcazou [Sun, 1 Feb 2026 19:31:41 +0000 (20:31 +0100)] 
Ada: Fix prefixed-view notation rejected for discriminated private type

The problem comes from an oversight in Analyze_Selected_Component.

gcc/ada/
PR ada/123902
* sem_ch4.adb (Analyze_Selected_Component): Also test
Core_Extensions_Allowed for discriminated private types.
Rework and augment commentary throughout the procedure.

gcc/testsuite/
* gnat.dg/prefix4.adb: New test.
* gnat.dg/prefix4_pkg.ads: New helper.

Co-authored-by: Liam Powell <liam@liampwll.com>
2 months agoAda: Fix iterator filter ignored on enumeration type with clause
Eric Botcazou [Sun, 1 Feb 2026 19:18:41 +0000 (20:18 +0100)] 
Ada: Fix iterator filter ignored on enumeration type with clause

The problem comes from an oversight in Expand_N_Loop_Statement.

gcc/ada/
PR ada/121316
* exp_ch5.adb (Expand_Iterator_Loop_Over_Array): Minor tweak.
(Expand_Iterator_Loop_Over_Container): Likewise.
(Expand_N_Loop_Statement): Use Statements (N) throughout.

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

Co-authored-by: Liam Powell <liam@liampwll.com>
2 months agotree-optimization/123755 - more (len-)masked call fixes
Richard Biener [Fri, 30 Jan 2026 07:19:06 +0000 (08:19 +0100)] 
tree-optimization/123755 - more (len-)masked call fixes

The testcase shows that we end up with (len-)masking a call even
when not semantically necessary.  The following aligns the condition
to apply len-masking with the condition to apply loop-masking, adjusting
downstream conditions to look at the chosen ifn instead of replicating
a possibly complex decision.

PR tree-optimization/123755
* tree-vect-stmts.cc (vectorizable_call): Adjust len-masking
condition.  Simplify code generation.

* gcc.dg/vect/vect-pr123755-2.c: New testcase.

2 months agotestsuite: skip pr118817 over unmet hostedlib needs
Alexandre Oliva [Sun, 1 Feb 2026 07:36:00 +0000 (04:36 -0300)] 
testsuite: skip pr118817 over unmet hostedlib needs

The test for -shared support doesn't fail on riscv64-elf, unlike other
barebones targets including riscv32-elf (testing with -fpic -shared
overflows HI20 relocs) that don't enable a hosted libstdc++.

This test thus got skipped on those other platforms, but we still
gave it a shot on riscv64-elf, and then it failed because libstdc++
doesn't have all the headers enabled that the test requires.

Require hostedlib.

for  gcc/testsuite/ChangeLog

* g++.dg/lto/pr118817_0.C: Require hostedlib.

2 months agotestsuite: riscv: pr110812_*.c needs medany on rv32
Alexandre Oliva [Sun, 1 Feb 2026 07:35:56 +0000 (04:35 -0300)] 
testsuite: riscv: pr110812_*.c needs medany on rv32

When linking the pr110812 units with lto after compiling them with a
riscv(32?) compiler that defaults to the medlow code model, the
compiler uses HI20 relocations that overflow with our linker scripts.

I suppose the test expects PC-relative relocations for symbol
resolution, as in the medany code model, so select that explicitly.

for  gcc/testsuite/ChangeLog

* gcc.target/riscv/lto/pr110812_0.c: Set cmodel explicitly.
* gcc.target/riscv/lto/pr110812_1.c: Likewise.

2 months agotestsuite: riscv: pr83403-*.c need common 32bit --param on rv32
Alexandre Oliva [Sun, 1 Feb 2026 07:35:52 +0000 (04:35 -0300)] 
testsuite: riscv: pr83403-*.c need common 32bit --param on rv32

Like various other 32-bit CPUs, riscv32 needs to bump the
max-completely-peeled-insns param to 300 to meet the expectations.

for  gcc/testsuite/ChangeLog

* gcc.dg/tree-ssa/pr83403-1.c: Bump param on riscv32.
* gcc.dg/tree-ssa/pr83403-2.c: Likewise.

2 months agotestsuite: riscv: pr90838-2.c cannot find 64-bit CTZ on rv32
Alexandre Oliva [Sun, 1 Feb 2026 07:35:48 +0000 (04:35 -0300)] 
testsuite: riscv: pr90838-2.c cannot find 64-bit CTZ on rv32

riscv32 has never had the 64-bit CTZ intrinsic that the test expects.
That expectation was likely a mistake.  Drop it.

for  gcc/testsuite/ChangeLog

* gcc.dg/pr90838-2.c: Drop 64-bit CTZ expectation on riscv32.

2 months agotestsuite: riscv: pr114139 goes 64-bit without choosing a 64-bit abi
Alexandre Oliva [Sun, 1 Feb 2026 07:35:44 +0000 (04:35 -0300)] 
testsuite: riscv: pr114139 goes 64-bit without choosing a 64-bit abi

This test selects a 64-bit cpu, which sets the arch to 64-bit, without
selecting a 64-bit abi, so it fails on riscv32-elf.  Set the abi.

for  gcc/testsuite/ChangeLog

* gcc.target/riscv/pr114139.c: Set the abi explicitly.

2 months agotestsuite: riscv: pr118170 goes 64-bit without choosing a 64-bit abi
Alexandre Oliva [Sun, 1 Feb 2026 07:35:41 +0000 (04:35 -0300)] 
testsuite: riscv: pr118170 goes 64-bit without choosing a 64-bit abi

The test selects a 64-bit cpu explicitly, which enables a 64-bit arch,
but the test doesn't set the abi, so it fails on riscv32-elf.  Set a
64-bit abi explicitly.

for  gcc/testsuite/ChangeLog

* gcc.target/riscv/pr118170.c: Set the abi explicitly.

2 months agotestsuite: riscv: set abi along with arch word size
Alexandre Oliva [Sun, 1 Feb 2026 07:35:37 +0000 (04:35 -0300)] 
testsuite: riscv: set abi along with arch word size

The shuffle-slide.c test fails on riscv32-elf because it overrides
arch to rv64gcv without selecting a 64-bit abi.  Set it to lp64d.

for  gcc/testsuite/ChangeLog

* gcc.target/riscv/rvv/autovec/vls-vlmax/shuffle-slide.c:
Set the abi explicitly.

2 months agotestsuite: riscv: set expected code model for pr113206-2.c
Alexandre Oliva [Sun, 1 Feb 2026 07:35:33 +0000 (04:35 -0300)] 
testsuite: riscv: set expected code model for pr113206-2.c

With a compiler that defaults to cmodel medany, pr113206-2.c ends up
generating an extra vsetvli insn.

Set the code model explicitly to medlow to meet the expectation.

This is unfortunately not enough to get the test to a pass on trunk.
It is on gcc-15 and the change is an improvement, but trunk still gets
an unexpected vsetvli even with the change.

for  gcc/testsuite/ChangeLog

* gcc.target/riscv/rvv/autovec/pr113206-2.c: Set the expected
code model explicitly.

2 months agotestsuite: riscv: set expected code model
Alexandre Oliva [Sun, 1 Feb 2026 07:35:30 +0000 (04:35 -0300)] 
testsuite: riscv: set expected code model

When testing a compiler configured to default to the medany code
model, riscv autovec binop vadd and vsub -nofm tests fail because
their codegen expectations don't match the generated code.

Set the code model to the medlow model that the tests expect.

for  gcc/testsuite/ChangeLog

* gcc.target/riscv/rvv/autovec/binop/vadd-rv32gcv-nofm.c: Set the
expected code model explicitly.
* gcc.target/riscv/rvv/autovec/binop/vadd-rv64gcv-nofm.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vsub-rv32gcv-nofm.c: Likewise.
* gcc.target/riscv/rvv/autovec/binop/vsub-rv64gcv-nofm.c: Likewise.

2 months agotestsuite: riscv: disable scheduling for rvv/autovec/bug-3.c
Alexandre Oliva [Sun, 1 Feb 2026 07:35:23 +0000 (04:35 -0300)] 
testsuite: riscv: disable scheduling for rvv/autovec/bug-3.c

Combine was prevented for some time from combining two ashifts when
the substituted insn couldn't be removed, and r15-7801 changed the
expectations to match.

Combine was later allowed to combine such insns, and the scheduler
reorders the insns so that the expected function body doesn't match.

I've added options to disable scheduling, and I've restored the
combine expectation.

for  gcc/testsuite/ChangeLog

* gcc.target/riscv/rvv/autovec/bug-3.c: Disable scheduling,
and restore expectation of slli combine.

2 months agotestsuite: riscv: valgrind: tolerate unhandled syscall
Alexandre Oliva [Sun, 1 Feb 2026 07:35:16 +0000 (04:35 -0300)] 
testsuite: riscv: valgrind: tolerate unhandled syscall

When running a riscv(32|64)-elf-targeting compiler on a
x86_64-linux-gnu with valgrind-3.18.1, it prints a multi-line warning
about an unhandled syscall, but the test works if we ignore those
lines to avoid an excess errors failure.

I've thus arranged for relevant pieces of the valgrind warning to be
pruned.

for  gcc/testsuite/ChangeLog

* gcc.target/riscv/pr122215.c: Prune valgrind unhandled
syscall multi-line warning.

2 months agotestsuite: riscv: adjust/xfail dynamic-lmul tests
Alexandre Oliva [Sun, 1 Feb 2026 07:35:09 +0000 (04:35 -0300)] 
testsuite: riscv: adjust/xfail dynamic-lmul tests

While investigating riscv*-elf testsuite failures in gcc-15, I found
mainline still had failures for a number of the dynamic-lmul tests I
investigated, though not always the same as gcc-15 due to other
changes.  Here are some adjustments to the tests, whether updates or
xfails, to fix or silence the failures for gcc-16, respectively.

* dynamic-lmul4-3.c: r16-843 had bumped the "Maximum lmul = 2" count,
which was reasonable then, but subsequent changes in e.g. r16-2515
restored the original count, so revert that expectation.

* dynamic-lmul4-7.c: SLP improvements seem to have caused us to find
more live V_REGs during analysis, so we choose 1 instead of 2 for
lmul.  Because of additional live V_REGs, AFAICT introduced by SLP, we
lower the RVV mode choice twice rather than the expected once.  Since
the SLP improvements AFAICT make the code worse, at least for leading
to a lower lmul choice, I'm marking these two deviations as expected
failures.

* dynamic-lmul4-5.c: Like 4-7, this one regressed in the lmul choice
due to extra live V_REGs, and thus got extra messages about preferring
a lower lmul.  As for the start/end patterns, I can't tell what they
were meant to test, but the live V_REGs have changed so significantly,
and are so likely to keep changing, that I figured we're better off
dropping those failing expectations.  This is the only test that had
them.

* dynamic-lmul4-6.c: For some reason I haven't tried to figure out,
but I guess it also has to do with SLP improvements, the "Maximum lmul
= [24]" messages are no longer printed after "Update local program
points for bb 6" for this test, so I'm XFAILing them, because that
feels like a regression even though we end up with the expected lmul.

* dynamic-lmul4-8.c: Same as 4-6.

* dynamic-lmul8-10.c: I haven't tried to figure out why the initial
maximum lmul estimate has fallen from 8 to 4, despite the V_REG's
count being (proportionally) the same and fitting, but we still choose
8 for lmul, so I'm dropping the requirement for an 'lmul = 8' match
under the tentative conclusion that the expectation is unnecessary.

* dynamic-lmul8-12.c: Same as 8-10 and 4-6.

* pr113112-3.c: We get a much higher lmul (m8) than expected (m2), for
the same e32 element size, but the generated code is far too much
larger and hairier.  While the lmul bump is probably a welcome
improvement, the expected choice of return instruction isn't found,
and I can't tell why the test prefers one over the other, so I'm
XFAILing all of them.

* pr113112-4.c: We get a lower lmul than expected, but that
expectation was different before r15-639, and we get what we used to
expect before that change.  Since we could do better at some point,
I'm XFAILing it.

for  gcc/testsuite/ChangeLog

* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul4-3.c: Revert
Maximum lmul = 2 count.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul4-7.c: XFAIL
unmet lmul selection expectations.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul4-5.c: Likewise,
and drop start/end patterns.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul4-6.c: XFAIL
missing Maximum lmul messages.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul4-8.c: Likewise.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-12.c: Drop
Maximum lmul = 8 message.  Likewise.
* gcc.dg/vect/costmodel/riscv/rvv/dynamic-lmul8-10.c: Likewise.
* gcc.dg/vect/costmodel/riscv/rvv/pr113112-3.c: XFAIL unexpected
selections of lmul, and of return insn.
* gcc.dg/vect/costmodel/riscv/rvv/pr113112-4.c: XFAIL unexpected
selection of lmul.

2 months agoc++: Fix error recovery after export keyword [PR121832]
Nathaniel Shead [Fri, 12 Sep 2025 13:26:20 +0000 (23:26 +1000)] 
c++: Fix error recovery after export keyword [PR121832]

When we enter cp_parser_explicit_template_declaration with the following
tokens being 'template <>', we never parse a parameter list and so with
-fconcepts we crash dereferencing a null pointer.  This can currently
only happen after a non-modules 'export' declaration, as all other paths
check early for this case.

PR c++/121832

gcc/cp/ChangeLog:

* parser.cc (cp_parser_explicit_template_declaration): Check for
null.

gcc/testsuite/ChangeLog:

* g++.dg/concepts/pr121832.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
2 months agoDaily bump.
GCC Administrator [Sun, 1 Feb 2026 00:16:28 +0000 (00:16 +0000)] 
Daily bump.

2 months agoa68: add TEST operator for bits to expanded prelude
Jose E. Marchesi [Sat, 31 Jan 2026 17:34:11 +0000 (18:34 +0100)] 
a68: add TEST operator for bits to expanded prelude

This patch adds support for a TEST operator for L bits.  Documentation
and tests are included.

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

* a68.h: Prototypes for a68_bits_test and a68_lower_test3.
* a68-low-bits.cc (a68_bits_test): New function.
* a68-low-prelude.cc (a68_lower_test3): Likewise.
* a68-parser-prelude.cc (gnu_prelude): Declare TEST operators and
their priority.
* ga68.texi (Extended bits operators): New section.

gcc/testsuite/ChangeLog

* algol68/execute/bits-test-1.a68: New test.

2 months agoa68: add SET and CLEAR operators for L bits
Jose E. Marchesi [Fri, 30 Jan 2026 10:41:05 +0000 (11:41 +0100)] 
a68: add SET and CLEAR operators for L bits

This commit adds two more operators to the extended standard prelude
that work on L bits values.

Tests and documention included.

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

* ga68.texi (POSIX files): Document SET and CLEAR operators.
* a68.h: Prototypes for a68_bits_set, a68_bits_clear,
a68_lower_set3 and a68_lower_clear3.
* a68-low-bits.cc (a68_bits_set): New function.
(a68_bits_clear): Likewise.
* a68-low-prelude.cc (a68_lower_set3): Likewise.
(a68_lower_clear3): Likewise.
* a68-parser-prelude.cc (gnu_prelude): Declare operators SET and
CLEAR and their priorities.

gcc/testsuite/ChangeLog

* algol68/execute/bits-clear-1.a68: New test.
* algol68/execute/bits-set-1.a68: Likewise.

2 months ago[PATCH] picolibc: Use %:find-file for both test and access to picolibc.ld
Keith Packard [Sat, 31 Jan 2026 14:00:26 +0000 (07:00 -0700)] 
[PATCH] picolibc: Use %:find-file for both test and access to picolibc.ld

If the gcc driver and linker don't agree on what the search path for
linker scripts is, then the driver may discover a file that
the linker won't end up using. This results in linking failures
when applications don't specific an explicit linker script.

Fix this by duplicating the call to %:find-file for both
test and in the parameter passed to the linker.

gcc/
* config/picolibc-spec.h (LIBC_LINK_SPEC): Use find-file for test
and access to picolibc.ld.

2 months agomiddle-end/123887 - fix another missing side-effect check
Richard Biener [Fri, 30 Jan 2026 18:30:40 +0000 (19:30 +0100)] 
middle-end/123887 - fix another missing side-effect check

The following fixes up another pattern lacking a check for
side-effects on operands made evaluated unconditional.

PR middle-end/123887
* match.pd ((a ? x : y) !=/== (b ? x : y)): Make sure
x and y have no side-effects before evaluating them
unconditionally.

* gcc.dg/torture/pr123887-2.c: New testcase.

2 months agoFortran: Introduce macros IS_PDT and IS_CLASS_PDT
Paul Thomas [Sat, 31 Jan 2026 10:34:26 +0000 (10:34 +0000)] 
Fortran: Introduce macros IS_PDT and IS_CLASS_PDT

2026-01-31  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
* array.cc (resolve_array_list): Use macro IS_PDT.
* gfortran.h : Supply macros IS_PDT and IS_CLASS_PDT.
* match.cc (gfc_match_type_is): Use IS_PDT and IS_CLASS_PDT as
appropriate.
* resolve.cc (gfc_resolve_ref, build_init_assign,
resolve_component): Likewise.
* trans-array.cc (gfc_trans_array_constructor_value,
trans_array_constructor, structure_alloc_comps,
has_parameterized_comps): Likewise.
* trans-decl.cc (gfc_get_symbol_decl, gfc_init_default_dt,
gfc_trans_deferred_vars, gfc_generate_function_code): Likewise.
* trans-expr.cc (conv_dummy_value, gfc_conv_structure,
gfc_trans_assignment_1): Likewise.
* trans-stmt.cc (trans_associate_var, gfc_trans_allocate,
gfc_trans_deallocate): Likewise.

2 months agoc++: Fix cp_fold_non_odr_use_1 [PR123557,PR123738]
Nathaniel Shead [Sat, 24 Jan 2026 08:34:53 +0000 (19:34 +1100)] 
c++: Fix cp_fold_non_odr_use_1 [PR123557,PR123738]

This fixes two issues with cp_fold_non_odr_use_1:

- When called to fold away a reference, it considers the use to not be
  an lvalue and so 'maybe_constant_value' folds all the way through the
  nested INDIRECT_REF to a prvalue.  Fixed by folding the op0 of the
  INDIRECT_REF rather than the ref itself and avoiding a double
  cp_fold_non_odr_use_1.

- When used to fold away the initializing expression for an INIT_EXPR,
  it doesn't mark any new TARGET_EXPRs as eliding.  Fixed by reapplying
  'set_target_expr_eliding' for the initializer of an INIT_EXPR if it
  got modified during ff_only_non_odr walk.

PR c++/123557
PR c++/123738

gcc/cp/ChangeLog:

* cp-gimplify.cc (cp_fold_maybe_rvalue): Call
cp_fold_non_odr_use_1 before recursing cp_fold.
(cp_fold): Pass op0 to cp_fold_non_odr_use_1 when folding a
reference.  Reapply set_target_expr_eliding on the initializing
expression of an INIT_EXPR.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/constexpr-ice22.C: New test.
* g++.dg/cpp2a/constexpr-ref2.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
2 months agoc++: Handle argument merging push_local_extern_decl_alias [PR123825]
Jakub Jelinek [Sat, 31 Jan 2026 09:19:26 +0000 (10:19 +0100)] 
c++: Handle argument merging push_local_extern_decl_alias [PR123825]

The first testcase comes directly from
https://eel.is/c++draft/meta.reflection#names-1.8.2
and shows that we don't handle for -freflection the function
argument name difference handling isn't performed for local externs,
which doesn't go the duplicate_decls route but directly remembers
the alias.
The following patch handles outlines the DECL_ARGUMENTS handling
from duplicate_decls and uses it in push_local_extern_decl_alias
(with some minor differences and for now not propagating attributes
back for the push_local_extern_decl_alias case unless -freflection).

ALso, I found that the addition of a new alias created completely broken
DECL_ARGUMENTS (copied at most the first PARM_DECL, never more than that).
That is because copy_decl clears DECL_CHAIN, so the loop always stopped
after the first iteration.

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

PR c++/123825
* cp-tree.h (merge_decl_arguments): Declare.
* decl.cc (duplicate_decls): Outline DECL_ARGUMENTS handling
into ...
(merge_decl_arguments): ... new function.
* name-lookup.cc (push_local_extern_decl_alias): Call
merge_decl_arguments.  Don't copy just the first PARM_DECL when
creating a new alias FUNCTION_DECL.

* g++.dg/reflect/has_identifier3.C: New test.
* g++.dg/reflect/identifier_of3.C: New test.
* g++.dg/cpp26/attr-indeterminate5.C: New test.

2 months agod: Merge upstream dmd, druntime e1f6680f50, phobos f87979028
Iain Buclaw [Fri, 30 Jan 2026 16:30:33 +0000 (17:30 +0100)] 
d: Merge upstream dmd, druntime e1f6680f50, phobos f87979028

D front-end changes:

- Import latest fixes from v2.112.0-beta.1.
- Associative array operations are now lowered to templates
  defined in `core.internal.newaa'.

D runtime changes:

- Import latest fixes from v2.112.0-beta.1.

Phobos changes:

- Import latest fixes from v2.112.0-beta.1.

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd e1f6680f50.
* Make-lang.in (D_FRONTEND_OBJS): Remove d/gluelayer.o, d/iasm.o,
d/iasmgcc.o.  Add d/iasm-package.o, d/iasm-gcc.o.
(d/iasm-%.o): New recipe.
* d-convert.cc (convert_expr): Remove library call to dynamic_cast.
* d-lang.cc (d_init_options): Set errorSupplementLimit parameter.
* decl.cc (DeclVisitor::visit): Update for new front-end interface.
* expr.cc (ExprVisitor::visit (EqualExp *)): Update for front-end
lowering expression using templates.
(ExprVisitor::visit (InExp *)): Likewise.
(ExprVisitor::visit (IndexExp *)): Likewise.
(ExprVisitor::visit (CastExp *)): Likewise.
(ExprVisitor::visit (RemoveExp *)): Likewise.
(ExprVisitor::visit (AddrExp *)): Likewise.
(ExprVisitor::visit (NewExp *)): Likewise.
(ExprVisitor::visit (ArrayLiteralExp *)): Likewise.
(ExprVisitor::visit (AssocArrayLiteralExp *)): Likewise.
* imports.cc (ImportVisitor::visit (AliasDeclaration *)): Update for
new front-end interface.
* runtime.def (DYNAMIC_CAST): Remove.
(INTERFACE_CAST): Remove.
(ARRAYLITERALTX): Remove.
(ADEQ2): Remove.
(ASSOCARRAYLITERALTX): Remove.
(AANEW): Remove.
(AAEQUAL): Remove.
(AAINX): Remove.
(AAGETY): Remove.
(AAGETRVALUEX): Remove.
(AADELX): Remove.
* typeinfo.cc (TypeInfoVisitor::visit): Layout xopEquals and xtoHash
in TypeInfo_AssociativeArray.
(create_typeinfo): Add new fields to internal typeinfo.
(check_typeinfo_type): Print instantiation trace of error.
* types.cc (TypeVisitor::visit (TypeStruct *)): Update for new
front-end interface.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime e1f6680f50.
* libdruntime/Makefile.am (DRUNTIME_DSOURCES): Add
core/internal/cast_.d.  Remove rt/aaA.d, rt/adi.d, rt/cast_.d.
(DRUNTIME_DSOURCES_POSIX): Add core/sys/posix/endian.d.
* libdruntime/Makefile.in: Regenerate.
* src/MERGE: Merge upstream phobos f87979028.
* src/Makefile.am (PHOBOS_DSOURCES): Add std/internal/entropy.d.
* src/Makefile.in: Regenerate.
* testsuite/libphobos.aa/test_aa.d: Adjust test.
* testsuite/libphobos.init_fini/custom_gc.d: Likewise.

gcc/testsuite/ChangeLog:

* gdc.dg/asm1.d: Adjust test.
* gdc.dg/asm5.d: Likewise.
* gdc.dg/pr100967.d: Likewise.
* gdc.dg/rtti1.d: Likewise.
* gdc.dg/rtti2.d: New test.

2 months agodoc: Switch delorie.com to https
Gerald Pfeifer [Sat, 31 Jan 2026 07:40:28 +0000 (08:40 +0100)] 
doc: Switch delorie.com to https

gcc:
* doc/install.texi (Binaries): Switch delorie.com to https.

2 months agotestsuite: arm: crypto-vsha1*_u32 tests got late-combine improvements
Alexandre Oliva [Sat, 31 Jan 2026 04:52:10 +0000 (01:52 -0300)] 
testsuite: arm: crypto-vsha1*_u32 tests got late-combine improvements

The late-combine pass enabled some of the vdup.32 instructions
expected in crypto-vsha1*_u32 tests to use d registers, so accept them
as well.

While at that, drop the excess + after ] in d register matches in
vmov.32 instructions.

for  gcc/testsuite/ChangeLog

* gcc.target/arm/crypto-vsha1cq_u32.c: Accept d regs in
vdup.32.  Drop extraneous + after ] in vmov.32 pattern.
* gcc.target/arm/crypto-vsha1h_u32.c: Likewise.
* gcc.target/arm/crypto-vsha1mq_u32.c: Likewise.
* gcc.target/arm/crypto-vsha1pq_u32.c: Likewise.

2 months agotestsuite: arm: add -mcpu=unset before -march
Alexandre Oliva [Sat, 31 Jan 2026 04:52:05 +0000 (01:52 -0300)] 
testsuite: arm: add -mcpu=unset before -march

Reset the cpu selection to the default on tests that set -march
explicitly instead of using dg-add-options.  The latter would reset
the cpu selection to avoid interference from TOOL_OPTIONS.

Also add +fp to -march in tests that don't override float-abi and fpu,
so that -mfloat-abi=hard -mfpu=auto in TOOL_OPTIONS won't cause a
failure.

for  gcc/testsuite/ChangeLog

* gcc.target/arm/bfloat16_simd_1_2.c: Add -mcpu=unset.
* gcc.target/arm/bfloat16_simd_2_2.c: Likewise.
* gcc.target/arm/bfloat16_simd_3_2.c: Likewise.
* gcc.dg/torture/pr120347.c: Likewise.  Add +fp to -march.

2 months agotestsuite: arm: update fast-math-complex-mls-half-float.c
Alexandre Oliva [Sat, 31 Jan 2026 04:51:53 +0000 (01:51 -0300)] 
testsuite: arm: update fast-math-complex-mls-half-float.c

Since the addition of DCE after complex lowering, reassoc1 has no
longer been impeded by COMPLEX_EXPRs, so it changes (a - (b + c)),
where (b + c) is the imaginary part of an intermediate complex value,
to ((a - b) - c), and this prevents the vectorizer from recognizing
the expected COMPLEX_ADD_ROT270 pattern in fms_elemconjsnd.

Stop expecting that pattern to be found on that test.

for  gcc/testsuite/ChangeLog

* gcc.dg/vect/complex/fast-math-complex-mls-half-float.c:
Don't expect COMPLEX_ADD_ROT270.

2 months agoanalyzer: fix ICE on rethrow without throw [PR123880]
David Malcolm [Sat, 31 Jan 2026 04:27:40 +0000 (23:27 -0500)] 
analyzer: fix ICE on rethrow without throw [PR123880]

gcc/analyzer/ChangeLog:
PR analyzer/123880
* engine.cc (throw_custom_edge::update_model): Gracefully handle
not knowing the current exception in a rethrow.
(exploded_node::on_throw): Likewise.

gcc/testsuite/ChangeLog:
PR analyzer/123880
* g++.dg/analyzer/exception-rethrow-3.C: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 months agocompare_tests: Don't hardcode grep -E
Pietro Monteiro [Sat, 31 Jan 2026 03:27:14 +0000 (22:27 -0500)] 
compare_tests: Don't hardcode grep -E

The non-unique test names report is broken on systems where 'grep -E' is
not supported.  Use egrep if a simple test for 'grep -E' fails.

contrib/ChangeLog:

* compare_tests: Use egrep if 'grep -E' is not supported.

Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
2 months agoc++: defer DECL_ONE_ONLY vs consteval-only [PR122785]
Jason Merrill [Wed, 28 Jan 2026 06:17:13 +0000 (14:17 +0800)] 
c++: defer DECL_ONE_ONLY vs consteval-only [PR122785]

The failure in the given PR occurs because when setting up an
imported vague-linkage variable, we currently call 'maybe_commonize_var'
which for -freflection checks 'consteval_only_p'.  Unfortunately this
latter function needs to call 'complete_type_p' which can perform
recursive loading of the (possibly yet-to-be-streamed) class type,
breaking modules assumptions.

If we just remove the consteval_only_p early exit from maybe_commonize_var,
we end up crashing at EOF while trying to mangle its comdat group, so we
need to undo maybe_commonize_var along with setting DECL_EXTERN.

PR c++/122785

gcc/cp/ChangeLog:

* decl.cc (maybe_commonize_var): Don't check consteval_only_p.
(make_rtl_for_nonlocal_decl): Undo make_decl_one_only for
consteval-only variables.

gcc/testsuite/ChangeLog:

* g++.dg/modules/reflect-1_a.H: New test.
* g++.dg/modules/reflect-1_b.C: New test.

Co-authored-by: Nathaniel Shead <nathanieloshead@gmail.com>
2 months agolibstdc++/regex: Suppress -Wpedantic warning about anonymous structs
Patrick Palka [Sat, 31 Jan 2026 02:01:08 +0000 (21:01 -0500)] 
libstdc++/regex: Suppress -Wpedantic warning about anonymous structs

Fixes some modules testsuite compilation errors.

libstdc++-v3/ChangeLog:

* include/bits/regex_executor.tcc (_ExecutorFrameBase): Add
#pragma GCC diagnostic to suppress -Wpedantic warning about
anonymous structs.

2 months agolibitm: testsuite: don't include libstdc++ paths in test names [PR69018]
Pietro Monteiro [Sat, 31 Jan 2026 01:22:49 +0000 (20:22 -0500)] 
libitm: testsuite: don't include libstdc++ paths in test names [PR69018]

Libitm C++ tests pass -B/full/path/to/build/libstc++/src/.libs on the
options argument to dg-runtest and the libstdc++ include paths as
the default-extra-options.  This causes 2 problems:

1) If a test uses `dg-options' then the libstdc++ include paths are
not passed to the compiler.

2) The `-B/full/path/to/build/libstc++/src/.libs' gets added to the
test name.  This makes comparing build done in different directories
harder because the hardcoded full path.

Stop passing options and default-extra-options to dg-runtest and move
dealing with the path-releated flags to libitm_target_compile in
libitm.exp, where they are added to additional_flags.

Also change the FSF address to the website in the license text.

libitm/ChangeLog:
PR libitm/69018
* testsuite/lib/libitm.exp (libitm_target_compile): Add
lang_include_flags and `-B${blddir}/${lang_library_paths}' to
additional_flags.
* testsuite/libitm.c++/c++.exp: Set lang_library_paths and lang_include_flags.

Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
2 months agoDaily bump.
GCC Administrator [Sat, 31 Jan 2026 00:16:35 +0000 (00:16 +0000)] 
Daily bump.

2 months agoFortran: Fix PR123868
Jerry DeLisle [Fri, 30 Jan 2026 21:25:23 +0000 (13:25 -0800)] 
Fortran: Fix PR123868

When copying derived types with allocatable array components where the
array element type also has allocatable components, the condition at
line 11071 was incorrectly triggering a call to gfc_duplicate_allocatable.
However, for allocatable arrays with nested allocatables (where
cmp_has_alloc_comps && c->as is true), the add_when_allocated code
already includes a gfc_duplicate_allocatable call (generated by the
recursive structure_alloc_comps call at lines 10290-10293).

This caused the outer array to be allocated twice: first by the explicit
gfc_duplicate_allocatable call at line 11099, and then again by the
gfc_duplicate_allocatable embedded in add_when_allocated.  The first
allocation was leaked when the second allocation overwrote the data
pointer.

PR121628 added "add_when_allocated != NULL_TREE ||" to the condition,
which was redundant for scalars (already handled by !c->as) and wrong
for arrays (caused double allocation).  Simply removing this clause
restores the correct pre-PR121628 behavior.

PR fortran/123868

gcc/fortran/ChangeLog:

* trans-array.cc (structure_alloc_comps): For COPY_ALLOC_COMP,
remove the add_when_allocated != NULL_TREE clause that PR121628
added.  This clause was redundant for scalars and caused double
allocation for arrays with nested allocatable components.

gcc/testsuite/ChangeLog:

* gfortran.dg/array_memcpy_2.f90: Update expected memcpy count
from 4 to 3, as the double allocation bug is now fixed.
* gfortran.dg/pr123868.f90: New test.

Signed-off-by: Christopher Albert <albert@alumni.tugraz.at>
2 months agoc++: non-empty constexpr constructor bodies in C++11 [PR123845]
Patrick Palka [Fri, 30 Jan 2026 20:25:43 +0000 (15:25 -0500)] 
c++: non-empty constexpr constructor bodies in C++11 [PR123845]

This patch makes us support C++14 non-empty constexpr constructor bodies
in C++11, as an extension.  This will make it trivial to safely fix the
C++11 library regression PR114865 that requires us to do
__builtin_clear_padding after initializing _M_i in std::atomic's
single-parameter constructor, and that's not really possible with the
C++11 constexpr restrictions.

Since we lower member initializers to constructor body statements
internally, and so constructor bodies are already effectively non-empty
internally even in C++11, supporting non-empty bodies in user code is
mostly a matter of relaxing the parse-time error.

But constexpr-ex3.C revealed that by accepting the non-empty body of A's
constructor, build_data_member_initialization goes on to mistake the
'i = _i' assignment as a member initializer, and we incorrectly accept
the constructor in C++11 mode (even though omitting mem-inits is only
valid since C++20).  Turns out this is caused by that function
recognizing MODIFY_EXPR only in C++11 mode, logic that was last changed
by r5-5013 (presumably to limit impact of the patch at the time) but I
reckon could just be removed outright.  This should be safe because the
result of build_data_member_initialization is only used by
cx_check_missing_mem_inits for validation; evaluation is in terms of
the entire lowered constructor body.

PR c++/123845
PR libstdc++/114865

gcc/cp/ChangeLog:

* constexpr.cc (build_data_member_initialization): Remove
C++11-specific recognition of MODIFY_EXPR.
(check_constexpr_ctor_body): Relax error diagnostic to a
pedwarn and don't clear DECL_DECLARED_CONSTEXPR_P upon
error.  Return true if complaining.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/constexpr-ex3.C: Adjust C++11 non-empty
constexpr constructor dg-error to a dg-warning.  Expect
a follow-up missing member initializer diagnostic in C++11 mode.
* g++.dg/cpp2a/constexpr-try1.C: Expect a follow-up
compound-statement in constexpr function diagnostic in C++11
mode.
* g++.dg/cpp2a/constexpr-try2.C: Likewise.  Adjust C++11
non-empty constexpr constructor dg-error to a dg-warning.
* g++.dg/cpp2a/constexpr-try3.C:  Adjust C++11 non-empty
constexpr constructor dg-error to a dg-warning.
* g++.dg/cpp0x/constexpr-ctor23.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
2 months agomiddle-end/123887 - trapping conditional operand turned unconditional
Richard Biener [Fri, 30 Jan 2026 14:32:39 +0000 (15:32 +0100)] 
middle-end/123887 - trapping conditional operand turned unconditional

The following properly checks expr_no_side_effects_p on two patterns
that turns a conditionally evaluated operand into unconditonal.

PR middle-end/123887
* match.pd ((zero_one ==/!= 0) ? .. z <op> y .. -> zero_one * z ..):
Check evaluating z unconditionally has no side-effects, like
trapping.

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

2 months agodebug/123886 - remove GTY((skip)) from external_die_map entry
Richard Biener [Fri, 30 Jan 2026 13:55:58 +0000 (14:55 +0100)] 
debug/123886 - remove GTY((skip)) from external_die_map entry

The following avoids GCing IDENTIFIER_POINTERs referenced from
external_die_map after we clear ggc_protect_identifiers.  I never
expected those to be GCed.

PR debug/123886
* dwarf2out.cc (sym_off_pair::sym): Remove GTY((skip)).

2 months agolibstdc++/regex: add [[gnu::always_inline]] to _Executor::_M_node
Patrick Palka [Fri, 30 Jan 2026 18:16:20 +0000 (13:16 -0500)] 
libstdc++/regex: add [[gnu::always_inline]] to _Executor::_M_node

The compiler understandably doesn't know that _M_node only ever has a
single call site, _M_dfs, (and is not directly called from other library
headers or user code) and so decides not to inline it.  So use the
always_inline attribute to force the inlining.  This seems sufficient to
make all _M_dfs subroutines get inlined away, and speeds up the executor
by 30% on some microbenchmarks.

libstdc++-v3/ChangeLog:

* include/bits/regex_executor.tcc (__detail::_Executor::_M_node)
[__OPTIMIZE__]: Add [[gnu::always_inline]] attribute.  Declare
inline.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2 months agoAda: Fix regression in visibility for nested use_type_clauses
Gary Dismukes [Fri, 30 Jan 2026 16:55:16 +0000 (17:55 +0100)] 
Ada: Fix regression in visibility for nested use_type_clauses

An earlier fix for wrong handling of visibility when a use_type_clause
with "all" occurs within a nested scope when there's a use_type_clause
in an enclosing scope without "all" was incorrect and led to primitives
being visible in a later nested scope that has a use_type_clause with
"all" for the same type.  We now properly restore Current_Use_Clause
to refer to the outer use_type_clause when ending the scope of nested
use_type_clauses.

gcc/ada/
* sem_ch8.adb (End_Use_Type): Remove test of Prev_Use_Clause as
as a condition for resetting In_Use and Current_Use_Clause, and
change setting of that flag and field based on Prev_Use_Clause
rather than setting them to Empty. Revise preceding comment.

2 months agolibstdc++/regex: Defer _M_current restoration to backtracking nodes [PR86164]
Patrick Palka [Fri, 30 Jan 2026 17:29:17 +0000 (12:29 -0500)] 
libstdc++/regex: Defer _M_current restoration to backtracking nodes [PR86164]

The incrementing of the current input string position (_M_current) is
done by _M_handle_match, which also makes sure to restore it afterwards,
via a restore_current frame.  But restoring _M_current is naturally only
necessary when backtracking is involved, not after every single match.

So this patch moves the responsibility of saving/restoring _M_current
from _M_handle_match to the branching nodes _M_handle_alternative and
_M_handle_repeat.  This is done by storing _M_current within the
fallback_next, fallback_rep_once_more and posix_alternative frames.
In turn we can get rid of the now unused restore_current frame kind.

This reduces the maximum size of the _M_frames stack by 15% for

  regex_match(string(200000, 'a'), "(a|b|c)*")

PR libstdc++/86164

libstdc++-v3/ChangeLog:

* include/bits/regex_executor.tcc (__detail::_ExecutorFrameOpcode):
Remove _S_fopcode_restore_current.
(__detail::_Executor::_M_handle_repeat): Pass _M_current when
pushing a fallback_next or fallback_rep_once_more frame.
(__detail::_Executor::_M_handle_match): Don't push a
restore_current frame.
(__detail::_Executor::_M_handle_backref): Likewise and simplify
accordingly.
(__detail::_Executor::_M_handle_alternative): Pass _M_current when
pushing a fallback_next or posix_alternative frame.
(__detail::_Executor::_M_dfs) <case _S_fopcode_fallback_next>:
Restore _M_current.
<case _S_fopcode_fallback_rep_once_more>: Likewise.
<case _S_fopcode_posix_alternative>: Likewise.
<case _S_fopcode_restore_current>: Remove.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2 months agolibstdc++/regex: Make DFS executor non-recursive [PR86164]
Patrick Palka [Fri, 30 Jan 2026 17:23:40 +0000 (12:23 -0500)] 
libstdc++/regex: Make DFS executor non-recursive [PR86164]

This patch replaces the recursive implementation of the DFS executor
with an iterative one using an explicit heap-based stack.  System
stack usage of the executor is now constant with respect to input size
rather than linear, avoding stack overflow errors when processing
long inputs.

PR libstdc++/86164

libstdc++-v3/ChangeLog:

* include/bits/regex.h (__detail::_Executor): Use inline
namespace _V2.
* include/bits/regex_executor.h (__detail::_ExecutorFrame):
Declare.
(__detail::_Executor): Use inline namespace _V2.
(__detail::_Executor::_M_node): Declare.
(__detail::_Executor::_M_frames): New data member.
* include/bits/regex_executor.tcc (__detail::_ExecutorFrameOpcode):
New.
(__detail::_ExecutorFrameBase): New.
(__detail::_ExecutorFrame): New.
(__detail::_Executor): Use inline namespace _V2.
(__detail::_Executor::_M_rep_once_more): Replace recursive
_M_dfs calls with an _S_opcode_next frame push, and any work
after such calls with an appropriate frame push.
(__detail::_M_handle_repeat): Likewise.
(__detail::_M_handle_subexpr_begin): Likewise.
(__detail::_M_handle_subexpr_end): Likewise.
(__detail::_M_handle_line_begin_assertion): Likewise.
(__detail::_M_handle_line_end_assertion): Likewise.
(__detail::_M_handle_word_boundary): Likewise.
(__detail::_M_handle_subexpr_lookahead): Likewise.
(__detail::_M_handle_match): Likewise.
(__detail::_M_handle_backref): Likewise.
(__detail::_M_handle_accept): Likewise.
(__detail::_M_handle_alternative): Likewise.
(__detail::_M_node): Factored out from _M_dfs.
(__detail::_M_dfs): Push an initial frame to _M_frames that
visits the starting node and pass this stack each subroutine.
Pop the latest _ExecutorFrame from _M_frames and handle
appropriately according to its _ExecutorFrameOpcode.  Loop until
_M_frames is empty.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2 months agodoc: Explain flto-toplevel-asm-heuristics
Michal Jires [Thu, 29 Jan 2026 14:07:49 +0000 (15:07 +0100)] 
doc: Explain flto-toplevel-asm-heuristics

This patch adds documentation for flto-toplevel-asm-heuristics
and mentions it in Remarks in Basic Asm.

gcc/ChangeLog:

* doc/extend.texi: Mention flto-toplevel-asm-heuristics.
* doc/invoke.texi: Add flto-toplevel-asm-heuristics.

2 months agoc++/reflection: check TYPE_BEING_DEFINED in define_aggregate
Marek Polacek [Wed, 28 Jan 2026 22:05:46 +0000 (17:05 -0500)] 
c++/reflection: check TYPE_BEING_DEFINED in define_aggregate

As discussed in
<https://gcc.gnu.org/pipermail/gcc-patches/2026-January/705756.html>,
we should check TYPE_BEING_DEFINED along with COMPLETE_TYPE_P in
eval_define_aggregate.  It seems that with this check added, we don't
need this code anymore:

      if (c == type)
        {
          auto_diagnostic_group d;
          error_at (loc, "%<define_aggregate%> evaluated from "
                         "%<consteval%> block enclosed by %qT being "
                         "defined", type);
  //...
}

so I'm removing that in this patch.

gcc/cp/ChangeLog:

* reflect.cc (eval_define_aggregate): Also give an error when
TYPE_BEING_DEFINED is true for the first argument.  Remove code
that did the same.

gcc/testsuite/ChangeLog:

* g++.dg/reflect/define_aggregate3.C: Adjust expected diagnostic.
* g++.dg/reflect/p2996-21.C: Likewise.

Reviewed-by: Jakub Jelinek <jakub@redhat.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
2 months agoc++/reflection: tweak eval_can_substitute
Marek Polacek [Wed, 28 Jan 2026 21:33:34 +0000 (16:33 -0500)] 
c++/reflection: tweak eval_can_substitute

As discussed in
<https://gcc.gnu.org/pipermail/gcc-patches/2026-January/705756.html>,
we should check for undeduced_auto_decl after performing
resolve_nondeduced_context_or_error.  Also add a test to exercise
the new check.

gcc/cp/ChangeLog:

* reflect.cc (eval_can_substitute): Check undeduced_auto_decl after
resolve_nondeduced_context_or_error.

gcc/testsuite/ChangeLog:

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

Reviewed-by: Jason Merrill <jason@redhat.com>
Reviewed-by: Jakub Jelinek <jakub@redhat.com>
2 months agolibga68: Use the internal malloc for UTF-32 to UTF-8 conversion
Pietro Monteiro [Fri, 30 Jan 2026 12:57:02 +0000 (07:57 -0500)] 
libga68: Use the internal malloc for UTF-32 to UTF-8 conversion

_libga68_u32_to_u8 called free on the result buffer on error, but the
buffer is allocated by the GC, so calling free on it is incorrect.

Instead of using the GC, use the internal malloc because this is an
internal function.

Remove the resultbuf parameter from the _libga68_u32_to_u8 since all
callers used NULL for it.

Last but not least, return a null-terminated char* from
_libga68_u32_to_u8.

libga68/ChangeLog:

* ga68-alloc.c (_libga68_realloc_internal): New function.
* ga68-posix.c (_libga68_posixperror): Adjust calls to _libga68_u32_to_u8.
(_libga68_posixfopen): Likewise.
(_libga68_posixcreat): Likewise.
(_libga68_posixgetenv): Likewise.
(_libga68_posixfputs): Likewise.
(_libga68_posixfconnect): Likewise.
* ga68-unistr.c (_libga68_u32_to_u8): Use internal allocator.
* ga68.h (_libga68_realloc_internal): New prototype.
(_libga68_u32_to_u8): Update prototype.

Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
2 months agoa68: Minor typo fix in doc
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>
2 months agoAdd missing PR reference
Eric Botcazou [Fri, 30 Jan 2026 11:43:53 +0000 (12:43 +0100)] 
Add missing PR reference

2 months 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.

2 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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 months 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.