]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
3 months agolibstdc++: Fix is_explict checks in extents test.
Tomasz Kamiński [Tue, 17 Mar 2026 08:34:37 +0000 (09:34 +0100)] 
libstdc++: Fix is_explict checks in extents test.

The condition was checking if extents<int, ...> is convertible to index_type,
and not the reverse. This patch tests implicit conversion from braced
initializer list (to cover multiple arguments) and is_convertible in case of
single index.

libstdc++-v3/ChangeLog:

* testsuite/23_containers/mdspan/extents/ctor_ints.cc: Updated
is_explicit, and added more test cases.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 months agotestsuite: Add also decltype(nullptr) testcase for PR124489
Jakub Jelinek [Tue, 17 Mar 2026 09:27:47 +0000 (10:27 +0100)] 
testsuite: Add also decltype(nullptr) testcase for PR124489

In r16-8116 Marek has fixed not just whitespace around
std::meta::info in diagnostics, but also std::nullptr_t.

This patch adds a testcase for that, such that the part of the
change related to NULLPTR_TYPE and this test can be backported.

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

PR c++/124489
* g++.dg/cpp0x/pr124489.C: New test.

3 months ago[PATCH] Add Myself to Write After Approval and DCO List
Prachi Godbole [Tue, 17 Mar 2026 07:35:24 +0000 (00:35 -0700)] 
[PATCH] Add Myself to Write After Approval and DCO List

ChangeLog:

* MAINTAINERS: Add myself to write after approval and DCO.

Signed-off-by: Prachi Godbole pgodbole@nvidia.com
3 months agofortran: Preserve scalar class pointers in OpenMP privatization [PR120286]
Christopher Albert [Tue, 10 Mar 2026 19:59:48 +0000 (20:59 +0100)] 
fortran: Preserve scalar class pointers in OpenMP privatization [PR120286]

OpenMP privatization currently treats scalar class pointers like owned
polymorphic class objects.  In the worker cleanup for private/firstprivate
class pointers, the generated code finalizes and frees ptr._data even though
the clause only copied pointer association status from a shared target.

Fix this in gfc_omp_clause_copy_ctor and gfc_omp_clause_dtor by unwrapping
saved descriptors first and by recognizing class-pointer container types
locally in those hooks.  That keeps scalar class pointers on the
association-only path without changing the broader polymorphic mapping
classification used for OpenMP warnings and deep mapping.

Add a runtime regression test for the original private(ptr) crash plus a
firstprivate(ptr) association check.

gcc/fortran/ChangeLog:

PR fortran/120286
* trans-openmp.cc (gfc_is_class_pointer_type): New helper.
(gfc_omp_clause_copy_ctor): Unwrap saved descriptors before
deciding whether privatization should preserve only pointer
association.  Handle scalar class pointers on that path too.
(gfc_omp_clause_dtor): Likewise.

gcc/testsuite/ChangeLog:

PR fortran/120286
* gfortran.dg/pr120286.f90: New test.

Signed-off-by: Christopher Albert <albert@tugraz.at>
3 months agoDaily bump.
GCC Administrator [Tue, 17 Mar 2026 00:16:31 +0000 (00:16 +0000)] 
Daily bump.

3 months agoc++/reflection: fix ICE on invalid splice [PR124496]
Marek Polacek [Sun, 15 Mar 2026 20:27:51 +0000 (16:27 -0400)] 
c++/reflection: fix ICE on invalid splice [PR124496]

Just an ICE-on-invalid, but while writing tests for 123237 my
typos would result in this crash often enough to prompt me to
go ahead and fix it.

We crash here because we are asserting that we've emitted hard
errors when cp_parser_splice_specifier returns error_mark_node
even when parsing tentatively.  In the crash20.C case we have
[:R<T>:] where we interpret the < as a "less than" operator and
expect that T will produce a primary expression, which it does
not.  But cp_parser_error won't emit any errors yet.

PR c++/124496

gcc/cp/ChangeLog:

* parser.cc (cp_parser_splice_specifier): Use NULL_TREE instead of
NULL.
(cp_parser_splice_expression): Don't assert seen_error() when not
committed to tentative parse.

gcc/testsuite/ChangeLog:

* g++.dg/reflect/crash20.C: New test.
* g++.dg/reflect/crash21.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
3 months agoc++/reflection: reject annotations on void parms [PR123618]
Marek Polacek [Mon, 16 Mar 2026 14:33:51 +0000 (10:33 -0400)] 
c++/reflection: reject annotations on void parms [PR123618]

Annotations on void parameter don't make much sense so they
should be rejected, even if the wording isn't currently so
clear on that.

PR c++/123618

gcc/cp/ChangeLog:

* tree.cc (handle_annotation_attribute): Reject annotations on void
parameters.

gcc/testsuite/ChangeLog:

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

Reviewed-by: Jason Merrill <jason@redhat.com>
3 months agoc++: Fix ICE with error mark for an attribute [PR124307]
Andrew Pinski [Sun, 15 Mar 2026 06:36:56 +0000 (23:36 -0700)] 
c++: Fix ICE with error mark for an attribute [PR124307]

After r16-6808-g4b0e94b394fa38, we started to ICE when the
std_attrs was error_mark_node. This fixes the problem by
checking if it was an error_mark_node before looking for
annotations.

Bootstrapped and tested on x86_64-linux-gnu with no regressions.

Changes since v1:
 * v2: Move the check for error mark earlier.
 * v3: small formating changes.

PR c++/124307

gcc/cp/ChangeLog:

* parser.cc (cp_parser_base_specifier): Check for
error mark like checking for non-nullness on the
attribute.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
3 months agolibstdc++: Add module initialization functions to the library [PR124268]
Jonathan Wakely [Wed, 11 Mar 2026 21:05:13 +0000 (21:05 +0000)] 
libstdc++: Add module initialization functions to the library [PR124268]

This ensures that the module init functions are present in libstdc++.so
and libstdc++.a, so that users of the std and std.compat modules don't
need to manually link to std.o and/or std.compat.o in addition to
compiling the CMIs.

This also adds a clean-local target to remove the generated interface
units and manifest, and the gcm.cache directory for the CMIs.

libstdc++-v3/ChangeLog:

PR libstdc++/124268
* config/abi/pre/gnu.ver: Export symbols.
* src/Makefile.am: Add libmodulesconvenience.la to libstdc++
link.
* src/Makefile.in: Regenerate.
* src/c++23/Makefile.am: Create libmodulesconvenience.la
and populate it with std.o and std.compat.o interface units.
Add clean-local target.
* src/c++23/Makefile.in: Regenerate.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 months agolibstdc++: Make ranges::distance work with volatile iterators (LWG 4242)
Jonathan Wakely [Thu, 12 Mar 2026 15:15:57 +0000 (15:15 +0000)] 
libstdc++: Make ranges::distance work with volatile iterators (LWG 4242)

This implements LWG 4242 which was approved in Sofia 2025.

I don't think the change from static_cast<const decay_t<I>&> to just
static_cast<decay_t<I>> is observable, but it doesn't hurt. What fixes
the problem identified in the issue is the is_array_v check, which
avoids the static_cast entirely for volatile-qualified iterators.

libstdc++-v3/ChangeLog:

* include/bits/ranges_base.h (distance(It&&, Sent)): Only decay
arrays to pointers when the type is actually an array, as per
LWG 4242.
* testsuite/24_iterators/range_operations/distance.cc: Add test
for LWG 4242.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 months agoc++: fix for printing std::meta::info [PR124489]
Marek Polacek [Fri, 13 Mar 2026 17:00:46 +0000 (13:00 -0400)] 
c++: fix for printing std::meta::info [PR124489]

When printing the diagnostics in this test, we're saying
"constexprstd::meta::info dm" which misses a space.  We
should use pp_cxx_ws_string which does pp_c_maybe_whitespace
when printing "std::meta::info".

PR c++/124489

gcc/cp/ChangeLog:

* error.cc (dump_type) <case NULLPTR_TYPE>: Use pp_cxx_ws_string
instead of pp_string.
<case META_TYPE>: Likewise.

gcc/testsuite/ChangeLog:

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

Reviewed-by: Jason Merrill <jason@redhat.com>
3 months agoUpdate gcc fr.po, sv.po
Joseph Myers [Mon, 16 Mar 2026 21:28:35 +0000 (21:28 +0000)] 
Update gcc fr.po, sv.po

* fr.po, sv.po: Update.

3 months agoa68: fix copy-pasto in install.texi
Jose E. Marchesi [Mon, 16 Mar 2026 21:07:03 +0000 (22:07 +0100)] 
a68: fix copy-pasto in install.texi

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

* doc/install.texi (Configuration): Fix copy pasto
--enable-objc-gc to --enable-algol68-gc.

3 months agolibstdc++: Rewrite test for compare_exchange padding
Jonathan Wakely [Wed, 11 Mar 2026 11:41:56 +0000 (11:41 +0000)] 
libstdc++: Rewrite test for compare_exchange padding

Change the struct to ensure there is a padding byte between the members,
which was previously not the case for byte-aligned targets such as
cris-elf.

Add a new helper function to verify that the padding bits in a struct S
and in the std::atomic<S> are zero, without needing to disable SRA. Then
rewrite the test in terms of that helper, so we check directly that the
atomic object has the correct value and has no padding bits. Previously
we loaded a value (with -fno-tree-sra to hopefully preserve padding) and
then just using memcmp on that value to see if it was bitwise identical
to another value, but didn't actually check the members were correct or
that the padding was clear.

Also add a loop around the weak compare-exchange, to tolerate spurious
failures as described in
https://gcc.gnu.org/pipermail/gcc-patches/2026-March/710289.html

libstdc++-v3/ChangeLog:

* testsuite/29_atomics/atomic/compare_exchange_padding.cc:
Rewrite to be robust against spurious failures of weak compare
exchange, and to check padding bits more directly.

3 months agolibstdc++: Improve diagnostics for std::allocator<incomplete type>
Jonathan Wakely [Mon, 9 Mar 2026 12:15:19 +0000 (12:15 +0000)] 
libstdc++: Improve diagnostics for std::allocator<incomplete type>

Using requires { sizeof(T); } in __new_allocator::allocate gives a
better diagnostic when the static_assert fails.

We can also reduce the total number of diagnostics due to invalid
sizeof(T) and alignof(T) by using the same requires-expression to make
the body of the function a discarded statement when the static_assert
already failed. This fixes a regression in diagnostic quality due to
making __new_allocator::allocate constexpr in r16-7271-g7197d0cce70525,
which caused a cascade of seven errors instead of just one for
std::allocator<incomplete-type>().allocate(1).

libstdc++-v3/ChangeLog:

* include/bits/allocator.h (allocator::allocate): Use specific
feature test macro for constexpr allocate and deallocate. Make
consteval path a discarded statement if sizeof(T) is ill-formed.
* include/bits/new_allocator.h (__new_allocator::allocate): Use
requires-expression for static_cast. Make function body a
discarded stament if sizeof(T) is ill-formed. Use if-constexpr
for alignment checks.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 months agoaarch64, testsuite: Add test for already-fixed PR [PR124491]
Alex Coplan [Mon, 16 Mar 2026 14:35:33 +0000 (14:35 +0000)] 
aarch64, testsuite: Add test for already-fixed PR [PR124491]

This adds a testcase for PR124491, which was fixed by these commits:

r16-6709-ga4716ece529dfd29d169ccc96979f7c747231f25
r16-6743-ge787d5ace5cc315892868f3e5e2a2a16fd31bcc8

I originally just added the test to the 15 branch with the backports for
those commits, but richi pointed out in the PR that we should have it on
trunk too, so this adds it to the trunk.

