* dmd/MERGE: Merge upstream dmd 55e64690bc.
* dmd/VERSION: Bump version to v2.113.0-beta.1.
* d-codegen.cc (d_build_call): Check if argument is already a
TARGET_EXPR.
* decl.cc (DeclVisitor::visit (FuncDeclaration *)): Don't use
`__result' decl as named return value if it's a ref type.
* expr.cc (ExprVisitor::visit (StructLiteralExp *)): Force TARGET_EXPR
if init symbol needs to be mutable.
* runtime.def (ARRAYSETLENGTHT): Remove.
(ARRAYSETLENGTHIT): Remove.
(ARRAYCOPY): Remove.
(ARRAYAPPENDCTX): Remove.
* typeinfo.cc (TypeInfoVisitor::visit (TypeInfoClassDeclaration *)):
Only scan class fields for pointer members.
Jakub Jelinek [Wed, 1 Apr 2026 18:13:23 +0000 (20:13 +0200)]
c++: Implement CWG3124 - Disallow annotations on block-scope externs and non-unique friend declarations
This issue says it is invalid to declare annotations on local externs or
non-defining friends and their arguments (if any).
2026-04-01 Jakub Jelinek <jakub@redhat.com>
* name-lookup.cc (push_local_extern_decl_alias): Diagnose annotations
on local externs and their arguments.
* decl.cc (grokdeclarator): Diagnose annotations on non-defining
friends and their arguments.
Jakub Jelinek [Wed, 1 Apr 2026 17:19:19 +0000 (19:19 +0200)]
c++: Change ^^:: mangling from LDmngE to LDmgsE
In
https://github.com/itanium-cxx-abi/cxx-abi/issues/208#issuecomment-3518384358
Richard Smith suggested (among other things) to use gs instead of ng
for ^^:: mangling, because gs is already used elsewhere in the grammar for
similar purposes (like [gs] nw <expression>* _ <type> E etc.).
This patch changes that, plus added the part I forgot to update when
mangling the annotations.
Note, in
https://github.com/itanium-cxx-abi/cxx-abi/issues/208#issuecomment-3571323241
Tim Song mentioned that perhaps for L Dm ta ... E we should be including
both the <alias prefix> and underlying <type> (probably with some
separation), because different TUs could have different aliases. Or shall
all decls which refer to type aliases be TU local?
2026-04-01 Jakub Jelinek <jakub@redhat.com>
* mangle.cc (write_reflection): Change ^^:: mangling in grammar
from LDmngE to LDmgsE.
* reflect.cc (reflection_mangle_prefix): Set prefix to "gs" rather
than "ng" for global_namespace.
* g++.dg/reflect/mangle1.C: Expect _Z3barILi310ELDmgsEEvv
rather than _Z3barILi310ELDmngEEvv.
Jakub Jelinek [Wed, 1 Apr 2026 17:15:51 +0000 (19:15 +0200)]
libstdc++: Attempt to implement LWG4537 - Improve define_static_array
The following patch attempts to implement
https://cplusplus.github.io/LWG/lwg-active.html#4537
I've also added tests for the returned type.
2026-04-01 Jakub Jelinek <jakub@redhat.com>
* include/std/meta (std::meta::__detail::__statically_sized): New
concept.
(std::meta::define_static_array): Change return type to auto. If
__statically_sized<_Rg>, return span with ranges::size(__r) as
second argument.
* g++.dg/reflect/define_static_array1.C (l): Another variable
with define_static_array test from array<int, 0>.
Add static assertions for types of the define_static_array results.
François Dumont [Mon, 30 Mar 2026 20:18:50 +0000 (22:18 +0200)]
libstdc++: [_GLIBCXX_DEBUG] Fix COW string valid range check
In revision 698a6af5dcbae5d935bcda8a461dea8458c658dc the _GLIBCXX_DEBUG code
for the Library Defect 438 has been removed as starting in C++11 the iterator
type is constrained through the _RequireInputIter requirement.
But the COW basic_string implementation used when _GLIBCXX_USE_CXX11_ABI=0 is
missing the _RequireInputIter constraint on a number of methods resulting in test
failures.
For the moment move the culprit __glibcxx_requires_valid_range call in the COW
basic_string implementation in a method where the iterator type has already been
checked.
libstdc++-v3/ChangeLog:
* include/bits/cow_string.h
(basic_string::replace(iterator, iterator, _InputIte, _InputIte)): Move
__glibcxx_requires_valid_range to...
(basic_string::_M_replace_dispatch(iterator, iterator, _InputIte,
_InputIte, __fase_type)): ...here.
* testsuite/21_strings/basic_string/debug/append_neg.cc: New test case.
* testsuite/21_strings/basic_string/debug/assign_neg.cc: New test case.
* testsuite/21_strings/basic_string/debug/construct_neg.cc: New test case.
* testsuite/21_strings/basic_string/debug/insert_neg.cc: New test case.
* testsuite/21_strings/basic_string/debug/replace_neg.cc: New test case.
Co-authored-by: Jonathan Wakely <jwakely@redhat.com> Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
David Faust [Wed, 1 Apr 2026 16:28:10 +0000 (09:28 -0700)]
MAINTAINERS: Update Qing Zhao email address
Qing has retired from Oracle, and asked me to update her email address
in MAINTAINERS on her behalf, as she temporarily does not have a
machine set up to push to the repo.
Patrick Palka [Wed, 1 Apr 2026 15:34:27 +0000 (11:34 -0400)]
libstdc++/ranges: Inline hidden friends' member function helpers
These helpers were needed to work around GCC's historically strict
interpretation of friendship for hidden friends whereby they did not
inherit the friends of the containing class. But this has been relaxed
in r13-465 which granted hidden friends the same access as any other
member declaration, and <ranges> additions since then rely on this
relaxed interpretation. (Note that Clang also has this relaxed
interpretation, but MSVC / EDG seem to have the strict interpretation.)
This patch removes these now redundant member functions and inlines
their logic directly into the respective friend operators, making
things simpler and more consistent.
libstdc++-v3/ChangeLog:
* include/std/ranges (iota_view::_Sentinel): Remove _M_equal and
_M_distance_from. Inline logic into friend operators.
(basic_istream_view::_Iterator): Remove _M_at_end. Inline logic
into operator==.
(transform_view::_Sentinel): Remove __distance_from and __equal.
Inline logic into friend operators.
(join_view::_Sentinel): Remove __equal. Inline logic into operator==.
(lazy_split_view::_OuterIter): Remove __at_end. Inline logic into
operator==.
(split_view::_Sentinel): Remove _M_equal. Inline logic into operator==.
(elements_view::_Sentinel): Remove _M_equal and _M_distance_from.
Inline logic into friend operators.
gcc/config/s390/s390.cc: In function ‘void print_operand(FILE*, rtx, int)’:
gcc/config/s390/s390.cc:8974:15: warning: format not a string literal and no format arguments [-Wformat-security]
8974 | fprintf (file, s390_branch_condition_mnemonic (x, FALSE));
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gcc/config/s390/s390.cc:8978:15: warning: format not a string literal and no format arguments [-Wformat-security]
8978 | fprintf (file, s390_branch_condition_mnemonic (x, TRUE));
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gcc/ChangeLog:
* config/s390/s390.cc (print_operand): Use fputs instead of
fprintf.
doc: Update docs for character set support and environment variables [PR70917]
The "Environment Variables" section of the GCC manual had
long-obsolete (20+ years!) information about environment variables
affecting character sets and encodings. In particular, GCC stopped
using environment variables to control how input files are parsed
in 2004.
gcc/ChangeLog
PR preprocessor/70917
* doc/invoke.texi (Environment Variables): Clarify that LC_ALL,
LC_CTYPE, LC_MESSAGES, and LANG affect only diagnostics and
informational output from GCC, not the encodings of input and
output files. Remove separate bit-rotten entry for LANG.
Jonathan Wakely [Mon, 30 Mar 2026 11:13:39 +0000 (12:13 +0100)]
libstdc++: Rename std::runtime_format for C++26 (P3953R3)
Last week in Croydon we approved P3953R3 to rename std::runtime_format
for C++26. The rationale is that with compile-time std::format, the name
std::runtime_format doesn't make sense. It's std::dynamic_format now
instead.
libstdc++-v3/ChangeLog:
* include/bits/chrono_io.h (__formatter_chrono::_S_empty_fs)
(__formatter_chrono::_M_C_y_Y, __formatter_chrono::_M_D_x)
(__formatter_chrono::_M_F, __formatter_chrono::_M_subsecs)
(__formatter_chrono_info::_M_format_to): Use
_Dynamic_format_string instead of _Runtime_format_string.
* include/bits/version.def (format): Bump value.
* include/bits/version.h: Regenerate.
* include/std/format (_Runtime_format_string): Rename to
_Dynamic_format_string.
(runtime_format): Rename to dynamic_format.
* include/std/print (println): Adjust comment to refer to
dynamic_format instead of runtime_format.
* testsuite/std/format/runtime_format.cc: Move to...
* testsuite/std/format/dynamic_format.cc: ...here.
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Andrew Pinski [Wed, 1 Apr 2026 02:56:00 +0000 (19:56 -0700)]
forwprop: Add missing NULL check on vdef in optimize_aggr_zeroprop [PR124742]
When I converted optimize_aggr_zeroprop into a forward walk instead of
a backward walk, I missed that the vdef of a memset call could be NULL.
This only happens when there is "undefined" declaration of memset exists.
Anyways this fixes the ICE by adding the NULL check and an early out.
Bootstrapped and tested on x86_64-linux-gnu.
PR tree-optimization/124742
gcc/ChangeLog:
* tree-ssa-forwprop.cc (optimize_aggr_zeroprop): Exit
if the vdef on the stmt is NULL.
gcc/testsuite/ChangeLog:
* gcc.dg/torture/pr124742-1.c: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
H.J. Lu [Tue, 31 Mar 2026 15:59:50 +0000 (08:59 -0700)]
Check BIGGEST_ALIGNMENT when forcing a local copy
BIGGEST_ALIGNMENT is the biggest alignment that any data type can require
on the target machine. It is not the biggest alignment that is supported,
just the biggest alignment that, when violated, may cause a fault.
MAX_SUPPORTED_STACK_ALIGNMENT is the maximum stack alignment guaranteed by
the backend. If SUPPORTS_STACK_ALIGNMENT is false, it is defined as
PREFERRED_STACK_BOUNDARY.
Adjust alignment check forcing a local copy if the argument on stack is
not aligned to its type and the current alignment is less than the
minimum of BIGGEST_ALIGNMENT and MAX_SUPPORTED_STACK_ALIGNMENT.
gcc/
PR middle-end/124697
* function.cc (assign_parm_adjust_stack_rtl): Force a local copy
if the current alignment is less than the minimum of
BIGGEST_ALIGNMENT and MAX_SUPPORTED_STACK_ALIGNMENT.
Martin Uecker [Fri, 27 Mar 2026 18:45:42 +0000 (19:45 +0100)]
c: Fix ICE related to field members that are arrays of pointers to structs [PR124635]
We get a checking error in verify_type, because I did not copy
TYPE_REVERSE_STORAGE_ORDER over from the original when reconstructing
derived types during the contruction of canonical types.
Richard Biener [Tue, 31 Mar 2026 17:48:30 +0000 (19:48 +0200)]
middle-end/124634 - add internal function internals documentation section
The following adds documentation for internal function details. I
have populated the internal function tables via macro expansion
of the internal-fn.def file, so it's quite boiler-plate and asks
for manual amending in more complicated places.
Without such a place it's quite difficult to tell people to document
things when they add new internal functions. We might want to split
the table into two, separating direct internal functions from others.
I have added some overall sentences related to internal functions
and builtins but left the API section as a FIXME.
I'm not sure we need a separate index - I have used IFN_ prefixes
which separates them nicely. Removing those would warrant a
separate index.
I've placed the contents after the GENERIC/GIMPLE chapters.
v2: wrap long lines and integrate Sandras changes
Built and inspected using texinfo 7.1.
PR middle-end/124634
* doc/ifn.texi: New file.
* doc/gccint.texi: Include ifn.texi.
* Makefile.in (TEXI_GCCINT_FILES): Add ifn.texi.
doc: Fix wrong documentation for -finput-charset [PR61896]
This patch fixes long-standing bugs in the documentation for
-finput-charset. Support for getting the default charset from the
locale has been disabled since 2004. The error behavior has never been
documented, and now there is -Winvalid-utf8 that should be mentioned
in this context too.
doc: Add copyright notices to .texi files that don't have one
I realized I'd forgotten to add a copyright notice to specs.texi when I
split that from invoke.texi a while back. Scanning the other .texi files
in the same directory, I found poly-int.texi was also missing a copyright.
Both are fixed with this patch.
fortran: Fix ICE in gfc_trans_create_temp_array for assumed-rank [PR100194]
When a non-contiguous assumed-rank actual argument is passed to a
contiguous assumed-rank dummy, the compiler routes it through
gfc_conv_subref_array_arg which uses the scalarizer. The scalarizer
requires known rank at compile time, but assumed-rank arrays have
rank = -1, hitting gcc_assert (ss->dimen > 0).
Skip the scalarizer path for assumed-rank expressions and let them
fall through to gfc_conv_array_parameter, which handles assumed-rank
via the runtime pack/unpack functions.
gcc/fortran/ChangeLog:
PR fortran/100194
* trans-expr.cc (gfc_conv_procedure_call): Skip
gfc_conv_subref_array_arg for assumed-rank actual arguments
(e->rank == -1) when the dummy is contiguous.
gcc/testsuite/ChangeLog:
PR fortran/100194
* gfortran.dg/pr100194.f90: New test.
Signed-off-by: Christopher Albert <albert@tugraz.at>
Jakub Jelinek [Tue, 31 Mar 2026 22:22:46 +0000 (00:22 +0200)]
c++: Fix up access_context::current and current_namespace
On Mon, Mar 30, 2026 at 01:15:07PM +0200, Tomasz Kaminski wrote:
> > auto
> > Q::baz () -> typename [: current_namespace () == ^^Q ? ^^int : ^^:: :]
> > {
> > return 0;
> > }
> > part also fails, there I don't know what's right but possibly it should
> > be in Q; in that case it would be a pre-existing bug already for
> > std::meta::access_context::current () too.
> >
> My reading of the standard may be wrong here.
I think you're right, but because it is a preexisting bug on
access_context, sending this as a separate patch rather than
updating the current_* patch.
2026-04-01 Jakub Jelinek <jakub@redhat.com>
* reflect.cc (reflect_current_scope): Use decl_namespace_list->last ()
in preference to current_namespace.
Jakub Jelinek [Tue, 31 Mar 2026 22:14:04 +0000 (00:14 +0200)]
c++: Handle annotations in data_member_spec/define_aggregate
The following patch attempts to implement another part of P3795R2,
in particular the addition of annotations to data_member_options
and handling it in data_member_spec/define_aggregate etc.
2026-03-31 Jakub Jelinek <jakub@redhat.com>
libstdc++-v3/
* include/std/meta (std::meta::data_member_options): Add annotations
member.
gcc/cp/
* reflect.cc (get_range_elts): If N is negative, just use the tree
as object to extract range from instead of finding Nth argument
of a call.
(eval_is_bit_field, eval_type_of, eval_size_of, eval_alignment_of,
eval_bit_size_of, eval_has_identifier, eval_identifier_of): Adjust
function comments from P3795R2.
(eval_display_string_of): Handle annotations in
REFLECT_DATA_MEMBER_SPEC.
(eval_annotations_of): Adjust function comments from P3795R2.
(eval_data_member_spec): Likewise. Read and diagnose annotations.
(eval_define_aggregate): Adjust function comments from P3795R2.
Create annotations.
(compare_reflections): Compare REFLECT_DATA_MEMBER_SPEC annotations.
* mangle.cc (write_reflection): Mangle REFLECT_DATA_MEMBER_SPEC
annotations.
gcc/testsuite/
* g++.dg/reflect/data_member_spec5.C: New test.
* g++.dg/reflect/data_member_spec6.C: New test.
* g++.dg/reflect/display_string_of1.C: Expect extra ", {}" before
closing paren for empty annotations, otherwise a list of annotations.
* g++.dg/reflect/u8display_string_of1.C: Likewise.
* g++.dg/reflect/define_aggregate9.C: New test.
* g++.dg/reflect/mangle1.C: Test mangling of REFLECT_DATA_MEMBER_SPEC
annotations.
Reviewed-by: Jason Merrill <jason@redhat.com> Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Jakub Jelinek [Tue, 31 Mar 2026 21:42:38 +0000 (23:42 +0200)]
c++, libstdc++: Implement current_{function,class,namespace} metafn addition from P3795R2
The following patch implements addition of std::meta::current_function,
std::meta::current_class, std::meta::current_namespace metafunctions
from P3795R2 - Miscellaneous Reflection Cleanup paper.
2026-03-31 Jakub Jelinek <jakub@redhat.com>
gcc/cp/
* metafns.gperf (enum metafn_code): Add METAFN_CURRENT_FUNCTION,
METAFN_CURRENT_CLASS and METAFN_CURRENT_NAMESPACE.
(enum metafn_kind): Add METAFN_KIND_INFO_VOID.
(current_function, current_class, current_namespace): New
metafunctions.
* pt.cc (value_dependent_expression_p): Make current_function(),
current_class() and current_namespace() calls dependent if they
are inside of template.
* reflect.cc (reflect_current_scope, eval_current_function,
eval_current_class, eval_current_namespace): New functions.
(eval_access_context_current): Use reflect_current_scope.
(process_metafunction): Handle METAFN_CURRENT_FUNCTION,
METAFN_CURRENT_CLASS and METAFN_CURRENT_NAMESPACE.
* metafns.h: Regenerate.
gcc/testsuite/
* g++.dg/reflect/current_function1.C: New test.
* g++.dg/reflect/current_function2.C: New test.
* g++.dg/reflect/current_class1.C: New test.
* g++.dg/reflect/current_class2.C: New test.
* g++.dg/reflect/current_namespace1.C: New test.
libstdc++-v3/
* include/std/meta (std::meta::current_function,
std::meta::current_class, std::meta::current_namespace): New
declarations.
* src/c++23/std.cc.in: Export those 3.
Reviewed-by: Jason Merrill <jason@redhat.com> Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Jakub Jelinek [Tue, 31 Mar 2026 21:38:11 +0000 (23:38 +0200)]
c++: Use anon enums in eval_data_member_spec
On Mon, Mar 30, 2026 at 03:46:57PM -0400, Jason Merrill wrote:
> Maybe it would be helpful to have local enums to name the indices in args?
Here is incremental patch to use local enums for those.
Tested on x86_64-linux, ok for trunk (it conflicts with the annotations
addition patch, but it can be easily resolved)?
2026-03-31 Jakub Jelinek <jakub@redhat.com>
* reflect.cc (eval_data_member_spec): Add anonymous enums for
fields in std::meta::data_member_options and
std::meta::data_member_options::_Name and use them instead of
hardcoded constants.
Dimitar Dimitrov [Sat, 28 Mar 2026 09:19:00 +0000 (11:19 +0200)]
testsuite: Require effective target fstack_protector for pr124041.c
Fix this spurious error on targets without stack protection ability:
FAIL: gcc.dg/torture/pr124041.c -O0 (test for excess errors)
Excess errors:
cc1: warning: '-fstack-protector' not supported for this target
Dimitar Dimitrov [Sun, 22 Mar 2026 09:12:09 +0000 (11:12 +0200)]
testsuite: Require int32plus effective target for pr122925.c
The test case logic relies on the constant literal -4 being promoted to
32-bit int. But on AVR and other targets with 16-bit int types, the
literal is promoted to 16-bit int, which changes the expression value
and ultimately failing the test:
FAIL: gcc.dg/pr122925.c execution test
Fix by requiring an effective target with at least 32-bit ints.
Eric Botcazou [Tue, 31 Mar 2026 16:42:19 +0000 (18:42 +0200)]
Fix internal error on non-byte-sized reference in GIMPLE DSE
This is a regression present on all the active branches and a sibling of:
https://gcc.gnu.org/pipermail/gcc-patches/2024-February/646628.html
during GIMPLE pass: dse
+===========================GNAT BUG DETECTED==============================+
| 16.0.1 20260331 (experimental) [master r16-8354-gbf6989de817] GCC error:|
| in exact_div, at poly-int.h:2179 |
| Error detected around opt107.adb:26:11 |
| Compiling opt107.adb
At least one caller of compute_trims, namely maybe_trim_constructor_store,
expects ref->size to be a multiple of a byte for trimming, and that is most
probably the case for others in practice, from a cursory reading. Therefore
the patch adds the same test on ref->size as the one added to ref->offset.
gcc/
* tree-ssa-dse.cc (compute_trims): Bail out if ref->size is not
byte aligned either.
gcc/testsuite/
* gnat.dg/opt107.adb: New test.
* gnat.dg/opt107_pkg.ads: New helper.
The gcc.dg/analyzer/null-deref-pr123981-1.c test FAILs on 64-bit x86
targets with -m32:
FAIL: gcc.dg/analyzer/null-deref-pr123981-1.c (test for excess errors)
gcc.dg/analyzer/null-deref-pr123981-1.c:10:3: error: implicit declaration of function '_writegsbase_u64' [-Wimplicit-function-declaration]
gcc.dg/analyzer/null-deref-pr123981-1.c:10:20: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
As always, restricting x86 tests by target triplet is wrong: instead of
target x86_64-*-* this needs to be x86 && lp64.
Tested on amd64-pc-solaris2.11, i386-pc-solaris2.11, and
x86_64-pc-linux-gnu.
Mikael Morin [Tue, 31 Mar 2026 13:34:29 +0000 (15:34 +0200)]
fortran: Give up reference factoring in case of shared tree [PR124661]
When we are about to create a variable to factor a subreference of an
array descriptor, check whether that subreference is shared with some of
the preliminary code and abort the factoring in that case.
In the example from the PR, the preliminary code contained bounds
checking code and the replacement of the subreferences by fresh
variables was causing those variables to be used before they were
defined in that bounds checking code.
PR fortran/121185
PR fortran/124661
gcc/fortran/ChangeLog:
* trans-array.cc (maybe_save_ref): New wrapper function around
save ref.
(set_factored_descriptor_value): Use the new wrapper function.
Add argument PRELIMINARY_CODE.
(gfc_conv_ss_descriptor): Update caller.
H.J. Lu [Sun, 29 Mar 2026 21:30:28 +0000 (14:30 -0700)]
x86: Call ix86_access_stack_p only for larger alignment
ix86_access_stack_p can be quite expensive. Don't check symbolic constant
load. Instead, call ix86_access_stack_p only if an INSN needs alignment
> stack alignment. This reduces the compile time of PR target/124684 from
185 seconds to 24 seconds. The compile time of PR target/124165 test is
unchanged.
PR target/124165
PR target/124684
* config/i386/i386.cc (ix86_symbolic_const_load_p_1): Renamed to
...
(ix86_need_alignment_p_1): This.
(ix86_symbolic_const_load_p): Renamed to ...
(ix86_need_alignment_p): This.
(ix86_find_max_used_stack_alignment): Call ix86_access_stack_p
only if the INSN needs alignment > stack alignment.
This patch incorporates changes to this file in Binutils
since October 2025. This file includes the new system
registers in the 2025 architecture extensions.
gcc/ChangeLog:
* config/aarch64/aarch64-sys-regs.def: Copy from Binutils.
Eric Botcazou [Tue, 31 Mar 2026 07:50:11 +0000 (09:50 +0200)]
Ada: Fix compiler crash on nested reduce attribute
This plugs a loophole in the resolution of reduction expressions, which
currently cannot be resolved when their immediate context is ambiguous,
for example in the case of a reduction expression nested in another one.
gcc/ada/
* sem_attr.adb (Analyze_Attribute) <Attribute_Reduce>: Rewrite the
analysis of a non-overloaded reducer. Moreover, when both actuals
are overloaded, compute the set of possible interpretations.
(Resolve_Attribute) <Attribute_Reduce>: Streamline the processing.
Jakub Jelinek [Tue, 31 Mar 2026 08:16:14 +0000 (10:16 +0200)]
c++: Fix up eval_data_member_spec
Ivan Lazaric reported privately a bug in eval_data_member_spec,
which I think can't be easily tested.
This is preceded by
if (!cpp_translate_string (parse_in, &istr, &ostr,
j == 2 ? CPP_STRING : CPP_UTF8STRING,
true))
so for j == 2 it does reverse conversion from -fnarrow-character-set= to
SOURCE_CHARSET (typically UTF-8) and otherwise (j == 1) from
UTF-8 to SOURCE_CHARSET, but the messages of exceptions were reversed.
Now, unless SOURCE_CHARSET is UTF-EBCDIC on s390x-tpf (dunno if that works
at all, but in theory could) and there is some character only in UTF-8 and
not in UTF-EBCDIC, or there is some narrow character set supported by iconv
which has characters not represented in UTF-8 (am not aware of those),
then cpp_translate_string shouldn't fail, so the code in there is just
for a theoretical case.
2026-03-31 Jakub Jelinek <jakub@redhat.com>
* reflect.cc (eval_data_member_spec): Fix up check for diagnostics
when reverse conversion fails.
Alexandre Oliva [Tue, 31 Mar 2026 00:58:19 +0000 (21:58 -0300)]
testsuite: x86: move alias-checks.C into vect
g++.dg/alias-checks.C requires vect_double outside vect.exp, where
-msse2 would have got enabled, but that effective_target is not
supposed to be used in such circumstances: it passes even when SSE2 is
disabled. Without enabling SSE2, vectors of doubles aren't really
available, so we don't get the expected vectorizations and the test
fails.
Instead of adding machine-specific options to alias-checks.C, I'm
moving it under g++.dg/vect/ and renaming it so that it gets, and
doesn't override, the default vector options for each platform.
Alexandre Oliva [Tue, 31 Mar 2026 00:58:01 +0000 (21:58 -0300)]
testsuite: x86: bump unroll insn limit for pr83403-*.c
Like rv32 and other targets, pr83403-[12].c need to bump
max-completely-peeled-insns to get the loops unrolled on x86 without
sse2 so as to enable the expected store motions.
for gcc/testsuite/ChangeLog
* gcc.dg/tree-ssa/pr83403-1.c: Bump
max-completely-peeled-insns on x86.
* gcc.dg/tree-ssa/pr83403-2.c: Likewise.
Alexandre Oliva [Tue, 31 Mar 2026 00:57:56 +0000 (21:57 -0300)]
testsuite: select -mfpmath=sse for pr32964.c on x86
When using the 387 FPU, we don't perform the expected optimization of
unions to floats. Setting -fexcess-precision=standard. doesn't fix it
for x86, but selecting -mfpmath=sse and forcing sse enabled does.
for gcc/testsuite/ChangeLog
* gcc.dg/tree-ssa/pr32964.c: Select the SSE FPU on x86.
Alexandre Oliva [Tue, 31 Mar 2026 00:57:48 +0000 (21:57 -0300)]
testsuite: drop loop optimizations in fstack-protector-strong.c
gcc.dg/fstack-protector-strong.c used to expect one stack_chk_fail per
function. When vectorizer improvements caused foo2 to get vectorized
to the point of enabling the loop and the automatic array-containing
data structure to be optimized away entirely, it no longer required
stack protection, and the expected pattern count was decreased.
However, on platforms that don't or can't vectorize the loop, it isn't
optimized away, and then we find the wrong pattern count.
Reverse the decrease and disable optimizations of the loop that could
cause it to be optimized out, so that we get the originally-expected
stack protection everywhere.
Alexandre Oliva [Tue, 31 Mar 2026 00:57:44 +0000 (21:57 -0300)]
testsuite: x86: pr115863-1.c should include stdint.h
stdint-gcc.h isn't necessarily installed by GCC or available from C
libraries. VxWorks ports don't generally have such a header
available. Include stdint.h instead.
Alexandre Oliva [Tue, 31 Mar 2026 00:57:34 +0000 (21:57 -0300)]
testsuite: analyzer: drop stderr from deref-before-check-2.c
On some VxWorks targets, stderr is #defined to a function call, and
this confuses the analyzer in test_1, so we skip the warning. That
appears to reveal a bug in the analyzer, but it doesn't seem to be
what the test was meant to test, so I'm dropping this unintended
feature from this testcase and filing PR124672 with a testcase to
reproduce it elsewhere.
for gcc/testsuite/ChangeLog
* c-c++-common/analyzer/deref-before-check-2.c (test_1):
Drop stderr.
H.J. Lu [Fri, 27 Jun 2025 22:27:25 +0000 (06:27 +0800)]
Adjust check for addressable misaligned stack argument
Adjust alignment check forcing a local copy if the argument on stack is
not aligned to its type and the current alignment, which is determined
by the backend, is less than MAX_SUPPORTED_STACK_ALIGNMENT when the
parameter has its address taken.
For x86, ignore argument passed on stack when updating stack alignment
since caller is responsible to align the outgoing stack for arguments
passed on stack.
gcc/
PR target/120839
PR middle-end/124671
* function.cc (assign_parm_adjust_stack_rtl): Get the parameter
as argument. Adjust alignment check forcing a local copy.
(assign_parms): Adjust.
* config/i386/i386.cc (ix86_argument_passed_on_stack_p): New.
(ix86_update_stack_alignment): Ignore argument passed on stack.
Jerry DeLisle [Mon, 30 Mar 2026 17:40:43 +0000 (10:40 -0700)]
fortran: Fix several issues with INQUIRE and unconnected units.
PR libfortran/124543
libgfortran/ChangeLog:
* io/inquire.c (inquire_via_unit): Fix return value for
NAMED. Add check for ACTION. Fix return values for
ENCODING, PENDING, READ, WRITE, READWRITE.
(inquire_via_filename): Add checks for ACTION, DELIM,
ASYNCHRONOUS, and PENDING. Fix return value for
ENCODING.
* io/unix.c (inquire_access): Change return value from no
to unknown.
Vineet Gupta [Mon, 30 Mar 2026 20:15:04 +0000 (13:15 -0700)]
bpf: md: Enable zero_extend{hi,qi}di2 to generate wN regs ...
... by adjusting the asm template reg string to 'W', similar to commit
gbd275e81812c for zero_extendsidi2. However unlike that change, this is
not a bug fix: zero_extendsidi2 relies on wN reg move to achieve the
32->64 semantics. A {8,16}->64 extension needs to be emulated anyways
by masking out extra bits so the reg used is not important.
However wN reg based codegen is still preferable in general:
- It is easier on verifier as it has to track fewer bits and avoids
corner case false positives.
- Better native codegen as upper bits are guaranteed to be zero and can
leverage target ISA mechanisms to achieve that mostly for free.
- Better native codegen on 32-bit targets which need to use 2 regs for
rN regs.
gcc/ChangeLog:
* config/bpf/bpf.md (zero_extendhidi2): Add alternates for
alu32 and use 'W' for reg operands.
(zero_extendqidi2): Ditto.
gcc/testsuite/ChangeLog:
* gcc.target/bpf/zero-ext.c: Add tests for {HI,QI}mode values.
Piyush Raj [Tue, 24 Feb 2026 20:17:54 +0000 (01:47 +0530)]
testsuite: bpf: Add initial BPF runtime tests
This patch adds runtime tests for BPF target.
These tests are based on existing compile-time tests and depends on
bpf.exp baseboard
To run the testsuite:
make check-gcc RUNTESTFLAGS="--target_board=bpf-vmtest bpf-torture.exp KERNEL_VERSION=6.15 LOG_LEVEL=ERROR"
Options:
KERNEL_VERSION (default: 6.15)
LOG_LEVEL (default: ERROR)
Note: VMTEST_DIR must be set in the environment.
See the bpf-vmtest-tool README for details.
gcc/testsuite/ChangeLog:
* gcc.target/bpf/torture/bpf-torture.exp: New testsuite.
* gcc.target/bpf/torture/invalid-memory-access.c: New test.
* gcc.target/bpf/torture/memcpy.c: New test.
* gcc.target/bpf/torture/memmove.c: New test.
* gcc.target/bpf/torture/memset.c: New test.
* gcc.target/bpf/torture/naked.c: New test.
* gcc.target/bpf/torture/nop.c: New test.
* gcc.target/bpf/torture/trace_openat.c: New test.
Richard Biener [Mon, 30 Mar 2026 12:30:45 +0000 (14:30 +0200)]
tree-optimization/124692 - update stmt before folding
The following makes sure SSA operands are up-to-date before folding.
Esp. when replace_uses_by is invoked from SCEV cprop which now has
ranger enabled we can otherwise end up ICEing where purpoted SSA
names now are constants. This follows what forwprop does.
PR tree-optimization/124692
* tree-cfg.cc (replace_uses_by): Call update_stmt after
substitution and before folding.
fortran: Fix free-form mixed OpenACC/OpenMP continuation state
Clear the opposite directive flag only for fresh free-form OpenMP/OpenACC
sentinel lines so continued directives do not leak OpenACC/OpenMP state into
the next independent directive.
PR fortran/108382
gcc/fortran/ChangeLog:
* scanner.cc (skip_free_oacc_sentinel): Clear openmp_flag only for
fresh OpenACC directive lines.
(skip_free_omp_sentinel): Clear openacc_flag only for fresh OpenMP
directive lines.
gcc/testsuite/ChangeLog:
* gfortran.dg/goacc/omp-108382.f90: New test.
Signed-off-by: Christopher Albert <albert@tugraz.at>
The values for chip IDs and the LITTLE.big variants have been confirmed
in the XNU sources (xnu/osfmk/arm/cpuid.h).
gcc/ChangeLog:
* config/aarch64/aarch64-cores.def (AARCH64_CORE): Add Apple M5
cores.
* config/aarch64/aarch64-tune.md: Regenerate.
* doc/invoke.texi: Add apple-m5 core to the ones listed
for arch and tune selections.
Jeff Law [Sun, 29 Mar 2026 23:36:25 +0000 (17:36 -0600)]
[RISC-V][PR target/124674] Define OImode in the usual way
This testcase tries to call build_nonstandard_integer_type for a 192-bit
precision type. This eventually faults because we don't have a suitably wide
mode.
Somewhat surprisingly, the targets are responsible for defining OImode. So
this adds it to the RISC-V port as well which trivially fixes the ICE. The
test is limited to rv64 as rv32 doesn't support int128. That could have been
handled with a target-supports selector just as easily.
Tested on riscv32-elf and riscv64-elf. Both the BPI and Pioneer are
experiencing NVME drive failures, so no bootstraps until I figure that out.
Waiting on the pre-commit tester to do its thing before pushing
Paul Thomas [Sat, 28 Mar 2026 09:08:54 +0000 (09:08 +0000)]
Fortran: Fix use-after-free in gfc_fixup_sibling_symbols [PR95879]
2026-03-28 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/95879
* parse.cc (fixup_st_func_formals): New function to update
statement function formal argument lists referencing a symbol
about to be freed.
(gfc_fixup_sibling_symbols): Call fixup_st_func_formals before
gfc_release_symbol.
gcc/testsuite
PR fortran/95879
* gfortran.dg/pr95879.f90: New test.
Alexandre Oliva [Wed, 25 Mar 2026 18:05:49 +0000 (15:05 -0300)]
testsuite: aarch64: skip erratas_opt_*.c on vxworks
VxWorks involves linking oddities in both kernel and rtp modes that
prevent the testcases for finding the expected outputs in the
erratas_opt_*.c testcases. One of the modes doesn't even perform
final linking, so it's kind of hopeless. Just skip them.
Alexandre Oliva [Wed, 25 Mar 2026 18:05:14 +0000 (15:05 -0300)]
testsuite: negated triplets need blank separators
!a-b-c is not the same as ! a-b-c. In !a-b-c, the '!' is part of the
triplet that istarget attempts to match. Fix all occurrences, except
for gcc.dg/vect/vect-93.c, that is taken care of separately.
Alexandre Oliva [Wed, 25 Mar 2026 18:04:53 +0000 (15:04 -0300)]
libgcc: vxworks: work around warnings promoted to errors on aarch64
In RTP mode, defining TLS_DELETE_HOOK_ARG as NULL AKA 0 elicits a
warning, that casting it to TASK_ID avoids.
objLibP.h defines an inline function that, depending on the
configuration, will have unused parameters. Allow warnings about
them.
vxTas calls are supposed to take __vx_tas_t, but upon passing it that
on aarch64, we get warnings about discarding volatile qualifiers, that
not even explicit type casts avoid. So, allow the warnings.
for libgcc/ChangeLog
* config/gthr-vxworks-tls.c (TLS_DELETE_HOOK_ARG): Type-cast
NULL constant to avoid warning.
* config/t-vxworks (LIBGCC2_CFLAGS): Tolerate unused-parameter
and discarded-qualifiers errors.
Alexandre Oliva [Mon, 23 Mar 2026 01:32:55 +0000 (22:32 -0300)]
libstdc++: simd: allow x86 -mlong-double-64
On a target that defaults to -mlong-double-64 -msse,
standard_abi_usable.cc and other tests fail to compile because of the
assert that rejects long double. As on ppc, we can trivially make
things work for -mlong-double-64.
for libstdc++-v3/ChangeLog
* include/experimental/bits/simd.h (__intrinsic_type): Accept
64-bit long doubles on x86 SSE.
which is just a 64-bit copy and doesn't clear the upper 32-bits as
semantically required by the pattern.
The issue is pattern's asm template missing ‘w’/'W' causing bpf_print_register ()
to only emit 'r' regs. Using ‘W’ in template generates correct code.
| w0 = w0
Note that 'W specifier ignores the RTL mode and unconditionally emits
the 'w' reg which might feel like creating a potential future bug.
However for this insn, it is correct/completely safe as follows:
- 'W1' for src operand: src operand has a SI mode in pattern.
- 'W0' for dst: Technically dst is DI, but the upper 32-bits of output
have to be 0 due to zero-extension, thus a 'w' reg is OK.
For selftests this is a wash, except for some spurious changes.
PR target/124670
gcc/ChangeLog:
* config/bpf/bpf.md (zero_extendsidi2): Use 'W' in asm template.
Paul Thomas [Fri, 27 Mar 2026 22:47:41 +0000 (22:47 +0000)]
Fortran: Fix ICE in interface mapping with assumed rank [PR102619]
2026-03-27 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/102619
* trans-expr.cc (gfc_get_interface_mapping_array): Add argument
'assumed_rank_formal', which if true returns the descriptor in
'ifm'.
(gfc_add_interface_mapping): Detect an assumed rank formal arg
of a non-intrinsic function to set 'assumed_rank_formal' and
pass the descriptor to gfc_get_interface_mapping_array.
gcc/testsuite/
PR fortran/102619
* gfortran.dg/pr102619.f90: New test.
Eric Botcazou [Fri, 27 Mar 2026 20:09:53 +0000 (21:09 +0100)]
Ada: Lift restriction on structural generic instantiation of subprograms
When an entity of a library-level package is used as actual in an attempted
structural instantiation of a library-level generic unit in the package, an
error is given since the structural instance is a library unit with circular
semantic dependence on the package.
This change lifts the restriction for generic subprograms by demoting the
structural instance into a local instance in this case, which means that
several instances might end up being present in a single partition, unless
the optimizer is run on the entire partition, for example by means of LTO.
gcc/ada/
* sem_ch12.adb (Analyze_Structural_Associations): Create a local
instance instead of a structural instance when a local entity of
a library-level package is used in a subprogram instantiation.
Eric Botcazou [Fri, 27 Mar 2026 17:38:09 +0000 (18:38 +0100)]
Ada: Fix overriding indicator wrongly rejected on protected procedure
The case itself is fairly pathological (and very likely not human made), but
it's a clear incentive to get rid of an old kludge in generic instantiation,
whereby the full view of a type is forced on nodes in the generic unit even
though only the partial declaration is visible to them.
gcc/ada/
PR ada/124596
* sem_ch12.ads (Check_Private_View): Move around.
* sem_ch12.adb (Check_Private_View): Retrieve the partial view
by means of a call to Incomplete_Or_Partial_View.
(Save_Global_References.Set_Global_Type): Do not force the full
view of a type when only the partial declaration is visible.
* sem_res.adb (Resolve_Actuals.Insert_Default): Remove obsolete
code coping with the above kludge.
gcc/testsuite/
* gnat.dg/generic_inst21.adb: New test.
Tobias Burnus [Fri, 27 Mar 2026 16:54:00 +0000 (17:54 +0100)]
libgomp: fix omp_target_is_present and omp_get_mapped_ptr
There were a few minor issues with the two routines, partially because of
not handling corner cases and partially some clarifications are only in
newer versions of the spec.
In particular, for omp_target_is_present
* NULL pointer aren't regarded as present
* For (unified-)shared memory, claiming that something has always corresponding
storage is wrong - it mostly never has. (but it is omp_target_is_accessible).
* Even with shared memory, 'declare target' usually has device memory. For
'link' it is made to point to the host, i.e. it is not mapped, all others
are still mapped. (With 'requires self_mapping', 'enter' should also not be
mapped (and turned internally to 'link'), only 'local' needs to be mapped.)
For omp_get_mapped_ptr
* For NULL we can return NULL early also for devices.
* For shared memory, we shouldn't touch link (it is not counting as mapped);
hence return NULL for it.
The documentation was updated add some missing cross references as the more
useful ones were missing. Additionally, the description for the two modified
routines has been updated.
libgomp/ChangeLog:
* target.c (omp_target_is_present, omp_get_mapped_ptr): Update handling
for nullptr and shared-memory devices.
* libgomp.texi (omp_target_is_present, omp_get_mapped_ptr): Update
description, add see-also @refs.
(omp_target_is_accessible, omp_target_associate_ptr): Add see-also
@refs.
* testsuite/libgomp.c/omp_target_is_present.c: New test.
* testsuite/libgomp.c/omp_target_is_present-2.c: New test.
Andrew Pinski [Thu, 26 Mar 2026 20:21:01 +0000 (13:21 -0700)]
regcprop: Return early in maybe_mode_change for unorder modes [PR124649]
Like r16-727-g2ec5082dd24cef but the call to partial_subreg_p happens
in a later place, maybe_mode_change.
For this example we have VNx4QImode and DImode which are not ordered.
Bootstrapped and tested on aarch64-linux-gnu.
PR rtl-optimization/124649
gcc/ChangeLog:
* regcprop.cc (maybe_mode_change): Return early
for unordered modes.
gcc/testsuite/ChangeLog:
* gcc.dg/torture/pr124649-1.c: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Paul Thomas [Fri, 27 Mar 2026 10:50:39 +0000 (10:50 +0000)]
Fortran: Fix ICE with allocation of scalar pointer entity [PR114021]
2026-03-27 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/114021
* symbol.cc (gfc_get_unique_symtree): If the namespace argument
is NULL, allocate a new symtree and provide it with the unique
name.
* trans-expr.cc (trans_scalar_assign): In the deep copy of a
derived type with allocatable components, fix the rhs value if
it is not a constant or a variable.
* trans-stmt.cc (gfc_trans_allocate): Do not deallocate
allocatable components of a source that is not a variable and
is a pointer. If the DECL_NAME or its IDENTIFIER_POINTER are
null,use gfc_get_unique_symtree with NULL namespace to obtain a
symtree for the assignment.
gcc/testsuite/
PR fortran/114021
* gfortran.dg/pr114021.f90: New test.
Robin Dapp [Tue, 24 Mar 2026 09:58:14 +0000 (10:58 +0100)]
RISC-V: Allow all vector modes during builtin registration. [PR124613]
In r16-7312-gecc37444062b40 we allowed all vector modes for the
any_target hook. Since then we would ICE in gcc.target/riscv/pr122051.c
as emit_move_multi_word would choose a fractional vector mode.
This patch disallows fractional vector modes for xtheadvector in
riscv_vector_mode_supported_p but makes an exception for builtin
registration (through a global variable). During registration we
need to have all modes available in order to maintain the registration
order for LTO streaming.
PR target/124613
gcc/ChangeLog:
* config/riscv/riscv-vector-builtins.cc (rvv_switcher::rvv_switcher):
Add riscv_registering_builtins.
(rvv_switcher::~rvv_switcher): Set riscv_registering_builtins to
false.
* config/riscv/riscv.cc (riscv_vector_mode_supported_p): Use
riscv_registering_builtins.
* config/riscv/riscv.h: Declare.
We can attempt to add DW_AT_artificial because of two reasons,
because of DECL_ARTIFICIAL on the decl and because of the
artificial function attribute which is attempted when marking
a decl DIE for inlining. The following guards the latter,
avoiding an ICE with checking enabled.
PR debug/124644
* dwarf2out.cc (dwarf2out_abstract_function): Only
add DW_AT_artificial if the decl isn't DECL_ARTIFICIAL.