]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
4 months agogccrs: nr: Add better error to unresolved attribute macro
Arthur Cohen [Tue, 16 Sep 2025 08:47:05 +0000 (10:47 +0200)] 
gccrs: nr: Add better error to unresolved attribute macro

gcc/rust/ChangeLog:

* resolve/rust-early-name-resolver-2.0.cc (Early::visit_attributes): Mention the name
of the attribute macro that hasn't been found.

4 months agoanalyzer: fix check against --param=analyzer-bb-explosion-factor=0
David Malcolm [Fri, 16 Jan 2026 15:54:32 +0000 (10:54 -0500)] 
analyzer: fix check against --param=analyzer-bb-explosion-factor=0

analyzer.texi documents --param=analyzer-bb-explosion-factor=0 as a way
to make the analysis bail out early, but I broke this in
r16-6063-g0b786d961d4426.

Fix thusly.

gcc/analyzer/ChangeLog:
* engine.cc (exploded_graph::process_worklist): Remove guard on
limit being non-zero when checking for -Wanalyzer-too-complex
on overall number of exploded nodes.  Allow for the origin enode.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 months agoanalyzer: add timevar values for supergraph manipulation [PR123145]
David Malcolm [Fri, 16 Jan 2026 15:54:31 +0000 (10:54 -0500)] 
analyzer: add timevar values for supergraph manipulation [PR123145]

Whilst tracking down the slowdown of PR analyzer/123145, I noticed that
the various supergraph manipulations introduced in
r16-6063-g0b786d961d4426 can take non-trivial amounts of time on
complicated TUs.  Add timevars to track each of them.

gcc/analyzer/ChangeLog:
PR analyzer/123145
* supergraph-fixup-locations.cc: Include "timevar.h".
(supergraph::fixup_locations): Track time spent as
TV_ANALYZER_SUPERGRAPH_FIXUP_LOCATIONS.
* supergraph-simplify.cc: Include "timevar.h".
(supergraph::simplify): Track time spent as
TV_ANALYZER_SUPERGRAPH_SIMPLIFY.
* supergraph-sorting.cc: Include "timevar.h".
(supergraph::sort_nodes): Track time spent as
TV_ANALYZER_SUPERGRAPH_SORTING.
* supergraph.cc (supergraph::supergraph): Track time spent as
TV_ANALYZER_SUPERGRAPH_CREATION rather than
TV_ANALYZER_SUPERGRAPH.

gcc/ChangeLog:
PR analyzer/123145
* timevar.def (TV_ANALYZER_SUPERGRAPH): Rename to...
(TV_ANALYZER_SUPERGRAPH_CREATION): ...this.
(TV_ANALYZER_SUPERGRAPH_FIXUP_LOCATIONS): New.
(TV_ANALYZER_SUPERGRAPH_SIMPLIFY): New.
(TV_ANALYZER_SUPERGRAPH_SORTING): New.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 months agoanalyzer: eliminate unused field eh_dispatch_edge_op::m_dst_snode [PR123540]
David Malcolm [Fri, 16 Jan 2026 15:54:31 +0000 (10:54 -0500)] 
analyzer: eliminate unused field eh_dispatch_edge_op::m_dst_snode [PR123540]

gcc/analyzer/ChangeLog:
PR analyzer/123540
* ops.cc (eh_dispatch_edge_op::make): Drop dst_snode param to
ctor.
(eh_dispatch_edge_op::eh_dispatch_edge_op): Likewise, dropping
field eh_dispatch_edge_op::m_dst_snode.
(eh_dispatch_try_edge_op::eh_dispatch_try_edge_op): Likewise.
(eh_dispatch_allowed_edge_op::eh_dispatch_allowed_edge_op):
Likewise.
* ops.h (eh_dispatch_edge_op::eh_dispatch_edge_op): Likewise.
(eh_dispatch_edge_op::m_dst_snode): Drop unused field.
(eh_dispatch_try_edge_op::eh_dispatch_try_edge_op): Drop unused
dst_snode param.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 months ago[PR123092, LRA]: Reprocess insn after equivalence substitution
Vladimir N. Makarov [Fri, 16 Jan 2026 15:09:52 +0000 (10:09 -0500)] 
[PR123092, LRA]: Reprocess insn after equivalence substitution

LRA in the test case substituted equivalence in an insn but did not
process the insn on satisfying constraints after that.  It resulted in
error "insn does not satisfy its constraints"

gcc/ChangeLog:

PR target/123092
* lra-constraints.cc (lra_constraints): Push insn on processing
stack after equivalence substitution.

gcc/testsuite/ChangeLog:

PR target/123092
* gcc.target/riscv/pr123092.c: New.

4 months agoc++/reflection: enable more testing
Marek Polacek [Thu, 15 Jan 2026 19:57:13 +0000 (14:57 -0500)] 
c++/reflection: enable more testing

These TODOs already work fine so let's enable more testing.

gcc/testsuite/ChangeLog:

* g++.dg/reflect/member15.C: Enable commented-out test.
* g++.dg/reflect/splice5.C: Likewise.  Add XFAIL.

Reviewed-by: Jason Merrill <jason@redhat.com>
4 months agoProvide gt_pch_get_address etc. on FreeBSD [PR110746]
Rainer Orth [Fri, 16 Jan 2026 12:12:03 +0000 (13:12 +0100)] 
Provide gt_pch_get_address etc. on FreeBSD [PR110746]

On FreeBSD/amd64, more than 700 tests FAIL like

FAIL: gcc.dg/pch/common-1.c  -O0 -g -I. -Dwith_PCH (test for excess errors)
Excess errors:
gcc/testsuite/gcc.dg/pch/common-1.c:1: sorry, unimplemented: PCH allocation failure

This can easily be fixed by implementing the
host_hooks.gt_pch_get_address hook.  The code is shamelessly stolen from
the openbsd implementation, only changing the names and omitting the
hppa and i386 code.  The former isn't supported by FreeBSD at all AFAIK,
while the latter has just been removed in FreeBSD 15.0.

Bootstrapped without regressions on x86_64-unknown-freebsd14.3: all PCH
failures are gone.

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

gcc:
PR pch/110746
* config/host-freebsd.cc: New file.
* config.host <*-*-freebsd*>: Use it.
* config/x-freebsd: New file.

4 months agoipa-cp: Fix devirt bonus for targets that cannot be inlined
Martin Jambor [Fri, 16 Jan 2026 11:04:23 +0000 (12:04 +0100)] 
ipa-cp: Fix devirt bonus for targets that cannot be inlined

PR 123412 has been filed because since commit
r16-3990-gad3fb999a1b568 (Jan Hubicka: Improve ipa-cp devirtualization
costing), there is accidentally zero devirtualization bonus for
functions which cannot be inlined.  This has resulted in
g++.dg/ipa/devirt-2.C failing since it has been pushed because the
required function is not cloned even with --param max-devirt-targets=1.

The intention was that we do get at least some small benefit boost and
so this patch adds an addition of the indirect edge frequency once
before the early continue statements.

gcc/ChangeLog:

2026-01-14  Martin Jambor  <mjambor@suse.cz>

PR ipa/123412
* ipa-cp.cc (devirtualization_time_bonus): Do add the indirect
edge frequency at least once even for targets which cannot be
inlined.

4 months agoc, c++: Fix vector enum division handling [PR123437]
Jakub Jelinek [Fri, 16 Jan 2026 10:03:18 +0000 (11:03 +0100)] 
c, c++: Fix vector enum division handling [PR123437]

To my surprise we accept generic vectors with enumeral element
types (unlike e.g. _Complex) and we don't actually try to
perform "integral" promotions for those either (which for scalars
promotes ENUMERAL_TYPE operands to their underlying type or
promoted underlying type).  I'm afraid it is inappropriate
to change the promotions at this point in stage4, that would
be a significant user visible change (though sure for a feature
that hopefully nobody actually uses).  Anyway, in GCC 16
development some assertions that RDIV_EXPR is only used for floating
(scalar/vector/complex) operands were added and those now trigger
on trying to divide vectors where both operands are enum vectors.
THis is due to the FEs using RDIV_EXPR instead of TRUNC_DIV_EXPR
when the operands (after promotions) don't have INTEGER_TYPE (or for C
BITINT_TYPE) operands.

This patch just adds vector enum to that.

2026-01-16  Jakub Jelinek  <jakub@redhat.com>
    Peter Damianov  <peter0x44@disroot.org>

PR c/123437
* c-typeck.cc (build_binary_op): Don't use RDIV_EXPR
resultcode if both types are integral, _BitInt or
newly VECTOR_TYPE of ENUMERAL_TYPE.

* typeck.cc (cp_build_binary_op): Don't use RDIV_EXPR
resultcode if both types are integral, _BitInt or
newly VECTOR_TYPE of ENUMERAL_TYPE.

* c-c++-common/pr123437.c: New test.

4 months agoi386: Fix up movhf_mask constraints [PR123607]
Jakub Jelinek [Fri, 16 Jan 2026 07:22:32 +0000 (08:22 +0100)] 
i386: Fix up movhf_mask constraints [PR123607]

As documented in the manuals and enforced by gas,
VMOVSH two operand loads and three operands moves accept both
masking and masking/zeroing, but VMOVSH two operand store accepts
only masking:
EVEX.LLIG.F3.MAP5.W0 10 /r VMOVSH xmm1{k1}{z}, m16
EVEX.LLIG.F3.MAP5.W0 11 /r VMOVSH m16{k1}, xmm1
EVEX.LLIG.F3.MAP5.W0 10 /r VMOVSH xmm1{k1}{z}, xmm2, xmm3
EVEX.LLIG.F3.MAP5.W0 11 /r VMOVSH xmm1{k1}{z}, xmm2, xmm3
But the constraints in movhf_mask define_insn were allowing 0C
for all the alternatives.  The following patch enforces just 0
(i.e. just non-zeroing masking) for the second alternative (i.e.
the store).

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

PR target/123607
* config/i386/i386.md (movhf_mask): Change constraint on
match_operand 2's second alternative from 0C to 0.

* g++.target/i386/avx512fp16-pr123607.C: New test.

4 months agoLoongArch: Fix bug123521.
Lulu Cheng [Mon, 12 Jan 2026 09:23:41 +0000 (17:23 +0800)] 
LoongArch: Fix bug123521.

In the vector initialization process, optimization can be performed
if it can be determined that all elements are the same, or if the
upper or lower halves are identical.  However, during this
optimization, when the identical element is an immediate value
larger than 10 bits, an internal compiler error (ICE) occurs.
The reason is that in such cases, the function
`simplify_gen_subreg (imode, reg_tmp, GET_MODE (reg_tmp), 0)` is
called, where `imode` is `E_DImode`.  The mode of `reg_tmp` in
`GET_MODE (reg_tmp)` is taken from the immediate value's mode,
which is `E_VOIDmode`.  This results in a move from `E_VOIDmode`
to `E_DImode`, an operation not supported by LoongArch.

PR target/123521

gcc/ChangeLog:

* config/loongarch/loongarch.cc
(loongarch_expand_vector_init_same): Fixed a bug in the
vector initialization section..

gcc/testsuite/ChangeLog:

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

Suggested-by: Xi Ruoyao <xry111@xry111.site>
4 months agoMIPS: Add R5900 to ISA_HAS_FMIN_FMAX.
David Guillen Fandos [Wed, 14 Jan 2026 23:45:37 +0000 (00:45 +0100)] 
MIPS: Add R5900 to ISA_HAS_FMIN_FMAX.

The R5900 doesn't have proper IEEE754 handling: for all its FP
instructions, like "c.eq.s" or "add.s".

Since most of the other instructions are also broken,
so we can just define this, and the users should know about
what they are doing.

gcc/ChangeLog:

* config/mips/mips.h (ISA_HAS_FMIN_FMAX): Add R5900;
note that, R5900 is not IEEE754 fully compatiable.

Signed-off-by: David Guillen Fandos <david@davidgf.net>
4 months agoDaily bump.
GCC Administrator [Fri, 16 Jan 2026 00:16:30 +0000 (00:16 +0000)] 
Daily bump.

4 months agotestsuite: Require target x86_64 and aarch64 for gcc.dg/pr123109.c
Pengxuan Zheng [Thu, 15 Jan 2026 19:53:21 +0000 (11:53 -0800)] 
testsuite: Require target x86_64 and aarch64 for gcc.dg/pr123109.c

This fixes failures on i686 and arm.

gcc/testsuite/ChangeLog:

* gcc.dg/pr123109.c: Require target x86_64 and aarch64.

Signed-off-by: Pengxuan Zheng <pengxuan.zheng@oss.qualcomm.com>
4 months agoFix RISC-V test after recent vectorizer changes
Jeff Law [Thu, 15 Jan 2026 19:49:55 +0000 (12:49 -0700)] 
Fix RISC-V test after recent vectorizer changes

Richi's patch to fix costing of permuted contiguous loads changed the code
generation for pr122445.c in the testsuite.  After reviewing the code, it looks
clearly better to me -- essentially covering 2X as many elements per vector op
with fewer total vector ops in the end (without resulting to LMUL > 1).

I've verified this fixes the overnight regressions seen on riscv{32,64}-elf.
The bootstrap and regression tests are in flight, but won't finish for many
more hours.

gcc/testsuite
* gcc.target/riscv/rvv/autovec/pr122445.c: Adjust expected output.

4 months agoc-family: Regenerate c.opt.urls
Jakub Jelinek [Thu, 15 Jan 2026 16:12:07 +0000 (17:12 +0100)] 
c-family: Regenerate c.opt.urls

We forgot to regenerate c.opt.urls after the addition of -freflection
to c.opt.

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

* c.opt.urls: Regenerate.

4 months agolibstdc++: Fix __cpp_impl_reflection comparisons
Jakub Jelinek [Thu, 15 Jan 2026 15:34:14 +0000 (16:34 +0100)] 
libstdc++: Fix __cpp_impl_reflection comparisons

Last night when applying Marek's patchset for testing I've noticed I forgot
to change these 5 spots when changing the -freflection -std=c++26 predefined
value from 202500 which meant we implement some reflection, but not the
whole paper, to 202506 which is the https://eel.is/c++draft/tab:cpp.predefined.ft
value for it.

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

* include/std/type_traits (std::is_reflection, std::is_fundamental,
std::is_reflection_v, std::is_consteval_only): Compare
__cpp_impl_reflection >= 202506L instead of 202500L.
* testsuite/20_util/variable_templates_for_traits.cc: Likewise.

4 months agoc++: C++26 Reflection [PR120775]
Marek Polacek [Wed, 14 Jan 2026 16:37:39 +0000 (11:37 -0500)] 
c++: C++26 Reflection [PR120775]

This patch implements C++26 Reflection as specified by P2996R13, which allows
users to perform magic.  This patch also implements related papers:
Annotations for Reflection (P3394R4),
Splicing a base class subobject (P3293R3),
define_static_{string,object,array} (P3491R3),
Function Parameter Reflection (P3096R12).
(I already implemented consteval blocks back in July.)
(We do not yet implement P3795.)

We also implemented some CWG issues that had been approved in Kona;
e.g., CWG 3101, 3109, 3111, 3115, 3117.

All metafunctions are implemented in this patch.

The feature needs to be enabled by -std=c++26 -freflection.

Some stats: the v1 patch was over 51,200 LOC which were written in ~335
commits.  It came with over 400 tests with 11,722 static_asserts.  We still
had about 50 TODOs and FIXMEs in the code.
v2 consists of about 56,000 LOC which were created in 440 commits.  We
now have 446 tests with 40 TODOs remaining.
v3 brought another 77 commits, mostly clean-ups and various bug fixes.