gcc/testsuite/ChangeLog:

PR middle-end/124491
* gcc.target/aarch64/torture/pr124491.c: New test.

3 months agotree-optimization/124528 - UB from SCEV
Richard Biener [Mon, 16 Mar 2026 08:55:26 +0000 (09:55 +0100)] 
tree-optimization/124528 - UB from SCEV

SCEV has a long-standing issue in that it negates the addend of
a subtraction within a SSA cycle without considering UB from
negating of the most negative value.  The following tries to
rectify this.

PR tree-optimization/124528
* tree-scalar-evolution.cc (scev_dfs::add_to_evolution):
Perform the negation in an unsigned type if we cannot make
sure it will not cause UB.

* gcc.dg/tree-ssa/scev-17.c: New testcase.

3 months agoRISC-V: Document big-endian support as experimental
Kito Cheng [Mon, 16 Mar 2026 09:00:43 +0000 (17:00 +0800)] 
RISC-V: Document big-endian support as experimental

The RISC-V big-endian ABI is not yet stable, add a note to the
-mbig-endian option documentation to warn users that support is
experimental and could change in incompatible ways.

gcc/ChangeLog:

* doc/invoke.texi: Add experimental warning for RISC-V
big-endian support.

3 months agoFortran: Regression in gfc_convert_to_structure_constructor [PR93832]
Paul Thomas [Mon, 16 Mar 2026 08:20:20 +0000 (08:20 +0000)] 
Fortran: Regression in gfc_convert_to_structure_constructor [PR93832]

2026-03-16  Paul Thomas  <pault@gcc.gnu.org>
    Steve Kargl  <kargls@comcast.net>

gcc/fortran
PR fortran/93832
* array.cc (resolve_array_bound): Emit error and return false
if bound expression is derived type or class.
* primary.cc (gfc_convert_to_structure_constructor): Do not
dereference NULL in character component test. Define 'shorter'
and use it help cure one of several whitespace issues.

gcc/testsuite/
PR fortran/93832
* gfortran.dg/pr93832.f90: New test.

3 months agoFortran: Fix segfault due to class actual in parentheses [PR105168]
Paul Thomas [Mon, 16 Mar 2026 07:23:49 +0000 (07:23 +0000)] 
Fortran: Fix segfault due to class actual in parentheses [PR105168]

2026-03-16  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/105168
* trans-expr.cc (gfc_conv_class_to_class): If the argument expr
is not a class type use the parent tree if that is a class.
(gfc_conv_procedure_call): If the argument expression is not a
variable, shift the bounds to give unity lbounds.
(gfc_trans_arrayfunc_assign): Return NULL_TREE instead of NULL.

gcc/testsuite/
PR fortran/105168
* gfortran.dg/pr105168.f90: New test.

3 months agoc++: Fix up sb as condition instantiation error-recovery [PR120039]
Jakub Jelinek [Mon, 16 Mar 2026 07:06:52 +0000 (08:06 +0100)] 
c++: Fix up sb as condition instantiation error-recovery [PR120039]

The following two testcases ICE during instantation.
Normally for the artificial var used for structured binding as condition
(which has NULL DECL_NAME) there is a DECL_EXPR which registers local
specialization and so tsubst_expr works fine.
But if there are errors while parsing the initializer, the VAR_DECL
has still NULL_TREE DECL_NAME, but error_mark_node TREE_TYPE and
when tsubst_expr is called on it, it falls back to calling lookup_name
(NULL_TREE) and ICEs on that.

The following patch fixes it by not calling lookup_name if DECL_NAME is
NULL.

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

PR c++/120039
PR c++/122559
* pt.cc (tsubst_expr) <case VAR_DECL>: Don't call lookup_name on
DECL_NAME (t) if it is NULL_TREE.

* g++.dg/cpp26/decomp28.C: New test.
* g++.dg/cpp26/decomp29.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
3 months agoxtensa: constantsynth: Add new 2-insns synthesis method
Takayuki 'January June' Suwa [Sun, 15 Mar 2026 09:32:48 +0000 (18:32 +0900)] 
xtensa: constantsynth: Add new 2-insns synthesis method

This patch adds a new 2-instructions constant synthesis method:

  - A positive integer value that, despite left-shifting the leading 0 bits,
    becomes a negative number that still fits into a signed 12-bit
      => "MOVI(.N) Ax, simm12" + "SRLI Ax, Ax, 1...10"

     /* example */
     int test(void) {
       return 0x1FFFFF55;  /* 0b00011111111111111111111101010101 */
     }

     ;; before (-O1 -mextra-l32r-costs=1)
      .literal_position
      .literal .LC0, 536870741
     test:
      entry sp, 32
      l32r a2, .LC0
      retw.n

     ;; after (-O1 -mextra-l32r-costs=1)
     test:
      entry sp, 32
      movi a2, -0x558
      srli a2, a2, 3
      retw.n

gcc/ChangeLog:

* config/xtensa/xtensa.cc
(constantsynth_method_lshr_mi12b): New.
(constantsynth_methods): Add constantsynth_method_lshr_mi12b.

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

3 months agoa68: add missing symbols to libga68/ga68.map
Jose E. Marchesi [Sun, 15 Mar 2026 20:09:32 +0000 (21:09 +0100)] 
a68: add missing symbols to libga68/ga68.map

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

* ga68.map: Add public symbols from posix and standard preludes.

3 months agofortran: Fix use-after-free in CLASS component error recovery [PR124482]
Christopher Albert [Fri, 13 Mar 2026 19:50:07 +0000 (20:50 +0100)] 
fortran: Fix use-after-free in CLASS component error recovery [PR124482]

The error recovery added in r16-8021 (PR106946) freed CLASS container
symbols when removing invalid CLASS components from a derived type.
However, gfc_build_class_symbol reuses existing containers when multiple
components share the same class type and attributes.  Freeing the
container for a failed component also invalidated it for previously
committed components, causing a use-after-free detectable with valgrind
and manifesting as a SEGV on Solaris/SPARC.

Fix by deferring CLASS container cleanup until after all failed
components are unlinked, then freeing the container only if no remaining
component still references it.

gcc/fortran/ChangeLog:

PR fortran/124482
* decl.cc (gfc_match_data_decl): Defer CLASS container cleanup
until after all failed components are unlinked.  Check remaining
component list before freeing a shared container.

Signed-off-by: Christopher Albert <albert@tugraz.at>
3 months agolibstdc++: [_GLIBCXX_DEBUG] _M_invalidate_if incompatible with C++20 [PR124444]
François Dumont [Sat, 14 Mar 2026 13:34:29 +0000 (14:34 +0100)] 
libstdc++: [_GLIBCXX_DEBUG] _M_invalidate_if incompatible with C++20 [PR124444]

__gnu_cxx::__scoped_lock cannot be instantiated in a C++20 constexpr function. Use
an intermediate method to avoid this situation.

libstdc++-v3/ChangeLog:
PR libstdc++/124444
* include/debug/safe_sequence.h (_Safe_sequence::_M_invalidate_if_impl): New.
(_Safe_sequence::_M_invalidate_if): Call later if not __is_constant_evaluated.
* include/debug/safe_sequence.tcc: Rename _M_invalidate_if into
_M_invalidate_if_impl and remove C++20 constexpr.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
3 months agoDaily bump.
GCC Administrator [Sun, 15 Mar 2026 00:16:26 +0000 (00:16 +0000)] 
Daily bump.

3 months agolibstdc++: Fix Doxygen @since comment in <text_encoding>
Jonathan Wakely [Sat, 14 Mar 2026 00:27:16 +0000 (00:27 +0000)] 
libstdc++: Fix Doxygen @since comment in <text_encoding>

This is a C++26 feature, not C++23.

libstdc++-v3/ChangeLog:

* include/std/text_encoding: Fix @since in Doxygen comment.

3 months agoc++: Ensure proper ordering of annotations in grokdeclarator [PR124399]
Jakub Jelinek [Sat, 14 Mar 2026 19:48:28 +0000 (20:48 +0100)] 
c++: Ensure proper ordering of annotations in grokdeclarator [PR124399]

For the cases in the new test like
[[=1]] int a [[=2]], b [[=3]];
we want to order the =1 annotation before =2 or =3 because
https://eel.is/c++draft/meta.reflection#annotation-2.sentence-2
and =1 precedes =2 and =3.
The way we merge the attribute lists in grokdeclarator is done
for speed and memory efficiency though, so we attr_chainon
*attrlist (i.e. =1 above) after declarator->std_attributes
(i.e. =2 or =3 above).  That has the advantage that we can keep
sharing the earlier *attrlist between multiple declarations, each one
will have its custom attributes at the start (if any) and then
a shared tail with the shared ones.

The following patch fixes it by checking if annotations are in
both lists (otherwise we keep doing what we've been doing before).
If they are in both, we chainon them the other way but of course
need to copy_list to unshare the shared one for that.

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

PR c++/124399
* decl.cc (grokdeclarator): If both *attrlist and
declarator->std_attributes list contain annotations, chainon
declarator->std_attributes to tail of copy_list (*attrlist)
rather than *attrlist to tail of declarator->std_attributes.

* g++.dg/reflect/annotations12.C: Uncomment two tests, remove
temporary test added until that is fixed.
* g++.dg/reflect/annotations13.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
3 months agoUpdate copyright years.
Jakub Jelinek [Sat, 14 Mar 2026 18:31:10 +0000 (19:31 +0100)] 
Update copyright years.

3 months agoMake it possible to run contrib/update-copyright.py --this-year again
Jakub Jelinek [Sat, 14 Mar 2026 18:28:17 +0000 (19:28 +0100)] 
Make it possible to run contrib/update-copyright.py --this-year again

gcc/algol68/a68-moids-sorting.cc got a copyright not recognized
by the script and loongarch gen-evolution.awk keeps being a problem.

This patch tweaks those so that
  contrib/update-copyright.py --this-year
can be run successfully again.

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

PR other/124508
* update-copyright.py: Add James Bohl. as another copyright.

* config/loongarch/genopts/gen-evolution.awk: Rename copyright_header
routine so that update-copyright.py isn't upset about it.

3 months agoa68: fix float standard conversion routine
Jose E. Marchesi [Sat, 14 Mar 2026 15:58:53 +0000 (16:58 +0100)] 
a68: fix float standard conversion routine

This commit fixes the implementation of the `float' standard
conversion routine, by amending a typo that originates in the Revised
Report.  It also makes the routine to properly handle short short and
short int arguments.

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

* standard.a68.in (float): Fix typo from RR and handle short* int
arguments properly.

gcc/testsuite/ChangeLog

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

3 months agoa68: fix string and character multiplication
Jose E. Marchesi [Sat, 14 Mar 2026 15:57:08 +0000 (16:57 +0100)] 
a68: fix string and character multiplication

This patch fixes the string operator for string and character
multiplication, to adjust to the semantics specified by the RR.  In
particular, multiplying by a negative number or zero must result in
the empty string.

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

* a68-low-strings.cc (a68_string_mult): Adjust to RR semantics for
negative or zero factor argument.
* ga68.texi (String operators): Adjust documentation accordingly.

gcc/testsuite/ChangeLog

* algol68/execute/mult-char-1.a68: Multiplying a char or string by
negative or zero factor results in the empty string.
* algol68/execute/mult-string-3.a68: Likewise.
* algol68/execute/mult-string-2.a68: Likewise.
* algol68/execute/mult-string-1.a68: Likewise.

3 months agoAda: Fix libgnat.so link failure on systems with older glibc
Matthias Klose [Sat, 14 Mar 2026 12:23:47 +0000 (13:23 +0100)] 
Ada: Fix libgnat.so link failure on systems with older glibc

It's a regression present on all active branches for older glibc versions,
where dladdr is still in the libdl.so library, and not included in libc.so
as in newer glibc versions.

gcc/ada/
PR ada/107475
* Makefile.rtl (s390% linux%): Define MISCLIB.
(arm% linux-gnueabi%): Likewise.
(%x32 linux%): Likewise.

3 months agoc++/modules: Fix crash on implicit redeclaration of ABI class types [PR124485]
Nathaniel Shead [Sat, 14 Mar 2026 00:25:47 +0000 (11:25 +1100)] 
c++/modules: Fix crash on implicit redeclaration of ABI class types [PR124485]

The crash in the given testcase occurs because the fix for PR122053,
r16-4228-gfa6544ef5f50a824cabeda4906453d4545fbf66f, added a call to
lazy_load_pending when doing push_tag, to prevent ICEs at least when
types are textually redefined in lieu of full PR99000 support.

But this means that we might not have loaded the declarations of the ABI
types in lookup_elaborated_type to merge them there yet, but still have
them by the time we get to check_module_override, causing errors, and
then an ICE because tinfo_base_init is not prepared for xref_tag to
fail.

It turns out that doing the lazy load in pushtag is too late; we replace
the decl, but we don't replace the type, and then we end up returning
the type that we were building anyway rather than the type we were
hoping to match against.

The reason I'd done it there originally is because that's the earliest
we have a decl to do lazy_load_pendings with, but it seems that instead
we should have another interface to lazy_load_pendings that can be used
if you already know the name and namespace of the entity that you're
keying too.

PR c++/124485

gcc/cp/ChangeLog:

* cp-tree.h (lazy_load_pendings): Declare new overload.
* module.cc (lazy_load_pendings): Define it.
* name-lookup.cc (lookup_elaborated_type): Load pending entities
with given name before doing namespace-scope lookup.
(pushtag): Remove no-longer-needed pending load.

gcc/testsuite/ChangeLog:

* g++.dg/modules/class-8_b.C: Adjusted expected behaviour.
* g++.dg/modules/pr124485_a.C: New test.
* g++.dg/modules/pr124485_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
3 months agoc++: Fix up partial instantiation of structured binding packs [PR124456]
Jakub Jelinek [Sat, 14 Mar 2026 08:52:42 +0000 (09:52 +0100)] 
c++: Fix up partial instantiation of structured binding packs [PR124456]

The following testcase ICEs during partial instantiation of structured
binding pack.  tsubst_pack_expansion assumed DECL_VALUE_EXPR
in that case will be TREE_VEC containing what should be expanded.
But when the initializer of the structured bindings is still type dependent,
we know neither the size of the sb pack nor its content, cp_finish_decomp
in that case doesn't set DECL_VALUE_EXPR to a TREE_VEC at all, but to
ARRAY_REF of the base and index within the structured binding (and pack if
any).
tsubst_pack_expansion can set arg_pack to NULL_TREE and in that case
      else
        {
          /* We can't substitute for this parameter pack.  We use a flag as
             well as the missing_level counter because function parameter
             packs don't have a level.  */
          gcc_assert (processing_template_decl || is_auto (parm_pack)
                      || args == NULL_TREE);
          unsubstituted_packs = true;
        }
will trigger and later on in the function unsubstituted_packs is handled
properly.

So, the following patch makes sure to set arg_pack to NULL_TREE in that
case.

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

PR c++/124456
* pt.cc (tsubst_pack_expansion): For structured binding pack
with type dependent pack set arg_pack to NULL_TREE.

* g++.dg/cpp26/decomp27.C: New test.

3 months agoc++/modules: Support loading a lazy member while trying to declare it [PR124478]
Nathaniel Shead [Fri, 13 Mar 2026 15:23:09 +0000 (02:23 +1100)] 
c++/modules: Support loading a lazy member while trying to declare it [PR124478]

The testcase shows an issue where we end up indirectly loading a
special member function while we're attempting to lazily declare it.
This causes errors in the install_implicit_member because
CLASSTYPE_LAZY* has been cleared, so it assumes that the member exists
already.

There are a few options to approach this issue:

1. Remove the error when we fail with install_implicit_member, and just
   silently assume that a case like this is happening.  This should be
   safe, but could make it harder to understand future issues in this
   area.

2. Put all implicitly declared special members on the pending list for
   the class type, and add calls to lazy_load_pendings at the start of
   lazily_declare_fn and check if the functions have now been
   provided.  But this could unnecessarily bloat out the pending tables
   as aggregate types used in lots of modules will add their special
   members to every module's pending table.

3. Detect exactly this special case in implicitly_declare_fn and halt
   processing.  This should only impact lazily_declare_fn, but makes its
   API more complex.

This patch takes option three.  Just because we know that the function
has been lazily declared somewhere else doesn't mean we can easily find
its declaration, however; luckily nothing actually uses the return type
of lazily_declare_fn, so we can change that to void instead and save on
some effort.

PR c++/124478

gcc/cp/ChangeLog:

* cp-tree.h (lazily_declare_fn): Make return type void.
* method.cc (is_lazy_special_member): New function.
(implicitly_declare_fn): Bail early if we lazy loaded the member
we're trying to declare.
(lazily_declare_fn): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/modules/imp-member-6_a.C: New test.
* g++.dg/modules/imp-member-6_b.C: New test.
* g++.dg/modules/imp-member-6_c.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
3 months agoDaily bump.
GCC Administrator [Sat, 14 Mar 2026 00:16:29 +0000 (00:16 +0000)] 
Daily bump.

3 months agotestsuite: make the prevent tailcall in pr17377.c more robust
Andrew Pinski [Sat, 14 Mar 2026 00:09:49 +0000 (17:09 -0700)] 
testsuite: make the prevent tailcall in pr17377.c more robust

With improvements (not actually implemented yet but shows up with LLVM),
the call in pr17377.c to prevent a tail call does not work. So
to make it more robust, we need to mark the variable x as being volatile.

Pushed as obvious after testing on x86_64-linux-gnu.

gcc/testsuite/ChangeLog:

* gcc.c-torture/execute/pr17377.c: Mark global variable x
as volatile.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
3 months agocprop_hardreg: purge dead edges and cleanupcfg if something changes [PR124454]
Andrew Pinski [Thu, 12 Mar 2026 22:35:30 +0000 (15:35 -0700)] 
cprop_hardreg: purge dead edges and cleanupcfg if something changes [PR124454]

cprop_hardreg changes:
```
(insn 69 62 183 6 (set (reg:SI 1 x1 [orig:107 _12 ] [107])
        (zero_extend:SI (mem:QI (reg/f:DI 1 x1 [150]) [0 MEM[(char *)_4]+0 S1 A64]))) "/app/example.cpp":8:7 discrim 1 149 {*zero_extendqisi2_aarch64}
     (expr_list:REG_EH_REGION (const_int 2 [0x2])
        (nil)))
```

into:
```
(insn 69 62 183 6 (set (reg:SI 1 x1 [orig:107 _12 ] [107])
        (zero_extend:SI (mem:QI (plus:DI (reg/f:DI 31 sp)
                    (const_int 56 [0x38])) [0 MEM[(char *)_4]+0 S1 A64]))) "/app/example.cpp":8:7 discrim 1 149 {*zero_extendqisi2_aarch64}
     (expr_list:REG_EH_REGION (const_int 2 [0x2])
        (nil)))
```

But that new instruction no longer traps as it is load from the stack. So later on
purge_dead_edges removes the REG_EH_REGION note and the edge to the eh landing pad
but this is during find_many_sub_basic_blocks in split3 and nothing then removes the
unreachable basic blocks.

To fix this, instead of depending on a later pass to clean this up, cprop_hardreg
should call purge_all_dead_edges if non-call exceptions were enabled and then
also call cleanup_cfg (to remove the unreachable blocks).

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

PR rtl-optimization/124454

gcc/ChangeLog:

* regcprop.cc (pass_cprop_hardreg::execute): If something
changed and non-call exceptions is on, call purge_all_dead_edges
and cleanup_cfg.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
3 months agolibcpp: Fix up -MP for - input [PR105412]
Jakub Jelinek [Fri, 13 Mar 2026 20:58:46 +0000 (21:58 +0100)] 
libcpp: Fix up -MP for - input [PR105412]

For -MP we used to emit something like below in GCC 9 and earlier:
touch a.h; echo '#include "a.h"' | ./cc1 -quiet -E -M -MP -
-: /usr/include/stdc-predef.h a.h
/usr/include/stdc-predef.h:
a.h:
but since r10-205 we emit instead just
touch a.h; echo '#include "a.h"' | ./cc1 -quiet -E -M -MP -
-: /usr/include/stdc-predef.h a.h
a.h:
i.e. the rule for /usr/include/stdc-predef.h is removed.  Similarly
with -nostdinc:
touch a.h; echo '#include "a.h"' | ./cc1 -quiet -E -nostdinc -M -MP -
-: a.h
a.h:
r10-205 changed that to:
touch a.h; echo '#include "a.h"' | ./cc1 -quiet -E -nostdinc -M -MP -
-: a.h
a.h:
The rationale for the change was
https://gcc.gnu.org/legacy-ml/gcc-patches/2019-05/msg00323.html
where after the mkdeps.cc reimplementation it started ICEing on
- input (file->path[0] is "" in that case).
The problem is that by leaving out the "" dependency (which we then
in some cases indeed ignore) the -MP printing
      if (CPP_OPTION (pfile, deps.phony_targets))
       for (unsigned i = 1; i < d->deps.size (); i++)
         fprintf (fp, "%s:\n", munge (d->deps[i]));
starts at d->deps[1] unconditionally and so ignores the first dependency
even when it is not the main file.
So, either we could just revert the r10-205 change and ensure we don't
ICE on it and keep ignoring it when it should be ignored, or the
following patch fixes it by not adding the "" dep, but remembering that
in that case we should start iterating from i = 0; and not from i = 1;

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

PR preprocessor/105412
* files.cc (_cpp_stack_file): Call deps_add_dep even on
empty file path.
* mkdeps.cc (class mkdeps): Add first_phony_dep member.
(mkdeps::mkdeps ()): Initialize it to 1.
(deps_add_dep): When called first with "" argument, decrease
d->first_phony_dep to 0.
(make_write): For -MP iterate from d->first_phony_dep
rather than 1.

Reviewed-by: Joseph Myers <josmyers@redhat.com>
3 months ago[PR117182, LRA]: Move point of skipping postponed insn
Vladimir N. Makarov [Fri, 13 Mar 2026 20:19:33 +0000 (16:19 -0400)] 
[PR117182, LRA]: Move point of skipping postponed insn

Working on PR117182 I found that a pseudo generated for save/restore
value around call is changed by equivalence which is constant as we
propagate equivalence for such pseudos to generate a better code.  The
constant substitutes output of the save insn which can be changed to
memory containing constant by reload insn.  We don't want this.  The
patch fixes this.

gcc/ChangeLog:

PR target/117182
* lra-constraints.cc (curr_insn_transform): Don't change an output
operand by constant or invariant equivalence.

3 months agoarm: Add support for _BitInt(N)
Andre Vieira [Fri, 13 Mar 2026 15:31:18 +0000 (15:31 +0000)] 
arm: Add support for _BitInt(N)

This patch adds support for C23's _BitInt feature to the arm port.

gcc/ChangeLog:

* config/arm/arm.cc (TARGET_C_BITINT_TYPE_INFO): New Macro.
(arm_return_in_memory): Return true for any _BitInt(N) where N > 64.
(arm_needs_doubleword_align): Return true for any _BitInt(N) where N > 32.
(arm_bitint_type_info): New.
* config/arm/arm-protos.h (arm_bitint_type_info): New declaration.

libgcc/ChangeLog:

* config/arm/libgcc-bpabi.ver: Add new symbols.
* config/arm/t-softfp: Enable use of floatbitinthf and pass necessary options to build fp16.

3 months agoc++/reflection: add test
Marek Polacek [Fri, 13 Mar 2026 17:57:37 +0000 (13:57 -0400)] 
c++/reflection: add test

This test now works too.  Fixed by r16-8009 I think.

gcc/testsuite/ChangeLog:

* g++.dg/reflect/expansion-stmt3.C: New test.

3 months agoaarch64: mingw: Fix _ARM_PCS_AAPCS64 [PR122953]
Saurabh Jha [Thu, 12 Mar 2026 11:57:26 +0000 (11:57 +0000)] 
aarch64: mingw: Fix _ARM_PCS_AAPCS64 [PR122953]

Windows platforms do not support the default procedure calling standard,
AAPCS64. So _ARM_PCS_AAPCS64 should not be set for Windows targets.

This fixes the setting of __ARM_PCS_AAPCS64 by making it conditional on
non-Windows targets.

PR target/122953

gcc/ChangeLog:

* config/aarch64/aarch64-c.cc
(TARGET_AARCH64_MS_ABI): Explicitly set it to 0 if not on mingw.
(aarch64_define_unconditional_macros): Remove __ARM_PCS_AAPCS64
from here.
(aarch64_update_cpp_builtins): Define __ARM_PCS_AAPCS64 if not
on Windows ABI.

---
Hey,

Regression tested on aarch64-linux-gnu and found no regressions.
Built for arch64-w64-mingw32, ran target dependent tests, and
found no regressions.

Ok for master?

Thanks,
Saurabh

3 months agoFortran: Fix caf-tests on older glibcs [PR124484]
Andre Vehreschild [Fri, 13 Mar 2026 11:24:41 +0000 (12:24 +0100)] 
Fortran: Fix caf-tests on older glibcs [PR124484]

gcc/testsuite/ChangeLog:

PR testsuite/124484
* gfortran.dg/coarray/caf.exp: Add -pthread and -lrt
for *-linux* targets for caf_shmem testing.

3 months agotree-profile: Formatting fixes
Jakub Jelinek [Fri, 13 Mar 2026 13:13:44 +0000 (14:13 +0100)] 
tree-profile: Formatting fixes

On Fri, Mar 13, 2026 at 11:12:54AM +0100, Jørgen Kvalsvik wrote:
> > Note, big parts of tree-profile.cc now use some weird formatting, not GCC
> > style, indentation by 4 columns instead of 2, { on the same column as line
> > above it instead of 2 columns to the right, etc.  I think it would be nice
> > to get that incrementally fixed.
>
> Yeah, since writing the MC/DC support it I've changed my setup to properly
> apply the GNU style, but I haven't wanted to make too much noise with
> patches for it. I can change the style incrementally whenever I pass over
> this, or maybe even a single pass that fixes all of it.

Given that it is so different from GNU style, incrementally adjusting it is
hard, if done incrementally it would mean usually reformat whole function
rather than just a few lines in it.

So I think it is better to change it once.

Here is my attempt to do so, fixed what I saw.

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

* tree-profile.cc (struct conds_ctx): Formatting fixes.
Rename B1, B2, G1, G2 and G3 members to b1, b2, g1, g2 and g3.
Adjust all uses.
(topological_cmp, topological_src_cmp, index_of, single_p,
single_edge, contract_edge_up): Formatting fixes.
(struct outcomes): Likewise.
(conditional_succs, condition_index, condition_uid,
masking_vectors, emit_assign, emit_bitwise_op): Likewise.
(make_top_index_visit, make_top_index): Likewise.  Rename
L argument to l.
(paths_between): Formatting fixes.
(struct condcov): Likewise.
(cov_length, cov_blocks, cov_masks, cov_maps, cov_free): Likewise.
(find_conditions): Likewise.  Don't start warning_at message with
uppercase letter.
(struct counters): Formatting fixes.
(find_counters, resolve_counter, resolve_counters,
instrument_decisions): Likewise.
(init_ic_make_global_vars): Comment formatting fixes.
(gimple_init_gcov_profiler): Formatting fixes.

3 months agotestsuite: Fix up gcc.dg/analyzer/ice-pr124375-1.c for 32-bit targets [PR124375]
Jakub Jelinek [Fri, 13 Mar 2026 13:11:57 +0000 (14:11 +0100)] 
testsuite: Fix up gcc.dg/analyzer/ice-pr124375-1.c for 32-bit targets [PR124375]

On Wed, Mar 11, 2026 at 08:51:03PM -0400, David Malcolm wrote:
>       * gcc.dg/analyzer/ice-pr124375-1.c: New test.

Unfortunately this test FAILs on i686-linux (and guess all
other sizeof (int) == sizeof (__PTRDIFF_TYPE__) targets).

The problem is that on x86_64-linux the warning is indeed emitted on the
  __printf_buffer_offset = __printf_buffer_spec /* { dg-warning "stack-based buffer over-read" } */
line but on i686-linux (or x86_64-linux with -m32) on the
                               : step0_jumps[' '];
line.  I think the difference is due to a useless cast missing on the latter
(int and __PTRDIFF_TYPE__ are either the same or uselessly compatible, so
there is no extra cast stmt which holds some particular location).
On lp64 the above is (int)(__print_buffer_spec ? &&do_form_unknown - &&do_form_unknown
: (__PTRDIFF_TYPE__) step0_jumps[' ']);

So, either we would need to expect this dg-warning for say lp64 only and
expect a dg-warning on the other line for ilp32 (but what to do for
non-lp64/ilp32 targets?), or limit the test to lp64 only, or the following
patch just forces it onto one line (we regularly go over the 80 line limit
in the testsuite, often by a lot) and then it really doesn't matter on which
column the warning is emitted.

Tested on x86_64-linux and i686-linux by making sure the pre r16-8019
still ICEd on it (both 64-bit and 32-bit) and that latest trunk warns
on the right line with both.

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

PR analyzer/124375
* gcc.dg/analyzer/ice-pr124375-1.c (__printf_buffer): Put the whole ?:
expression on a single line.

3 months agoCount non-complex incoming edges [PR124462]
Jørgen Kvalsvik [Fri, 13 Mar 2026 09:45:26 +0000 (10:45 +0100)] 
Count non-complex incoming edges [PR124462]

This is really a gcov/instrumentation bug, but it was filed under ipa.

We did filter out incoming complex edges, but didn't account for the
case where a block has multiple incoming edges without actually being a
conditional outcome.  We also need to check that we have >= 2 incoming
edges after filtering out the complex ones to make sure it is a (short
circuiting) before we try to compute the masking table.

PR ipa/124462

gcc/ChangeLog:

* tree-profile.cc (masking_vectors): Skip blocks with less than
2 non-complex incoming edges.

gcc/testsuite/ChangeLog:

* g++.dg/gcov/pr124462.C: New test.

3 months agoxtensa: constantsynth: Minor changes
Takayuki 'January June' Suwa [Wed, 11 Mar 2026 18:19:41 +0000 (03:19 +0900)] 
xtensa: constantsynth: Minor changes

gcc/ChangeLog:

* config/xtensa/xtensa.cc (constantsynth_pass1):
Change the comparison between src and SET_SRC(pat) to be performed
using rtx_equal_p rather than between references (pointer values)
directly, and adjust the destination of changes in validate_change
to eliminate the need to call gen_rtx_SET.
(constantsynth_pass2):
Fill in missing spacing in one place and changes dump file output
slightly.

3 months agoxtensa: Rename/reduce from split_DI_SF_DF_const to convert_SF_const in 'xt_largeconst2'
Takayuki 'January June' Suwa [Wed, 11 Mar 2026 18:18:45 +0000 (03:18 +0900)] 
xtensa: Rename/reduce from split_DI_SF_DF_const to convert_SF_const in 'xt_largeconst2'

The order in which split_DI_SF_DF_const in the target-specific pass
'xt_largeconst2' is processed has been changed to be after split2, so
that the splitting of D[IF]mode assignments to S[IF]mode by the split
parts of movd[if]_internal MD patterns is now performed earlier.

Therefore, in split_DI_SF_DF_const, there is no need to split the
allocation of the D[IF]mode constant, and only the function to change
the allocation of the SFmode constant to SImode remains.

This patch reduces the functionality of split_DI_SF_DF_const as
described above and renames it to convert_SF_const.

gcc/ChangeLog:

* config/xtensa/xtensa.cc (xtensa_split_operand_pair)
Move the common code from the split part of movd[if]_internal
MD patterns into this function, since this function is only
called from the split part of that patterns.
Also, during non-debug optimization, re-register new literal
pool entries with the split values themselves instead of
splitting the memory reference of the source numeric constant
placed in the pool.
(split_DI_SF_DF_const):
Rename to convert_SF_const and remove the split function of
D[IF]mode constant assignment.
(do_largeconst2):
Change the call from split_DI_SF_DF_const to convert_SF_const.
* config/xtensa/xtensa.md (movdi_internal, movdf_internal):
Reduce their split parts to just a call to xtensa_split_operand_pair.

3 months agoxtensa: Minor changes to FPreg_neg_scaled_simm12b in 'xt_largeconst2'
Takayuki 'January June' Suwa [Wed, 11 Mar 2026 18:17:44 +0000 (03:17 +0900)] 
xtensa: Minor changes to FPreg_neg_scaled_simm12b in 'xt_largeconst2'

Having a non-zero finite REAL_VALUE_TYPE is equivalent to having it be
normal, because REAL_VALUE_TYPE can only be zero, normal, infinity, or
NaN (see gcc/real.h).

gcc/ChangeLog:

* config/xtensa/xtensa.cc (FPreg_neg_scaled_simm12b_1):
Change the test to determine whether REAL_VALUE_TYPE is a non-
zero finite value to whether it is normal.
(FPreg_neg_scaled_simm12b):
Place the call to FPreg_neg_scaled_simm12b_1 last in the
expression to improve performance, and change the dump file
output slightly.

3 months agoxtensa: Split target-specific pass 'xt_largeconst' into two
Takayuki 'January June' Suwa [Wed, 11 Mar 2026 18:16:38 +0000 (03:16 +0900)] 
xtensa: Split target-specific pass 'xt_largeconst' into two

Previously, in 1eefa6e0c84e3008ed7ac44d08a8e5206038fb33 and a series of
subsequent commits, we added a target-specific optimization pass
'xt_largeconst' right after postreload to convert assignments of numeric
constants that don't fit into immediate fields to a more efficient
implementation than the standard one (references to literal pool entries),
if available.

However, the processes performed in this pass are a mixture of essential
and optional ones (such as optimizations), which is not good in terms of
structure or execution efficiency.  Additionally, large numeric constant
assignments may be emitted after this pass, for example during stack frame
construction in function prologue.

To address these issues, this patch splits the processing in this pass
into two parts:

  - places the mandatory processing (i.e., restoring delegitimized forms
    of large numeric constant assignments to valid ones) immediately after
    postreload, and
  - places the rest, optional processing (i.e., optimizations) immediately
    before regrename, which a reasonable location after pro_and_epilogue
    and before sched2.

gcc/ChangeLog:

* config/xtensa/xtensa-passes.def (pass_xtensa_largeconst):
Rename to pass_xtensa_largeconst1.
(pass_xtensa_largeconst2): New target-specific pass.
* config/xtensa/xtensa-protos.h (make_pass_xtensa_largeconst):
Rename to make_pass_xtensa_largeconst1.
(make_pass_xtensa_largeconst2): New function prototype.
* config/xtensa/xtensa.cc (litpool_set_src_1):
Change to process large numeric constant assignments to DImode
as well as [SH]Imode.
(do_largeconst):
Rename it to do_largeconst1 and leave only the mandatory insn
transformation process.
(do_largeconst2): New function that inherits the optional insn
transformation processes from the old do_largeconst.
(rest_of_handle_largeconst):
Rename to rest_of_handle_largeconst1 and change to call
do_largeconst1.
(rest_of_handle_largeconst2): New function that calls
do_largeconst2.
(pass_data_xtensa_largeconst)
Rename to pass_data_xtensa_largeconst1.
(pass_xtensa_largeconst):
Rename to pass_xtensa_largeconst1 and change to call
rest_of_handle_largeconst1.
(pass_data_xtensa_largeconst2): New opt_pass data.
(pass_xtensa_largeconst2):
New rtl_opt_pass that runs rest_of_handle_largeconst2 when non-
debug optimizations are enabled.
(make_pass_xtensa_largeconst):
Rename to make_pass_xtensa_largeconst1.
(make_pass_xtensa_largeconst2): New function definition.

3 months agoi386: Fix up movrs<mode> suffix for -masm=intel [PR124461]
Jakub Jelinek [Fri, 13 Mar 2026 08:16:26 +0000 (09:16 +0100)] 
i386: Fix up movrs<mode> suffix for -masm=intel [PR124461]

For movrs<mode> the insn was using insn suffix unconditionally, so
movrsl or movrsq even for -masm=intel, when gas expects movrs and derives
what size of insn it is from the operands.

There is no movrs effective target, so I've just used dg-do compile with
scan-assembler to test it instead of dg-do assemble.

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

PR target/124461
* config/i386/i386.md (movrs<mode>): Use <imodesuffix> only for
-masm=att, not for -masm=intel.

* gcc.target/i386/movrs-pr124461.c: New test.

Reviewed-by: Uros Bizjak <ubizjak@gmail.com>
3 months agoc++: Include 26 in make check-c++-all
Jakub Jelinek [Fri, 13 Mar 2026 08:15:11 +0000 (09:15 +0100)] 
c++: Include 26 in make check-c++-all

I'm not regularly using make check-c++-all (using
GXX_TESTSUITE_STDS=98,11,14,17,20,23,26 instead), so this is just
from curiosity.
I wonder if it is a good idea to leave 26 out (whether it is intentional
or not).  I know impcx includes 26 plus -fimplicit-constexpr, but e.g.
given r16-7990 some tests will not be tested at all for 26 in that case and
others will test different behavior.

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

* Make-lang.in (check-c++-all): Also test c++26.

Reviewed-by: Jason Merrill <jason@redhat.com>
3 months agoc++: Fix up *display_string_of on anon union member [PR124388]
Jakub Jelinek [Fri, 13 Mar 2026 08:13:09 +0000 (09:13 +0100)] 
c++: Fix up *display_string_of on anon union member [PR124388]

{,u8}display_string_of was printing any unnamed FIELD_DECL as
%T::<unnamed bit-field>, but anon union member is also unnamed and
is not a bit-field.

Fixed by printing %T::<anonymous union> for anon union NSDM and
%T::<unnamed member> for anything else unnamed (e.g. anon struct NSDM).

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

PR c++/124388
* reflect.cc (eval_display_string_of): Only print <unnmamed bit-field>
for DECL_UNNAMED_BIT_FIELD, for anon union print <anonymous union>,
otherwise print <unnamed member>.

* g++.dg/reflect/display_string_of1.C (S, NS5::S): Add
union { int a; }.  Add static_assertions that the unnamed non-static
data member is printed as <unnamed member>.
* g++.dg/reflect/u8display_string_of1.C (S, NS5::S): Add
union { int a; }.  Add static_assertions that the unnamed non-static
data member is printed as <unnamed member>.

Reviewed-by: Jason Merrill <jason@redhat.com>
3 months agofortran: Fix OpenMP iterator depend lowering for component arrays [PR102459]
Christopher Albert [Tue, 10 Mar 2026 17:46:54 +0000 (18:46 +0100)] 
fortran: Fix OpenMP iterator depend lowering for component arrays [PR102459]

When lowering an OpenMP depend clause with an iterator expression such as
x(j)%a, the front end currently looks only at the first REF_ARRAY to
decide between scalar-reference lowering and array-descriptor lowering.
For x(j)%a that first ref is the scalar base element x(j), but the full
expression is still the rank-1 component array a.

As a result, the code calls gfc_conv_expr_reference on an array-valued
expression, which later reaches gfc_conv_scalarized_array_ref without a
scalarizer state and ICEs.

Fix this by choosing the lowering path from the rank of the full
expression.  Rank-zero expressions still use gfc_conv_expr_reference,
while array-valued expressions are lowered through gfc_conv_expr_descriptor.
Apply the same adjustment to the analogous depobj helper and add a
regression test for task depend clauses covering both x(j)%a and the
scalar control case x(j)%a(1).

gcc/fortran/ChangeLog:

PR fortran/102459
* trans-openmp.cc (gfc_trans_omp_clauses): Choose the scalar
reference path from the full expression rank rather than the first
array reference.
(gfc_trans_omp_depobj): Likewise.

gcc/testsuite/ChangeLog:

PR fortran/102459
* gfortran.dg/pr102459.f90: New test.

Signed-off-by: Christopher Albert <albert@tugraz.at>
3 months agoDaily bump.
GCC Administrator [Fri, 13 Mar 2026 00:16:40 +0000 (00:16 +0000)] 
Daily bump.

3 months agoFortran: Allow task-reduction allocatable scalars without outer ref [PR102596]
Christopher Albert [Tue, 10 Mar 2026 18:16:24 +0000 (19:16 +0100)] 
Fortran: Allow task-reduction allocatable scalars without outer ref [PR102596]

OpenMP task reduction lowering can call gfc_omp_clause_default_ctor for
an allocatable scalar with outer == NULL_TREE.  That is valid for scalar
allocatables that only need fresh storage allocation and do not need a
copied descriptor or allocatable-component walk.

The Fortran hook asserted unconditionally on outer != NULL_TREE, so
reduction(task, +:r) with an allocatable scalar ICEd during omplower.

Fix this by requiring outer only for the cases that actually use it:
descriptor-based allocatables and types with allocatable components.
Keep the assertion for those cases and allow NULL outer for plain scalar
allocatables.  Add a regression test for the allocatable task-reduction
case.

gcc/fortran/ChangeLog:

PR fortran/102596
* trans-openmp.cc (gfc_omp_clause_default_ctor): Only require an
outer reference when the constructor path actually uses it.

gcc/testsuite/ChangeLog:

PR fortran/102596
* gfortran.dg/pr102596.f90: New test.

Signed-off-by: Christopher Albert <albert@tugraz.at>
3 months agoc++/reflection: Support members_of and imported namespace-scope names [PR124200]
Nathaniel Shead [Sun, 22 Feb 2026 15:20:38 +0000 (02:20 +1100)] 
c++/reflection: Support members_of and imported namespace-scope names [PR124200]

namespace_members_of needs to iterate over all VECTOR_BINDINGs
for the given namespace, and handle deduplication.

PR c++/124200

gcc/cp/ChangeLog:

* name-lookup.h (walk_namespace_bindings): Declare.
* name-lookup.cc (walk_namespace_bindings): New function.
* reflect.cc (namespace_members_of): Use it.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Co-authored-by: Thomas Berger <loki+gcc@loki.codes>
Reviewed-by: Jason Merrill <jason@redhat.com>
Reviewed-by: Marek Polacek <polacek@redhat.com>
3 months agoc++/modules: Reparent linemaps for partition direct loads [PR124309]
Nathaniel Shead [Sun, 8 Mar 2026 14:10:02 +0000 (01:10 +1100)] 
c++/modules: Reparent linemaps for partition direct loads [PR124309]

The attached testcase failed because when part-11_d.C sees the import
of X through Z:part, the module's location is maintained as the indirect
(imported) location through Y that came first, but it is still promoted
to a direct import.

When part-11_e.C reads the module then it sees a direct import of X
through Z, but there is no valid source location for X in Z (because we
only kept the imported location) and so we report a bad CMI.

This fixes the issue by updating a module seen as direct for the first
time via a partition to reparent the module's location to where the
partition imported it from, so we properly process it as a direct
location that we need to write out, similarly to what we do when we
reimport an indirect module within the module purview.

PR c++/124309

gcc/cp/ChangeLog:

* module.cc (enum module_directness): Fix inconsistent
capitalisation.
(module_state::read_imports): Reparent module locations newly
seen as direct via partition.

gcc/testsuite/ChangeLog:

* g++.dg/modules/part-11_a.C: New test.
* g++.dg/modules/part-11_b.C: New test.
* g++.dg/modules/part-11_c.C: New test.
* g++.dg/modules/part-11_d.C: New test.
* g++.dg/modules/part-11_e.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
3 months agoUpdate gcc sv.po
Joseph Myers [Thu, 12 Mar 2026 22:39:15 +0000 (22:39 +0000)] 
Update gcc sv.po

* sv.po: Update.

3 months agosimplify-rtx: Fix the case where subreg of a vec_concat could fail [PR123822]
Andrew Pinski [Wed, 11 Mar 2026 20:01:08 +0000 (13:01 -0700)] 
simplify-rtx: Fix the case where subreg of a vec_concat could fail [PR123822]

So combine (rightfully) produces:
(subreg:DD (vec_concat:V2DI (const_int -1 [0xffffffffffffffff])
        (reg:DI 145 [ _22 ])) 0)

And then calls simplify_subreg on it.
simplify_subreg then sees it can remove the vec_concat as this is
the lower part and try to do `(subreg:DD (const_int -1 [0xffffffffffffffff]))`
but that is an invalid constant for DF64 so simplify_subreg rejects
that and returns NULL but there is code in simplify_subreg to create
a SUBREG then if the subreg validates. The problem is we are using DImode
for the inner mode and that validates but when gen_rtx_SUBREG is called
the inner mode of DImode is not there; only VOIDmode.
So the fix is to check for VOIDmode before the call to validate_subreg.

Bootstrapped and tested on x86_64-linux-gnu. And lightly tested for aarch64-linux-gnu.

PR rtl-optimization/123822

gcc/ChangeLog:

* simplify-rtx.cc (simplify_context::simplify_subreg): Check the
mode of the part to be non-VOIDmode before calling gen_rtx_SUBREG.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr123822-1.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
3 months ago[PR124452, LRA]: Move point of skipping postponed insn
Vladimir N. Makarov [Thu, 12 Mar 2026 20:47:16 +0000 (16:47 -0400)] 
[PR124452, LRA]: Move point of skipping postponed insn

Patch for PR115042 skipped processing postponed insns after possible
generation of address reloads for the postponed insns.  The reload
insns were lost in the code and this resulted in wrong code generation.

To fix this the patch moves skipping the postponed insn before any
reload generation.

gcc/ChangeLog:

PR rtl-optimization/124452
* lra-constraints.cc (curr_insn_transform): Move return on the
postponed insn before any reload generation.

3 months agotestsuite/c++: Fix lifetime of lambda in pr103953.C [PR119930]
Andrew Pinski [Sat, 7 Mar 2026 19:24:14 +0000 (11:24 -0800)] 
testsuite/c++: Fix lifetime of lambda in pr103953.C [PR119930]

So in the end the problem with pr103953.C is the lifetime
of a lambda object is not extended past the statement.
With sane operator new we are able to delete stores using
that object as it is dead afterwards.

So the fix to the testcase is to make the lambda its own
object and then call it.

I also went back to check to make sure the original issue was
reproducible with this version too.

Tested on x86_64-linux-gnu and the testcase failure is gone.

PR testsuite/119930

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/torture/pr103953.C: Store the second
lambda into its own object to extend its lifeime.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
3 months agoRevert "build: Properly set gas_flag/gnu_ld_flag"
Rainer Orth [Thu, 12 Mar 2026 20:09:39 +0000 (21:09 +0100)] 
Revert "build: Properly set gas_flag/gnu_ld_flag"

As reported in

https://gcc.gnu.org/pipermail/gcc-patches/2026-March/709850.html

this patch

commit fdd1d058f289eda39b6eb1386a0dabef3478d298
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date:   Fri Feb 6 20:31:27 2026 +0100

    build: Properly set gas_flag/gnu_ld_flag

still causes testsuite regressions in some scenarious (a cross to
arm-none-eabi in this case).

Comparing gcc/auto-host.h before and after that patch shows that
HAVE_GNU_AS and HAVE_GNU_LD are mis-detected again:

@@ -1640 +1616 @@
-#define HAVE_GNU_AS 1
+#define HAVE_GNU_AS 0
@@ -1652 +1628 @@
-#define HAVE_GNU_LD 1
+#define HAVE_GNU_LD 0

Since

commit c807ac4d96dbb2e612fa2e8ebf7485b2fc3db117
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date:   Sun Mar 1 18:04:03 2026 +0100

    Switch to HAVE_SOLARIS_AS

and

commit 96f3b4dfe16984299d65d7a071a5586dafcbd046
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date:   Sun Mar 1 18:32:26 2026 +0100

    Switch to HAVE_SOLARIS_LD

this patch is no longer needed to avoid the HAVE_GNU_AS/HAVE_GNU_LD
misdetections on Solaris.  In fact, the few remaining uses of those
macros are expected to be removed in GCC 17 stage 1.

For the moment, I'd like to revert the patch above.

Bootstrapped without regressions no i386-pc-solaris2.11,
sparc-sun-solaris2.11, x86_64-pc-linux-gnu, and by comparing auto-host.h
in make configure-gcc for a cross to arm-none-eabi.

This reverts commit fdd1d058f289eda39b6eb1386a0dabef3478d298.

3 months agoFortran: [PR121743] ICE in build_function_decl.
Jerry DeLisle [Thu, 12 Mar 2026 17:23:47 +0000 (10:23 -0700)] 
Fortran: [PR121743] ICE in build_function_decl.

PR fortran/121743

gcc/fortran/ChangeLog:

* trans-decl.cc (build_function_decl): Adjust the
gcc_assert condition to avoid the ICE.

gcc/testsuite/ChangeLog:

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

Co-Authored-By: Gilles Gouaillardet <gilles.gouaillardet@gmail.com>
3 months agotestsuite: Remove xfails in gcc.dg/attr-alloc_size-11.c [PR80006]
Rainer Orth [Thu, 12 Mar 2026 19:57:21 +0000 (20:57 +0100)] 
testsuite: Remove xfails in gcc.dg/attr-alloc_size-11.c [PR80006]

As described in PR middle-end/80006, the gcc.dg/attr-alloc_size-11.c
test XPASSes on many targets:

XPASS: gcc.dg/attr-alloc_size-11.c missing range info for short (test for warnings, line 51)
XPASS: gcc.dg/attr-alloc_size-11.c missing range info for signed char (test for warnings, line 50)

Therefore, this patch removes the xfails.

Tested on i386-pc-solaris2.11, sparc-sun-solaris2.11, and
x86_64-pc-linux-gnu.

2026-03-02  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc/testsuite:
PR tree-optimization/80006
* gcc.dg/attr-alloc_size-11.c (dg-warning): Remove xfails.

3 months agotestsuite: Fix gcc.dg/plugin/must-tail-call-2.c on SPARC [PR121159]
Rainer Orth [Thu, 12 Mar 2026 19:53:50 +0000 (20:53 +0100)] 
testsuite: Fix gcc.dg/plugin/must-tail-call-2.c on SPARC [PR121159]

The gcc.dg/plugin/must-tail-call-2.c test FAILs on 32 and 64-bit SPARC:

FAIL: gcc.dg/plugin/must-tail-call-2.c -fplugin=./must_tail_call_plugin.so (test for excess errors)

Excess errors:
gcc.dg/plugin/must-tail-call-2.c:58:3: error: cannot tail-call: target is not able to optimize the call into a sibling call

As discussed in the PR, this can be avoided by compiling with
-fdelayed-branch on SPARC.

Tested on sparc-sun-solaris2.11, sparc64-unknown-linux-gnu, and
x86_64-pc-linux-gnu.

2026-03-09  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc/testsuite:
PR middle-end/121159
* gcc.dg/plugin/must-tail-call-2.c (dg-additional-options): Add
-fdelayed-branch on SPARC.

3 months agolibphobos: Implement IeeeFlags on SPARC [PR123202]
Rainer Orth [Thu, 12 Mar 2026 19:51:02 +0000 (20:51 +0100)] 
libphobos: Implement IeeeFlags on SPARC [PR123202]

The libphobos.phobos/std_math_hardware.d test FAILs on SPARC:

FAIL: libphobos.phobos/std_math_hardware.d (test for excess errors)
UNRESOLVED: libphobos.phobos/std_math_hardware.d compilation failed to produce executable

Excess errors:
libphobos.phobos/std_math_hardware.d:7: error: undefined identifier 'FloatingPointControl'

There's currently no support for IeeeFlags on SPARC.

One part of an implementation has already been committed to upstream phobos

commit aa963e98c55b36b5d608f9443d96c66b63d16d8f
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date:   Thu Feb 19 12:47:58 2026 +0100

    std/math/hardware.d: Partial IeeeFlags implementation on SPARC (#10958)

but the actual implementation is specific to a GDC-specific part of
hardware.d which isn't upstream yet.  This patch provides that part.

Tested on sparc-sun-solaris2.11 and sparc64-unknown-linux-gnu.

2025-12-19  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

libphobos:
PR d/123202
* src/std/math/hardware.d (getIeeeFlags) [GNU && SPARC_Any]: Implement.
(resetIeeeFlags) [GNU && SPARC_Any]: Likewise.
(hasExceptionTraps) [SPARC_Any]: Return true.
(getControlState) [GNU && SPARC_Any]: Implement.
(setControlState) [GNU && SPARC_Any]: Likewise.

3 months agolibstdc++: Increase timeout for 23_containers/mdspan/submdspan tests [PR124290]
Rainer Orth [Thu, 12 Mar 2026 19:46:22 +0000 (20:46 +0100)] 
libstdc++: Increase timeout for 23_containers/mdspan/submdspan tests [PR124290]

The 23_containers/mdspan/submdspan/selections tests often time out on
Solaris/SPARC:

WARNING: 23_containers/mdspan/submdspan/selections/left_padded.cc  -std=gnu++26 (test for excess errors) program timed out.
FAIL: 23_containers/mdspan/submdspan/selections/left_padded.cc  -std=gnu++26 (test for excess errors)

Even on an unloaded system, compilation takes ca. 4 minutes, close to
the default DejaGnu timeout of 5 minutes.  Setting/increasing the
timeout factor to 2 was not enough, so this patch raises it to 4 for all
5 tests.

Tested on sparc-sun-solaris2.11 and x86_64-pc-linux-gnu.

2026-03-06  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

libstdc++-v3:
PR libstdc++/124290
* testsuite/23_containers/mdspan/submdspan/selections/left_padded.cc:
Use dg-timeout-factor 4.
* testsuite/23_containers/mdspan/submdspan/selections/left.cc:
* testsuite/23_containers/mdspan/submdspan/selections/right_padded.cc:
* testsuite/23_containers/mdspan/submdspan/selections/right.cc:
Likewise.
* testsuite/23_containers/mdspan/submdspan/selections/stride.cc:
Likewise.

3 months agoc++/reflection: add fixed test
Marek Polacek [Thu, 12 Mar 2026 19:27:54 +0000 (15:27 -0400)] 
c++/reflection: add fixed test

This test I got today was just fixed by r16-8027 earlier today.

gcc/testsuite/ChangeLog:

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

3 months agoc++/reflection: class member access with [: T::BASELINK :] [PR124440]
Marek Polacek [Wed, 11 Mar 2026 17:28:30 +0000 (13:28 -0400)] 
c++/reflection: class member access with [: T::BASELINK :] [PR124440]

Let

  struct B { consteval virtual int fn() const { return 1; } };
  struct D : B { consteval int fn() const override { return 2; } };

and consider

  d.[:^^B::fn:]()  // #1
  d.[:^^B:]::fn()  // #2

then #1 should yield 2 and #2 should yield 1: #1 doesn't count as
qualified name lookup and so should be treated as "d.fn()" where
lookup_vfn_in_binfo in build_over_call finds D::fn.  But #2 is like
"d.B::fn()" which should prevent a virtual function call and we
should be calling B::fn.

We already handle this correctly outside of templates: finish_call_expr
only checks IDK to see if it should disallow_virtual, but in tsubst_expr
it looks at BASELINK_QUALIFIED_P, which is wrongly set for #1.

BASELINK_QUALIFIED_P is always set by adjust_result_of_q_name_lookup,
so cp_parser_postfix_dot_deref_expression should clear it for case #1.
With this patch, we only set BASELINK_QUALIFIED_P if qualifying_scope
was not null.

Unfortunately we can't avoid the adjust_result_ call because then
lookup_vfn_in_binfo gets a binfo that isn't BINFO_PRIMARY_P and it won't
find D::fn.  It seems it is necessary to have that adjust_result_ ->
lookup_base adjustment.

And then tsubst_expr has to do the same thing for when we have

  d.[:^^T::fn:]()

where T is a tparm that is substituted with B.

PR c++/124440

gcc/cp/ChangeLog:

* parser.cc (cp_parser_postfix_dot_deref_expression): Pass
parser->scope to adjust_result_of_qualified_name_lookup even
when splice_p.  Assign the result of
adjust_result_of_qualified_name_lookup to name.
* pt.cc (tsubst_expr): Call adjust_result_of_qualified_name_lookup
for BASELINKs in splice-expressions.
* search.cc (adjust_result_of_qualified_name_lookup): Return early
if decl is not a BASELINK.  If qualifying_scope is null, use decl's
binfo.  Set BASELINK_QUALIFIED_P only if qualifying_scope wasn't
null.

gcc/testsuite/ChangeLog:

* g++.dg/reflect/member21.C: Uncomment the commented out asserts.

Reviewed-by: Jason Merrill <jason@redhat.com>
3 months agoFortran: Add missing deferred type PDT errors in allocate [PR115316]
Paul Thomas [Thu, 12 Mar 2026 17:50:55 +0000 (17:50 +0000)] 
Fortran: Add missing deferred type PDT errors in allocate [PR115316]

2026-03-12  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/115316
* match.cc (spec_list_type): A version of gfc_spec_list_type,
which returns true if any of the LEN parameters are deferred.
(gfc_match_allocate): Use it to set saw_deferred if any of the
parameters of the allocate object are deferred.

gcc/testsuite/
PR fortran/115316
* gfortran.dg/pdt_87.f03: New test.

3 months agoFortran: gfortran PDT component access [PR122696]
Paul Thomas [Thu, 12 Mar 2026 17:35:51 +0000 (17:35 +0000)] 
Fortran: gfortran PDT component access [PR122696]

2026-03-12  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/122696
* resolve.cc (resolve_assoc_var): A generic function selector
must be resolved to a specific function before doing anything
more with the associate name.

gcc/testsuite/
PR fortran/122696
* gfortran.dg/pdt_89.f03: New test.

3 months agoAda: Fix Program_Error raised in a Bounded_Indefinite_Holders instance
Steve Baird [Thu, 12 Mar 2026 17:18:36 +0000 (18:18 +0100)] 
Ada: Fix Program_Error raised in a Bounded_Indefinite_Holders instance

If Ada.Containers.Bounded_Indefinite_Holders is instantiated with an
Element_Type that requires finalization, the declaration of a Holder
object with an explicit initial value may incorrectly raise Program_Error
during its elaboration.

gcc/ada/
PR ada/124016
* libgnat/a-cbinho.adb (Create_Subpool): Handle the case where
the type Holder_Subpool has nontrivial finalization. Declare the
local variable Subpool with its Import aspect specified (to avoid
unwanted finalization), and make corresponding changes in order to
initialize that variable.
* libgnat/s-stposu.ads (_Adjust_Clone): New procedure.
* libgnat/s-stposu.adb (_Adjust_Clone): New body.

3 months agoAda: Fix missing error for dangling pointer from access discriminant
Eric Botcazou [Thu, 12 Mar 2026 17:11:34 +0000 (18:11 +0100)] 
Ada: Fix missing error for dangling pointer from access discriminant

This restores the original computation of the scope depth of the innermost
enclosing master of a given node and performs a couple of other cleanups.

Note that this has uncovered an issue in the ACATS c3a0025 test and the
change contains the modification that has been submitted to the ACAA.

gcc/ada/
PR ada/124369
* accessibility.adb (Accessibility_Message): Give an error instead
of a warning in an instance when No_Dynamic_Accessibility_Checks is
in effect.
(Innermost_Master_Scope_Depth): Restore the original computation of
the nearest enclosing dynamic scope.
* sem_attr.adb (Resolve_Attribute) <Attribute_Access>: Call the
Accessibility_Message routine in all cases to give accessibility
errors and do not return.  Call the Static_Accessibility_Level
function in all cases to compute static accessibility levels.
Add guard before calling Prefix_With_Safe_Accessibility_Level.

gcc/testsuite/
* ada/acats-3/tests/c3/c3a0025.a: Tweak.
* ada/acats-4/tests/c3/c3a0025.a: Likewise.
* gnat.dg/access12.adb: New test.

3 months agoAda: Fix missing accessibility check in assignment for aliased parameter
Eric Botcazou [Thu, 12 Mar 2026 16:58:41 +0000 (17:58 +0100)] 
Ada: Fix missing accessibility check in assignment for aliased parameter

This plugs a loophole related to static accessibility checks in assignment
for aliased parameters.

gcc/ada/
PR ada/124376
* sem_res.adb (Resolve_Actuals.Check_Aliased_Parameter): Deal with
assignment statements.

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

3 months agoAda: Complete implementation of AI12-0402
Eric Botcazou [Thu, 12 Mar 2026 16:52:08 +0000 (17:52 +0100)] 
Ada: Complete implementation of AI12-0402

This implements AI12-0402 in the function computing the accessibility level
of function calls in the general case, as opposed to the more specific case
of the RM 6.4.1(6.4) legality rule.  This also removes a ??? note attached
to the handling of N_Assignment_Statement nodes in this function.

gcc/ada/
PR ada/124376
* accessibility.adb (Accessibility_Level): Minor formatting tweaks.
(Accessibility_Level.Function_Call_Or_Allocator_Level): Implement
AI12-0402.  Reimplement the loop climbing up the parent chain to
find an object being initialized.  Restrict the specific handling
of N_Assignment_Statement nodes to the anonymous access type case.
* doc/gnat_rm/implementation_of_ada_2022_features.rst: Adjust the
entries of AI12-0277, AI12-0345 & AI12-0372, add one for AI12-0402.
* gnat_rm.texi: Regenerate.

3 months agoc++: require C++26 for -freflection [PR124447]
Marek Polacek [Wed, 11 Mar 2026 20:10:12 +0000 (16:10 -0400)] 
c++: require C++26 for -freflection [PR124447]

-freflection is unusable without C++26 so let's not allow it.

PR c++/124447

gcc/c-family/ChangeLog:

* c-opts.cc (c_common_post_options): Error if -freflection is used
without -std=c++26 or -std=gnu++26.

Reviewed-by: Jason Merrill <jason@redhat.com>
3 months agoipa-prop: Skip analysis od static constructor entries with no index (PR124260)
Martin Jambor [Thu, 12 Mar 2026 15:59:34 +0000 (16:59 +0100)] 
ipa-prop: Skip analysis od static constructor entries with no index (PR124260)

PR 124260 is about dereferencing a NULL "index" tree when traversing
static constructors of global variables.  As discussed in the bug, it
is unclear whether that is allowed but ObjC compiler creates these at
least on 32bit hosts.  Ian plans to fix this in the FE in the next
stage1 but for this stage4, such entries can be easily skipped in
ipa-prop (too).  The collected information is used for speculative
"devirtualization" ony and so if we miss a relevant entry, it may only
result in a "bad" decision whether to do that or not.

gcc/ChangeLog:

2026-03-11  Martin Jambor  <mjambor@suse.cz>

PR objc/124260
* ipa-prop.cc (ipa_analyze_var_static_initializer): Skip a constructor
entry if its index is NULL.

3 months agoc++/modules: Support diagnostic classification changes in macros [PR124459]
Nathaniel Shead [Thu, 12 Mar 2026 13:47:36 +0000 (00:47 +1100)] 
c++/modules: Support diagnostic classification changes in macros [PR124459]

Diagnostic classification changes via _Pragma can occur in macros, but
weren't taking effect in imported modules.  The issue is that we were
reading the diagnostic classification map before we processed the macro
maps, which meant that all locations in macros were just falling back
to the abstract location of the module itself.  Fixed by moving the
processing after we've read the macro maps.

PR c++/124459

gcc/cp/ChangeLog:

* module.cc (module_state::read_initial): Move
read_diagnostic_classification after read_macro_maps.

gcc/testsuite/ChangeLog:

* g++.dg/modules/warn-spec-4_a.C: New test.
* g++.dg/modules/warn-spec-4_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
3 months agoc++/modules: Merge synthesized definitions of defaulted members [PR124311]
Nathaniel Shead [Mon, 2 Mar 2026 14:24:06 +0000 (01:24 +1100)] 
c++/modules: Merge synthesized definitions of defaulted members [PR124311]

When a TU synthesizes a definition of a defaulted member function we
mark the TU that did this as the originating module, and so export it
from there.  If this TU is imported into a module that already has a
declaration of this entity the declarations should be merged.

This patch fixes an issue where this merging was not occurring for
explicitly defaulted member functions, by checking DECL_DEFAULTED_FN
instead of just DECL_ARTIFICIAL.

PR c++/124311

gcc/cp/ChangeLog:

* module.cc (trees_in::key_mergeable): Check DECL_DEFAULTED_FN
instead of DECL_ARTIFICIAL.

gcc/testsuite/ChangeLog:

* g++.dg/modules/imp-member-5_a.C: New test.
* g++.dg/modules/imp-member-5_b.C: New test.
* g++.dg/modules/imp-member-5_c.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
3 months agoc++/modules: Check for redeclarations of members in wrong module
Nathaniel Shead [Sat, 7 Mar 2026 06:14:55 +0000 (17:14 +1100)] 
c++/modules: Check for redeclarations of members in wrong module

We had missed checking whether we were doing an (outside class)
declaration of a member attached to the wrong module.  This patch adds
those checks.

Within duplicate_decls/maybe_module_redeclare there's not a nice way to
do this because the attachment of a member is always calculated based on
the attachment of its owning type, which defeats the purpose here.
Instead I added the checks to start_decl and grokfndecl where we do
other various checks for if a redeclaration of a class member is legal.

gcc/cp/ChangeLog:

* decl.cc (start_decl): Check module_may_redeclare for members.
(grokfndecl): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/modules/class-12_a.C: New test.
* g++.dg/modules/class-12_b.C: New test.
* g++.dg/modules/class-12_c.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
3 months agotestsuite: Add testcase for bug fixed on trunk but not in 15/14 [PR124154]
Jakub Jelinek [Thu, 12 Mar 2026 14:23:48 +0000 (15:23 +0100)] 
testsuite: Add testcase for bug fixed on trunk but not in 15/14 [PR124154]

This testcase used to be rejected before r16-970, but is accepted since
then.  It used to be rejected in 15.1 and 14.2 too, but PR120123
r15-9757 and r14-11823 backports started to ICE on it instead.
In 13/12 it is still rejected, so not a regression there.

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

PR c++/124154
* g++.dg/cpp23/explicit-obj-lambda21.C: New test.

3 months agoc++/modules: Fix ICE in xref_basetypes on class redefinition
Nathaniel Shead [Sat, 7 Mar 2026 13:13:28 +0000 (00:13 +1100)] 
c++/modules: Fix ICE in xref_basetypes on class redefinition

In a modules scenario, when we bail out of begin_class_definition due to
an error in module_may_redeclare, we return error_mark_node but had
already started building the class definition.  When we re-enter
cp_parser_class_head we then successfully reach xref_basetypes, where we
then crash because the binfo slot is non-null.

This fixes the issue by moving the module_may_redeclare check earlier,
to before we call xref_basetypes, so that we don't start building the
definition if we were going to bail anyway.  As a side effect this also
moves the check to before we update the DECL_SOURCE_LOCATION of the type
to the start of the class head, so that when we complain about
mismatched attachment we can point to the imported declaration rather
than referring to ourselves again.

gcc/cp/ChangeLog:

* semantics.cc (begin_class_definition): Move
module_may_redeclare check to...
* parser.cc (cp_parser_class_head): ...here.

gcc/testsuite/ChangeLog:

* g++.dg/modules/class-13_a.C: New test.
* g++.dg/modules/class-13_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
3 months agoc++/modules: Don't create bindings for hidden friends [PR124390]
Nathaniel Shead [Sat, 7 Mar 2026 15:48:10 +0000 (02:48 +1100)] 
c++/modules: Don't create bindings for hidden friends [PR124390]

In r16-6343-gc368ea51b3bae27e3007b9bd89f6162c4c80259f we stopped walking
attached decls for a DECL_MODULE_KEYED_DECLS_P entity during dependency
gathering so that we didn't unnecessarily expose them if they weren't
going to be emitted anyway, and relied on walking the definition to
properly setup dependencies.

But the linked PR shows that if those attached decls instantiate a
template that pushes a hidden friend, they might be found anyway even if
we don't find them via the function definition, because we see the
hidden decls during add_binding_entity.

Apart from causing this crash, walking these hidden decls is both
pointless (hidden friends, if needed, will always be walked by their
owning class type, and ADL does not need namespace-scope bindings to
call them) and expensive, because this can cause a large swathe of other
otherwise discarded GMF entities to be marked as reachable.

This patch fixes the issue by not creating bindings for hidden friends.
Perhaps no hidden entities should have bindings at all, but doing this
causes make_dependency to break on the underlying alias decl for a
purview DECL_LOCAL_DECL_P when considering additional bindings that need
to be created, and I think we might need this to stay around so that we
can properly merge these decls anyway (though I haven't investigated
this yet).  So this patch goes for a more minimal fix for now.

PR c++/124390

gcc/cp/ChangeLog:

* module.cc (depset::hash::add_binding_entity): Don't create
bindings for hidden friends.

gcc/testsuite/ChangeLog:

* g++.dg/modules/friend-13.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
3 months agoc++: Fix up ICE check_out_of_consteval_use_r on some OpenMP clauses
Jakub Jelinek [Thu, 12 Mar 2026 14:13:54 +0000 (15:13 +0100)] 
c++: Fix up ICE check_out_of_consteval_use_r on some OpenMP clauses

When testing make check in libgomp with
RUNTESTFLAGS='--target_board=unix/-std=gnu++26/-freflection'
there are several ICEs.  One is what I've just committed a fix for,
another one is on OpenMP clauses with iterators, where we use
TREE_VEC with 6 arguments as a temporary hack created by
cp_parser_omp_iterator, the first operand of that is an artificial
VAR_DECL for a variable that should be later on temporarily in scope
when handling the iterator during gimplification, then a few
expressions for low/high bound/step and finally the last one can
be a BLOCK covering the expression in the clause argument.  Unfortunately
check_out_of_consteval_use_r just ICEs on it, BLOCK doesn't have TREE_TYPE.
While this could be handled specially for
OMP_CLAUSE with OMP_CLAUSE_{DEPEND,AFFINITY,TO,FROM,MAP} only and only for
TREE_VECs in TREE_LIST of their argument, just punting on BLOCK like the
patch below seems to be far easier.

Note, with these 2 changes no ICEs in libgomp make check left.

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

* reflect.cc (check_out_of_consteval_use_r): Don't walk BLOCK
subtrees.

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

3 months agobootstrap/124406 - fix lean LTO profiledboostrap
Richard Biener [Thu, 12 Mar 2026 12:03:02 +0000 (13:03 +0100)] 
bootstrap/124406 - fix lean LTO profiledboostrap

On s390x we are seeing CFG divergence when using the boostrap-lto-lean
config with profiledbootstrap which uses a non-LTO build for
stageprofile and a LTO build for stagefeedback.  This is caused by
local IPA pure-const skipping some analysis only when not doing LTO.

The following removes this divergence.  Proposed by Honza in the PR,
profilebootstrapped with bootstrap-lto-lean on s390x-linux-gnu.

PR bootstrap/124406
* ipa-pure-const.cc (skip_function_for_local_pure_const):
Do not analyze interposable functions when LTO is enabled.

3 months agosh: Remove TARGET_PROMOTE_PROTOTYPES
H.J. Lu [Wed, 11 Mar 2026 15:43:01 +0000 (08:43 -0700)] 
sh: Remove TARGET_PROMOTE_PROTOTYPES

TARGET_PROMOTE_PROTOTYPES is an optimization, not an ABI requirement.
TARGET_PROMOTE_FUNCTION_MODE should be used for ABI requirement, which
is properly defined for sh.  Remove TARGET_PROMOTE_PROTOTYPES from sh.

gcc/

PR target/122925
PR target/119979
* config/sh/sh.cc (TARGET_PROMOTE_PROTOTYPES): Removed.

gcc/testsuite/

PR target/122925
PR target/119979
* gcc.dg/pr122925.c: New test.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
3 months agofortran: Fix UB in transfer_expr [PR124450]
Jakub Jelinek [Thu, 12 Mar 2026 11:39:43 +0000 (12:39 +0100)] 
fortran: Fix UB in transfer_expr [PR124450]

trans-io.cc (transfer_array_component) calls transfer_expr with
NULL code:
  transfer_expr (&se, &cm->ts, tmp, NULL, NULL_TREE);
I'm surprised it doesn't ICE in other spots that dereference
code->whatever but each one is guarded with some condition
that perhaps don't trigger in that case for some reason.
Anyway, the &code->loc case does trigger, it doesn't ICE, but
it is undefined behavior in the compiler when code is NULL,
and we'd crash if the where argument of 3*sizeof(void*) is
dereferenced.  Code I've checked can handle NULL where though.

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

PR fortran/124450
* trans-io.cc (transfer_expr): If code is NULL, call
transfer_array_component with NULL where argument rather than
&code->loc.

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

3 months agoFortran: gfortran PDT component access [PR97818]
Paul Thomas [Thu, 12 Mar 2026 11:21:23 +0000 (11:21 +0000)] 
Fortran: gfortran PDT component access [PR97818]

2026-03-12  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/97818
* trans-decl.cc (gfc_trans_deferred_vars): Make sure that the
result symbol is referenced before allocating parameterized
components.

gcc/testsuite/
PR fortran/97818
* gfortran.dg/pdt_88.f03: New test.

3 months agofold-mem-offsets: Clarify why do_analysis pre-marks the memory insn
Philipp Tomsich [Mon, 23 Feb 2026 19:22:03 +0000 (20:22 +0100)] 
fold-mem-offsets: Clarify why do_analysis pre-marks the memory insn

The bitmap_set_bit call before fold_offsets in do_analysis is
intentional: fold_offsets requires all uses of a definition to already
be in can_fold_insns before it will mark the definition as foldable.
Pre-marking the memory instruction (which is the root use) is necessary
for its address definitions to pass this check during the DFS.

Replace the generic comment with one that explains this dependency.

gcc/ChangeLog:

* fold-mem-offsets.cc (do_analysis): Revise comment.

3 months agolibstdc++: Fix mingw-w64 build due to __max macro
Jonathan Wakely [Wed, 11 Mar 2026 21:22:12 +0000 (21:22 +0000)] 
libstdc++: Fix mingw-w64 build due to __max macro

The stdlib.h header on mingw defines a function-like macro called __max,
which causes an error here:

include/format:3785:55: error: macro '__max' requires 2 arguments, but only 1 given
 3785 |               iter_difference_t<_OutIter> __max(_M_max);

We have lots of existing variables called __max, but this is the only
case that uses direct-initialization and so interferes with the
function-like macro in stdlib.h

The fix applied here is just to rename the variable. We can't use
direct-list-initialization because the conversion from size_t to the
difference type would be narrowing. We prefer not to use
copy-initialization so that conversion to the difference type is
explicit not implicit.

libstdc++-v3/ChangeLog:

* include/std/format (__format::_Ptr_sink::_M_finish): Rename
__max variable to __m.
* testsuite/17_intro/names.cc (__max): Define function-like
macro.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 months agosymtab: Fix init and fini priority to reset to default [PR120030]
Andrew Pinski [Wed, 11 Mar 2026 21:41:31 +0000 (14:41 -0700)] 
symtab: Fix init and fini priority to reset to default [PR120030]

Right now if try to reset the priority of a constructor to the
default (65535), there is an ICE.
To fix this the assert is wrong and intead we should check
if the priority is already the default if not then we should
just update it.

Bootstrapped and tested on x86_64-linux-gnu.

PR middle-end/120030

gcc/ChangeLog:

* symtab.cc (symtab_node::set_init_priority): Better
handle the case of setting the priority back to default.
(cgraph_node::set_fini_priority): Likewise.

gcc/testsuite/ChangeLog:

* gcc.dg/constructor-2.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
3 months agodoc/extend: Document constructor/destructor attribute applying
Andrew Pinski [Wed, 11 Mar 2026 21:35:06 +0000 (14:35 -0700)] 
doc/extend: Document constructor/destructor attribute applying

Again while looking into PR 120030, there was no documentation
of what it means to have multiple constructor/destructor attributes
on the same function. Basically the last priority wins.

gcc/ChangeLog:

* doc/extend.texi (constructor/destructor): Add documentation
about multiple attributes here.

3 months agodoc/extend: Document constructor/destructor priority when none is supplied
Andrew Pinski [Wed, 11 Mar 2026 21:29:20 +0000 (14:29 -0700)] 
doc/extend: Document constructor/destructor priority when none is supplied

Noticed while working on PR 120030, the priority/order of constructor/destructor
without an argument is not documented.
This adds that the default priority is 65535 (last in order).

gcc/ChangeLog:

* doc/extend.texi (constructor/destructor): Document
the priority when none is supplied.

3 months agoopenmp, c++: Fix up TREE_TYPE of OMP_TASK
Jakub Jelinek [Thu, 12 Mar 2026 08:09:42 +0000 (09:09 +0100)] 
openmp, c++: Fix up TREE_TYPE of OMP_TASK

I've made a typo a few years ago and used void_node instead of void_type_node
as TREE_TYPE of OMP_TASK in the taskwait depend case.  This got later
on copied also for dispatch.
With reflection this leads to ICEs (but guess except for the testcase
we should also backport it to release branches).

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

* parser.cc (cp_parser_omp_taskwait): Set TREE_TYPE of OMP_TASK
to void_type_node rather than void_node.
(cp_parser_omp_dispatch): Likewise.

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

3 months agolibstdc++: Use CTAD for span in std::define_static_object [PR124443]
Jakub Jelinek [Thu, 12 Mar 2026 07:50:35 +0000 (08:50 +0100)] 
libstdc++: Use CTAD for span in std::define_static_object [PR124443]

The standard in https://eel.is/c++draft/meta.reflection#meta.define.static-17
uses CTAD for span but we were avoiding that and using span<const _Up>
instead.

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

PR libstdc++/124443
* include/std/meta (std::define_static_object): Use CTAD for span.

3 months agoc++: Support proxy iterators in reflection get_range_elts [PR124425]
Jakub Jelinek [Thu, 12 Mar 2026 07:48:47 +0000 (08:48 +0100)] 
c++: Support proxy iterators in reflection get_range_elts [PR124425]

I've punted up on proxy iterators because I didn't know how to construct
a test for those.

The following patch adds support for thosse.  Besides converting those
to valuet if needed and for classes making sure they live in a TARGET_EXPR
where they can be subsequently destructed, the patch adds
CLEANUP_POINT_EXPRs around the deref and inc expressions such that the
TARGET_EXPRs in those expressions are immediately destructed after returning
what we need.
cmp doesn't need that because
  cmp = condition_conversion (cmp);
already adds that.
Without the CLEANUP_POINT_EXPRs stuff is destructed (and marked as if out of
lifetime) only in some CLEANUP_POINT_EXPR surrounding the metafn call, which
is certainly too late for stuff that is reentered and left again in every
iteration.
I wrongly thought I'd need to duplicate the first part of CLEANUP_POINT_EXPR
handling in reflect.cc (which is complicated because struct constexpr_ctx
is only defined in constexpr.cc), then cxx_eval_constant_expression
e.g. deref and then duplicate the second part of CLEANUP_POINT_EXPR
handling, but it seems that the CLEANUP_POINT_EXPR evaluation just returns
what was returned from the recursive call on its operand, which is I think
exactly what we need.

This change broke 2 testcases, reflect_constant_array4.C and
define_static_array4.C, but IMHO correctly so, apparently what I had
there was creating std::pair<const int &, const int &> with references
to something that should have been immediately destructed in each iteration.
So, the patch fixes those tests to use std::pair<int, int> instead.

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

PR c++/124425
* reflect.cc (get_range_elts): Handle proxy iterators.  Call
fold_build_cleanup_point_expr on both deref and inc.

* g++.dg/reflect/define_static_array4.C: Enable commented out
static_asserts and fix up the first one.
(as_pair): Make sure to return std::pair <int, int>.
* g++.dg/reflect/reflect_constant_array4.C: Enable commented out
static_asserts and fix up the first one.
(as_pair): Make sure to return std::pair <int, int>.
* g++.dg/reflect/reflect_constant_array7.C: New test.
* g++.dg/reflect/reflect_constant_array8.C: New test.