I'd like to thank:
Jakub Jelinek, whose efforts can only be described as heroic and who
never ceases to amaze me even after nearly 15 years of working together,
he implemented many difficult metafunctions, annotations, mangling,
converted our metafunction dispatch to using gperf, and so on and on;
Jonathan Wakely for his libstdc++ patch review and generous & impeccable
advice even at odd hours; Dan Katz for his work on the Reflection papers,
writing Reflection tests for clang++ (many of which I've stolen^Wused),
for his advice, bug reports, and generally cheering me on; Jason Merrill
for his guidance, patch review, and, in fact, encouraging me to take on
this project in the first place; Michael Levine, Valentyn Yukhymenko, and
Alex Yesmanchyk for their nice contributions to Reflection; and Tomasz
Kamiński for providing test cases, finding bugs, and answering my C++
questions.

PR c++/120775
PR c++/123081
PR c++/122634

gcc/ChangeLog:

* attribs.cc (attribute_value_equal): Return false if either attribute
is ATTR_UNIQUE_VALUE_P.
(merge_attributes): Handle lists with ATTR_UNIQUE_VALUE_P values.
* doc/invoke.texi: Document -freflection.
* dwarf2out.cc (is_base_type) <case default>: Check
TREE_CODE >= LAST_AND_UNUSED_TREE_CODE instead of is_cxx_auto.
(gen_type_die_with_usage): For TREE_CODE >= LAST_AND_UNUSED_TREE_CODE
trees use use DW_TAG_unspecified_type.
* tree-core.h (struct tree_base): Update a comment.
* tree.h (ATTR_UNIQUE_VALUE_P): Define.
(BINFO_BASE_ACCESSES): Update the comment.

gcc/c-family/ChangeLog:

* c-attribs.cc (attribute_takes_identifier_p): Return false for C++
annotations.  Handle "old parm name".
* c-cppbuiltin.cc (c_cpp_builtins): Define __cpp_impl_reflection.
* c.opt (freflection): New.

gcc/cp/ChangeLog:

* Make-lang.in: Add cp/reflect.o.  Add a rule for cp/metafns.h.
* config-lang.in: Add reflect.cc.
* constexpr.cc (constexpr_global_ctx): Add consteval_block and
metafns_called members.  Initialize them.
(cxx_constexpr_quiet_p): New.
(cxx_constexpr_manifestly_const_eval): New.
(cxx_constexpr_caller): New.
(cxx_constexpr_consteval_block): New.
(enum value_cat): Move into cp-tree.h.
(cxx_eval_constant_expression): Move the declaration into cp-tree.h.
No longer static.  Handle REFLECT_EXPR.  Handle conversion of
a reflection to the meta::info type.
(cxx_eval_cxa_builtin_fn): Override current_function_decl.
(cxx_eval_builtin_function_call): Handle __builtin_is_string_literal.
(is_std_allocator): Also check __new_allocator.
(is_std_allocator_allocate): No longer static.
(cxa_allocate_and_throw_exception): New.
(cxx_eval_call_expression): Handle metafunctions.  Maybe set
metafns_called.
(reduced_constant_expression_p): Handle REFLECT_EXPR.
(cxx_eval_binary_expression): Use compare_reflections for comparing
reflections.
(find_immediate_fndecl): Don't walk REFLECT_EXPR_P.
(cxx_eval_outermost_constant_expr): Set global_ctx.consteval_block.
Detect consteval-only smuggling.
(potential_constant_expression_1): Return true for REFLECT_EXPR
and SPLICE_EXPR.
* constraint.cc (diagnose_trait_expr): Add CPTK_IS_CONSTEVAL_ONLY case.
* cp-gimplify.cc (immediate_escalating_function_p): No longer static.
(promote_function_to_consteval): Likewise.
(cp_gimplify_expr) <case CALL_EXPR>: Detect any surviving consteval-only
expressions.
<case CP_BUILT_IN_IS_STRING_LITERAL>: Handle.
(wipe_consteval_only_r): New.
(cp_fold_immediate_r): Detect invalid uses of consteval-only types.
Clear consteval-only DECL_EXPRs.
(cp_genericize_r): Wipe consteval-only vars from BIND_EXPR_VARS and
BLOCK_VARS.
* cp-objcp-common.cc (cp_common_init_ts): Mark META_TYPE, SPLICE_SCOPE,
SPLICE_EXPR, and REFLECT_EXPR.
* cp-trait.def (IS_CONSTEVAL_ONLY): New trait.
* cp-tree.def (REFLECT_EXPR, META_TYPE, SPLICE_EXPR, SPLICE_SCOPE): New
trees.
* cp-tree.h (enum cp_tree_index): Add CPTI_ANNOTATION_IDENTIFIER,
CPTI_STD_META, and CPTI_META_INFO_TYPE.
(std_meta_node): Define.
(meta_info_type_node): Define.
(annotation_identifier): Define.
(REFLECTION_TYPE_P): Define.
(REFLECT_EXPR_P): Define.
(REFLECT_EXPR_HANDLE): Define.
(enum reflect_kind): New.
(REFLECT_EXPR_KIND): Define.
(SET_REFLECT_EXPR_KIND): Define.
(SPLICE_EXPR_EXPRESSION_P): Define.
(SET_SPLICE_EXPR_EXPRESSION_P): Define.
(SPLICE_EXPR_MEMBER_ACCESS_P): Define.
(SET_SPLICE_EXPR_MEMBER_ACCESS_P): Define.
(SPLICE_EXPR_ADDRESS_P): Define.
(SET_SPLICE_EXPR_ADDRESS_P): Define.
(SPLICE_SCOPE_EXPR): Define.
(SPLICE_SCOPE_TYPE_P): Define.
(WILDCARD_TYPE_P): Include SPLICE_SCOPE.
(COMPONENT_REF_SPLICE_P): Define.
(SCALAR_TYPE_P): Include REFLECTION_TYPE_P.
(ENUM_BEING_DEFINED_P): Define.
(OLD_PARM_DECL_P): Define.
(MULTIPLE_NAMES_PARM_P): Define.
(cp_preserve_using_decl): Declare.
(DEF_OPERATOR, DEF_ASSN_OPERATOR): Include META.
(struct ovl_op_info_t): Add meta_name member.
(enum cp_built_in_function): Add CP_BUILT_IN_IS_STRING_LITERAL.
(build_stub_type): Declare.
(current_function_decl_without_access_scope): Declare.
(dependent_namespace_p): Declare.
(convert_reflect_constant_arg): Declare.
(finish_base_specifier): Adjust declaration.
(parsing_lambda_declarator): Declare.
(fold_builtin_is_string_literal): Declare.
(annotation_p): Declare.
(finish_class_member_access_expr): Adjust declaration.
(immediate_escalating_function_p): Declare.
(promote_function_to_consteval): Declare.
(is_std_allocator_allocate): Declare.
(cxa_allocate_and_throw_exception): Declare.
(enum value_cat): Define.
(cxx_eval_constant_expression): Declare.
(cxx_constexpr_quiet_p): Declare.
(cxx_constexpr_manifestly_const_eval): Declare.
(cxx_constexpr_caller): Declare.
(cxx_constexpr_consteval_block): Declare.
(init_reflection): Declare.
(metafunction_p): Declare.
(direct_base_parent): Declare.
(process_metafunction): Declare.
(get_reflection): Declare.
(get_null_reflection): Declare.
(splice): Declare.
(check_out_of_consteval_use): Declare.
(consteval_only_p): Declare.
(compare_reflections): Declare.
(valid_splice_type_p): Declare.
(valid_splice_scope_p): Declare.
(check_splice_expr): Declare.
(make_splice_scope): Declare.
(dependent_splice_p): Declare.
(reflection_mangle_prefix): Declare.
(check_consteval_only_fn): Declare.
* cvt.cc (convert_to_void): Call check_out_of_consteval_use.
* cxx-pretty-print.cc (cxx_pretty_printer::unary_expression): New
REFLECT_EXPR case.
(cxx_pretty_printer::expression): Likewise.
(cxx_pretty_printer::simple_type_specifier): New META_TYPE case.
(cxx_pretty_printer::type_id): Likewise.
* decl.cc (duplicate_decls): Merge parameter names for Reflection.
Maybe set OLD_PARM_DECL_P.
(initialize_predefined_identifiers): Add "annotation ".
(cxx_init_decl_processing): Add __builtin_is_string_literal.  Call
init_reflection.
(maybe_commonize_var): Do nothing for consteval_only_p.
(check_initializer): Default-initialize std::meta::info.
(make_rtl_for_nonlocal_decl): For consteval_only_p vars, set
DECL_EXTERNAL and return early.
(cp_finish_decl): Call check_out_of_consteval_use.  Don't go
creating a varpool node for consteval_only_p.
(get_tuple_size): Check the instantiation instead of the type.
(grokfndecl): Call check_consteval_only_fn.
(xref_basetypes): Stitch annotations onto BINFO_BASE_ACCESSES.
(finish_enum_value_list): Clear ENUM_BEING_DEFINED_P.
* decl2.cc (is_late_template_attribute): Handle all annotations as
late.
(cp_check_const_attributes): Don't handle annotations here.
(maybe_make_one_only): Do nothing for consteval_only_p.
(mark_needed): Likewise.
(min_vis_expr_r): Handle reflections.
(prune_vars_needing_no_initialization): Skip consteval_only_p.
(no_linkage_error): Return early for metafunctions.
(c_parse_final_cleanups): Don't write out consteval_only_p vars.  Avoid
complaining about metafunctions.
* error.cc (dump_type): New cases for CONST_DECL, META_TYPE, and
SPLICE_SCOPE.
(dump_type_prefix): New cases for META_TYPE and SPLICE_SCOPE.
(dump_type_suffix): Likewise.
(dump_decl): Dump SPLICE_EXPR.
(dump_expr): Dump REFLECT_EXPR and SPLICE_EXPR.
* init.cc (build_zero_init_1): Build a null reflection value.
(perform_member_init): Call check_out_of_consteval_use.
* lex.cc (DEF_OPERATOR, OPERATOR_TRANSITION): Update defines.
* mangle.cc (write_type): Mangle META_TYPE.
(write_expression): Handle REFLECT_EXPR.
(write_reflection): New.
(write_template_arg_literal): New REFLECT_EXPR case.
(write_template_arg): Handle REFLECT_EXPR.
* method.cc (build_stub_type): No longer static.
* module.cc (trees_out::type_node): Handle META_TYPE.
(trees_in::tree_node): Likewise.
* name-lookup.cc (name_lookup::adl_type): std::meta is an associated
namespace of std::meta::info.
(strip_using_decl): Don't strip when cp_preserve_using_decl.
(handle_namespace_attrs): Handle annotations.
(do_namespace_alias): Handle SPLICE_EXPR.
(lookup_qualified_name): When cp_preserve_using_decl, don't do
OVL_FUNCTION.
(finish_using_directive): Detect annotations on using directive.
* operators.def: Update for META_NAME.
* parser.cc: New cp_preserve_using_decl global.
(enum required_token): Add RT_CLOSE_SPLICE.
(get_required_cpp_ttype): Return CPP_CLOSE_SPLICE for RT_CLOSE_SPLICE.
(cp_parser_next_tokens_start_splice_type_spec_p): New.
(cp_parser_next_tokens_can_start_splice_scope_spec_p): New.
(cp_parser_splice_specifier): New.
(cp_parser_splice_type_specifier): New.
(cp_parser_splice_expression): New.
(cp_parser_splice_scope_specifier): New.
(cp_parser_splice_spec_is_nns_p): New.
(cp_parser_nth_token_starts_splice_without_nns_p): New.
(cp_parser_primary_expression): Handle CPP_OPEN_SPLICE.  Give an
error for ^^ outside reflection.
(cp_parser_unqualified_id): Allow r.~typename [:R:].
(cp_parser_nested_name_specifier_opt): Cope with splice-scope-specifier.
(cp_parser_qualifying_entity): Parse splice-scope-specifier.
(cp_parser_postfix_expression): Deal with [: :] after a typename.
(cp_parser_postfix_dot_deref_expression): Parse & handle splices
in a class member access.  Pass splice_p to
finish_class_member_access_expr.
(cp_parser_reflection_name): New.
(cp_parser_reflect_expression): New.
(cp_parser_unary_expression): Parse reflect-expression.
(cp_parser_declaration): Parse splice-scope-specifier.
(cp_parser_decomposition_declaration): Detect annotations on structured
bindings.
(cp_parser_decltype_expr): Parse splice-expression.
(cp_parser_template_id): New parsed_templ argument.  If it's nonnull,
don't parse the template name.  Turn an assert into a condition.
(cp_parser_type_specifier): Handle typename [: :].
(cp_parser_simple_type_specifier): Parse splice-type-specifier.
(cp_parser_enum_specifier): Set ENUM_BEING_DEFINED_P.
(cp_parser_namespace_alias_definition): Parse splice-specifier.
(cp_parser_using_directive): Likewise.
(cp_parser_type_id_1): New bool * parameter to distinguish between
types and type aliases.  Set it.
(cp_parser_type_id): Adjust the call to cp_parser_type_id_1.
(cp_parser_template_type_arg): Likewise.
(cp_parser_trailing_type_id): Likewise.
(cp_parser_base_specifier): Handle annotations.  Maybe give an error
for splice-scope-specifier.  Parse splice-type-specifier.  Pass
annotations to finish_base_specifier.
(cp_parser_annotation): New.
(cp_parser_std_attribute_list): Detect mixing annotations and attributes
in the same list.
(cp_parser_annotation_list): New.
(cp_parser_std_attribute_spec): Parse annotations.
(cp_parser_skip_balanced_tokens): Also handle CPP_OPEN_SPLICE
and CPP_CLOSE_SPLICE.
(cp_parser_type_requirement): Parse splice-type-specifier.
(cp_parser_lookup_name): Also consider dependent namespaces.  Don't
call check_accessibility_of_qualified_id for USING_DECLs.
(cp_parser_required_error): Handle RT_CLOSE_SPLICE.
* pt.cc (current_function_decl_without_access_scope): New.
(verify_unstripped_args_1): REFLECT_EXPR_P is OK.
(iterative_hash_template_arg): Handle REFLECT_EXPR.
(convert_nontype_argument): Maybe give an error for REFLECTION_TYPE_P.
(for_each_template_parm_r): Handle SPLICE_SCOPE.
(instantiate_class_template): Handle annotations.
(tsubst_pack_index): Make static.
(tsubst_decl): Handle NAMESPACE_DECL.
(tsubst_splice_scope): New.
(tsubst_splice_expr): New.
(tsubst): Don't return early for NAMESPACE_DECL.   New META_TYPE case.
Handle a splice-specifier that expanded into a NAMESPACE_DECL.  Handle
SPLICE_SCOPE, SPLICE_EXPR, and TEMPLATE_ID_EXPR.
(tsubst_scope): Also accept NAMESPACE_DECL.
(tsubst_qualified_id): Check dependent_namespace_p.
(tsubst_lambda_expr): Set LAMBDA_EXPR_CONSTEVAL_BLOCK_P.
(tsubst_expr): Allow dependent_splice_p in an assert.  Check
COMPONENT_REF_SPLICE_P and pass it to finish_class_member_access_expr.
<case NAMESPACE_DECL>: Remove.
New REFLECT_EXPR and SPLICE_EXPR cases.
(unify): Handle META_TYPE.
(instantiate_body): Call check_consteval_only_fn.
(tsubst_enum): Set ENUM_BEING_DEFINED_P.
(dependent_type_p_r): A splice-scope-specifier is dependent.
(dependent_namespace_p): New.
(value_dependent_expression_p): Handle REFLECT_EXPR.  Also handle
[meta.reflection.access.context]/8.
(type_dependent_expression_p): REFLECT_EXPR_P is not type-dependent.
(convert_reflect_constant_arg): New.
* search.cc (check_final_overrider): Adjust for CWG 3117.
* semantics.cc (finish_base_specifier): Handle annotations.
(parsing_lambda_declarator): No longer static.
(finish_id_expression_1): Check dependent_namespace_p.
(fold_builtin_is_string_literal): New.
(trait_expr_value): Handle CPTK_IS_CONSTEVAL_ONLY.
(finish_trait_expr): Likewise.
* tree.cc (handle_annotation_attribute): New.
(builtin_valid_in_constant_expr_p): Return true for
CP_BUILT_IN_IS_STRING_LITERAL.
(cp_tree_equal): Handle comparing REFLECT_EXPRs.
(internal_attributes): Add "annotation ".
(annotation_p): New.
* typeck.cc (finish_class_member_access_expr): New splice_p argument.
Handle dependent splices.  Implement splicing a base class subobject.
Handle class member access using a splice-expression.
(cp_build_binary_op): Handle comparing std::meta::infos.
(check_return_expr): Call check_out_of_consteval_use.
* metafns.gperf: New file.
* metafns.h: New file.
* reflect.cc: New file.

libcc1/ChangeLog:

* libcp1plugin.cc (start_class_def): Update the call to
finish_base_specifier.

libcpp/ChangeLog:

* charset.cc (_cpp_destroy_iconv): Destroy narrow_cset_desc and
utf8_cset_desc.
(cpp_translate_string): New.
(cpp_valid_identifier): New.
* include/cpplib.h: Add OPEN_SPLICE, CLOSE_SPLICE, and REFLECT_OP to
TTYPE_TABLE.
(cpp_translate_string): Declare.
(cpp_valid_identifier): Declare.
* internal.h (struct cpp_reader): Add reverse_narrow_cset_desc and
reverse_utf8_cset_desc fields.
* lex.cc (_cpp_lex_direct): Emit CPP_CLOSE_SPLICE, CPP_REFLECT_OP,
and CPP_OPEN_SPLICE tokens.

libstdc++-v3/ChangeLog:

* include/Makefile.am (std_headers): Add ${std_srcdir}/meta.
* include/Makefile.in: Regenerate.
* include/bits/iterator_concepts.h (std::ranges::__access::__begin): Add
constexpr.
* include/bits/version.def (reflection): New.
* include/bits/version.h: Regenerate.
* include/precompiled/stdc++.h: Include <meta> for C++26.
* include/std/meta: New file.
* include/std/type_traits (std::is_reflection): New trait.
(std::is_fundamental): Include is_reflection for C++26 -freflection.
(std::is_reflection_v): New variable template.
(std::is_consteval_only): New trait.
(std::is_consteval_only_v): New variable template.
* src/c++23/std.cc.in: Add <meta> exports.
* testsuite/20_util/variable_templates_for_traits.cc: Add -freflection as
dg-additional-options for C++26.  Add std::is_reflection_v test in that case.
* testsuite/20_util/is_consteval_only/requirements/explicit_instantiation.cc: New test.
* testsuite/20_util/is_consteval_only/requirements/typedefs.cc: New test.
* testsuite/20_util/is_consteval_only/value.cc: New test.
* testsuite/20_util/is_reflection/requirements/explicit_instantiation.cc: New test.
* testsuite/20_util/is_reflection/requirements/typedefs.cc: New test.
* testsuite/20_util/is_reflection/value.cc: New test.

gcc/testsuite/ChangeLog:

* g++.dg/DRs/dr2581-1.C: Add -freflection.
* g++.dg/DRs/dr2581-2.C: Likewise.
* g++.dg/reflect/access_context1.C: New test.
* g++.dg/reflect/access_context2.C: New test.
* g++.dg/reflect/access_context3.C: New test.
* g++.dg/reflect/adl1.C: New test.
* g++.dg/reflect/alignment_of1.C: New test.
* g++.dg/reflect/alignment_of2.C: New test.
* g++.dg/reflect/annotations1.C: New test.
* g++.dg/reflect/annotations2.C: New test.
* g++.dg/reflect/annotations3.C: New test.
* g++.dg/reflect/annotations4.C: New test.
* g++.dg/reflect/annotations5.C: New test.
* g++.dg/reflect/annotations6.C: New test.
* g++.dg/reflect/annotations7.C: New test.
* g++.dg/reflect/annotations8.C: New test.
* g++.dg/reflect/anon1.C: New test.
* g++.dg/reflect/anon2.C: New test.
* g++.dg/reflect/anon3.C: New test.
* g++.dg/reflect/bases_of1.C: New test.
* g++.dg/reflect/bases_of2.C: New test.
* g++.dg/reflect/bases_of3.C: New test.
* g++.dg/reflect/bit_size_of1.C: New test.
* g++.dg/reflect/bitfield1.C: New test.
* g++.dg/reflect/can_substitute1.C: New test.
* g++.dg/reflect/class1.C: New test.
* g++.dg/reflect/class2.C: New test.
* g++.dg/reflect/common_reference1.C: New test.
* g++.dg/reflect/common_type1.C: New test.
* g++.dg/reflect/compare1.C: New test.
* g++.dg/reflect/compare10.C: New test.
* g++.dg/reflect/compare2.C: New test.
* g++.dg/reflect/compare3.C: New test.
* g++.dg/reflect/compare4.C: New test.
* g++.dg/reflect/compare5.C: New test.
* g++.dg/reflect/compare6.C: New test.
* g++.dg/reflect/compare7.C: New test.
* g++.dg/reflect/compare8.C: New test.
* g++.dg/reflect/compare9.C: New test.
* g++.dg/reflect/compat1.C: New test.
* g++.dg/reflect/complete1.C: New test.
* g++.dg/reflect/constant_of1.C: New test.
* g++.dg/reflect/constant_of2.C: New test.
* g++.dg/reflect/constant_of3.C: New test.
* g++.dg/reflect/constant_of4.C: New test.
* g++.dg/reflect/constant_of5.C: New test.
* g++.dg/reflect/constant_of6.C: New test.
* g++.dg/reflect/constant_of7.C: New test.
* g++.dg/reflect/constant_of8.C: New test.
* g++.dg/reflect/constant_of9.C: New test.
* g++.dg/reflect/crash1.C: New test.
* g++.dg/reflect/crash10.C: New test.
* g++.dg/reflect/crash11.C: New test.
* g++.dg/reflect/crash12.C: New test.
* g++.dg/reflect/crash13.C: New test.
* g++.dg/reflect/crash14.C: New test.
* g++.dg/reflect/crash15.C: New test.
* g++.dg/reflect/crash16.C: New test.
* g++.dg/reflect/crash17.C: New test.
* g++.dg/reflect/crash18.C: New test.
* g++.dg/reflect/crash2.C: New test.
* g++.dg/reflect/crash3.C: New test.
* g++.dg/reflect/crash4.C: New test.
* g++.dg/reflect/crash5.C: New test.
* g++.dg/reflect/crash6.C: New test.
* g++.dg/reflect/crash7.C: New test.
* g++.dg/reflect/crash8.C: New test.
* g++.dg/reflect/crash9.C: New test.
* g++.dg/reflect/data_member_spec1.C: New test.
* g++.dg/reflect/data_member_spec2.C: New test.
* g++.dg/reflect/data_member_spec3.C: New test.
* g++.dg/reflect/data_member_spec4.C: New test.
* g++.dg/reflect/dealias1.C: New test.
* g++.dg/reflect/dealias2.C: New test.
* g++.dg/reflect/dealias3.C: New test.
* g++.dg/reflect/define_aggregate1.C: New test.
* g++.dg/reflect/define_aggregate2.C: New test.
* g++.dg/reflect/define_aggregate3.C: New test.
* g++.dg/reflect/define_aggregate4.C: New test.
* g++.dg/reflect/define_aggregate5.C: New test.
* g++.dg/reflect/define_static_array1.C: New test.
* g++.dg/reflect/define_static_array2.C: New test.
* g++.dg/reflect/define_static_array3.C: New test.
* g++.dg/reflect/define_static_array4.C: New test.
* g++.dg/reflect/define_static_object1.C: New test.
* g++.dg/reflect/define_static_object2.C: New test.
* g++.dg/reflect/define_static_string1.C: New test.
* g++.dg/reflect/dep1.C: New test.
* g++.dg/reflect/dep10.C: New test.
* g++.dg/reflect/dep11.C: New test.
* g++.dg/reflect/dep2.C: New test.
* g++.dg/reflect/dep3.C: New test.
* g++.dg/reflect/dep4.C: New test.
* g++.dg/reflect/dep5.C: New test.
* g++.dg/reflect/dep6.C: New test.
* g++.dg/reflect/dep7.C: New test.
* g++.dg/reflect/dep8.C: New test.
* g++.dg/reflect/dep9.C: New test.
* g++.dg/reflect/diag1.C: New test.
* g++.dg/reflect/diag2.C: New test.
* g++.dg/reflect/diag3.C: New test.
* g++.dg/reflect/diag4.C: New test.
* g++.dg/reflect/display_string_of1.C: New test.
* g++.dg/reflect/eh1.C: New test.
* g++.dg/reflect/eh2.C: New test.
* g++.dg/reflect/eh3.C: New test.
* g++.dg/reflect/eh4.C: New test.
* g++.dg/reflect/eh5.C: New test.
* g++.dg/reflect/eh6.C: New test.
* g++.dg/reflect/eh7.C: New test.
* g++.dg/reflect/eh8.C: New test.
* g++.dg/reflect/eh9.C: New test.
* g++.dg/reflect/enumerators_of1.C: New test.
* g++.dg/reflect/error1.C: New test.
* g++.dg/reflect/error10.C: New test.
* g++.dg/reflect/error2.C: New test.
* g++.dg/reflect/error3.C: New test.
* g++.dg/reflect/error4.C: New test.
* g++.dg/reflect/error5.C: New test.
* g++.dg/reflect/error6.C: New test.
* g++.dg/reflect/error8.C: New test.
* g++.dg/reflect/error9.C: New test.
* g++.dg/reflect/expr1.C: New test.
* g++.dg/reflect/expr10.C: New test.
* g++.dg/reflect/expr11.C: New test.
* g++.dg/reflect/expr12.C: New test.
* g++.dg/reflect/expr13.C: New test.
* g++.dg/reflect/expr14.C: New test.
* g++.dg/reflect/expr2.C: New test.
* g++.dg/reflect/expr3.C: New test.
* g++.dg/reflect/expr4.C: New test.
* g++.dg/reflect/expr5.C: New test.
* g++.dg/reflect/expr6.C: New test.
* g++.dg/reflect/expr7.C: New test.
* g++.dg/reflect/expr8.C: New test.
* g++.dg/reflect/expr9.C: New test.
* g++.dg/reflect/extract1.C: New test.
* g++.dg/reflect/extract2.C: New test.
* g++.dg/reflect/extract3.C: New test.
* g++.dg/reflect/extract4.C: New test.
* g++.dg/reflect/extract5.C: New test.
* g++.dg/reflect/extract6.C: New test.
* g++.dg/reflect/extract7.C: New test.
* g++.dg/reflect/extract8.C: New test.
* g++.dg/reflect/extract9.C: New test.
* g++.dg/reflect/feat1.C: New test.
* g++.dg/reflect/feat2.C: New test.
* g++.dg/reflect/has_c_language_linkage1.C: New test.
* g++.dg/reflect/has_default_argument1.C: New test.
* g++.dg/reflect/has_default_argument2.C: New test.
* g++.dg/reflect/has_default_member_initializer1.C: New test.
* g++.dg/reflect/has_ellipsis_parameter1.C: New test.
* g++.dg/reflect/has_external_linkage1.C: New test.
* g++.dg/reflect/has_external_linkage2.C: New test.
* g++.dg/reflect/has_identifier1.C: New test.
* g++.dg/reflect/has_identifier2.C: New test.
* g++.dg/reflect/has_internal_linkage1.C: New test.
* g++.dg/reflect/has_internal_linkage2.C: New test.
* g++.dg/reflect/has_linkage1.C: New test.
* g++.dg/reflect/has_module_linkage1.C: New test.
* g++.dg/reflect/has_module_linkage2.C: New test.
* g++.dg/reflect/has_parent1.C: New test.
* g++.dg/reflect/has_template_arguments1.C: New test.
* g++.dg/reflect/has_template_arguments2.C: New test.
* g++.dg/reflect/has_template_arguments3.C: New test.
* g++.dg/reflect/has_template_arguments4.C: New test.
* g++.dg/reflect/identifier_of1.C: New test.
* g++.dg/reflect/identifier_of2.C: New test.
* g++.dg/reflect/init1.C: New test.
* g++.dg/reflect/init10.C: New test.
* g++.dg/reflect/init11.C: New test.
* g++.dg/reflect/init12.C: New test.
* g++.dg/reflect/init13.C: New test.
* g++.dg/reflect/init14.C: New test.
* g++.dg/reflect/init15.C: New test.
* g++.dg/reflect/init16.C: New test.
* g++.dg/reflect/init17.C: New test.
* g++.dg/reflect/init2.C: New test.
* g++.dg/reflect/init3.C: New test.
* g++.dg/reflect/init4.C: New test.
* g++.dg/reflect/init5.C: New test.
* g++.dg/reflect/init6.C: New test.
* g++.dg/reflect/init7.C: New test.
* g++.dg/reflect/init8.C: New test.
* g++.dg/reflect/init9.C: New test.
* g++.dg/reflect/is_accessible1.C: New test.
* g++.dg/reflect/is_accessible2.C: New test.
* g++.dg/reflect/is_alias_template1.C: New test.
* g++.dg/reflect/is_assignment1.C: New test.
* g++.dg/reflect/is_bit_field1.C: New test.
* g++.dg/reflect/is_class_member1.C: New test.
* g++.dg/reflect/is_class_template1.C: New test.
* g++.dg/reflect/is_complete_type1.C: New test.
* g++.dg/reflect/is_complete_type2.C: New test.
* g++.dg/reflect/is_concept1.C: New test.
* g++.dg/reflect/is_const1.C: New test.
* g++.dg/reflect/is_consteval_only1.C: New test.
* g++.dg/reflect/is_constructible_type1.C: New test.
* g++.dg/reflect/is_constructible_type2.C: New test.
* g++.dg/reflect/is_constructor_template1.C: New test.
* g++.dg/reflect/is_constuctor1.C: New test.
* g++.dg/reflect/is_conversion_function1.C: New test.
* g++.dg/reflect/is_conversion_function_template1.C: New test.
* g++.dg/reflect/is_copy_assignment1.C: New test.
* g++.dg/reflect/is_copy_constructor1.C: New test.
* g++.dg/reflect/is_data_member_spec1.C: New test.
* g++.dg/reflect/is_default_constructor1.C: New test.
* g++.dg/reflect/is_defaulted1.C: New test.
* g++.dg/reflect/is_defaulted2.C: New test.
* g++.dg/reflect/is_deleted1.C: New test.
* g++.dg/reflect/is_deleted2.C: New test.
* g++.dg/reflect/is_destructor1.C: New test.
* g++.dg/reflect/is_enumerable_type1.C: New test.
* g++.dg/reflect/is_enumerator1.C: New test.
* g++.dg/reflect/is_explicit1.C: New test.
* g++.dg/reflect/is_explicit2.C: New test.
* g++.dg/reflect/is_explicit_object_parameter1.C: New test.
* g++.dg/reflect/is_final1.C: New test.
* g++.dg/reflect/is_function1.C: New test.
* g++.dg/reflect/is_function2.C: New test.
* g++.dg/reflect/is_function3.C: New test.
* g++.dg/reflect/is_function_parameter1.C: New test.
* g++.dg/reflect/is_function_parameter2.C: New test.
* g++.dg/reflect/is_function_template1.C: New test.
* g++.dg/reflect/is_function_template2.C: New test.
* g++.dg/reflect/is_function_type1.C: New test.
* g++.dg/reflect/is_literal_operator1.C: New test.
* g++.dg/reflect/is_literal_operator_template1.C: New test.
* g++.dg/reflect/is_lrvalue_reference_qualified1.C: New test.
* g++.dg/reflect/is_move_assignment1.C: New test.
* g++.dg/reflect/is_move_constructor1.C: New test.
* g++.dg/reflect/is_mutable_member1.C: New test.
* g++.dg/reflect/is_namespace1.C: New test.
* g++.dg/reflect/is_namespace_alias1.C: New test.
* g++.dg/reflect/is_namespace_member1.C: New test.
* g++.dg/reflect/is_noexcept1.C: New test.
* g++.dg/reflect/is_noexcept2.C: New test.
* g++.dg/reflect/is_noexcept3.C: New test.
* g++.dg/reflect/is_noexcept4.C: New test.
* g++.dg/reflect/is_nonstatic_data_member1.C: New test.
* g++.dg/reflect/is_object1.C: New test.
* g++.dg/reflect/is_object2.C: New test.
* g++.dg/reflect/is_operator_function1.C: New test.
* g++.dg/reflect/is_operator_function_template1.C: New test.
* g++.dg/reflect/is_override1.C: New test.
* g++.dg/reflect/is_pure_virtual1.C: New test.
* g++.dg/reflect/is_special_member_function1.C: New test.
* g++.dg/reflect/is_static_member1.C: New test.
* g++.dg/reflect/is_string_literal1.C: New test.
* g++.dg/reflect/is_structured_binding1.C: New test.
* g++.dg/reflect/is_structured_binding2.C: New test.
* g++.dg/reflect/is_template1.C: New test.
* g++.dg/reflect/is_template2.C: New test.
* g++.dg/reflect/is_type1.C: New test.
* g++.dg/reflect/is_type_alias1.C: New test.
* g++.dg/reflect/is_type_alias2.C: New test.
* g++.dg/reflect/is_type_alias3.C: New test.
* g++.dg/reflect/is_user_declared1.C: New test.
* g++.dg/reflect/is_user_declared2.C: New test.
* g++.dg/reflect/is_user_provided1.C: New test.
* g++.dg/reflect/is_user_provided2.C: New test.
* g++.dg/reflect/is_variable1.C: New test.
* g++.dg/reflect/is_variable_template1.C: New test.
* g++.dg/reflect/is_virtual1.C: New test.
* g++.dg/reflect/is_volatile1.C: New test.
* g++.dg/reflect/lex1.C: New test.
* g++.dg/reflect/lex2.C: New test.
* g++.dg/reflect/mangle1.C: New test.
* g++.dg/reflect/member-visibility1.C: New test.
* g++.dg/reflect/member-visibility2.C: New test.
* g++.dg/reflect/member1.C: New test.
* g++.dg/reflect/member10.C: New test.
* g++.dg/reflect/member11.C: New test.
* g++.dg/reflect/member12.C: New test.
* g++.dg/reflect/member13.C: New test.
* g++.dg/reflect/member14.C: New test.
* g++.dg/reflect/member15.C: New test.
* g++.dg/reflect/member16.C: New test.
* g++.dg/reflect/member17.C: New test.
* g++.dg/reflect/member18.C: New test.
* g++.dg/reflect/member19.C: New test.
* g++.dg/reflect/member2.C: New test.
* g++.dg/reflect/member20.C: New test.
* g++.dg/reflect/member3.C: New test.
* g++.dg/reflect/member4.C: New test.
* g++.dg/reflect/member5.C: New test.
* g++.dg/reflect/member6.C: New test.
* g++.dg/reflect/member7.C: New test.
* g++.dg/reflect/member8.C: New test.
* g++.dg/reflect/member9.C: New test.
* g++.dg/reflect/members_of1.C: New test.
* g++.dg/reflect/members_of2.C: New test.
* g++.dg/reflect/members_of3.C: New test.
* g++.dg/reflect/members_of4.C: New test.
* g++.dg/reflect/members_of5.C: New test.
* g++.dg/reflect/members_of6.C: New test.
* g++.dg/reflect/members_of7.C: New test.
* g++.dg/reflect/metafn-ptr1.C: New test.
* g++.dg/reflect/ns1.C: New test.
* g++.dg/reflect/ns2.C: New test.
* g++.dg/reflect/ns3.C: New test.
* g++.dg/reflect/ns4.C: New test.
* g++.dg/reflect/ns5.C: New test.
* g++.dg/reflect/ns6.C: New test.
* g++.dg/reflect/null1.C: New test.
* g++.dg/reflect/null2.C: New test.
* g++.dg/reflect/null3.C: New test.
* g++.dg/reflect/null4.C: New test.
* g++.dg/reflect/null5.C: New test.
* g++.dg/reflect/object_of1.C: New test.
* g++.dg/reflect/object_of2.C: New test.
* g++.dg/reflect/odr1.C: New test.
* g++.dg/reflect/offset_of1.C: New test.
* g++.dg/reflect/operator_of1.C: New test.
* g++.dg/reflect/override1.C: New test.
* g++.dg/reflect/p2996-1.C: New test.
* g++.dg/reflect/p2996-10.C: New test.
* g++.dg/reflect/p2996-11.C: New test.
* g++.dg/reflect/p2996-12.C: New test.
* g++.dg/reflect/p2996-13.C: New test.
* g++.dg/reflect/p2996-14.C: New test.
* g++.dg/reflect/p2996-15.C: New test.
* g++.dg/reflect/p2996-16.C: New test.
* g++.dg/reflect/p2996-17.C: New test.
* g++.dg/reflect/p2996-18.C: New test.
* g++.dg/reflect/p2996-19.C: New test.
* g++.dg/reflect/p2996-2.C: New test.
* g++.dg/reflect/p2996-20.C: New test.
* g++.dg/reflect/p2996-21.C: New test.
* g++.dg/reflect/p2996-3.C: New test.
* g++.dg/reflect/p2996-4.C: New test.
* g++.dg/reflect/p2996-5.C: New test.
* g++.dg/reflect/p2996-6.C: New test.
* g++.dg/reflect/p2996-7.C: New test.
* g++.dg/reflect/p2996-8.C: New test.
* g++.dg/reflect/p2996-9.C: New test.
* g++.dg/reflect/p3394-1.C: New test.
* g++.dg/reflect/p3491-1.C: New test.
* g++.dg/reflect/p3491-2.C: New test.
* g++.dg/reflect/p3491-3.C: New test.
* g++.dg/reflect/pack-index1.C: New test.
* g++.dg/reflect/parameters_of1.C: New test.
* g++.dg/reflect/parameters_of2.C: New test.
* g++.dg/reflect/parameters_of3.C: New test.
* g++.dg/reflect/parameters_of4.C: New test.
* g++.dg/reflect/parameters_of5.C: New test.
* g++.dg/reflect/parameters_of6.C: New test.
* g++.dg/reflect/parent_of1.C: New test.
* g++.dg/reflect/parm1.C: New test.
* g++.dg/reflect/parm2.C: New test.
* g++.dg/reflect/parm3.C: New test.
* g++.dg/reflect/parm4.C: New test.
* g++.dg/reflect/pr122634-1.C: New test.
* g++.dg/reflect/pr122634-2.C: New test.
* g++.dg/reflect/qrn1.C: New test.
* g++.dg/reflect/qrn2.C: New test.
* g++.dg/reflect/range_args.C: New test.
* g++.dg/reflect/reflect_constant1.C: New test.
* g++.dg/reflect/reflect_constant2.C: New test.
* g++.dg/reflect/reflect_constant3.C: New test.
* g++.dg/reflect/reflect_constant4.C: New test.
* g++.dg/reflect/reflect_constant5.C: New test.
* g++.dg/reflect/reflect_constant6.C: New test.
* g++.dg/reflect/reflect_constant7.C: New test.
* g++.dg/reflect/reflect_constant8.C: New test.
* g++.dg/reflect/reflect_constant9.C: New test.
* g++.dg/reflect/reflect_constant_array1.C: New test.
* g++.dg/reflect/reflect_constant_array2.C: New test.
* g++.dg/reflect/reflect_constant_array3.C: New test.
* g++.dg/reflect/reflect_constant_array4.C: New test.
* g++.dg/reflect/reflect_constant_string1.C: New test.
* g++.dg/reflect/reflect_constant_string2.C: New test.
* g++.dg/reflect/reflect_function1.C: New test.
* g++.dg/reflect/reflect_function2.C: New test.
* g++.dg/reflect/reflect_object1.C: New test.
* g++.dg/reflect/reflect_object2.C: New test.
* g++.dg/reflect/reflect_object3.C: New test.
* g++.dg/reflect/reflect_object4.C: New test.
* g++.dg/reflect/return_type_of1.C: New test.
* g++.dg/reflect/return_type_of2.C: New test.
* g++.dg/reflect/serialize1.C: New test.
* g++.dg/reflect/serialize2.C: New test.
* g++.dg/reflect/size_of1.C: New test.
* g++.dg/reflect/source_location_of1.C: New test.
* g++.dg/reflect/source_location_of2.C: New test.
* g++.dg/reflect/splice1.C: New test.
* g++.dg/reflect/splice2.C: New test.
* g++.dg/reflect/splice3.C: New test.
* g++.dg/reflect/splice4.C: New test.
* g++.dg/reflect/splice5.C: New test.
* g++.dg/reflect/splice6.C: New test.
* g++.dg/reflect/splice7.C: New test.
* g++.dg/reflect/splicing-base1.C: New test.
* g++.dg/reflect/splicing-base2.C: New test.
* g++.dg/reflect/splicing-base3.C: New test.
* g++.dg/reflect/splicing-base4.C: New test.
* g++.dg/reflect/storage_duration1.C: New test.
* g++.dg/reflect/storage_duration2.C: New test.
* g++.dg/reflect/storage_duration3.C: New test.
* g++.dg/reflect/subobjects_of1.C: New test.
* g++.dg/reflect/substitute1.C: New test.
* g++.dg/reflect/substitute2.C: New test.
* g++.dg/reflect/symbol_of1.C: New test.
* g++.dg/reflect/symbol_of2.C: New test.
* g++.dg/reflect/template_arguments_of1.C: New test.
* g++.dg/reflect/template_arguments_of2.C: New test.
* g++.dg/reflect/template_arguments_of3.C: New test.
* g++.dg/reflect/template_of1.C: New test.
* g++.dg/reflect/template_of2.C: New test.
* g++.dg/reflect/template_of3.C: New test.
* g++.dg/reflect/tuple1.C: New test.
* g++.dg/reflect/tuple2.C: New test.
* g++.dg/reflect/type1.C: New test.
* g++.dg/reflect/type10.C: New test.
* g++.dg/reflect/type2.C: New test.
* g++.dg/reflect/type3.C: New test.
* g++.dg/reflect/type4.C: New test.
* g++.dg/reflect/type5.C: New test.
* g++.dg/reflect/type6.C: New test.
* g++.dg/reflect/type7.C: New test.
* g++.dg/reflect/type8.C: New test.
* g++.dg/reflect/type9.C: New test.
* g++.dg/reflect/type_of1.C: New test.
* g++.dg/reflect/type_of2.C: New test.
* g++.dg/reflect/type_rels1.C: New test.
* g++.dg/reflect/type_trait1.C: New test.
* g++.dg/reflect/type_trait10.C: New test.
* g++.dg/reflect/type_trait11.C: New test.
* g++.dg/reflect/type_trait12.C: New test.
* g++.dg/reflect/type_trait13.C: New test.
* g++.dg/reflect/type_trait2.C: New test.
* g++.dg/reflect/type_trait3.C: New test.
* g++.dg/reflect/type_trait4.C: New test.
* g++.dg/reflect/type_trait5.C: New test.
* g++.dg/reflect/type_trait6.C: New test.
* g++.dg/reflect/type_trait8.C: New test.
* g++.dg/reflect/type_trait9.C: New test.
* g++.dg/reflect/u8display_string_of1.C: New test.
* g++.dg/reflect/u8identifier_of1.C: New test.
* g++.dg/reflect/u8symbol_of1.C: New test.
* g++.dg/reflect/underlying_type1.C: New test.
* g++.dg/reflect/using1.C: New test.
* g++.dg/reflect/value_or_object1.C: New test.
* g++.dg/reflect/variable_of1.C: New test.
* g++.dg/reflect/variable_of2.C: New test.
* g++.dg/reflect/variable_of3.C: New test.
* g++.dg/reflect/variant1.C: New test.
* g++.dg/reflect/variant2.C: New test.
* g++.dg/reflect/vector1.C: New test.
* g++.dg/reflect/visibility1.C: New test.

Co-authored-by: Jakub Jelinek <jakub@redhat.com>
Signed-off-by: Valentyn Yukhymenko <vyuhimenko@bloomberg.net>
Signed-off-by: Alex Yesmanchyk <ayesmanchyk@bloomberg.net>
Signed-off-by: Michael Levine <mlevine55@bloomberg.net>
Reviewed-by: Jason Merrill <jason@redhat.com>
4 months agoRemove .res specs to fix COFF passthrough [PR123504]
Peter Damianov [Sat, 10 Jan 2026 09:19:54 +0000 (09:19 +0000)] 
Remove .res specs to fix COFF passthrough [PR123504]

Some packages (gnulib) pass COFF object files with .res extension
directly to gcc, expecting them to be passed through to the linker,
instead of windres.  However, the current EXTRA_DEFAULT_COMPILERS spec
intercepts all .res files and runs them through windres, which fails for
COFF files that are not Windows resource files (Microsoft Visual C
binary resource file as identified by libmagic/file).

This patch removes the .res file specs, leaving only the .rc
support specs active. At a later date, this can be reviewed.

The driver could inspect the .res file to see if it's a object file or,
but, it's somewhat questionable if handling .res is even useful.

gcc/ChangeLog:

PR driver/123504
* config/i386/cygming.h (EXTRA_DEFAULT_COMPILERS): Comment out
.res spec to allow COFF files with .res extension to pass
through to the linker.
* config/aarch64/cygming.h (EXTRA_DEFAULT_COMPILERS): Likewise.

Signed-off-by: Jonathan Yong <10walls@gmail.com>
4 months agoira: Implicit uses via hard register constraints
Stefan Schulze Frielinghaus [Thu, 15 Jan 2026 14:14:59 +0000 (15:14 +0100)] 
ira: Implicit uses via hard register constraints

In ira_implicitly_set_insn_hard_regs() all potentially used registers
stemming from single register constraints are recorded.  Since hard
register constraints are pretty similar, do the same for those, too.
This requires to setup the preferred alternatives which is done via
ira_setup_alts() and also implemented for hard register constraints by
this patch.

This fixes an ICE were previously sched1 swapped the order of the
instructions

(insn 10 9 6 2 (parallel [
            (set (reg:DF 118)
                (asm_operands:DF ("") ("={fr2}") 0 [
                        (reg:TF 121 [ a ])
                    ]
                     [
                        (asm_input:TF ("{fr1}") t.i:5)
                    ]
                     [] t.i:5))
            (clobber (reg:SI 98 ca))
        ]) "t.i":5:3 -1
     (expr_list:REG_DEAD (reg:TF 121 [ a ])
        (expr_list:REG_UNUSED (reg:SI 98 ca)
            (nil))))
...
(insn 13 6 14 2 (set (reg:DF 34 2)
        (const_double:DF 0.0 [0x0.0p+0])) "t.i":6:3 606 {*movdf_hardfloat64}
     (nil))

for the attached example.  This led to an ICE because register 34/fr2
was then live while allocating for pseudo 121.

gcc/ChangeLog:

* ira-lives.cc (ira_implicitly_set_insn_hard_regs): Honor hard
register constraints.
* ira.cc (ira_setup_alts): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/asm-hard-reg-1.c: New test.

4 months agoDeal with combinations of hard register constraints
Stefan Schulze Frielinghaus [Thu, 15 Jan 2026 14:14:59 +0000 (15:14 +0100)] 
Deal with combinations of hard register constraints

Currently, multiple hard register constraints in one alternative are not
supported.  Likewise, a combination of hard register constraints and
regular register constraints is not supported.  Note, a combination of
hard register constraints and non-register constraints as e.g. immediate
constraints is supported.  This is inspired by the i386 target where
constraints like aI are used which could be expressed as {ax}I, too.

gcc/ChangeLog:

* doc/extend.texi: Document current limitations of hard register
constraints.
* stmt.cc (parse_output_constraint): Reject multiple hard
register constraints or a combination of hard register
constraints and regular register constraints in one alternative.
(parse_input_constraint): Ditto.

gcc/testsuite/ChangeLog:

* gcc.dg/asm-hard-reg-error-1.c: Remove tests containing
multiple hard register constraints in one alternative.
* gcc.dg/asm-hard-reg-error-6.c: New test.

4 months agoaarch64: Add comment explaining code layout
Alfie Richards [Fri, 9 Jan 2026 16:51:34 +0000 (16:51 +0000)] 
aarch64: Add comment explaining code layout

gcc/ChangeLog:

* config/aarch64/aarch64-simd.md: Add comment.
* config/aarch64/aarch64-sme.md: Likewise.
* config/aarch64/aarch64-sve-builtins-base.def: Likewise.
* config/aarch64/aarch64-sve-builtins-sme.def: Likewise.
* config/aarch64/aarch64-sve-builtins-sve2.def: Likewise.
* config/aarch64/aarch64-sve-builtins.def: Likewise.
* config/aarch64/aarch64-sve.md: Likewise.
* config/aarch64/aarch64-sve2.md: Likewise.
* config/aarch64/aarch64.md: Likewise.

4 months agosparc: Remove TARGET_SUN_TLS
Rainer Orth [Thu, 15 Jan 2026 12:03:59 +0000 (13:03 +0100)] 
sparc: Remove TARGET_SUN_TLS

All remaining uses of TARGET_SUN_TLS refer to either

* a feature missing in Solaris as:

  Lack of support for R_SPARC_TLS_DTPOFF{32,64}: while Solaris ld
  supports those just fine, I know of no Solaris as syntax for them.

* workarounds for bugs in Solaris as in sparc_tls_got,
  sparc_legitimize_tls_address, and the tls_delay_slot attribute

Therefor this patch replaces all uses of TARGET_SUN_TLS with
!HAVE_GNU_AS.

Bootstrapped without regressions on sparc-sun-solaris2.11,
sparcv9-sun-solaris2.11 (as and gas), and sparc64-unknown-linux-gnu.

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

gcc:
* config/sparc/sparc.h (TARGET_SUN_TLS): Remove.
* config/sparc/sol2.h (TARGET_SUN_TLS): Likewise.

* config/sparc/sparc.cc (TARGET_ASM_OUTPUT_DWARF_DTPREL): Guard
with HAVE_GNU_AS.
(sparc_tls_got): Guard with !HAVE_GNU_AS.
(sparc_legitimize_tls_address): Likewise.
* config/sparc/sparc.md ("tls_delay_slot"): Likewise.
("@tie_add<P:mode>"): Likewise.

4 months agocompare-debug: Don't print discriminators for -fdump-final-insns= [PR121045]
Jakub Jelinek [Thu, 15 Jan 2026 11:03:34 +0000 (12:03 +0100)] 
compare-debug: Don't print discriminators for -fdump-final-insns= [PR121045]

Given the discussions in the PR, seems it is intentional that debug
stmts are taken into account when assigning discriminators which is
something that is actually never emitted into generated code, only
into debug info, so for -g0 we might as well not try to compute them
at all.

But discriminators are printed in the dumps, including -fdump-final-insns=
dump which affect -fcompare-debug.

So, the following patch arranges not to print discriminators in that
dump (i.e. when TDF_COMPARE_DEBUG is set in flags).

I think we should also (but it can be handled incrementally) add
some new TDF_* flag and -fdump-{tree,rtl,ipa}-<pass> modifier which
will also disable printing discriminators (similar to nouid/TDF_NOUID)
so that people can use it e.g. in -fcompare-debug -fdump-tree-all-nodiscrim
and don't have to ignore discrim N changes in the dumps.

This patch fixes
-FAIL: c-c++-common/torture/pr116156-1.c   -O1  (test for excess errors)
-FAIL: c-c++-common/torture/pr116156-1.c   -O2  (test for excess errors)
-FAIL: c-c++-common/torture/pr116156-1.c   -O2 -flto -fno-use-linker-plugin -flto-partition=none  (test for excess errors)
-FAIL: c-c++-common/torture/pr116156-1.c   -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions  (test for excess errors)
-FAIL: c-c++-common/torture/pr116156-1.c   -O3 -g  (test for excess errors)
-FAIL: c-c++-common/torture/pr116156-1.c   -Os  (test for excess errors)
-FAIL: g++.dg/torture/pr58552.C   -O1  (test for excess errors)
-FAIL: g++.dg/torture/pr58552.C   -O2  (test for excess errors)
-FAIL: g++.dg/torture/pr58552.C   -O2 -flto -fno-use-linker-plugin -flto-partition=none  (test for excess errors)
-FAIL: g++.dg/torture/pr58552.C   -O3 -g  (test for excess errors)
-FAIL: g++.dg/torture/pr58552.C   -Os  (test for excess errors)
so no testcase added for it.

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

PR debug/121045
* tree-pretty-print.h (dump_location): Add new dump_flags_t
argument defaulted to TDF_NONE.
* tree-pretty-print.cc (dump_location): Add flags argument.  Don't
print discriminator if TDF_COMPARE_DEBUG bit is set in flags.
(dump_block_node, dump_generic_node): Pass through flags to
dump_location.
* gimple-pretty-print.cc (dump_gimple_phi, pp_gimple_stmt_1,
dump_implicit_edges): Likewise.
(gimple_dump_bb_as_sarif_properties): Pass dump_flags to
dump_location.
* print-rtl.cc (rtx_writer::print_rtx_operand_code_L): If dump_flags
has TDF_COMPARE_DEBUG bit set, don't print discriminators.

4 months agoUse -m32/-m64 with Solaris/x86 as
Rainer Orth [Thu, 15 Jan 2026 10:13:49 +0000 (11:13 +0100)] 
Use -m32/-m64 with Solaris/x86 as

GCC currently uses -xarch=generic/-xarch=generic64 with Solaris/x86 as
to select either 32 or 64-bit output.  However, -xarch isn't even
documented any longer, but still accepted for compatibility.  Even for
-xchip, only generic is documented, not generic64.

This patch uses -m32/-m64 instead, which is already used in
gcc/configure.ac.

Bootstrapped without regressions on i386-pc-solaris2.11 and
amd64-pc-solaris2.11.

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

gcc:
* config/i386/sol2.h [!HAVE_GNU_AS] (ASM_CPU32_DEFAULT_SPEC): Use -m32.
(ASM_CPU64_DEFAULT_SPEC): Use -m64.

4 months agoipa/122852: Don't delete unreachable callback edges.
Josef Melcr [Mon, 8 Dec 2025 14:35:33 +0000 (15:35 +0100)] 
ipa/122852: Don't delete unreachable callback edges.

Hi,
previously, callback edges of a carrying edge redirected to
__builtin_unreachable  were deleted, as I thought they would
mess with the callgraph, given that they were no longer correct.
In some cases, the edges would be deleted when duplicating
a fn summary, producing a segfault. This patch changes this
behavior.  It redirects the callback edges to __builtin_unreachable and
adds an exception for such cases in the verifier.  Callback edges are
now also required to point to __builtin_unreachable if their carrying
edge is pointing to __builtin_unreachable.

Bootstrapped and regtested on x86_64-linux, no regressions.

OK for master?

Thanks,
Josef

PR ipa/122852

gcc/ChangeLog:

* cgraph.cc (cgraph_node::verify_node): Verify that callback
edges are unreachable when the carrying edge is unreachable.
* ipa-fnsummary.cc (redirect_to_unreachable): Redirect callback
edges to unreachable when redirecting the carrying edge.

libgomp/ChangeLog:

* testsuite/libgomp.c/pr122852.c: New test.

Signed-off-by: Josef Melcr <josef.melcr@suse.com>
4 months agosparc: Remove HAVE_AS_SPARC_UA_PCREL and HAVE_AS_SPARC_UA_PCREL_HIDDEN
Rainer Orth [Thu, 15 Jan 2026 08:50:04 +0000 (09:50 +0100)] 
sparc: Remove HAVE_AS_SPARC_UA_PCREL and HAVE_AS_SPARC_UA_PCREL_HIDDEN

The SPARC backend currently has workarounds for two bugs in old versions
of the assembler and linker.  However, I find both
HAVE_AS_SPARC_UA_PCREL and HAVE_AS_SPARC_UA_PCREL_HIDDEN are always
defined as 1 on both Solaris/SPARC and Linux/sparc64.

I've checked all combinations of the assemblers supported on SPARC: the
Solaris 11.4 FCS as and ld, current Solaris as and ld, gas and gld 2.30
and 2.45.  The tests work on all of those, so the workarounds can be
removed.

Bootstrapped on sparc-sun-solaris2.11 (as and gas) and
sparc64-unknown-linux-gnu.

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

gcc:
* configure.ac (gcc_cv_as_sparc_ua_pcrel): Remove.
(gcc_cv_as_sparc_ua_pcrel_hidden): Likewise.
* configure: Regenerate.
* config.in: Regenerate.

* config/sparc/sparc.h (ASM_PREFERRED_EH_DATA_FORMAT): Remove
!HAVE_AS_SPARC_UA_PCREL, !HAVE_AS_SPARC_UA_PCREL_HIDDEN support.
* config/sparc/sol2.h (ASM_PREFERRED_EH_DATA_FORMAT): Remove.
* config/sparc/sparc.cc (TARGET_ASM_OUTPUT_DWARF_DTPREL): Remove
HAVE_AS_SPARC_UA_PCREL guard.

4 months agosparc: Switch TARGET_SUN_TLS default
Rainer Orth [Thu, 15 Jan 2026 08:45:06 +0000 (09:45 +0100)] 
sparc: Switch TARGET_SUN_TLS default

sparc/sparc.h currently defaults to TARGET_SUN_TLS.  All other SPARC
targets and Solaris with GNU as have to override this, although this is
only needed on Solaris/SPARC with the native assembler.

To simplify the code, this patch switches the default to TARGET_SUN_TLS
set to 0, removing the need for all the overrides.

TARGET_GNU_TLS is only used in two places and can be replaced by
!TARGET_SUN_TLS, too.

Bootstrapped without regressions on sparc-sun-solaris2.11 (as and gas)
and sparc64-unknown-linux-gnu.

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

gcc:
* config/sparc/sparc.h (TARGET_TLS): Define as HAVE_AS_TLS.
Update comment.
(TARGET_SUN_TLS): Define as 0.
(TARGET_GNU_TLS): Remove.
* config/sparc/freebsd.h (TARGET_SUN_TLS): Remove.
(TARGET_GNU_TLS): Remove.
* config/sparc/linux.h: Likewise.
* config/sparc/linux64.h: Likewise.
* config/sparc/sol2.h (TARGET_SUN_TLS): Redefine as 1.
Guard with HAVE_AS_TLS && !HAVE_GNU_AS.
(TARGET_GNU_TLS): Remove.
* config/sparc/sparc.cc (TARGET_ASM_OUTPUT_DWARF_DTPREL): Use
!TARGET_SUN_TLS in guard.
with !TARGET_SUN_TLS only.
* config/sparc/sparc.md ("tls_delay_slot"): Guard with
!TARGET_SUN_TLS.

4 months agoRemove Solaris/SPARC ASM_OUTPUT_ALIGNED_COMMON [PR38118]
Rainer Orth [Thu, 15 Jan 2026 08:13:34 +0000 (09:13 +0100)] 
Remove Solaris/SPARC ASM_OUTPUT_ALIGNED_COMMON [PR38118]

sparc/sol2.h has its own definition of ASM_OUTPUT_ALIGNED_COMMON,
overriding the elfos.h version.  This was introduced back in 2010 as a
workaround for a bug in old versions of the Solaris/SPARC assembler (PR
target/38118).  However, even the Solaris 11.4 FCS as, the oldest one
currently supported, doesn't have this bug any longer.  Besides, the
workaround hasn't been effective anymore since GCC 10 without ill
effect.

Therefore the override definition can simply be removed.

Bootstrapped without regression on sparc-sun-solaris2.11 (as and gas).

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

gcc:
PR target/38118
* config/sparc/sol2.h (ASM_OUTPUT_ALIGNED_COMMON): Remove.

4 months agoFix x86 testsuite fallout from VF == 1 epilogue vectorization change
Richard Biener [Thu, 15 Jan 2026 07:55:34 +0000 (08:55 +0100)] 
Fix x86 testsuite fallout from VF == 1 epilogue vectorization change

The following fixes reported fallout with -march=cascadelake.

* gcc.dg/vect/fast-math-slp-38.c: Avoid epilogue vectorization.

4 months agoFix testsuite fallout of VF == 1 epilogue vectorization change
Richard Biener [Thu, 15 Jan 2026 07:51:36 +0000 (08:51 +0100)] 
Fix testsuite fallout of VF == 1 epilogue vectorization change

The following fixes a testsuite fallout on aarch64.

* gcc.dg/vect/complex/fast-math-complex-add-half-float.c:
Avoid epilogue vectorization.

4 months agotestsuite: Add testcase for already fixed PR [PR120322]
Jakub Jelinek [Thu, 15 Jan 2026 06:46:24 +0000 (07:46 +0100)] 
testsuite: Add testcase for already fixed PR [PR120322]

This testcase started to be miscompiled with r16-170 and got fixed
again with r16-960.

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

PR tree-optimization/120322
* gcc.dg/torture/pr120322.c: New test.

4 months ago[Autofdo] Add hierarchical discriminator for loop unrolling
Kugan Vivekanandarajah [Thu, 15 Jan 2026 03:40:32 +0000 (14:40 +1100)] 
[Autofdo] Add hierarchical discriminator for loop unrolling

Add hierarchical discriminator support for loop unrolling.
Assigns multiplicity and copyid discriminators to distinguish unrolled
iterations.

gcc/ChangeLog:

* cfgloopmanip.cc (duplicate_loop_body_to_header_edge): Assign
hierarchical discriminators for loop unrolling.
* cfgloopmanip.h (DLTHE_RECORD_HIERARCHICAL_DISCRIMINATOR): New flag.
* tree-ssa-loop-ivcanon.cc (try_unroll_loop_completely): Pass flag
to enable hierarchical discriminator assignment.
(try_peel_loop): Likewise.

gcc/testsuite/ChangeLog:

* gcc.dg/hierarchical-discriminator-unroll.c: New test.

Signed-off-by: Kugan Vivekanandarajah <kvivekananda@nvidia.com>
4 months ago[AutoFDO] Add hierarchical discriminator for loop versioning
Kugan Vivekanandarajah [Thu, 15 Jan 2026 03:39:33 +0000 (14:39 +1100)] 
[AutoFDO] Add hierarchical discriminator for loop versioning

Add hierarchical discriminator support for loop versioning pass.
Assigns copyid discriminators to distinguish different loop versions.

gcc/ChangeLog:

* gimple-loop-versioning.cc (loop_versioning::version_loop): Assign
copyid discriminators to distinguish different loop versions.

gcc/testsuite/ChangeLog:

* gcc.dg/hierarchical-discriminator-loop-version.c: New test.

Signed-off-by: Kugan Vivekanandarajah <kvivekananda@nvidia.com>
4 months ago[AutoFDO] Add hierarchical discriminator for vectorizer
Kugan Vivekanandarajah [Thu, 15 Jan 2026 03:37:50 +0000 (14:37 +1100)] 
[AutoFDO] Add hierarchical discriminator for vectorizer

Add hierarchical discriminator support for vectorized loop versioning.
Assigns copyid discriminators to distinguish vectorized and scalar versions.

gcc/ChangeLog:

* tree-vect-loop-manip.cc (vect_loop_versioning): Assign copyid
discriminators for vectorized and scalar loop versions.
* tree-vect-loop.cc (vect_transform_loop): Assign copyid
discriminators for vectorized and scalar loop versions.

gcc/testsuite/ChangeLog:

* gcc.dg/hierarchical-discriminator-vect-version.c: New test.

Signed-off-by: Kugan Vivekanandarajah <kvivekananda@nvidia.com>
4 months ago[Autofdo] Add hierarchical discriminator support
Kugan Vivekanandarajah [Thu, 15 Jan 2026 03:36:44 +0000 (14:36 +1100)] 
[Autofdo] Add hierarchical discriminator support

This patch introduces the basic infrastructure for hierarchical
discriminators with format [Base:8][Multiplicity:7][CopyID:11][Unused:6].
It adds helper functions to create and extract discriminator components.

gcc/ChangeLog:

* Makefile.in: Add hierarchical_discriminator.o to OBJS.
* hierarchical_discriminator.cc: New file.
* hierarchical_discriminator.h: New file.
* function.h (copyid_alloc): New.
* input.cc (location_with_discriminator_components): New function.
(get_discriminator_components_from_loc): Likewise.
* input.h (DISCR_BASE_BITS): New constant.
(DISCR_MULTIPLICITY_BITS): Likewise.
(DISCR_COPYID_BITS): Likewise.
(DISCR_UNUSED_BITS): Likewise.
(DISCR_BASE_MASK): Likewise.
(DISCR_MULTIPLICITY_MASK): Likewise.
(DISCR_COPYID_MASK): Likewise.
(DISCR_BASE_SHIFT): Likewise.
(DISCR_MULTIPLICITY_SHIFT): Likewise.
(DISCR_COPYID_SHIFT): Likewise.
(DISCR_BASE_MAX): Likewise.
(DISCR_MULTIPLICITY_MAX): Likewise.
(DISCR_COPYID_MAX): Likewise.
(location_with_discriminator_components): New function declaration.
(get_discriminator_components_from_loc): Likewise.

Signed-off-by: Kugan Vivekanandarajah <kvivekananda@nvidia.com>
4 months agoLoongArch: Fix ICE when explicit-relocs is none
DengJianbo [Tue, 13 Jan 2026 07:21:54 +0000 (15:21 +0800)] 
LoongArch: Fix ICE when explicit-relocs is none

When set -mexplicit-relocs=none, the symbol address should be caclulated
by macro instructions, for example la.local. Due to the condition
TARGET_CMODEL_EXTREME in movdi_symbolic_off64, this template can not be
matched in case the cmodel is normal. If the variable has attribute
model("extreme"), gcc will get crashed with error unrecognizable insns.
This patch fix this issue by removing TARGET_CMODEL_EXTREME, since it
already checked in prediction symbolic_off64_or_reg_operand.

gcc/ChangeLog:

* config/loongarch/loongarch.md: Remove condition in template
movdi_symbolic_off64.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/la64/attr-model-6.c: New test.

4 months agoa68: fix documentation of lseek in manual
Jose E. Marchesi [Wed, 14 Jan 2026 23:58:10 +0000 (00:58 +0100)] 
a68: fix documentation of lseek in manual

The first argument of lseek is a `long long int'.

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

* ga68.texi (POSIX files): Fix documentation of lseek.

4 months agoa68: fix documentation of -f[no-]brackets
Jose E. Marchesi [Fri, 9 Jan 2026 23:53:48 +0000 (00:53 +0100)] 
a68: fix documentation of -f[no-]brackets

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

* ga68.texi (Dialect options): {..} is not a valid variant of
(...).

4 months agoDaily bump.
GCC Administrator [Thu, 15 Jan 2026 00:16:30 +0000 (00:16 +0000)] 
Daily bump.

4 months agoRISC-V: Enable the ZD constraint only when xmipscbop is enabled [PR123092]
Peter Bergner [Wed, 14 Jan 2026 21:12:21 +0000 (15:12 -0600)] 
RISC-V: Enable the ZD constraint only when xmipscbop is enabled [PR123092]

The ZD constraint is specific to the mips prefetch instruction.  It is
currently always enabled, leading to ICEs when xmipscbop is disabled.
Solved by only enabling the ZD constraint whenever xmipscbop is enabled.

2026-01-14  Peter Bergner  <bergner@tenstorrent.com>

gcc/
PR target/123092
* config/riscv/constraints.md (ZD): Disable when xmipscbop is disabled.

Signed-off-by: Peter Bergner <bergner@tenstorrent.com>
4 months agoC: fix issues when supporting counted_by fields in anonymous structure/unions [PR1224...
Qing Zhao [Wed, 14 Jan 2026 17:14:01 +0000 (17:14 +0000)] 
C: fix issues when supporting counted_by fields in anonymous structure/unions [PR122495,PR122496]

Currently, GCC does not fully support the cases when a FAM or pointer field and
its corresponding counted_by field are in different anonymous structure/unions
of a common named structure.

For example:

struct nested_mixed {
  struct {
    union {
      int b;
      float f;
    };
    int n;
  };
  struct {
    PTR_TYPE *pointer __attribute__((__counted_by__(n)));
    FAM_TYPE c[] __attribute__((__counted_by__(b)));
  };
} *nested_mixed_annotated;

In order to support such cases, we always need to locate the first outer
named structure as the root, and then lookup_field inside this named
structure. When building the component_ref for the counted_by field,
we need to build a chain of component_ref starting from the root structure.

When supporting the above in general, we also need to handle the following
several special cases correctly:

A. Support an untagged type as its own top-level type.  */
struct { int a; char b[] __attribute__ ((counted_by (a))); } *x;

B. Support an unnamed field with a named struct/union.  */
struct s { struct { int a; char b[] __attribute__ ((counted_by (a))); } *x; } *y;

C. When -fms-extensions is enabled:

   C.1 Do not support the inward-to-outward counted-by field reference
       since checking the validity of such reference depends on unknown
       situation at the end of the structure definition.

struct bar {
  char *buf __counted_by (n); /* { dg-error "attribute is not a field declaration in the same structure as" } */
};

   C.2 support the outward-to-inward counted-by field reference.

PR C/122495
PR C/122496

gcc/c/ChangeLog:

* c-decl.cc (grokfield): Call verify_counted_by_for_top_anonymous_type
for named field.
(verify_counted_by_attribute): Change the prototype to a recursive
routine.
(verify_counted_by_for_top_anonymous_type): New routine.
(finish_struct): Set C_TYPE_FIELDS_HAS_COUNTED_BY and call the routine
verify_counted_by_attribute only for named structure.
* c-parser.cc (c_parser_declaration_or_fndef): Call
verify_counted_by_for_top_anonymous_type for the decl.
(c_parser_parameter_declaration): Call
verify_counted_by_for_top_anonymous_type for the parameter.
(c_parser_type_name): Call verify_counted_by_for_top_anonymous_type
for the type.
* c-tree.h (C_TYPE_FIELDS_HAS_COUNTED_BY): New flag.
(verify_counted_by_for_top_anonymous_type): New routine.
* c-typeck.cc (build_counted_by_ref): Locate the root named structure,
build a chain of component_ref starting from the root structure.

gcc/testsuite/ChangeLog:

* gcc.dg/counted-by-anonymous-2-char.c: New test.
* gcc.dg/counted-by-anonymous-2-float.c: New test.
* gcc.dg/counted-by-anonymous-2-struct.c: New test.
* gcc.dg/counted-by-anonymous-2-union.c: New test.
* gcc.dg/counted-by-anonymous-2.c: New test.
* gcc.dg/counted-by-anonymous-3.c: New test.
* gcc.dg/counted-by-anonymous.c: New test.
* gcc.dg/ubsan/counted-by-anonymous-bounds-1.c: New test.
* gcc.dg/ubsan/counted-by-anonymous-bounds-2.c: New test.
* gcc.dg/ubsan/counted-by-anonymous-bounds.c: New test.

4 months agoMAINTAINERS: update my email address
Vineet Gupta [Wed, 14 Jan 2026 19:11:18 +0000 (11:11 -0800)] 
MAINTAINERS: update my email address

ChangeLog

* MAINTAINERS: Update to my linux.dev email.

Signed-off-by: Vineet Gupta <vineet.gupta@linux.dev>
4 months agoipa-cp: Always return the right type in ipa_value_from_jfunc (PR123542)
Martin Jambor [Wed, 14 Jan 2026 19:41:57 +0000 (20:41 +0100)] 
ipa-cp: Always return the right type in ipa_value_from_jfunc (PR123542)

PR 123542 is about triggering a checking assert that verifies that we
indeed clone a function for the constant value we started evaluating.
The issue is that we get a double 2 instead of a float 2 which comes
down to function ipa_value_from_jfunc not doing the necessary
conversion when dealing directly with constants (and ancestor jump
functions but that is very unlikley to cause problems).

This patch makes sure the required conversion is performed in all
cases (even for the ancestor JFs) and checks that the result type is
known, because when the function is invoked from ipa-modref.cc or
ipa-fnsummary.cc that may not be the case.

gcc/ChangeLog:

2026-01-14  Martin Jambor  <mjambor@suse.cz>

PR ipa/123542
* ipa-cp.cc (ipa_value_from_jfunc): Always use
ipacp_value_safe_for_type.  Bail out if parm_type is NULL.

gcc/testsuite/ChangeLog:

2026-01-14  Martin Jambor  <mjambor@suse.cz>

PR ipa/123542
* gcc.dg/ipa/pr123542.c: New test.

4 months agotestsuite: Enable cross testing for simulate-thread tests
Joseph Myers [Wed, 14 Jan 2026 17:10:33 +0000 (17:10 +0000)] 
testsuite: Enable cross testing for simulate-thread tests

The simulate-thread tests exit early in cross and remote cases.  Apply
fixes similar to (but affecting separate code) those recently posted
for the guality tests: do not use [transform gdb] since that's a cross
GDB and the tests expect to run GDB on the target, test existence on
the target not the build system, and copy required files to the target
(deleting them later).

Tested for x86_64-pc-linux-gnu to make sure native testing isn't
broken, and with cross to aarch64-linux.

* lib/gcc-dg.exp (gdb-exists): Do not use [transform gdb].  Run
selected GDB with -v on target rather than testing for existence
on build system.
* lib/gcc-simulate-thread.exp (simulate-thread): Do not return
early for non-native and remote.  Download executable and GDB
command file to target before running GDB there, and delete when
closing target.

4 months agotestsuite: Fix issues with cross testing in guality tests
Joseph Myers [Wed, 14 Jan 2026 17:09:40 +0000 (17:09 +0000)] 
testsuite: Fix issues with cross testing in guality tests

The guality tests expect to run (native) GDB on the target.  If this
is available, there is some support for cross testing, but with
various defects and limitations, some of them fixed here.

* GUALITY_GDB_NAME doesn't get passed through to the target for remote
  testing (a general limitation of the DejaGnu interface: it doesn't
  support setting environment variables on the target).  Not fixed
  here.

* Using in-tree GDB is only appropriate when host = target, since
  in-tree GDB runs on the host and the testsuite runs GDB on the
  target.  Fixed here.  (Note that [isnative] isn't used because that
  refers to build = target, and we need host = target here.)

* [transform gdb] is not appropriate because that's a cross-GDB and
  the tests run GDB on the target, so need a native GDB.  Fixed here.

* gdb-test (used by some guality tests) exits early in cross and
  remote cases (whereas the tests running GDB directly from the test
  itself via popen can already do so on the target without needing
  further patches).  Fixed here.  There are various other fixes done
  in gdb-test as well; it needs to transfer files to the target then
  delete them afterwards.

* report_gdb expects to run GDB on the host when the tests run it on
  the target.  Fixed here.

Note: some similar fixes will also be needed for simulate-thread tests
to get them working for cross testing, but I haven't done those yet.

Tested for x86_64-pc-linux-gnu to make sure native testing isn't
broken, and with cross to aarch64-linux.

* lib/gcc-gdb-test.exp (gdb-test): Do not return early for
non-native and remote.  Download executable and GDB command file
to target before running GDB there, and delete when closing
target.
(report_gdb): Use target when testing GDB availability and
version.
* g++.dg/guality/guality.exp: Only use in-tree GDB when host =
target.  Do not use [transform gdb].
* gcc.dg/guality/guality.exp: Likewise.
* gfortran.dg/guality/guality.exp: Likewise.

4 months agoc++: UX improvements for close matches in print_candidates
David Malcolm [Wed, 14 Jan 2026 16:49:12 +0000 (11:49 -0500)] 
c++: UX improvements for close matches in print_candidates

This patch improves the UX for various cases of "no declaration matches"
where print_candidates encounters a close match.

For example, consider the const vs non-const here:

class foo
{
public:
  void test (int i, int j, void *ptr, int k);
};

// Wrong "const"-ness of param 3.
void foo::test (int i, int j, const void *ptr, int k)
{
}

where we emit (with indentation provided by the prior patch):

test.cc:8:6: error: no declaration matches ‘void foo::test(int, int, const void*, int)’
    8 | void foo::test (int i, int j, const void *ptr, int k)
      |      ^~~
  • there is 1 candidate
    • candidate is: ‘void foo::test(int, int, void*, int)’
      test.cc:4:8:
          4 |   void test (int i, int j, void *ptr, int k);
            |        ^~~~
test.cc:1:7: note: ‘class foo’ defined here
    1 | class foo
      |       ^~~

which requires the user to look through the pairs of parameters
and try to find the mismatch by eye.

This patch adds notes identifying that parameter 3 has the mismatch, and
what the mismatch is, using a pair of colors to highlight and contrast
the type mismatch.

test.cc:8:6: error: no declaration matches ‘void foo::test(int, int, const void*, int)’
    8 | void foo::test (int i, int j, const void *ptr, int k)
      |      ^~~
  • there is 1 candidate
    • candidate is: ‘void foo::test(int, int, void*, int)’
      test.cc:4:8:
          4 |   void test (int i, int j, void *ptr, int k);
            |        ^~~~
      • parameter 3 of candidate has type ‘void*’...
        test.cc:4:34:
            4 |   void test (int i, int j, void *ptr, int k);
              |                            ~~~~~~^~~
      • ...which does not match type ‘const void*’
        test.cc:8:43:
            8 | void foo::test (int i, int j, const void *ptr, int k)
              |                               ~~~~~~~~~~~~^~~
test.cc:1:7: note: ‘class foo’ defined here
    1 | class foo
      |       ^~~

This also works for the "this" case, improving the UX for messing up
const vs non-const between decls and defns of member functions; see
bad-fndef-2.C for an example.

For screenshots showing the colorization effect, see slides 9-12 of my
Cauldron talk:
https://gcc.gnu.org/wiki/cauldron2025#What.27s_new_with_diagnostics_in_GCC_16
("Hierarchical diagnostics (not yet in trunk)").

gcc/cp/ChangeLog:
* call.cc (get_fndecl_argument_location): Use DECL_SOURCE_LOCATION
for "this".
* cp-tree.h (class candidate_context): New.
(print_candidates): Add optional candidate_context param.
* decl2.cc: Include "gcc-rich-location.h" and
"tree-pretty-print-markup.h".
(struct fndecl_signature): New.
(class parm_rich_location): New.
(class fndecl_comparison): New.
(class decl_mismatch_context): New.
(check_classfn): For the "no declaration matches" case, pass an
instance of a custom candidate_context subclass to
print_candidates, using fndecl_comparison to report on close
matches.
* pt.cc (print_candidates): Add optional candidate_context param.
Use it if provided to potentially emit per-candidate notes.

gcc/testsuite/ChangeLog:
* g++.dg/diagnostic/bad-fndef-1.C: Add directives to expect
"void *" vs "const void *" notes about parameter 3 of the close
candidate.
* g++.dg/diagnostic/bad-fndef-2.C: New test.
* g++.dg/diagnostic/bad-fndef-3.C: New test.
* g++.dg/diagnostic/bad-fndef-4.C: New test.
* g++.dg/diagnostic/bad-fndef-5.C: New test.
* g++.dg/diagnostic/bad-fndef-6.C: New test.
* g++.dg/diagnostic/bad-fndef-7.C: New test.
* g++.dg/diagnostic/bad-fndef-7b.C: New test.
* g++.dg/diagnostic/bad-fndef-8.C: New test.
* g++.dg/diagnostic/bad-fndef-9.C: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 months agoc++: use nesting and counts in print_candidates
David Malcolm [Wed, 14 Jan 2026 16:43:57 +0000 (11:43 -0500)] 
c++: use nesting and counts in print_candidates

In r15-6116-gd3dd24acd74605 I updated print_z_candidates to print a
count of the number of candidates, and to show the number of each
candidate in the list if there is more than one.

The following patch updates print_candidates to work in a similar
way, showing counts, numbering, and using nesting.

Consider this test case for which we print 2 candidates:

class foo
{
public:
  void test (int i, int j, void *ptr, int k);
  void test (int i, int j, int k);
};

// Wrong "const"-ness of a param, for one of the overloads (param 3).
void foo::test (int i, int j, const void *ptr, int k)
{
}

The output before the patch is:

test.cc:9:6: error: no declaration matches ‘void foo::test(int, int, const void*, int)’
    9 | void foo::test (int i, int j, const void *ptr, int k)
      |      ^~~
test.cc:5:8: note: candidates are: ‘void foo::test(int, int, int)’
    5 |   void test (int i, int j, int k);
      |        ^~~~
test.cc:4:8: note:                 ‘void foo::test(int, int, void*, int)’
    4 |   void test (int i, int j, void *ptr, int k);
      |        ^~~~
test.cc:1:7: note: ‘class foo’ defined here
    1 | class foo
      |       ^~~

With the patch, the output looks like:

test.cc:9:6: error: no declaration matches ‘void foo::test(int, int, const void*, int)’
    9 | void foo::test (int i, int j, const void *ptr, int k)
      |      ^~~
  • there are 2 candidates
    • candidate 1: ‘void foo::test(int, int, int)’
      test.cc:5:8:
          5 |   void test (int i, int j, int k);
            |        ^~~~
    • candidate 2: ‘void foo::test(int, int, void*, int)’
      test.cc:4:8:
          4 |   void test (int i, int j, void *ptr, int k);
            |        ^~~~
test.cc:1:7: note: ‘class foo’ defined here
    1 | class foo
      |       ^~~

which I believe is much more readable.

I dabbled with removing the "there is 1 candidate" line for the case of
a single candidate, but I think I prefer it to be present.

FWIW I've been experimenting with followups that
* show more nested information about the problems (e.g. the "void *"
vs "const void *" mismatch) - having the candidates be nested is a
useful step towards that
* potentially look at the "edit distance" of the type signatures to find
close matches, and perhaps reordering/highlighting them (e.g. in the
above candidate 2 is arguably a closer match than candidate 1, due to
the "const" snafu) - gathering an auto_vec might help with that.

gcc/cp/ChangeLog:
* call.cc (print_z_candidates): Move inform_n call into a new
inform_num_candidates function.
* class.cc (check_methods): Pass location to call to
print_candidates.
(resolve_address_of_overloaded_function): Likewise.
* cp-tree.h (print_candidates): Add location_t param.
(inform_num_candidates): New decl.
* decl.cc (make_typename_type): Pass location to call to
print_candidates.
(reshape_init_class): Likewise.
(lookup_and_check_tag): Likewise.
* decl2.cc (check_classfn): Likewise.
* error.cc (qualified_name_lookup_error): Likewise.
* init.cc (build_new_1): Likewise.
* name-lookup.cc (lookup_using_decl): Likewise.
(set_decl_namespace): Likewise.
(push_namespace): Likewise.
* parser.cc (cp_parser_nested_name_specifier_opt): Likewise.
(cp_parser_lookup_name): Likewise.
* pt.cc  (print_candidates_1): Drop, converting the looping part
into...
(flatten_candidates): ...this new function.
(inform_num_candidates): New function.
(print_candidates): Use flatten_candidates to build an auto_vec
of candidates, and use this to print them here, rather than in
print_candidates_1.  Eliminate the dynamic allocation of spaces
for a prefix in favor of printing "candidate %i" when there is
more than one candidate.  Add "error_loc" param and pass it to
inform_num_candidates to show a heading, and add nesting levels
for it and for the candidate notes.
(determine_specialization): Pass location to calls to
print_candidates.
* search.cc (lookup_member): Likewise.
* semantics.cc (finish_id_expression_1): Likewise.

gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/inline-ns2.C: Make dg-message directives non-empty.
* g++.dg/cpp23/explicit-obj-lambda11.C: Prune the extra note.
* g++.dg/diagnostic/bad-fndef-1.C: New test.
* g++.dg/lookup/decl1.C: Give the dg-message directives different
messages.
* g++.dg/lookup/using17.C: Update expected output.
* g++.dg/parse/non-dependent2.C: Likewise.
* g++.old-deja/g++.other/lineno2.C: Give the dg-message directives
different messages.
* g++.old-deja/g++.pt/t37.C: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 months agoc++: Don't ICE on computed goto in potential_constant_expression_1 [PR123551]
Jakub Jelinek [Wed, 14 Jan 2026 16:09:13 +0000 (17:09 +0100)] 
c++: Don't ICE on computed goto in potential_constant_expression_1 [PR123551]

r16-968-g5c6364b09a6 has added if (DECL_ARTIFICIAL (*target)) return true;
stmt for GOTO_EXPRs.  This unfortunately ICEs if *target is not a decl,
which is the case for computed gotos.  For those we should always reject
them, so the following patch additionally checks for LABEL_DECL
before testing DECL_ARTIFICIAL on it.

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

PR c++/123551
* constexpr.cc (potential_constant_expression_1) <case GOTO_EXPR>:
Only test DECL_ARTIFICIAL on LABEL_DECLs.

* g++.dg/ext/goto2.C: New test.

4 months agoAArch64: Use anchors for FP constants [PR 121240]
Wilco Dijkstra [Tue, 13 Jan 2026 16:21:05 +0000 (16:21 +0000)] 
AArch64: Use anchors for FP constants [PR 121240]

Use anchors for FP constants - instead of using mergeable sections which blocks
anchors, load FP constants from the constdata section.  To avoid the anchor
loads being deoptimized later, ensure the cost of a CONST_DOUBLE is larger than
the cost of a MEM that loads it from constdata.  Codesize is slightly smaller,
performance on SPECFP2017 is ~0.30% better.

gcc:
PR target/121240
* config/aarch64/aarch64.md (mov<mode>): Expand FP immediates early.
* config/aarch64/aarch64.cc (aarch64_select_rtx_section): Force
immediates <= 8 bytes to constdata.
(aarch64_rtx_costs): Increase cost of CONST_DOUBLE loaded from memory.

gcc/testsuite:
PR target/121240
* gcc.target/aarch64/dbl_mov_immediate_1.c: Adjust test.
* gcc.target/aarch64/pr63304_1.c: Likewise.

4 months agoAArch64: Improve immediate generation [PR 114528]
Wilco Dijkstra [Mon, 12 Jan 2026 14:19:46 +0000 (14:19 +0000)] 
AArch64: Improve immediate generation [PR 114528]

Improve immediate generation to support 2-instruction MOV+ADD/SUB
of 12-bit shifted immediate. Eg.

long f1 (void)
{
  return 0x123400567000;
}

now generates:

mov     x0, 20014547599360
add     x0, x0, 5664768
ret

gcc:
PR target/114528
* config/aarch64/aarch64.cc (aarch64_check_mov_add_imm12):
New function to check and emit MOV+ADD/SUB immediates.
(aarch64_internal_mov_immediate): Add support for MOV+ADD/SUB
immediates.

gcc/testsuite:
PR target/114528
* gcc.target/aarch64/pr114528.c: New test.

4 months agoexpand: Handle variable-length vector constructors with debug [PR123392]
Tejas Belagod [Tue, 13 Jan 2026 16:58:38 +0000 (16:58 +0000)] 
expand: Handle variable-length vector constructors with debug [PR123392]

Variable-length Vector initializer constructors currently only work in
non-debug mode.  It ICEs when compiled with -g.  This patch fixes it to handle
variable-length vector intialization by limiting the constructor elements to
the lower bound of the variable length poly which is also the maximum number
of elements allowed in the initializer.

PR middle-end/123392
gcc/
* cfgexpand.cc (expand_debug_expr): Handle variable-length initializer
for CONSTRUCTOR.

gcc/testsuite/

* gcc.target/aarch64/sve/acle/general/pr123392.c: New.

4 months agoAdd 'libgomp.c++/target-std__[...]-concurrent-usm.C' test cases for C++ 'std::unorder...
Thomas Schwinge [Fri, 30 May 2025 09:37:46 +0000 (11:37 +0200)] 
Add 'libgomp.c++/target-std__[...]-concurrent-usm.C' test cases for C++ 'std::unordered_map', 'std::unordered_multimap', 'std::unordered_multiset', 'std::unordered_set'

libgomp/
* testsuite/libgomp.c++/target-std__unordered_map-concurrent-usm.C:
New.
* testsuite/libgomp.c++/target-std__unordered_multimap-concurrent-usm.C:
Likewise.
* testsuite/libgomp.c++/target-std__unordered_multiset-concurrent-usm.C:
Likewise.
* testsuite/libgomp.c++/target-std__unordered_set-concurrent-usm.C:
Likewise.
* testsuite/libgomp.c++/target-std__unordered_map-concurrent.C:
Adjust.
* testsuite/libgomp.c++/target-std__unordered_multimap-concurrent.C:
Likewise.
* testsuite/libgomp.c++/target-std__unordered_multiset-concurrent.C:
Likewise.
* testsuite/libgomp.c++/target-std__unordered_set-concurrent.C:
Likewise.

4 months agoAdd 'libgomp.c++/target-std__[...]-concurrent-usm.C' test cases for C++ 'std::flat_ma...
Thomas Schwinge [Fri, 30 May 2025 09:37:46 +0000 (11:37 +0200)] 
Add 'libgomp.c++/target-std__[...]-concurrent-usm.C' test cases for C++ 'std::flat_map', 'std::flat_multimap', 'std::flat_multiset', 'std::flat_set'

libgomp/
* testsuite/libgomp.c++/target-std__flat_map-concurrent-usm.C:
New.
* testsuite/libgomp.c++/target-std__flat_multimap-concurrent-usm.C:
Likewise.
* testsuite/libgomp.c++/target-std__flat_multiset-concurrent-usm.C:
Likewise.
* testsuite/libgomp.c++/target-std__flat_set-concurrent-usm.C:
Likewise.
* testsuite/libgomp.c++/target-std__flat_map-concurrent.C: Adjust.
* testsuite/libgomp.c++/target-std__flat_multimap-concurrent.C:
Likewise.
* testsuite/libgomp.c++/target-std__flat_multiset-concurrent.C:
Likewise.
* testsuite/libgomp.c++/target-std__flat_set-concurrent.C:
Likewise.

4 months agoFix up 'libgomp.c++/target-std__[...]-concurrent-usm.C' dynamic memory allocation
Thomas Schwinge [Fri, 30 May 2025 09:37:46 +0000 (11:37 +0200)] 
Fix up 'libgomp.c++/target-std__[...]-concurrent-usm.C' dynamic memory allocation

OpenMP/USM implies memory accessible from host as well as device, but doesn't
imply that allocation vs. deallocation may be done in the opposite context.
For most of the test cases, (by construction) we're not allocating memory
during device execution, so have nothing to clean up.  (..., but still document
these semantics.)  But for a few, we have to clean up:
'libgomp.c++/target-std__map-concurrent-usm.C',
'libgomp.c++/target-std__multimap-concurrent-usm.C',
'libgomp.c++/target-std__multiset-concurrent-usm.C',
'libgomp.c++/target-std__set-concurrent-usm.C'.

For 'libgomp.c++/target-std__multimap-concurrent-usm.C' (only), this issue
already got addressed in commit 90f2ab4b6e1463d8cb89c70585e19987a58f3de1
"libgomp.c++/target-std__multimap-concurrent.C: Fix USM memory freeing".
However, instead of invoking the 'clear' function (which doesn't generally
guarantee to release dynamically allocated memory; for example, see PR123582
"C++ unordered associative container: dynamic memory management"), we properly
restore the respective object into pristine state.

libgomp/
* testsuite/libgomp.c++/target-std__array-concurrent-usm.C:
'#define OMP_USM'.
* testsuite/libgomp.c++/target-std__forward_list-concurrent-usm.C:
Likewise.
* testsuite/libgomp.c++/target-std__list-concurrent-usm.C:
Likewise.
* testsuite/libgomp.c++/target-std__span-concurrent-usm.C:
Likewise.
* testsuite/libgomp.c++/target-std__map-concurrent-usm.C:
Likewise.
* testsuite/libgomp.c++/target-std__multimap-concurrent-usm.C:
Likewise.
* testsuite/libgomp.c++/target-std__multiset-concurrent-usm.C:
Likewise.
* testsuite/libgomp.c++/target-std__set-concurrent-usm.C:
Likewise.
* testsuite/libgomp.c++/target-std__valarray-concurrent-usm.C:
Likewise.
* testsuite/libgomp.c++/target-std__vector-concurrent-usm.C:
Likewise.
* testsuite/libgomp.c++/target-std__bitset-concurrent-usm.C:
Likewise.
* testsuite/libgomp.c++/target-std__deque-concurrent-usm.C:
Likewise.
* testsuite/libgomp.c++/target-std__array-concurrent.C: Comment.
* testsuite/libgomp.c++/target-std__bitset-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__deque-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__forward_list-concurrent.C:
Likewise.
* testsuite/libgomp.c++/target-std__list-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__span-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__valarray-concurrent.C:
Likewise.
* testsuite/libgomp.c++/target-std__vector-concurrent.C: Likewise.
* testsuite/libgomp.c++/target-std__map-concurrent.C [OMP_USM]:
Fix up dynamic memory allocation.
* testsuite/libgomp.c++/target-std__multimap-concurrent.C
[OMP_USM]: Likewise.
* testsuite/libgomp.c++/target-std__multiset-concurrent.C
[OMP_USM]: Likewise.
* testsuite/libgomp.c++/target-std__set-concurrent.C [OMP_USM]:
Likewise.

4 months agolibgomp: Add a few more OpenMP/USM test cases
Thomas Schwinge [Fri, 9 May 2025 13:09:51 +0000 (15:09 +0200)] 
libgomp: Add a few more OpenMP/USM test cases

... where there are clear differences in behavior for OpenMP/USM run-time
configurations.

We shall further clarify all the intended semantics, once the implementation
begins to differentiate OpenMP 'requires unified_shared_memory' vs.
'requires self_maps'.

libgomp/
* testsuite/libgomp.c-c++-common/map-arrayofstruct-2-usm.c: New.
* testsuite/libgomp.c-c++-common/map-arrayofstruct-3-usm.c:
Likewise.
* testsuite/libgomp.c-c++-common/struct-elem-5-usm.c: Likewise.
* testsuite/libgomp.c-c++-common/target-present-1-usm.c: Likewise.
* testsuite/libgomp.c-c++-common/target-present-2-usm.c: Likewise.
* testsuite/libgomp.c-c++-common/target-present-3-usm.c: Likewise.
* testsuite/libgomp.fortran/map-subarray-5-usm.f90: Likewise.
* testsuite/libgomp.fortran/map-subarray-6-usm.f90: Likewise.
* testsuite/libgomp.fortran/map-subarray-7-usm.f90: Likewise.
* testsuite/libgomp.fortran/target-allocatable-1-1-usm.f90:
Likewise.
* testsuite/libgomp.fortran/target-allocatable-1-2-usm.f90:
Likewise.
* testsuite/libgomp.fortran/target-enter-data-2-usm.F90: Likewise.
* testsuite/libgomp.fortran/target-present-1-usm.f90: Likewise.
* testsuite/libgomp.fortran/target-present-2-usm.f90: Likewise.
* testsuite/libgomp.fortran/target-present-3-usm.f90: Likewise.
* testsuite/libgomp.fortran/target-allocatable-1-1.f90: Adjust.
* testsuite/libgomp.fortran/target-allocatable-1-2.f90: Likewise.
* testsuite/libgomp.fortran/target-present-1.f90: Likewise.
* testsuite/libgomp.fortran/target-present-2.f90: Likewise.
* testsuite/libgomp.fortran/target-present-3.f90: Likewise.

4 months agodefaults: Use argument in default EH_RETURN_DATA_REGNO definition [PR123115]
Jakub Jelinek [Wed, 14 Jan 2026 14:56:29 +0000 (15:56 +0100)] 
defaults: Use argument in default EH_RETURN_DATA_REGNO definition [PR123115]

All targets use the EH_RETURN_DATA_REGNO macro argument except for
NVPTX which uses the default.
The problem is that we get then -Wunused-but-set-variable warning
when building df-scan.cc for NVPTX target with GCC 16 (post r16-2258
PR44677) on:
      unsigned int i;
      /* Mark the registers that will contain data for the handler.  */
      for (i = 0; ; ++i)
        {
          unsigned regno = EH_RETURN_DATA_REGNO (i);
          if (regno == INVALID_REGNUM)
            break;
If it were multiple targets suffering from this, I'd think about
adding something to use i in loops like this, but as it is
just the default definition, the following patch fixes it by
using the argument.

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

PR middle-end/123115
* defaults.h (EH_RETURN_DATA_REGNO): Add void (N) to the macro
definition inside of a comma expression before INVALID_REGNUM.

4 months agocombine: Partially revert the r12-4475 changes [PR120250]
Jakub Jelinek [Wed, 14 Jan 2026 14:53:44 +0000 (15:53 +0100)] 
combine: Partially revert the r12-4475 changes [PR120250]

The r12-4475 change added extra code to recog_for_combine to attempt to
force some constants into the constant pool.
Unfortunately, as this (UB at runtime) testcase shows, such changes are
harmful for computed_jump_p jumps.  The computed_jump_p returns false
for loads from constant pool MEMs:
    case MEM:
      return ! (GET_CODE (XEXP (x, 0)) == SYMBOL_REF
                && CONSTANT_POOL_ADDRESS_P (XEXP (x, 0)));
and so if we try to optimize a computed jump that way, it becomes
a non-computed jump which doesn't match any other jump category
(simplejump_p, tablejump_p, condjump_p, returnjump_p, eh_returnjump_p,
asm goto) and doesn't have any label recorded in JUMP_LABEL (because,
it doesn't really jump to any LABEL), so some passes like dwarf2cfi
can get confused about it and ICE.

The following patch just prevents that, by only doing the r12-4475
changes if it is not a jump.

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

PR target/120250
* combine.cc (recog_for_combine): Don't try to put SET_SRC
into a constant pool if SET_DEST is pc_rtx.

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

4 months agotree-optimization/123190 - fix costing of permuted contiguous loads
Richard Biener [Wed, 14 Jan 2026 11:45:19 +0000 (12:45 +0100)] 
tree-optimization/123190 - fix costing of permuted contiguous loads

The following fixes a regression from the time we split load groups
along SLP boundaries.  When we face a permuted load from an access
that is contiguous across loop iterations we emit code that loads
the whole group and then emit required permutations.  The permutations
might not need all those loads, and if we split the group we would
not have emitted them.  Fortunately when analyzing a permutation
we compute both the number of required permutes and the number of
loads that will survive the followin DCE.  So make sure to use that
when costing.  This allows the previously added testcase for PR123190
to undergo epilog vectorization also at -O2 plus when using non-generic
tuning, such as tuning for Zen4 which ups the cost for XMM loads.

PR tree-optimization/123190
* tree-vectorizer.h (vect_load_store_data): Add n_loads member.
* tree-vect-stmts.cc (get_load_store_type): Record the
number of required loads for permuted loads.
(vectorizable_load): Make use of this when costing loads
for VMAT_CONTIGUOUS[_REVERSE].

* gcc.dg/vect/costmodel/x86_64/costmodel-pr123190-1.c: Do not
require -mtune=generic.
* gcc.dg/vect/costmodel/x86_64/costmodel-pr123190-2.c: Add
variant with -O2 instead of -O3, inner loop not unrolled.

4 months agotree-optimization/123190 - allow VF == 1 epilog vectorization
Richard Biener [Wed, 14 Jan 2026 09:53:05 +0000 (10:53 +0100)] 
tree-optimization/123190 - allow VF == 1 epilog vectorization

The following adjusts the condition where we reject vectorization
because the scalar loop runs only for a single iteration (or two,
in case we need to peel for gaps).  Because this is over-eager
when considering the case of VF == 1 where instead the cost model
should decide wheter it is worthwhile or not.  I'm playing
conservative here and exclude the case of two iterations as I
do not have benchmark evidence.

This helps fixing a regression observed with improved SLP handling,
not exactly for the options used in the PR though, but for a more
common -O3 -march=x86-64-v3 this speeds up 433.milc by 6%.

PR tree-optimization/123190
* tree-vect-loop.cc (vect_analyze_loop_costing): Allow
vectorizing loops with a single scalar iteration iff the
vectorization factor is 1.

* gcc.dg/vect/costmodel/x86_64/costmodel-pr123190-1.c: New testcase.
* gcc.dg/vect/slp-28.c: Avoid epilogue vectorization for
simplicity.

4 months agosimplify-rtx: Fix up SUBREG and LSHIFTRT order canonicalization for AND with constant...
Jakub Jelinek [Wed, 14 Jan 2026 12:21:57 +0000 (13:21 +0100)] 
simplify-rtx: Fix up SUBREG and LSHIFTRT order canonicalization for AND with constant [PR123544]

On Tue, Nov 04, 2025 at 12:59:03PM +0530, Kishan Parmar wrote:
>       PR rtl-optimization/93738
>       * simplify-rtx.cc (simplify_binary_operation_1): Canonicalize
>       SUBREG(LSHIFTRT) into LSHIFTRT(SUBREG) when valid.

This change regressed the following testcase on aarch64-linux.
From what I can see, the PR93738 change has been written with non-paradoxical
SUBREGs in mind but on this testcase on aarch64 we have a paradoxical SUBREG,
in particular simplify_binary_operation_1 is called with AND, SImode,
(subreg:SI (lshiftrt:HI (subreg:HI (reg/v:SI 108 [ x ]) 0)
        (const_int 8 [0x8])) 0)
and op1 (const_int 32767 [0x7fff]) and simplifies that since the PR93738
optimization was added into
(and:SI (lshiftrt:SI (reg/v:SI 108 [ x ])
        (const_int 8 [0x8]))
    (const_int 32767 [0x7fff]))
This looks wrong to me.
Consider (reg/v:SI 108 [ x ]) 0) could have value 0x12345678U.
The original expression takes lowpart 16-bits from that, i.e. 0x5678U,
shifts that right logically by 8 bits, so 0x56U, makes a paradoxical SUBREG
from that, i.e. 0x????0056U and masks that with 0x7fff, i.e. result is 0x56U.
The new expression shifts 0x12345678U logically right by 8 bits, i.e. 0x123456U and
masks it by 0x7fff, result 0x3456U.

Thus, I think we need to limit to non-paradoxical SUBREGs.
On the rlwimi-2.c testcase I see on powerpc64le-linux no differences in
emitted assembly without/with the patch.

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

PR rtl-optimization/123544
* simplify-rtx.cc (simplify_context::simplify_binary_operation_1)
<case AND>: Don't canonicalize (subreg (lshiftrt (x cnt)) low) into
(lshiftrt (subreg x low) cnt) if the SUBREG is paradoxical.

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

4 months agolibstdc++: Add comment justifying separate proxy_random_access_iterator_wrapper.
Tomasz Kamiński [Wed, 14 Jan 2026 09:35:59 +0000 (10:35 +0100)] 
libstdc++: Add comment justifying separate proxy_random_access_iterator_wrapper.

It meets Cpp17RandomAccessIterator requirements, but does not satisfy
random_access_iterator concept.

libstdc++-v3/ChangeLog:

* testsuite/util/testsuite_iterators.h: Modify comment.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 months agoEnable time profile function reordering with AutoFDO.
Prathamesh Kulkarni [Wed, 14 Jan 2026 09:41:03 +0000 (09:41 +0000)] 
Enable time profile function reordering with AutoFDO.

The patch enables time profile based reordering with AutoFDO with
-fauto-profile -fprofile-reorder-functions, by mapping timestamps obtained from perf
into node->tp_first_run.

The rationale for doing this is:
(1) GCC already implements time-profile function reordering with PGO, the patch enables
it with AutoFDO.
(2) While time profile ordering is primarly meant for optimizing startup time,
we've also observed good effects on code-locality for large internal workloads.
(3) Possibly useful for function reordering when accurate profile annotation is
hard with AutoFDO -- For eg, if branch samples are missing (due to absence of
LBR like structure).

On AutoFDO tools side, a corresponding patch extends gcov to emit 64-bit perf timestamp that
records first execution of function, which loosely corresponds to PGO's time_profile counter.
The timestamp is stored adjacent to head field in toplevel function info.

On GCC side, this patch makes the following changes:

(1) Changes to auto-profile pass:
The patch adds a new field timestamp to function_instance,
and populates it in read_function_instance.
It maintains a new timestamp_info_map from timestamp -> <name, tp_first_run>,
which maps timestamps sorted in ascending order to (1..N), so lowest ordered
timestamp is mapped to 1 and so on. The rationale for this is that
timestamps are 64-bit integers, and we don't need the full 64-bit range
for ordering by tp_first_run.

During annotation, the timestamp associated with function_instance is looked up
in timestamp_info_map, and corresponding mapped value is assigned
to node->tp_first_run.

Dhruv's sourcefile tracking patch already handles LTO privatized symbols.
The patch adds a workaround for mismatched/empty filenames, which should go away
when the issues with AutoFDO tools dwarf parsing are resolved.

(2) Param to disable profile driven opts.
The patch adds param auto-profile-reorder-only which only enables time-profile reordering with
AutoFDO:
(a) Useful as a debugging aid to isolate regression to either function reordering or profile driven opts.
(b) As a stopgap measure to avoid regressions with AutoFDO profile driven opts.
(c) Possibly useful for architectures which do not support branch sampling.

gcc/ChangeLog:
* auto-profile.cc: (string_table::filenames): New method.
(function_instance::timestamp_): New member.
(function_instance::timestamp): New accessor for timestamp_ member.
(function_instance::set_timestamp): New function.
(function_instance::prop_timestamp): Likewise.
(function_instance::prop_timestamp_1): Likewise.
(function_instance::function_instance): Initialize timestamp_ to 0.
(function_instance::read_function_instance): Adjust prototype by
replacing head_count with toplevel param with default value true, and
stream in head_count and timestamp values from gcov file.
(autofdo::timestamp_info_map): New std::map.
(autofdo_source_profile::get_function_instance_by_decl): New argument
filename with default value NULL.
(autofdo_source_profile::read): Populate timestamp_info_map and
propagate timestamp to inlined instances from toplevel function.
(afdo_annotate_cfg): Assign node->tp_first_run based on
timestamp_info_map and bail out of annotation if
param_auto_profile_reorder_only is enabled.
* params.opt: New param auto-profile-reorder-only.

Signed-off-by: Prathamesh Kulkarni <prathameshk@nvidia.com>
4 months agoMAINTAINERS: update Paolo Carlini email address
Jason Merrill [Wed, 14 Jan 2026 03:24:46 +0000 (11:24 +0800)] 
MAINTAINERS: update Paolo Carlini email address

Paolo is no longer at Oracle.

ChangeLog:

* MAINTAINERS: Update Paolo Carlini email address.

4 months agox86: Disable tight loop alignment for m_CORE_ATOM
Lili Cui [Wed, 14 Jan 2026 01:53:04 +0000 (09:53 +0800)] 
x86: Disable tight loop alignment for m_CORE_ATOM

For the E-core front end, aligning tight loops provides little benefit.

gcc/ChangeLog:

* config/i386/x86-tune.def (X86_TUNE_ALIGN_TIGHT_LOOPS):
disable tight loop alignment for m_CORE_ATOM.

4 months agoClarify function body mismatch
Nathan Sidwell [Thu, 18 Dec 2025 14:11:05 +0000 (09:11 -0500)] 
Clarify function body mismatch

Clearly label the expected and found function bodies.

gcc/testsuite/
* lib/scanasm.exp (check_function_body): Clarify mismatch labelling.

4 months agogcc/tree.h, match.pd: remove 'warn_strict_overflow' ref
Daniel Barboza [Mon, 12 Jan 2026 12:02:26 +0000 (04:02 -0800)] 
gcc/tree.h, match.pd: remove 'warn_strict_overflow' ref

During ML discussions of a match.pd pattern that was introducing a new
instance of 'warn_strict_overflow', Richard mentioned that this use
should be discouraged [1]. After pointing out that this usage was
documented in tree.h he then explained that we should remove the note
from the header [2]. Here's the reasoning:

"Ah, we should remove that note.  -Wstrict-overflow proved useless IMO,
it's way too noisy as it diagnoses when the compiler relies on overflow
not happening, not diagnosing when it possibly happens.  That's not a
very useful diagnostic to have - it does not point to a possible problem
in the code (we could as well diagnose _all_ signed arithmetic
operations for the same argument that we might eventually rely on
overflow not happening)."

Aside from removing the tree.h node we're also removing the 2 references
in match.pd. match.pd patterns tend to be copied around to serve as a
base for new patterns (like I did in [3] adding a
'fold_overflow_warning'), and if we want to discourage the use avoiding
its spread is a good start.

Note that there are a lot of references left, most of them in
gcc/fold-const.cc. Some references are using in nested helpers inside
the file, entangled with code that does other things. Removing all
references from the project is out of scope for this quick patch.

[1] https://gcc.gnu.org/pipermail/gcc-patches/2026-January/705320.html
[2] https://gcc.gnu.org/pipermail/gcc-patches/2026-January/705482.html
[3] https://gcc.gnu.org/pipermail/gcc-patches/2026-January/704992.html

gcc/ChangeLog:

* match.pd: remove 'fold_overflow_warning' references.
* tree.h (TYPE_OVERFLOW_UNDEFINED): remove note telling
that we must use warn_strict_overflow for every optimization
based on TYPE_OVERFLOW_UNDEFINED.

gcc/testsuite/ChangeLog:

* gcc.dg/Wstrict-overflow-1.c: Removed because we no longer
issue a 'fold_overflow_warning' with the
`(le (minus (@0 INTEGER_CST@1)) INTEGER_CST@2)` pattern.

Signed-off-by: Daniel Barboza <daniel.barboza@oss.qualcomm.com>
4 months agoMAINTAINERS: add myself to write after approval
Daniel Barboza [Wed, 14 Jan 2026 00:12:28 +0000 (21:12 -0300)] 
MAINTAINERS: add myself to write after approval

ChangeLog:

* MAINTAINERS: Add myself to write after approval.

4 months agoDaily bump.
GCC Administrator [Wed, 14 Jan 2026 00:16:30 +0000 (00:16 +0000)] 
Daily bump.

4 months agomatch: Remove redundant type checks from `(T1)(a bit_op (T2)b)` pattern.
Andrew Pinski [Tue, 13 Jan 2026 23:21:56 +0000 (15:21 -0800)] 
match: Remove redundant type checks from `(T1)(a bit_op (T2)b)` pattern.

As mentioned in https://gcc.gnu.org/pipermail/gcc-patches/2026-January/705657.html,
there were some redundant checks in this pattern. In the first if,
the check for pointer and OFFSET_TYPE is redundant as there is a check for
INTEGRAL_TYPE_P before hand. For the second one, the check for INTEGRAL_TYPE_P
on the inner most type is not needed as there is a types_match right afterwards

Pushed as obvious after bootstra/test on x86_64-linux-gnu.

gcc/ChangeLog:

* match.pd (`(T1)(a bit_op (T2)b)`): Remove redundant
type checks.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
4 months agoc++: modules and coroutines
Nathaniel Shead [Fri, 9 Jan 2026 10:36:32 +0000 (21:36 +1100)] 
c++: modules and coroutines

While working on another issue I found that currently modules do not
work with coroutines at all.  This patch fixes a number of issues in
both the coroutines logic and modules logic to ensure that they play
well together.  To summarize:

- The coroutine proxy objects did not have a DECL_CONTEXT set (required
  for modules to merge declarations).

- The coroutine transformation functions are always non-inline, even
  for an inline ramp function, which means that modules need an override
  to ensure the definitions are available where needed.

- Coroutine transformation functions were not marked DECL_COROUTINE_P,
  despite accessors implying that they were.

- In an importing TU we had lost the connection between the ramp
  functions and the transform functions, as they were kept in a pair
  of global maps.

- Modules streaming couldn't discriminate between the actor or destroy
  functions when merging.

- Modules streaming wasn't setting the cfun->coroutine_component flag,
  needed to activate the middle-end coroutine lowering pass.

This patch also separates the coroutine_info_table initialization from
the ensure_coro_initialized function.  If the first time we see a
coroutine is from a module import, we need to register the
transformation functions now but calling ensure_coro_initialized would
lookup e.g. std::coroutine_traits, which may only be visible from this
module that we're currently reading, causing a recursive load.
Separating the concerns allows this to work correctly.

gcc/cp/ChangeLog:

* coroutines.cc (create_coroutine_info_table): New function.
(get_or_insert_coroutine_info): Mark static.
(ensure_coro_initialized): Likewise; use
create_coroutine_info_table.
(coro_promise_type_found_p): Set DECL_CONTEXT for proxies.
(coro_set_ramp_function): New function.
(coro_set_transform_functions): New function.
(coro_build_actor_or_destroy_function): Use
coro_set_ramp_function, mark as DECL_COROUTINE_P.
* cp-tree.h (coro_set_transform_functions): Declare.
(coro_set_ramp_function): Declare.
* module.cc (struct merge_key): New field coro_disc.
(dumper::impl::nested_name): Distinguish coroutine transform
functions.
(get_coroutine_discriminator): New function.
(trees_out::key_mergeable): Stream coroutine discriminator.
(check_mergeable_decl): Adjust comment, check for matching
coroutine discriminator.
(trees_in::key_mergeable): Read coroutine discriminator.
(has_definition): Override for coroutine transform functions.
(trees_out::write_function_def): Stream linked ramp, actor, and
destroy functions for coroutines.
(trees_in::read_function_def): Read them.
(module_state::read_cluster): Set cfun->coroutine_component.

gcc/testsuite/ChangeLog:

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

Reviewed-by: Iain Sandoe <iain@sandoe.co.uk>
Reviewed-by: Jason Merrill <jason@redhat.com>
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
4 months agoc++/modules: Update lang_decl_bool streaming
Nathaniel Shead [Sat, 10 Jan 2026 02:52:37 +0000 (13:52 +1100)] 
c++/modules: Update lang_decl_bool streaming

The set of lang_decl flags that we were streaming had gotten out of sync
with the current list; update them.

One notable change is that anticipated_p, which had previously been
deliberately skipped, is now only used for DECL_OMP_PRIVATIZED_MEMBER,
and so should probably be streamed as well.

gcc/cp/ChangeLog:

* module.cc (trees_out::lang_decl_bools): Update list of flags.
(trees_in::lang_decl_bools): Likewise.

Reviewed-by: Jason Merrill <jason@redhat.com>
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
4 months agomatch: (X >> C) NE/EQ 0 -> X LT/GE 0 [PR123109]
Pengxuan Zheng [Fri, 9 Jan 2026 18:49:45 +0000 (10:49 -0800)] 
match: (X >> C) NE/EQ 0 -> X LT/GE 0 [PR123109]

Implement (X >> C) NE/EQ 0 -> X LT/GE 0 in match.pd instead of fold-const.cc.

Bootstrapped and tested on x86_64 and aarch64.

PR tree-optimization/123109

gcc/ChangeLog:

* fold-const.cc (fold_binary_loc): Remove (X >> C) NE/EQ 0 -> X LT/GE 0
folding.
* match.pd (`(X >> C) NE/EQ 0 -> X LT/GE 0`): New pattern.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/vrp99.c: Update test.
* gcc.dg/pr123109.c: New test.

Signed-off-by: Pengxuan Zheng <pengxuan.zheng@oss.qualcomm.com>
4 months agomatch: Add simplification of `(a*zero_one_valued_p) & b` if `a & b` simplifies [PR119402]
Andrew Pinski [Tue, 13 Jan 2026 02:58:47 +0000 (18:58 -0800)] 
match: Add simplification of `(a*zero_one_valued_p) & b` if `a & b` simplifies [PR119402]

This is a small reassociation for `a*bool & b` into `(a & b) * bool` checking if
`a & b` simplifies. Since it could be the case `b` is `~a` or `a` or something
else that might simplify when anding with `a`.

Note this fixes a regression for aarch64 where the cost of a multiply vs `&-` changed
in GCC 14 and can no longer optimize some cases at the RTL level.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/119402
gcc/ChangeLog:

* match.pd (`(a*zero_one_valued_p) & b`): New pattern.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/bitops-14.c: New test.
* gcc.dg/tree-ssa/bitops-15.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
4 months agotestsuite/aarch64: Fix aarch64/signbitv2sf.c [PR122522]
Andrew Pinski [Tue, 13 Jan 2026 19:43:42 +0000 (11:43 -0800)] 
testsuite/aarch64: Fix aarch64/signbitv2sf.c [PR122522]

The problem here is after some heurstics changes the check
loop is now unrolled so we eliminate the array. This means
the check for not having -2147483648 no longer works as
we don't handle SLP in this case.
So the best option is to force the check loop not to unroll
(no vectorize) as this is just testing we SLP the normal
signbit places rather than dealing with the checking loop.

Pushed as obvious after testing the testcase on aarch64-linux-gnu.

PR testsuite/122522
gcc/testsuite/ChangeLog:

* gcc.target/aarch64/signbitv2sf.c (main): Disable
unrolling and vectorizer for the checking loop.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
4 months agoc: fix checking ICE related to transparent unions and atomic [PR123309]
Martin Uecker [Tue, 13 Jan 2026 18:09:53 +0000 (19:09 +0100)] 
c: fix checking ICE related to transparent unions and atomic [PR123309]

When matching function arguments in composite_type_internal and one
type comes from a transparent union, it is possible to end up with
atomic and non-atomic types because this case is not handled correctly.
The type matching logic is rewritten in a cleaner way to use helper
functions and to not walk the argument lists three times.  With this
change, a checking assertion can be added to test for matching qualifiers
for pointers. (In general, this assumption is still violated for
function return types.)

PR c/123309

gcc/c/ChangeLog:
* c-typeck.cc (transparent_union_replacement): New function.
(composite_type_internal): Rewrite logic.
(type_lists_compatible_p): Remove dead code for NULL arguments.

gcc/testsuite/ChangeLog:
* gcc.dg/pr123309.c: New test.
* gcc.dg/union-composite-type.c: New test.

4 months agolibstdc++: Fix handling iterators with proxy subscript in heap algorithms.
Tomasz Kamiński [Tue, 13 Jan 2026 15:29:42 +0000 (16:29 +0100)] 
libstdc++: Fix handling iterators with proxy subscript in heap algorithms.

This patch replaces uses of subscripts in heap algorithms, that where introduced
in r16-4100-gaaeca77a79a9a8 with dereference of advanced iterators.

The Cpp17RandomAccessIterator requirements, allows operator[] to return any
type that is convertible to reference, however user-provided comparators are
required only to accept result of dereferencing the iterator (i.e. reference
directly). This is visible, when comparator defines operator() for which
template arguments can be deduduced from reference (which will fail on proxy)
or that accepts types convertible from reference (see included tests).

For test we introduce a new proxy_random_access_iterator_wrapper iterator
in testsuite_iterators.h, that returns a proxy type from subscript operator.
This is separate type (instead of additional template argument and aliases),
as it used for test that work with C++98.

libstdc++-v3/ChangeLog:

* include/bits/stl_heap.h (std::__is_heap_until, std::__push_heap)
(std::__adjust_heap): Replace subscript with dereference of
advanced iterator.
* testsuite/util/testsuite_iterators.h (__gnu_test::subscript_proxy)
(__gnu_test::proxy_random_access_iterator_wrapper): Define.
* testsuite/25_algorithms/sort_heap/check_proxy_brackets.cc: New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 months agoFortran: Detect missing quote in namelist read.
Jerry DeLisle [Tue, 13 Jan 2026 02:45:05 +0000 (18:45 -0800)] 
Fortran: Detect missing quote in namelist read.

PR libfortran/123012

libgfortran/ChangeLog:

* io/list_read.c (read_character): Add new check after
get_string and provide better comments.

gcc/testsuite/ChangeLog:

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

4 months agoifcvt: Improve `cmp?a&b:a` to try with -1 [PR123312]
Andrew Pinski [Sat, 10 Jan 2026 07:14:22 +0000 (23:14 -0800)] 
ifcvt: Improve `cmp?a&b:a` to try with -1 [PR123312]

After the current improvements to ifcvt, on some targets for
cmp?a&b:a it is better to produce `(cmp?b:-1) & a` rather than
`(!cmp?a:0)|(a & b)`. So this extends noce_try_cond_zero_arith (with
a rename to noce_try_cond_arith) to see if `cmp ? a : -1` is cheaper than
`!cmp?a:0`.

Bootstrapped and tested on x86_64-linux-gnu.

PR rtl-optimization/123312
gcc/ChangeLog:

* ifcvt.cc (noce_try_cond_zero_arith): Rename to ...
(noce_try_cond_arith): This. For AND try `cmp ? a : -1`
also to see which one cost less.
(noce_process_if_block): Handle the rename.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
4 months agowinnt-utf8.manifest: make long path aware
Jonathan Yong [Tue, 13 Jan 2026 17:24:46 +0000 (17:24 +0000)] 
winnt-utf8.manifest: make long path aware

Based on:
https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests#longpathaware

gcc:
* config/i386/winnt-utf8.manifest: enable longPathAware.

Signed-off-by: Jonathan Yong <10walls@gmail.com>
4 months agowinnt-utf8.manifest: Use XML example from Microsoft
Jonathan Yong [Tue, 13 Jan 2026 16:51:50 +0000 (16:51 +0000)] 
winnt-utf8.manifest: Use XML example from Microsoft

Based on example from:
https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests#activecodepage

PR driver/108865

gcc:
* config/i386/winnt-utf8.manifest: correct XML tags

Signed-off-by: Jonathan Yong <10walls@gmail.com>
4 months ago[PR tree-optimization/123530] Fix ICE in recently added match.pd pattern
Jeff Law [Tue, 13 Jan 2026 14:16:05 +0000 (07:16 -0700)] 
[PR tree-optimization/123530] Fix ICE in recently added match.pd pattern

The gimple optimization passes can create negative shift counts and pass them
into the simplification routines as seen by the code in pr123530.  If we then
call tree_to_uhwi on those values we get a nice little ICE.

This guards the tree_to_uhwi calls on tree_fits_uhwi_p and resolves the ICE.  I
just protected them all in this recently added pattern.

Bootstrapped and regression tested on x86 and riscv.  Also tested on the rest
of the embedded targets without any regressions.

Pushing to the trunk.

PR tree-optimization/123530
gcc/
* match.pd (reassociating xor to enable rotations): Verify constants
fit into a uhwi before trying to extract them as a uhwi.

gcc/testsuite/
* gcc.dg/torture/pr123530.c: New test.

4 months agomiddle-end/123573 - fix VEC_PERM folding more
Richard Biener [Tue, 13 Jan 2026 11:59:41 +0000 (12:59 +0100)] 
middle-end/123573 - fix VEC_PERM folding more

The following fixes the fix from r16-6709-ga4716ece529dfd some
more by making sure permute to one operand folding faces same
element number vectors but also insert a VIEW_CONVERT_EXPR for
the case one is VLA and one is VLS (when the VLA case is actually
constant, like with -msve-vector-bits=128).  It also makes the
assert that output and input element numbers match done in
fold_vec_perm which this pattern eventually dispatches to into
a check (as the comment already indicates).

Testcases are in the target specific aarch64 testsuite already.

PR middle-end/123573
* fold-const.cc (fold_vec_perm): Actually check, not assert,
that input and output vector element numbers agree.
* match.pd (vec_perm @0 @1 @2): Make sure element numbers
are the same when folding to an input vector and wrap that
inside a VIEW_CONVERT_EXPR.

4 months agoforwprop: Fix type mismatch in vec constructor [PR123525].
Robin Dapp [Mon, 12 Jan 2026 14:45:46 +0000 (15:45 +0100)] 
forwprop: Fix type mismatch in vec constructor [PR123525].

This issue got raised after r16-6671 in which I removed checks for
number-of-element equality.  In the splat case with conversion:

  vector(16) int w;
  vector(8) long int v;
  _13 = BIT_FIELD_REF <w_12(D), 32, 160>;
  _2 = (long int) _13;
  _3 = (long int) _13;
  ...
  _9 = (long int) _13;
  _1 = {_2, _3, _4, _5, _6, _7, _8, _9};

right now we do
  _16 = VEC_PERM_EXPR <w_12(D), w_12(D), { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 }>;
  _17 = VIEW_CONVERT_EXPR<vector(8) intD.6>(_16);

where the view convert is actually an optimized
  _17 = BIT_FIELD_REF (_16, 512, 0);

512 is the size of the unconverted source but we should actually use the
converted source type.  That's what this patch does.

PR tree-optimization/123525

gcc/ChangeLog:

* tree-ssa-forwprop.cc (simplify_vector_constructor): Use
converted source type for conversion bit field ref.

gcc/testsuite/ChangeLog:

* gcc.dg/vect/pr123525.c: New test.
* g++.dg/vect/pr123525-2.cc: New test.

4 months agoif-conv: Prevent vector types in scalar cond reduction [PR123301].
Robin Dapp [Fri, 9 Jan 2026 20:57:49 +0000 (21:57 +0100)] 
if-conv: Prevent vector types in scalar cond reduction [PR123301].

Currently we allow vector types in scalar conditional reductions by
accident (via the GNU vector extension).  This patch prevents that.

PR tree-optimization/123301

gcc/ChangeLog:

* tree-if-conv.cc (convert_scalar_cond_reduction):
Disallow vector types.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/pr123301.c: New test.

4 months agortlanal: Determine nonzero bits of popcount from operand [PR123501].
Robin Dapp [Fri, 9 Jan 2026 12:25:40 +0000 (13:25 +0100)] 
rtlanal: Determine nonzero bits of popcount from operand [PR123501].

The PR involves large mask vectors (e.g. V128BI) from which we take
the popcount.  Currently a (popcount:DI (V128BI)) is assumed to have
at most 8 set bits as we assume the popcount operand also has DImode.

This patch uses the operand mode for unary operations and thus
calculates a proper nonzero-bits mask.

We could do the same estimate for ctz and clz but they use nonzero in a
non-poly way and I didn't want to change more than necessary.  Therefore
the patch just returns -1 when we have a different operand mode for
ctz/clz.

PR rtl-optimization/123501
PR rtl-optimization/123444

gcc/ChangeLog:

* rtlanal.cc (nonzero_bits1): Use operand mode instead of
operation mode.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/reduc/pr123501.c: New test.

4 months agoamdgcn: Adjust failure mode for gfx908 USM: 'libgomp.fortran/map-alloc-comp-9-usm...
Thomas Schwinge [Fri, 9 May 2025 13:05:57 +0000 (15:05 +0200)] 
amdgcn: Adjust failure mode for gfx908 USM: 'libgomp.fortran/map-alloc-comp-9-usm.f90'

The change/rationale that commit 1cf9fda4936de54198858b8f54cd9707a3725f4e
"amdgcn: Adjust failure mode for gfx908 USM" applied to a number of test cases
likewise applies to 'libgomp.fortran/map-alloc-comp-9-usm.f90'.

libgomp/
* testsuite/libgomp.fortran/map-alloc-comp-9-usm.f90: Require
working Unified Shared Memory to run the test.

4 months agoopenmp: Bump Version from 4.5 to 5.2 (2/4): Some more '-Wno-deprecated-openmp'
Thomas Schwinge [Mon, 15 Dec 2025 15:12:33 +0000 (16:12 +0100)] 
openmp: Bump Version from 4.5 to 5.2 (2/4): Some more '-Wno-deprecated-openmp'

These changes should've been included in
commit 382edf047effcd5b1ce66389742bd1b3e178ac95
"openmp: Bump Version from 4.5 to 5.2 (2/4)", to avoid some more instances of:

    warning: use of 'omp declare target' as a synonym for 'omp begin declare target' has been deprecated since OpenMP 5.2 [-Wdeprecated-openmp]

    warning: 'to' clause with 'declare target' deprecated since OpenMP 5.2, use 'enter' [-Wdeprecated-openmp]

    Warning: Non-C_PTR type argument at (1) is deprecated, use HAS_DEVICE_ADDR [-Wdeprecated-openmp]

    Warning: 'to' clause with 'declare target' at (1) deprecated since OpenMP 5.2, use 'enter' [-Wdeprecated-openmp]

libgomp/
* testsuite/libgomp.c++/examples-4/declare_target-2.C: Add
'-Wno-deprecated-openmp'.
* testsuite/libgomp.c/declare-variant-3-sm30.c: Likewise.
* testsuite/libgomp.c/declare-variant-3-sm35.c: Likewise.
* testsuite/libgomp.c/declare-variant-3-sm37.c: Likewise.
* testsuite/libgomp.c/declare-variant-3-sm52.c: Likewise.
* testsuite/libgomp.c/declare-variant-3-sm53.c: Likewise.
* testsuite/libgomp.c/declare-variant-3-sm61.c: Likewise.
* testsuite/libgomp.c/declare-variant-3-sm70.c: Likewise.
* testsuite/libgomp.c/declare-variant-3-sm75.c: Likewise.
* testsuite/libgomp.c/declare-variant-3-sm80.c: Likewise.
* testsuite/libgomp.c/declare-variant-3-sm89.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx10-3-generic.c:
Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx1030.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx1031.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx1032.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx1033.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx1034.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx1035.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx1036.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx11-generic.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx1100.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx1101.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx1102.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx1103.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx1150.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx1151.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx1152.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx1153.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx9-4-generic.c:
Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx9-generic.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx900.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx902.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx904.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx906.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx908.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx909.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx90a.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx90c.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx942.c: Likewise.
* testsuite/libgomp.c/declare-variant-4-gfx950.c: Likewise.
* testsuite/libgomp.c/examples-4/async_target-2.c: Likewise.
* testsuite/libgomp.c/interop-hsa.c: Likewise.
* testsuite/libgomp.c/target-20.c: Likewise.
* testsuite/libgomp.c/target-simd-clone-1.c: Likewise.
* testsuite/libgomp.c/target-simd-clone-2.c: Likewise.
* testsuite/libgomp.c/target-simd-clone-3.c: Likewise.
* testsuite/libgomp.fortran/alloc-managed-1.f90: Likewise.
* testsuite/libgomp.fortran/target9.f90: Likewise.

4 months agoopenmp: Bump Version from 4.5 to 5.2 (2/4): 'libgomp.oacc-c-c++-common/vred2d-128...
Thomas Schwinge [Mon, 15 Dec 2025 15:12:33 +0000 (16:12 +0100)] 
openmp: Bump Version from 4.5 to 5.2 (2/4): 'libgomp.oacc-c-c++-common/vred2d-128.c' [PR123098]

'libgomp.oacc-c-c++-common/vred2d-128.c' had gotten '-Wno-deprecated-openmp'
applied as part of commit 382edf047effcd5b1ce66389742bd1b3e178ac95
"openmp: Bump Version from 4.5 to 5.2 (2/4)", which conceptually doesn't make
sense, as 'libgomp.oacc-c-c++-common/vred2d-128.c' isn't an OpenMP test case.
In commit 9c119b0fdd9ba5a6821c0b4c5874ade8f4969109
"openmp: Limit - reduction -Wdeprecated-openmp diagnostics to OpenMP, testsuite fixes [PR123098]",
the erroneous diagnostic got disabled, so we don't need
'-Wno-deprecated-openmp' anymore.

PR testsuite/123098
libgomp/
* testsuite/libgomp.oacc-c-c++-common/vred2d-128.c: Remove
'-Wno-deprecated-openmp'.

4 months agoUse -latomic_asneeded or -lgcc_s_asneeded to workaround libtool issues [PR123396]
Jakub Jelinek [Tue, 13 Jan 2026 09:06:47 +0000 (10:06 +0100)] 
Use -latomic_asneeded or -lgcc_s_asneeded to workaround libtool issues [PR123396]

On Mon, Jan 12, 2026 at 12:13:35PM +0100, Florian Weimer wrote:
> One way to work around the libtool problem would be to stick the
> as-needed into an existing .so linker script, or create a new one under
> a different name (say libatomic_optional.so) that has AS_NEEDED in it,
> and link with -latomic_optional.  Then libtool would not have to be
> taught about --push-state/--pop-state etc.

That seems to work.

So far bootstrapped (c,c++,fortran,lto only) and make install tested
on x86_64-linux, tested on a small program without need to libatomic and
struct S { char a[25]; };
_Atomic struct S s;

int main () { struct S t = s; s = t; }
which does at -O0.
Before this patch I got
for i in `find x86_64-pc-linux-gnu/ -name lib\*.so.\*.\*`; do ldd -u $i 2>&1 | grep -q libatomic.so.1 && echo $i; done
x86_64-pc-linux-gnu/libsanitizer/ubsan/.libs/libubsan.so.1.0.0
x86_64-pc-linux-gnu/libsanitizer/asan/.libs/libasan.so.8.0.0
x86_64-pc-linux-gnu/libsanitizer/hwasan/.libs/libhwasan.so.0.0.0
x86_64-pc-linux-gnu/libsanitizer/lsan/.libs/liblsan.so.0.0.0
x86_64-pc-linux-gnu/libsanitizer/tsan/.libs/libtsan.so.2.0.0
x86_64-pc-linux-gnu/32/libsanitizer/ubsan/.libs/libubsan.so.1.0.0
x86_64-pc-linux-gnu/32/libsanitizer/asan/.libs/libasan.so.8.0.0
x86_64-pc-linux-gnu/32/libstdc++-v3/src/.libs/libstdc++.so.6.0.35
x86_64-pc-linux-gnu/libgcobol/.libs/libgcobol.so.2.0.0
x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.35
With this patch it prints nothing.

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

PR libstdc++/123396
gcc/
* configure.ac (gcc_cv_ld_use_as_needed_ldscript): New test.
(USE_LD_AS_NEEDED_LDSCRIPT): New AC_DEFINE.
* gcc.cc (LINK_LIBATOMIC_SPEC): Use "-latomic_asneeded" instead
of LD_AS_NEEDED_OPTION " -latomic " LD_NO_AS_NEEDED_OPTION
if USE_LD_AS_NEEDED_LDSCRIPT is defined.
(init_gcc_specs): Use "-lgcc_s_asneeded" instead of
LD_AS_NEEDED_OPTION " -lgcc_s " LD_NO_AS_NEEDED_OPTION
if USE_LD_AS_NEEDED_LDSCRIPT is defined.
* config.in: Regenerate.
* configure: Regenerate.
libatomic/
* acinclude.m4 (LIBAT_BUILD_ASNEEDED_SOLINK): New AM_CONDITIONAL.
* libatomic_asneeded.so: New file.
* libatomic_asneeded.a: New file.
* Makefile.am (toolexeclib_DATA): Set if LIBAT_BUILD_ASNEEDED_SOLINK.
(all-local): Install those files into gcc subdir.
* Makefile.in: Regenerate.
* configure: Regenerate.
libgcc/
* config/t-slibgcc (SHLIB_ASNEEDED_SOLINK,
SHLIB_MAKE_ASNEEDED_SOLINK, SHLIB_INSTALL_ASNEEDED_SOLINK): New
vars.
(SHLIB_LINK): Include $(SHLIB_MAKE_ASNEEDED_SOLINK).
(SHLIB_INSTALL): Include $(SHLIB_INSTALL_ASNEEDED_SOLINK).

4 months agoFortran: Check constant PDT type specification parameters [PR112460]
Paul Thomas [Tue, 13 Jan 2026 08:19:05 +0000 (08:19 +0000)] 
Fortran: Check constant PDT type specification parameters [PR112460]

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

gcc/fortran
PR fortran/112460
* array.cc (resolve_array_list): Stash the first PDT element
and check its type specification parameters against those of
subsequent elements.
* expr.cc (get_parm_list_from_expr): New function to extract the
type spec lists from expressions to be compared.
(gfc_check_type_spec_parms): New function to compare type spec
lists between two expressions. Emit an error if any constant
values are different.
(gfc_check_assign): Check that the PDT type specification parms
are the same on lhs and rhs.
* gfortran.h : Add prototype for gfc_check_type_spec_parms.
* trans-expr.cc (copyable_array_p): PDT arrays are not copyable

gcc/testsuite
PR fortran/112460
* gfortran.dg/pdt_81.f03: New test.

4 months agotree-optimization/123539 - signed UB in vector reduction
Richard Biener [Mon, 12 Jan 2026 13:10:32 +0000 (14:10 +0100)] 
tree-optimization/123539 - signed UB in vector reduction

With previous changes I overlooked one use of vectype.

PR tree-optimization/123539
* tree-vect-loop.cc (vect_create_epilog_for_reduction):
Use the compute vectype to pun down to smaller or element
size for by-element reductions.

4 months agoxfail store_merging_19.c for the same reason as store_merging_18.c
Andrew Pinski [Tue, 13 Jan 2026 05:06:49 +0000 (21:06 -0800)] 
xfail store_merging_19.c for the same reason as store_merging_18.c

store_merging_19.c is almost the same as store_merging_18.c except
it has assume align in it to allow it work on strict align targets.
Somehow when I was looking at the testresults I noticed 18 but not 19
when I was looking into failures.

Pushed as obvious.

gcc/testsuite/ChangeLog:

* gcc.dg/store_merging_19.c: xfail.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
4 months agoVN: Fix VN ICE for large _BitInt types
Kito Cheng [Mon, 29 Dec 2025 06:14:25 +0000 (14:14 +0800)] 
VN: Fix VN ICE for large _BitInt types

gcc.dg/torture/bitint-18.c triggers an ICE in push_partial_def when
compiling for RISC-V with -O2.  The issue occurs because
build_nonstandard_integer_type cannot handle bit widths larger than
MAX_FIXED_MODE_SIZE.

For BITINT_TYPE with maxsizei > MAX_FIXED_MODE_SIZE, use build_bitint_type
instead of build_nonstandard_integer_type, similar to what tree-sra.cc does.

gcc/ChangeLog:

* tree-ssa-sccvn.cc (vn_walk_cb_data::push_partial_def): Use
build_bitint_type for BITINT_TYPE when maxsizei exceeds
MAX_FIXED_MODE_SIZE.

4 months agoRISC-V: Add support for _BitInt [PR117581]
Kito Cheng [Mon, 12 Jan 2026 13:31:11 +0000 (21:31 +0800)] 
RISC-V: Add support for _BitInt [PR117581]

This patch implements _BitInt support for RISC-V target by defining the
type layout and ABI requirements.  The limb mode selection is based on
the bit width, using appropriate integer modes from QImode to TImode.
The implementation also adds the necessary libgcc version symbols for
_BitInt runtime support functions.

Changes in v3:
- Require sync_char_short effective target for bitint-64.c, bitint-82.c
  and bitint-84.c tests since they use atomic operations.
- Add -fno-section-anchors to bitint-32-on-rv64.c and adjust expected
  assembly output patterns.

Changes in v2:
- limb_mode use up to XLEN when N > XLEN, which is different setting from
  the abi_limb_mode.
- Adding missing floatbitinthf in libgcc.

gcc/ChangeLog:

PR target/117581
* config/riscv/riscv.cc (riscv_bitint_type_info): New function.
(TARGET_C_BITINT_TYPE_INFO): Define.

gcc/testsuite/ChangeLog:

PR target/117581
* gcc.dg/torture/bitint-64.c: Add sync_char_short effective target
requirement.
* gcc.dg/torture/bitint-82.c: Likewise.
* gcc.dg/torture/bitint-84.c: Likewise.
* gcc.target/riscv/bitint-32-on-rv64.c: New test.
* gcc.target/riscv/bitint-alignments.c: New test.
* gcc.target/riscv/bitint-args.c: New test.
* gcc.target/riscv/bitint-sizes.c: New test.

libgcc/ChangeLog:

PR target/117581
* config/riscv/libgcc-riscv.ver: New file.
* config/riscv/t-elf (SHLIB_MAPFILES): Add libgcc-riscv.ver.
* config/riscv/t-softfp32 (softfp_extras): Add floatbitinttf and
fixtfbitint.

4 months agopr122458.c: Replace .quad with .dc.a
H.J. Lu [Tue, 13 Jan 2026 03:17:57 +0000 (11:17 +0800)] 
pr122458.c: Replace .quad with .dc.a

Replace .quad with .dc.a to avoid

/export/build/gnu/tools-build/gcc/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/tools-build/gcc/build-x86_64-linux/gcc/ /export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.dg/ipa/pr122458.c -m32 -fdiagnostics-plain-output -O2 -lm -o pr122458.exe
/usr/local/bin/as: /tmp/cc9Bw0pX.o: unsupported relocation type: 0x1
/tmp/ccGrIiOC.s: Assembler messages:
/tmp/ccGrIiOC.s:4: Error: cannot represent relocation type BFD_RELOC_64
compiler exited with status 1
FAIL: gcc.dg/ipa/pr122458.c (test for excess errors)

for 32-bit targets.

PR ipa/122458
* gcc.dg/ipa/pr122458.c: Replace .quad with .dc.a.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
4 months agoAdd TARGET_MMX_WITH_SSE to the condition of all 64-bit _Float16 vector related patterns.
liuhongt [Fri, 9 Jan 2026 01:46:38 +0000 (17:46 -0800)] 
Add TARGET_MMX_WITH_SSE to the condition of all 64-bit _Float16 vector related patterns.

gcc/ChangeLog:

PR target/123484
* config/i386/mmx.md (divv4hf3): Add TARGET_MMX_WITH_SSE to
the condition.
(cmlav4hf4): Ditto.
(cmla_conjv4hf4): Ditto.
(cmulv4hf3): Ditto.
(cmul_conjv4hf3): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr123484.c: New test.

4 months agoDaily bump.
GCC Administrator [Tue, 13 Jan 2026 00:16:32 +0000 (00:16 +0000)] 
Daily bump.

4 months agomatch: Simplify `(T1)(a bit_op (T2)b)` to `((T1)a bit_op b)` When b is T1 type and...
Andrew Pinski [Sun, 11 Jan 2026 07:17:12 +0000 (23:17 -0800)] 
match: Simplify `(T1)(a bit_op (T2)b)` to `((T1)a bit_op b)` When b is T1 type and truncating from T2 [PR122845]

This adds the simpliciation of:
```
  <unnamed-signed:3> _1;

  _2 = (signed char) _1;
  _3 = _2 ^ -47;
  _4 = (<unnamed-signed:3>) _3;
```

to:
```
  <unnamed-signed:3> _n;
  _4 = _1 ^ -47;
```

This also fixes PR 122843 by optimizing out the xor such that we get:
```
  _1 = b.a;
  _21 = (<unnamed-signed:3>) t_23(D);
  // t_23 in the original testcase was 200 so this is reduced to 0
  _5 = _1 ^ _21;
  # .MEM_24 = VDEF <.MEM_13>
  b.a = _5;
```
And then there is no cast catch this pattern:
`(bit_xor (convert1? (bit_xor:c @0 @1)) (convert2? (bit_xor:c @0 @2)))`
As we get:
```
  _21 = (<unnamed-signed:3>) t_23(D);
  _5 = _1 ^ _21;
  _22 = (<unnamed-signed:3>) t_23(D);
  _7 = _5 ^ _22;
  _25 = (<unnamed-signed:3>) t_23(D);
  _8 = _7 ^ _25;
  _26 = (<unnamed-signed:3>) t_23(D);
  _9 = _7 ^ _26;
```
After unrolling and then fre will optimize away all of those xor.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/122845
PR tree-optimization/122843
gcc/ChangeLog:

* match.pd (`(T1)(a bit_op (T2)b)`): Also
simplify if T1 is the same type as b and T2 is wider
type than T1.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/bitops-12.c: New test.
* gcc.dg/tree-ssa/bitops-13.c: New test.
* gcc.dg/store_merging_18.c: xfail store merging.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
4 months agoFortran: Add additional checks for constant expressions.
Steven G. Kargl [Mon, 12 Jan 2026 21:58:39 +0000 (13:58 -0800)] 
Fortran: Add additional checks for constant expressions.

PR fortran/91960

gcc/fortran/ChangeLog:

* resolve.cc (resolve_fl_parameter): Check the righthand symbol
is a constant expression.

gcc/testsuite/ChangeLog:

* gfortran.dg/pr69962.f90: Adjust testcase to ignore new error message.
* gfortran.dg/pr91960_1.f90: New test.
* gfortran.dg/pr91960_2.f90: New test.