Tomasz Kamiński [Fri, 27 Feb 2026 19:14:44 +0000 (20:14 +0100)]
libstdc++: Add #pragma to slience null-dereference warning in istreambuf_iterator::operator++ [PR105580]
The warning was produced by following sequence, given an istream_iterator<char>
it, such that *it will result in hitting EoF in it->_M_get(), and thus clearing
_M_sbuf, the subsequent call to ++it, will result in _M_sbuf->sbumpc() call on
null pointer. This is however an false-positive, as in such situation
it == istream_iteator() returns true, and the iterator should not be
incremented in first place.
This patch sliences the issue, by disabling the "-Wnull-dereference" using
GCC diagnostic pragmas. To work correctly the pragmas needs to be placed around
streambuf functions on which the issue originating from istreambuf_iterator are
reported.
PR libstdc++/105580
libstdc++-v3/ChangeLog:
* include/std/streambuf (streambuf::gptr, streambuf::egptr)
(streambuf::gbump): Surround with pragma disabling -Wnull-dereference.
* testsuite/24_iterators/istreambuf_iterator/105580.cc: Remove check for
warning being emitted.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
Jakub Jelinek [Mon, 2 Mar 2026 09:46:00 +0000 (10:46 +0100)]
i386: Fix up avx512fp16_mov<mode> AVX10.2 operand order for -masm=intel [PR124294]
This insn uses incorrect operand order for -masm=intel in the AVX10.2
variant.
I've checked for similar mistakes and haven't found any in all the i386/*.md
files.
Note, I also wonder why the insn doesn't use * in front of the define_insn
name, I can't find anything that would need gen_avx512fp16_movv8{hi,hf,bf}.
2026-03-02 Jakub Jelinek <jakub@redhat.com>
PR target/124294
* config/i386/sse.md (avx512fp16_mov<mode>): Fix ordering of operands
for -masm=intel for the avx10_2 alternative. Fix up indentation in
the insn condition.
(vec_set<mode>_0): Fix comment typo, higer -> higher.
Jakub Jelinek [Mon, 2 Mar 2026 09:42:29 +0000 (10:42 +0100)]
Add r16-7757 -> r16-7745 to ignored_commits
2026-03-02 00:16:26,078:INFO:root:While processing 9a7da540b63e7d77e747b5cdd6fdbbd3954e28c8:
2026-03-02 00:16:26,078:INFO:root:Expected empty second line in commit message: "Revert "[PR115042, LRA]: Postpone processing of new reload insns" as it"
Tamar Christina [Mon, 2 Mar 2026 08:16:38 +0000 (08:16 +0000)]
testsuite: Fix testism in avx512fp16-xorsign-1.c
After r16-7762-g0383e6c398a this test now only vectorizes
the main loop and not the early break result checking loop
due to the FP * being able to raise an FE and we're compiling
with -ftrapping-math.
Test was marked unsupported so didn't notice it before.
testsuite: arm: drop additional option -march=armv7-a
Since r16-7155-g74907f407db641, the -march option is part of the
arm_neon effective target, thus, the extra -march is pointless.
Using -march=armv7-a also prevents testing using softfp or hard float
ABI.
gcc/testsuite/ChangeLog:
* gcc.target/arm/addr-modes-int.c: Drop additional option
-march=armv7-a.
testsuite: add -Wno-overflow to avoid warning in test [PR123191]
Without -Wno-overflow, for arm-none-eabi targets, I see warnings like:
coreutils-group_number.c:13:21: warning: conversion from 'long long unsigned int' to 'size_t' {aka 'unsigned int'} changes value from '18446744073709551615' to '4294967295' [-Woverflow]
Jakub Jelinek [Mon, 2 Mar 2026 07:02:45 +0000 (08:02 +0100)]
testsuite: Fix up anon4.C test for excess precision targets
The g++.dg/reflect/anon4.C test FAILs on i686-linux, because with
extended precision the store to .c rounds to double precision, but comparison
of it against 3.14 constant doesn't.
2026-03-02 Jakub Jelinek <jakub@redhat.com>
* g++.dg/reflect/anon4.C (test): Use (double) 3.14 instead of 3.14 in
comparisons.
Rainer Orth [Sun, 1 Mar 2026 17:32:26 +0000 (18:32 +0100)]
Switch to HAVE_SOLARIS_LD
When configuring GCC to use GNU ld on Solaris, gcc/configure can get
inconsistent ideas about gnu_ld_flag, which results in wrong settings
for various macros:
* Toplevel configure determines LD from PATH using
NCN_STRICT_CHECK_TOOLS(LD, ld). This may be either Solaris ld or GNU ld.
* The resulting LD is always passed to gcc/configure in stages 1 to 3.
* However, when LD and the value of --with-ld differ, there can result
two values of gnu_ld_flag in different sections of gcc/configure:
** config/lib-ld.m4 (AC_LIB_PROG_LD_GNU) determines gnu_ld_flag from $LD.
** However, gcc/configure also checks gcc_cv_ld which can come from
either --with-ld or PATH.
* When this happens, several linker tests arrive at wrong values,
e.g. Solaris ld versions of LD_AS_NEEDED_OPTION when actually GNU ld
is used.
To avoid this, this patch determines gnu_ld_flag from ld -V/--version
once gcc_cv_ld has finally been set.
Besides, just like the HAVE_GNU_AS case, the majority of HAVE_GNU_LD
uses are in Solaris-specific code to distinguish GNU ld from Solaris ld.
Again, it's easier to turn the check around, checking for Solaris ld
directly, which this patch does.
Bootstrapped without regressions on sparcv9-sun-solaris2.11,
amd64-pc-solaris2.11, sparc64-unknown-linux-gnu, and
x86_64-pc-linux-gnu.
Rainer Orth [Sun, 1 Mar 2026 17:04:03 +0000 (18:04 +0100)]
Switch to HAVE_SOLARIS_AS
The vast majority of the remaining uses of HAVE_GNU_AS are in
Solaris-specific code to distinguish uses of GNU as from Solaris as.
It's simpler to turn the check around, checking for Solaris as directly
instead.
The following patch does just that.
Bootstrapped without regressions on sparcv9-sun-solaris2.11,
amd64-pc-solaris2.11, sparc64-unknown-linux-gnu, and x86_64-pc-linux-gnu.
Nathaniel Shead [Wed, 25 Feb 2026 12:19:32 +0000 (23:19 +1100)]
c++/reflection: Improve static_assert diagnostics when comparing reflections
This adds another case to static_assert to print a helpful diagnostic
when comparing reflections. This makes it easier to see what's gone
wrong when doing 'static_assert(some_query(^^a) == some_query(^^b));'
by decomposing the resulting resulting reflection.
gcc/cp/ChangeLog:
* constexpr.cc (diagnose_failing_condition): Also decompose
comparisons of reflections.
gcc/testsuite/ChangeLog:
* g++.dg/reflect/diag5.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Marek Polacek <polacek@redhat.com> Reviewed-by: Jason Merrill <jason@redhat.com>
Jerry DeLisle [Sun, 1 Mar 2026 01:30:41 +0000 (17:30 -0800)]
Fortran: Fix libfortran cannot be cross compiled [PR124286]
Remove unneeded check for a sane CLZL and regenerate using
the correct version of autoconf.
PR fortran/124286
libgfortran/ChangeLog:
* acinclude.m4: Remove LIBGFOR_CHECK_SANE_BUILTIN_CLZL.
* caf/shmem/allocator.c (next_power_of_two): Use known sane
builtin.
* configure: Regenerate.
* configure.ac: Remove use of LIBGFOR_CHECK_SANE_BUILTIN_CLZL.
Marek Polacek [Wed, 25 Feb 2026 21:05:17 +0000 (16:05 -0500)]
c++: ICE with scoped member variable template-id [PR123143]
In this test we crash in lookup_member with
s.S::template a<42> == 42
but not without the "S::". The problem is that lookup_member gets
a TEMPLATE_DECL and not an identifier.
In tsubst_expr/COMPONENT_REF for variable templates we should not
go to the "Lookup the template functions" block; we should let
finish_class_member_access_expr do the job.
PR c++/123143
gcc/cp/ChangeLog:
* pt.cc (tsubst_expr) <case COMPONENT_REF>: Check identifier_p
before doing lookup for a template function.
Marek Polacek [Thu, 26 Feb 2026 20:53:16 +0000 (15:53 -0500)]
c++/reflection: reflection is unevaluated operand [PR123608]
We reject this test with
error: default argument '^^a' uses local variable 'a'
However: [dcl.fct.default]/9: "A parameter shall not appear as
a potentially-evaluated expression in a default argument.", and
[expr.reflect]/7: "The id-expression of a reflect-expression
is an unevaluated operand."
We still have to look at REFLECT_EXPRs in check_out_of_consteval_use_r
though, otherwise it wouldn't work too well.
PR c++/123608
gcc/cp/ChangeLog:
* cp-tree.h (unevaluated_p): Include REFLECT_EXPR.
* reflect.cc (check_out_of_consteval_use_r): Don't give up early
on REFLECT_EXPR_P.
Eric Botcazou [Sat, 28 Feb 2026 18:48:23 +0000 (19:48 +0100)]
Ada: Fix infinite recursion on unchecked union with representation clause
This is a regression present on all active branches: the compiler enters an
infinite recursion when it is generating the initialization procedure of an
unchecked union type with a representation clause, because the layout it has
done for it is problematic. This comes from an old kludge added to support
aggregates for such types, so the fix is to further tweak this kludge.
gcc/ada/
PR ada/124285
* gcc-interface/decl.cc (components_to_record): Force a packed
layout for the innermost variant of an unchecked union type with
fixed part and full representation clause.
gcc/testsuite/
* gnat.dg/specs/unchecked_union3.ads: New test.
So when DOM discovers the edge equivalence for vptr_14 on the 4->5 edge DOM now
back-propagates the value to the uses of vptr_14, particularly uses in bb#1.
That allows us to discover a simple equivalence for _1 which is a key nugget to
unlocking this BZ.
1 = (_3 != 0) by way of traversing the 2->4 edge.
1 = (vptr_14 != 0) by way of traversing the 4->5 edge
_1 = 0 by backproping the state of vptr_14 to use point in bb1
The last step is to back-propagate the _1 = 0 equivalence to the use points of
_1 in bb1. In particular to this statement
_3 = _1 | _2;
If we know that _1 == 0, then _3 and _2 must have the same values (nonzero in
this case).
_2 = ownvptr_15(D) != 0;
Since we know the state of _2, we can compute the state of ownvptr_15. Which
was the goal. We're still on the 4->5 edge, but we've managed to compute an
equivalence for ownvptr_15 which in turn allows us to know how the branch at
the end of bb5 will go.
Note this is not jump threading. It's a conditional equivalence with back
propagation.
The additional lookups in the hash table trigger messages in the dump file.
The unconstrained_commons.f test scans the DOM dump file to ensure certain
messages never appear. That scan test is now bogus. The test has other things
it checks to ensure DOM hasn't done anything wrong. So that one scan test in
unconstrained_commons.f has been removed.
Bootstrapped and regression tested on x86, armv7, loongarch64, riscv64.
Regression tested on the usual crosses as well.
PR tree-optimization/90036
gcc/
* tree-ssa-dom.cc (back_propagate_equivalences): Accept new
argument for available expression stack. Lookup equivalences
in the expression hash table too. If an expression hash a
known constant value, record it and recurse.
(record_temporary_equivalences): Back propagate for a subset of
edge equivalences.
gcc/testsuite
* gcc.dg/tree-ssa/pr90036.c: New test.
* gfortran.dg/unconstrained_commons.f: Drop useless DOM hash table
lookup check.
David Malcolm [Sat, 28 Feb 2026 04:35:46 +0000 (23:35 -0500)]
aarch64: improve diagnostics for bogus JSON tuning inputs [PR124094]
Use json-diagnostic.{h,cc} to improve the diagnostics issued
for malformed and invalid JSON tuning inputs: report the
file/line/column and, if possible, the JSON Pointer of the
problematic input.
$ ./xgcc -B. -S test.c -muser-provided-CPU=unsigned-3.json
cc1: warning: JSON tuning file does not contain version information; compatibility cannot be verified
cc1: error: key ‘tune_params.sve_width’ value 5000000000 is out of range for ‘uint’ type [0, 4294967295]
cc1: error: validation failed for the provided JSON data
$ ./xgcc -B. -S test.c -muser-provided-CPU=unsigned-3.json
cc1: warning: JSON tuning file does not contain version information; compatibility cannot be verified
unsigned-3.json: In JSON value ‘/tune_params/sve_width’
unsigned-3.json:3:18: error: key ‘tune_params.sve_width’ value 5000000000 is out of range for ‘uint’ type [0, 4294967295]
3 | "sve_width": 5000000000
| ^~~~~~~~~~
cc1: error: validation failed for the provided JSON data
gcc/ChangeLog:
PR target/124094
* config/aarch64/aarch64-generate-json-tuning-routines.py
(generate_field_code): Add "ctxt, " arg to function call when
operation is "parse".
(generate_function): Add "gcc_json_context &ctxt, " param to
function decl when operation is "parse".
* config/aarch64/aarch64-json-tunings-parser-generated.inc:
Regenerate, passing around a gcc_json_context &.
* config/aarch64/aarch64-json-tunings-parser.cc: Include
"json-diagnostic.h".
(WARNING_OPT) New macro.
(PARSE_INTEGER_FIELD): Add "ctxt" param and pass it around.
(PARSE_UNSIGNED_INTEGER_FIELD): Likewise.
(PARSE_BOOLEAN_FIELD): Likewise.
(PARSE_STRING_FIELD): Likewise.
(PARSE_OBJECT): Likewise.
(PARSE_ARRAY_FIELD): Likewise.
(PARSE_ENUM_FIELD): Likewise.
(parse_func_type): Likewise.
(parse_object_helper): Likewise. Use json_error rather than error.
(inform_about_wrong_kind_of_json_value): New.
(extract_string): Add "ctxt" param. Replace "warning" with a pair
of calls to json_warning and
inform_about_wrong_kind_of_json_value, tweaking wording
accordingly.
(extract_integer): Likewise.
(extract_unsigned_integer): Likewise.
(parse_enum_field): Likewise.
(validate_and_traverse): Replace "warning" and "error" with
"json_warning" and "json_error".
(check_version_compatibility): Use WARNING_OPT. Add
auto_diagnostic_group to group the error and note.
(aarch64_load_tuning_params_from_json_string): Add "js_filename"
param. Use gcc_json_context to capture location info. Use it
when reporting errors to get file/line/column info. Replace check
on root being non-null with assertion, as this is guaranteed if
error is non-null. Replace warning with json_warning.
(aarch64_load_tuning_params_from_json): Pass data_filename to
aarch64_load_tuning_params_from_json_string for use when reporting
diagnostics.
(selftest::test_json_integers): Add a placeholder filename.
(selftest::test_json_boolean): Likewise.
(selftest::test_json_strings): Likewise.
(selftest::test_json_enums): Likewise.
gcc/testsuite/ChangeLog:
PR target/124094
* gcc.target/aarch64/aarch64-json-tunings/boolean-2.c: Add options
-fdiagnostics-show-caret -fdiagnostics-show-line-numbers. Replace
dg-error with a pair of dg-regexps to verify that we report the
filename and JSON Pointer of where the error occurs, and then
the filename and location within the JSON file. Verify that we
quote and underline the pertinent part of the JSON file.
* gcc.target/aarch64/aarch64-json-tunings/empty-brackets.c: Likewise.
* gcc.target/aarch64/aarch64-json-tunings/enum-2.c: Likewise.
* gcc.target/aarch64/aarch64-json-tunings/integer-2.c: Likewise.
* gcc.target/aarch64/aarch64-json-tunings/integer-3.c: Likewise.
* gcc.target/aarch64/aarch64-json-tunings/string-2.c: Likewise.
* gcc.target/aarch64/aarch64-json-tunings/unidentified-key.c: Likewise.
* gcc.target/aarch64/aarch64-json-tunings/unsigned-2.c: Likewise.
* gcc.target/aarch64/aarch64-json-tunings/unsigned-3.c: Likewise.
* gcc.target/aarch64/aarch64-json-tunings/malformed.c: New test,
to verify behavior on a malformed JSON input file.
* gcc.target/aarch64/aarch64-json-tunings/malformed.json: New
test file. This is malformed JSON, due to a missing ':" between
key and value.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
David Malcolm [Sat, 28 Feb 2026 04:35:45 +0000 (23:35 -0500)]
Add json-diagnostic.{cc,h}
This patch adds support for emitting diagnostics about JSON input files
to global_dc, showing both the file/line/columns and the JSON Pointer
for the problematic json::value. Test coverage is added by the followup
on aarch64.
gcc/ChangeLog:
* Makefile.in (OBJS-libcommon): Add json-diagnostic.o.
* diagnostics/client-data-hooks.h
(class client_data_hooks_decorator): New.
* diagnostics/context.cc (context::set_client_data_hooks): Return
the old hooks.
* diagnostics/context.h (context::set_client_data_hooks): Update
decl likewise.
* json-diagnostic.cc: New file.
* json-diagnostic.h: New file.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
David Malcolm [Sat, 28 Feb 2026 04:35:44 +0000 (23:35 -0500)]
diagnostics: split out physical_location_maker from libgdiagnostics
Make this code usable elsewhere.
No functional change intended.
gcc/ChangeLog:
* Makefile.in (OBJS-libcommon):
Add diagnostics/physical-location-maker.o.
* diagnostics/physical-location-maker.cc: New file, adapted from
material in libgdiagnostics.cc.
* diagnostics/physical-location-maker.h: New file, adapted from
material in libgdiagnostics.cc.
* libgdiagnostics.cc: Include
"diagnostics/physical-location-maker.h".
(diagnostic_manager::diagnostic_manager): Initialize
m_phys_loc_maker.
(diagnostic_manager::new_location_from_file_and_line): Split out
into physical_location_maker.
(diagnostic_manager::new_location_from_file_line_column):
Likewise.
(diagnostic_manager::ensure_linemap_for_file_and_line): Likewise.
(diagnostic_manager::m_phys_loc_maker): New field.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
David Malcolm [Sat, 28 Feb 2026 04:35:44 +0000 (23:35 -0500)]
diagnostics: use label_text for logical_location strings
Doing so makes it possible for logical_locations::manager subclasses to
return copies of temporary buffers, rather than requiring
the buffer to outlive the call. This is useful for generating
JSON pointer strings, for logical locations within JSON files.
gcc/ChangeLog:
* diagnostics/html-sink.cc
(html_builder::make_element_for_diagnostic): Update for logical
location strings being returned as label_text rather than
const char *.
* diagnostics/logical-locations.h
(logical_locations::manager::get_short_name): Return label_text
rather than const char *.
(logical_locations::manager::get_name_with_scope): Likewise.
(logical_locations::manager::get_internal_name): Likewise.
* diagnostics/sarif-sink.cc
(sarif_builder::ensure_sarif_logical_location_for): Update for
logical location strings being returned as label_text rather than
const char *.
(sarif_builder::make_minimal_sarif_logical_location): Likewise.
* diagnostics/selftest-logical-locations.cc
(test_manager::get_short_name): Likewise.
(test_manager::get_name_with_scope): Likewise.
(test_manager::get_internal_name): Likewise.
(selftest_logical_locations_cc_tests): Likewise.
* diagnostics/selftest-logical-locations.h
(test_manager::get_short_name): Likewise.
(test_manager::get_name_with_scope): Likewise.
(test_manager::get_internal_name): Likewise.
* diagnostics/state-graphs-to-dot.cc
(state_diagram::on_node_in_table): Likewise.
* libgdiagnostics.cc
(impl_logical_location_manager::get_short_name): Likewise.
(impl_logical_location_manager::get_name_with_scope): Likewise.
(impl_logical_location_manager::get_internal_name): Likewise.
* tree-logical-location.cc
(tree_logical_location_manager::get_short_name): Likewise.
(tree_logical_location_manager::get_name_with_scope): Likewise.
(tree_logical_location_manager::get_internal_name): Likewise.
* tree-logical-location.h
(tree_logical_location_manager::get_short_name): Likewise.
(tree_logical_location_manager::get_name_with_scope): Likewise.
(tree_logical_location_manager::get_internal_name): Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Sandra Loosemore [Fri, 27 Feb 2026 01:26:20 +0000 (01:26 +0000)]
doc: Restore anchors for deleted attribute section names.
This is a followup to commit gcc-16-7674-g6e3c137f5db: when I merged
attribute subsections, I should have left @anchors with the old names
in place to avoid breaking external links and bookmarks.
gcc/ChangeLog
* doc/extend.texi (Attributes): Rename the node "GNU Attribute
Syntax" node back to "Attribute Syntax"; fix references. Add
@anchor for sections recently merged away at the new location of
the material they used to contain.
openmp: Re-add support for private references to variable-length arrays with allocator clause [PR113436]
The previous patch for PR113436 fixed the testsuite regressions, but disabled
support for allocators when applied to references to variable-length objects
in private clauses. This patch re-adds it.
PR middle-end/113436
* omp-low.cc (lower_omp_target): Merge branches for allocating memory
for private clauses. Add handling for references when allocator
clause not specified.
gcc/testsuite/
PR middle-end/113436
* g++.dg/gomp/pr113436.C: Rename to...
* g++.dg/gomp/pr113436-1.C: ... this. Remove restriction on C++
dialect.
(f): Remove use of auto.
* g++.dg/gomp/pr113436-2.C: New. Original renamed to...
* g++.dg/gomp/pr113436-5.C: ... this. Add tests for alignment.
(f): Test references to VLAs of pointers.
* g++.dg/gomp/pr113436-3.C: New.
* g++.dg/gomp/pr113436-4.C: New.
libgomp/
PR middle-end/113436
* testsuite/libgomp.c++/pr113436-1.C (test_vla_by_ref): New.
(main): Add call to test_vla_by_ref.
* testsuite/libgomp.c++/pr113436-2.C (test_vla_by_ref): New.
(main): Add call to test_vla_by_ref.
Harald Anlauf [Tue, 24 Feb 2026 19:58:53 +0000 (20:58 +0100)]
Fortran: deferred-length character results and -fno-automatic [PR78187]
As the SAVE attribute cannot be specified for dummy variables and function
results (F2023:C862), the option -fno-automatic should not treat them as
automatically saved.
PR fortran/78187
gcc/fortran/ChangeLog:
* trans-decl.cc (gfc_trans_deferred_vars): An initialization block
shall be generated for deferred-length character results even
when -fno-automatic is given.
gcc/testsuite/ChangeLog:
* gfortran.dg/deferred_character_40.f90: New test.
Eric Botcazou [Fri, 27 Feb 2026 20:41:38 +0000 (21:41 +0100)]
Ada: Fix bogus visibility error for expression of iterated association
This completes the transition of the Resolve_Iterated_Association procedure
to the preanalysis of the original nodes for the sake of instantiations.
gcc/ada/
PR ada/124201
PR ada/124282
* exp_aggr.adb (Expand_Iterated_Component): Replace the iteration
variable in the expression as well.
* sem_aggr.adb (Resolve_Iterated_Component_Association): Preanalyze
the expression directly as well.
gcc/testsuite/
* gnat.dg/generic_inst18.adb: New test.
Eric Botcazou [Fri, 27 Feb 2026 18:54:33 +0000 (19:54 +0100)]
Ada: Fix assertion failure for unfrozen mutably tagged type as actual
This is a follow-up to the fix done last December at:
https://gcc.gnu.org/pipermail/gcc-patches/2025-December/704521.html
The fix is not sufficient when nested layers of generics are involved,
so this changes the implementation of mutably tagged types to have the
declaration of their CW-equivalent type immediately analyzed. But this
in turn requires making sure that the root type is frozen before the
CW-equivalent type in all cases.
gcc/ada/
PR ada/123306
* freeze.adb (Freeze_Entity): For a class-wide equivalent type of
a non-interface root type, freeze the root type before it.
* sem_ch3.adb (Derived_Type_Declaration): Minor tweak.
* sem_ch12.adb (Analyze_One_Association): Revert latest change.
* sem_ch13.adb (Analyze_Attribute_Definition_Clause) <Size>: When
the prefix is a class-wide type, insert the declaration of the CW-
equivalent type immediately after that of the root type, and the
size check for the root type into its own freezing actions.
gcc/testsuite/
* gnat.dg/specs/mutably_tagged2.ads: New test.
Owen Avery [Tue, 10 Feb 2026 03:45:48 +0000 (22:45 -0500)]
gccrs: Remove ProcMacroInvocLexer
ProcMacroInvocLexer and MacroInvocLexer were only separate because one
stored instances of const_TokenPtr directly, while the other stored
instances of AST::Token (a thin wrapper around const_TokenPtr). This
patch removes ProcMacroInvocLexer and makes MacroInvocLexer directly
store const_TokenPtr instances.
gcc/rust/ChangeLog:
* Make-lang.in (GRS_OBJS): Remove entries.
* ast/rust-ast.cc (DelimTokenTree::parse_to_meta_item): Handle
changes to AttributeParser.
(AttributeParser::AttributeParser): Change signature.
* ast/rust-macro.h (AttributeParser::AttributeParser): Likewise.
* expand/rust-macro-expand.cc
(MacroExpander::expand_eager_invocations): Handle changes to
MacroInvocLexer.
(MacroExpander::parse_proc_macro_output): Use MacroInvocLexer
instead of ProcMacroInvocLexer.
* expand/rust-macro-expand.h: Remove inclusion of
"rust-proc-macro-invoc-lexer.h".
* expand/rust-macro-invoc-lexer.cc
(MacroInvocLexer::peek_token): Handle changes to MacroInvocLexer
internal representation.
(MacroInvocLexer::get_token_slice): Likewise.
(MacroInvocLexer::split_current_token): Likewise and fix
iterator handling.
* expand/rust-macro-invoc-lexer.h (class MacroInvocLexerBase):
Remove and combine with...
(class MacroInvocLexer): ...its now only derived class.
* expand/rust-proc-macro-invoc-lexer.cc: Removed.
* expand/rust-proc-macro-invoc-lexer.h: Removed.
* parse/rust-parse-impl-proc-macro.cc: Removed.
Harishankar [Sat, 31 Jan 2026 12:15:51 +0000 (17:45 +0530)]
gccrs: parser: Fix rogue null pointer in null_denotation_path
The compiler previously crashed with a segmentation fault when parsing
a struct or tuple expression that failed to parse correctly (e.g.,
returning nullptr). This occurred because the parser implicitly wrapped
the null pointer result in a successful tl::expected, causing a crash
later when the compiler attempted to use the invalid pointer. This
patch adds checks in null_denotation_path to ensure that failed struct
and tuple parsing results are returned as errors (tl::unexpected)
instead of null pointers.
Fixes Rust-GCC/gccrs#4426
gcc/rust/ChangeLog:
* parse/rust-parse-impl-expr.hxx (null_denotation_path):
Check for null struct and tuple expressions to prevent segmentation fault.
Harishankar [Sat, 31 Jan 2026 12:15:51 +0000 (17:45 +0530)]
gccrs: parser: Fix ICE on invalid arithmetic expression
The compiler previously crashed with a segmentation fault when parsing
an arithmetic expression where the left-hand side was invalid (e.g.,
after a failed macro expansion). This occurred because the parser
attempted to access the location of the null 'left' pointer. This
patch adds a check to ensure the left operand is valid before proceeding.
Fixes Rust-GCC/gccrs#4414
gcc/rust/ChangeLog:
* parse/rust-parse-impl-expr.hxx (parse_arithmetic_or_logical_expr):
Check for null left operand to prevent segmentation fault.
Jayant Chauhan [Fri, 16 Jan 2026 17:23:28 +0000 (22:53 +0530)]
gccrs: ast: Add qualified_call helper to Builder
This patch implements the `qualified_call` helper method in the `Builder`
class. This logic was previously intended to be a local helper in
`DeriveClone`, but moving it to the `Builder` allows it to be reused
across the compiler for constructing qualified function calls.
It updates `DeriveClone::clone_call` to use this new `Builder` method,
simplifying the code and resolving the TODO.
Fixes Rust-GCC#4393
gcc/rust/ChangeLog:
* ast/rust-ast-builder.h (Builder::qualified_call): New method declaration.
* ast/rust-ast-builder.cc (Builder::qualified_call): Implement new method.
* expand/rust-derive-clone.cc (DeriveClone::clone_call): Use builder.qualified_call.
jayant chauhan [Sun, 1 Feb 2026 13:18:28 +0000 (18:48 +0530)]
gccrs: parser: Fix ICE in AnonConst by handling null macro result
The parse_anon_const function triggered an assertion failure (ICE) when
receiving a success Result containing a null expression pointer. This
occurred because null_denotation_path directly returned the result of
parse_macro_invocation_partial (which returns a raw pointer) without
checking for failure.
When parse_macro_invocation_partial failed (returning nullptr), it was
wrapped into a tl::expected success state containing nullptr, rather than
an error state.
This patch adds a check in null_denotation_path to verify if the parsed
macro invocation is null. If it is, it now returns a tl::unexpected error,
ensuring that invalid expressions are correctly reported as errors
upstream.
Fixes Rust-GCC#4412
gcc/rust/ChangeLog:
* parse/rust-parse-impl-expr.hxx (null_denotation_path): Check
if macro invocation returns null and return error.
Islam-Imad [Tue, 3 Feb 2026 12:11:48 +0000 (14:11 +0200)]
gccrs : parse: Fix ICE when using 'dyn' without trait bound
The parser was accepting 'dyn' as a standalone type in contexts like:
static STATIC_1: dyn = 1;
This invalid syntax should be rejected at parse time.
Fixes Rust-GCC/gccrs#3905
gcc/rust/ChangeLog:
* lex/rust-lex.cc (is_whitespace): refactor if-else to switch
* lex/rust-token.h: refactor if-else to switch
* parse/rust-parse-impl.hxx: return nullptr when type is in invalid state
gcc/testsuite/ChangeLog:
* rust/compile/issue-3904.rs: refactor the testcase to match the new thrown error
jayant chauhan [Sun, 1 Feb 2026 11:09:30 +0000 (16:39 +0530)]
gccrs: util/attributes: Fix ICE on bare #[deprecated] attribute
The check_deprecated_attribute function previously assumed that the
attribute always contained an input (arguments). However, #[deprecated]
is valid without arguments. Accessing the input on a bare #[deprecated]
attribute resulted in a null pointer dereference and a segmentation fault.
This patch adds a guard clause to check if the attribute has input
before attempting to access it, preventing the crash.
Fixes Rust-GCC#4410
gcc/rust/ChangeLog:
* util/rust-attributes.cc (check_deprecated_attribute): Guard against
attributes without input.
Harishankar [Thu, 22 Jan 2026 13:43:30 +0000 (19:13 +0530)]
gccrs: ast: Fix module path resolution for sibling modules in root
Currently, the compiler fails to resolve module paths when a file in the
root directory (e.g. 'bar.rs') attempts to load a sibling module
(e.g. 'foo.rs') if a 'bar/' directory does not exist. The compiler
incorrectly assumes that if 'bar.rs' is not 'mod.rs', it must look
exclusively in a subdirectory.
This patch adds a fallback mechanism in 'Module::process_file_path'.
If the subdirectory search fails, it strips the implicit subdirectory
and attempts to resolve the module in the parent directory, consistent
with Rust 2018 path rules.
Fixes Rust-GCC/gccrs#4402
gcc/rust/ChangeLog:
* ast/rust-ast.cc (Module::process_file_path): Add fallback search
for sibling modules when subdirectory search fails.
gcc/testsuite/ChangeLog:
* rust/compile/issue-4402.rs: New test.
* rust/compile/issue_4402_foo.rs: New test.
* rust/compile/compile.exp:Ignore issue_4402_foo.rs
Jayant Chauhan [Fri, 16 Jan 2026 16:58:00 +0000 (22:28 +0530)]
gccrs: util/attributes: Error on malformed lint attributes
Emit a diagnostic when lint attributes (allow, deny, warn, forbid) are
used without arguments. Previously, these attributes were accepted silently
if malformed, which could lead to confusion or ignored lints. This ensures
users are informed of the expected form: #[allow(lint_name)].
Fixes Rust-GCC#4358
gcc/rust/ChangeLog:
* util/rust-attributes.cc (check_lint_attribute): New helper.
(AttributeChecker::visit): Call helper for lint attributes on functions.
The compiler implicitely inject the core crate in every crate but those
explicitely tagged with `no_core`. Since most of the tests were
developped with no core in mind, most of those shall have the no_core
attribute inserted.
The core library is made accessible through the `core` identifier in
every crate unless the crate opt out with the `#![no_core]` attribute.
This commit implicitely inject this extern crate when required.
gcc/rust/ChangeLog:
* ast/rust-ast.cc (Crate::inject_extern_crate): Add a function to
inject an extern crate item to a crate.
* ast/rust-ast.h: Add function prototype for inject_extern_crate.
* rust-session-manager.cc (has_attribute): Add helper to determine if
a crate has a given inner attribute.
(Session::compile_crate): Add a step to inject the core extern crate
when the no_core attribute is missing.
* util/rust-attribute-values.h: Add the no_core attribute value.
gccrs: Prevent resolution of items within parent modules
An item from a parent module should be brought into scope with a Use
declaration and not implicitly. This means we should not continue
iterating over the upper ribs when meeting a module rib.
This fix breaks the compilation of core since the items from the
uppermost ribs are brought within scope with the prelude mechanism which
is not complete yet.
gcc/rust/ChangeLog:
* resolve/rust-forever-stack.hxx: Prevent iteration on parent ribs.
gcc/testsuite/ChangeLog:
* rust/compile/name_resolution26.rs: New test.
* rust/compile/derive-default1.rs: Add no_core attribute and fix the
testcase with a proper name usage which does not break name resolution
rules.
* rust/compile/derive-eq-invalid.rs: Likewise.
* rust/compile/derive-hash1.rs: Likewise.
* rust/compile/issue-2905-2.rs: Likewise.
* rust/compile/issue-3402-1.rs: Likewise.
* rust/compile/issue-3403.rs: Likewise.
* rust/compile/name_resolution18.rs: Likewise.
* rust/compile/privacy2.rs: Likewise.
* rust/execute/torture/derive-default1.rs: Likewise.
* rust/core/core.exp: Revert last compilation step to attribute check.
* typecheck/rust-hir-type-check-pattern.cc (visit(StructPattern)): Implement
type check case for HIR::StructPatternFieldTuplePat.
* checks/errors/rust-hir-pattern-analysis.cc (lower_struct_pattern): Implement
case for HIR::StructPatternField::ItemType::TUPLE_PAT.
* backend/rust-compile-pattern.cc:
* CompilePatternCheckExpr::visit (HIR::StructPattern): Implement code
gen for HIR::StructPatternField::ItemType::TUPLE_PAT case.
* CompilePatternBindings::handle_struct_pattern_tuple_pat: Implement
bindings for HIR::StructPatternFieldTuplePat.
* backend/rust-compile-pattern.h: Update function definition for
handle_struct_pattern_tuple_pat.
Mason Pike [Fri, 26 Dec 2025 15:06:51 +0000 (16:06 +0100)]
gccrs: add outer attributes
gcc/rust/ChangeLog:
* util/rust-attributes.cc: add attributes to the __outer_attributes set.
This prevents some inconsistent behavior, like: https://godbolt.org/z/Eq1GE7xxY
Mason Pike [Fri, 26 Dec 2025 14:45:47 +0000 (15:45 +0100)]
gccrs: remove some loops
gcc/rust/ChangeLog:
* util/rust-attributes.cc: factor out loops from
several functions to prevent us from having to loop
several times over the same attributes
Jayant Chauhan [Fri, 16 Jan 2026 19:49:56 +0000 (01:19 +0530)]
gccrs: expand: Refactor field expansion and add documentation
This patch refactors and in
to use a common template helper , reducing
code duplication as requested by the FIXME. It also adds missing documentation
for .
gcc/rust/ChangeLog:
* expand/rust-expand-visitor.h (expand_closure_params): Add documentation.
(expand_fields): New private template helper.
* expand/rust-expand-visitor.cc (expand_struct_fields): Use helper.
(expand_tuple_fields): Use helper.
Jayant Chauhan [Fri, 16 Jan 2026 19:20:36 +0000 (00:50 +0530)]
gccrs: backend: Factor out asm operand chaining
This patch introduces a static helper in .
This removes code duplication when building tree lists for assembly inputs
and outputs. It also removes commented-out debug code to clean up the file.
gcc/rust/ChangeLog:
* backend/rust-compile-asm.cc (chain_asm_operand): New helper.
(CompileAsm::asm_construct_outputs): Use helper and remove dead code.
(CompileAsm::asm_construct_inputs): Use helper and remove dead code.
* rust/compile/issue-4375-ice-regression.rs: New test.
* rust/compile/issue-4375-multiple-errors.rs: New test.
* rust/compile/issue-4375-tuple-pattern.rs: New test.
Jayant Chauhan [Thu, 15 Jan 2026 17:59:10 +0000 (23:29 +0530)]
gccrs: util/attributes: handle #[export_name] on static items
This patch enables validation for the #[export_name] attribute when used
on static items. It reuses the validation logic introduced for functions
to ensure that statics also receive compile-time checks for malformed
inputs (e.g. non-string literals).
Fixes Rust-GCC#4388
gcc/rust/ChangeLog:
* util/rust-attributes.cc (AttributeChecker::visit): Add check for
export_name on static items.
Jayant Chauhan [Thu, 15 Jan 2026 17:15:40 +0000 (22:45 +0530)]
gccrs: util/attributes: error on malformed #[export_name] input
Emit a diagnostic when #[export_name] is used without arguments or
with invalid arguments (non-string literals). This prevents silent
failures or backend crashes when lowering the attribute to GIMPLE,
ensuring the attribute follows the expected form: #[export_name = name].
Fixes Rust-GCC#4387
gcc/rust/ChangeLog:
* util/rust-attributes.cc (check_export_name_attribute): New helper.
(AttributeChecker::visit): Check export_name on functions.
Arthur Cohen [Wed, 14 Jan 2026 17:42:37 +0000 (18:42 +0100)]
gccrs: nr: Add proper prelude resolution and fill it upon encountering a prelude.
gcc/rust/ChangeLog:
* ast/rust-ast.h: Add Type::Kind.
* ast/rust-macro.h: Use it.
* ast/rust-path.h: Likewise.
* ast/rust-type.h: Likewise.
* resolve/rust-default-resolver.cc (is_lang_impl): New method.
(DefaultResolver::visit): Collect lang item implementations in the
prelude.
* resolve/rust-forever-stack.h: Add new method for lang prelude injection.
* resolve/rust-forever-stack.hxx: Define it.
* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Identifier patterns
can resolve to empty structs or variants.
* resolve/rust-name-resolution-context.h: Improve resolution.
The rust language requires the export_name attribute to change the name
of a symbol within the assembly whilst keeping a different name at the
language level. This is used multiple times within rust-for-linux.
gcc/rust/ChangeLog:
* backend/rust-compile-base.cc: Change the assembly name on functions
with the export_name attribute. Do not mangle the name.
* util/rust-attribute-values.h: Add export_name attribute value.
* util/rust-attributes.cc: Add export_name attribute to builtin
attribute list.
Jayant Chauhan [Tue, 13 Jan 2026 21:17:00 +0000 (02:47 +0530)]
gccrs: util/attributes: Check that #[target_feature] is only used on unsafe functions
The #[target_feature] attribute allows code generation that may not be
supported by the runtime hardware, making it inherently unsafe. This
patch adds a check to ensure it is only applied to functions declared
as 'unsafe', matching rustc behavior (E0658).
Fixes Rust-GCC#4234
gcc/rust/ChangeLog:
* util/rust-attributes.cc (AttributeChecker::visit):
Reject #[target_feature] on non-unsafe functions.
gcc/testsuite/ChangeLog:
* rust/compile/issue-4234.rs: New test.
* rust/compile/unsafe11.rs: Mark function as unsafe to
to satisfy new #[target_feature] restriction.
Removes duplicate error in block expression parsing.
Removes cascading error in match arm parsing.
Adds proper error detection for unterminated expression.
Fixes Rust-GCC/gccrs#1210
gcc/rust/ChangeLog:
* parse/rust-parse-impl-expr.hxx: Removes duplicate errors.
* parse/rust-parse-impl.hxx: Detects when an expression without
block is not properly terminated
Jayant Chauhan [Tue, 13 Jan 2026 08:10:47 +0000 (13:40 +0530)]
gccrs: util/attributes: Error on #[repr] applied to functions
The #[repr] attribute is only valid for structs, enums, and unions.
Applying it to a function is invalid and should result in an error.
This patch adds a check in the attribute visitor to reject #[repr]
on functions, matching rustc behavior.
Fixes Rust-GCC#4232
gcc/rust/ChangeLog:
* util/rust-attributes.cc (AttributeChecker::check_attributes): Emit error for #[repr].
Harishankar [Tue, 6 Jan 2026 13:50:29 +0000 (19:20 +0530)]
gccrs: Fix ICE in insert_associated_trait_impl due to recursion
Recursive const blocks containing trait implementations previously caused
an assertion failure (ICE) because the compiler re-visited existing IDs.
This patch adds a check to return early if the ID exists, enabling
graceful handling of recursion.
Fixes Rust-GCC/gccrs#4166
gcc/rust/ChangeLog:
* typecheck/rust-typecheck-context.cc (insert_associated_trait_impl):
Prevent ICE by checking for existing ID.
* typecheck/rust-hir-type-check.h: Update declarations.
Jayant Chauhan [Fri, 9 Jan 2026 23:47:33 +0000 (05:17 +0530)]
gccrs: util/attributes: error on malformed #[link_section] input
Emit a diagnostic when #[link_section] is used without arguments on
functions or static items, matching rustc behavior. This prevents
silent acceptance of empty attributes and provides a helpful
diagnostic that shows the expected form.
Fixes Rust-GCC#4229
gcc/rust/ChangeLog:
* util/rust-attributes.cc (check_link_section_attribute): New helper.
(AttributeChecker::visit): Check link_section on functions and statics.
gcc/testsuite/ChangeLog:
* rust/compile/link_section-malformed.rs: New test.
James Bohl [Fri, 27 Feb 2026 12:32:16 +0000 (07:32 -0500)]
a68: Allow full range of negative values in integral denotations
Signed-off-by: James Bohl <bohlj47@gmail.com>
gcc/algol68/ChangeLog
* a68-low-prelude.cc (a68_lower_negate2): Annotate denotation
as being negated.
* a68-low-units.cc (a68_lower_denotation): Allow the full range
of negative values if the denotation is negated.
* a68-types.h (struct NODE_T): Add negated field.
(NEGATED): Define.
* a68-parser.cc (a68_new_node): Initialize NEGATED.
gcc/testsuite/ChangeLog
* algol68/compile/error-denotation-2.a68: Check for no error on
minimum negative value.
* algol68/compile/error-denotation-3.a68: Likewise.
Tamar Christina [Fri, 27 Feb 2026 14:21:36 +0000 (14:21 +0000)]
vect: enforce trapping math checks when early breaks [PR124142]
The loop
void
__attribute__((noipa))
bug (int f, int *w, int l)
{
int i;
for (i = 0; i < l; ++i)
while (f % w[i]) w[i]--;
}
is an uncounted loop which performs a trapping operation during vectorization.
Normally the vectorizer doesn't stop vectorization if the operation can't be
masked (though ifcvt does).
For Early breaks however this is unsafe as we are introducing a trap where the
original scalar code may not have.
Some tests now fail to vectorize (including some tsvc ones) which I could have
xfail'ed but instead decided to add -fno-trapping-math just to get the
additional coverage they provide.
gcc/ChangeLog:
PR tree-optimization/124142
* tree-vect-data-refs.cc (vect_analyze_early_break_dependences):
For early break require masking when operation can trap.
Jeff Law [Sun, 22 Feb 2026 16:26:38 +0000 (09:26 -0700)]
[1/n][PR tree-optimization/90036] All refinement of entries in DOM hash table
This is the first of a few patches to fix pr90036.
I've gone back and forth about whether or not to fix this for gcc-16 or queue
for gcc-17. Ultimately I don't think these opportunities are *that* common, so
I don't expect widespread code generation changes.
I'm going to drop the changes in a small series as the changes stand on their
own. This gives us better bisectability.
--
The first patch allows refinement of existing equivalences in a case where we'd
missed it before. In particular say we have <res> = <expr> in the expression
hash table. We later use <expr> in a way that creates a temporary expression
equivalence. We'll fail to record that temporary expression equivalence
because of the pre-existing entry in the hash table.
And just to be clear, the old equivalence will be restored when we leave the
domwalk scope of the newer, more precise, hash table entry.
This matters for pr90036 as we initially enter a simple equivalence in the
table with the result being an SSA_NAME. Later we have a conditional that
allows us to refine the result to a constant. And we're going to need that
constant result to trigger additional simplifications and equivalence
discovery.
Bootstrapped and regression tested on x86_64, aarch64, riscv64 and probably a
couple others as well. It's also been tested across the embedded targets in my
tester. Pushing to the trunk.
PR tree-optimization/90036
gcc/
* tree-ssa-scopedtables.cc (avail_exprs_stack::record_cond): Always
record the new hash table entry.
Xi Ruoyao [Fri, 27 Feb 2026 08:54:40 +0000 (16:54 +0800)]
middle-end: allow expand_vector_broadcast to broadcast QImode to BImode vector [PR 124280]
A boolean value is in QImode, but a vector of booleans is in VxxBImode.
And both AArch64 SVE and RISC-V V have vec_duplicatevXXbi accepting a QI
scalar. Allow this case.
PR middle-end/124280
gcc/
* optabs.cc (expand_vector_broadcast): Allow broadcasting QImode
to BImode vector.
Martin Jambor [Fri, 27 Feb 2026 13:26:13 +0000 (14:26 +0100)]
ipa-prop: Reset param_index of indir. edge when there are no jfuncs (PR123229)
In my commit r16-6149-g14ee9a2b41bafa I have added an early exit to
update_indirect_edges_after_inlining which was however wrong, as
demonstrated by the PR123229 testcase. This patch reverts that change,
restoring the previous behavior in this regard.
In the testcase, the edge being inlined is a call to a thunk, which do
not have jump functions associated with them. This means that with
the early exit we neither reset the parameter index associated with
the indirect edge nor update the edges and the usage flags associated
with them
In the testcase, this meant that the param_used_by_indirect_call flag
was not updated, which in turn meant that the inlining edge cost cache
did not copy necessary information into the context which led to the
fact that two contexts which were not the same were considered the
same, and the checking code that evaluations in the cache should match
a re-evaluation triggered. But unfortunately this bug can probably
have all sorts of weird and unexpected consequences.
The testcase also shows that inlined thunks are a barrier to
devirtualization which is something I will try to address next stage1.
gcc/ChangeLog:
2026-02-27 Martin Jambor <mjambor@suse.cz>
PR ipa/123229
* ipa-prop.cc (update_indirect_edges_after_inlining): Reset parameter
index associated with an indirect edge if the inlined edge does not
have any jump functions.
Soumya AR [Thu, 26 Feb 2026 04:55:48 +0000 (04:55 +0000)]
aarch64: Fix NULL structures in base tunings being silently ignored by JSON parser
In the JSON parser's parse_object_helper for const pointer members, we have a
if (!member) return; guard at entry.
This is because the function works by dereferencing the member pointer and
making a non-const copy of the object it points to. The parser can then
override this copy with new values and re-assign the pointer to the new object.
This is problematic if member is NULL in the base tunings, but provided in the
JSON file, which can happen with some combinations of -mcpu and
-muser-provided-CPU.
For example, with no -mcpu, if the generic tunings has issue_info set to
nullptr (eg. generic_armv8_a), then even if the user does provide issue_info
data in the JSON file, parse_object_helper will silently ignore it.
The naive fix for this is to create a zero-initialized copy of the object if
it is NULL, and then override it with the new values from the JSON file.
However, this results in another problem: if the user provides only selective
fields of the strucutre, the rest of the fields will be set to zero and
potentially interfere with costing decisions.
I think at that point the best we can do is emit a warning. With David Malcolm's
improved JSON diagnostics, we can be specific about the problematic structure as
well.
----
Since we potentially zero-initialize objects, I had to add a default constructor
to objects that only had parameterized constructors.
Bootstrapped and regtested on aarch64-linux-gnu, OK for trunk?
Signed-off-by: Soumya AR <soumyaa@nvidia.com>
gcc/ChangeLog:
* config/aarch64/aarch64-json-tunings-parser.cc (parse_object_helper):
Zero-initialize objects that are NULL in the base tunings, if provided
in JSON tunings.
* config/aarch64/aarch64-protos.h (struct sve_vec_cost): Add default
constructor.
(struct aarch64_simd_vec_issue_info): Likewise.
(struct aarch64_sve_vec_issue_info): Likewise.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/aarch64-json-tunings/nullptr-issue-info.c:
New test.
* gcc.target/aarch64/aarch64-json-tunings/nullptr-issue-info.json:
New test input.
Martin Jambor [Fri, 27 Feb 2026 10:58:01 +0000 (11:58 +0100)]
ipa: Meet same speculative and certain polymorphic contexts (PR123629)
PR 123629 is a somewhat complicated situation. IPA-CP clones for a
known speculative polymorphic context in a situation when a caller
bringing the known context has itself already been cloned, and now we
can determine that the context coming from that clone is not
speculative (but otherwise the same). This confuses the meet function
of contexts which gives up and returns a useless context, which in
turn triggers an assert because the value we originally cloned for is
nowhere to be found in the data structures which describe what we know
about the function clone.
This patch changes the meet function so that it can deal with this
situation. When one of the contexts does not have a certain
component, the other one is moved to the speculative one.
gcc/ChangeLog:
2026-02-23 Martin Jambor <mjambor@suse.cz>
PR ipa/123629
* ipa-polymorphic-call.cc
(ipa_polymorphic_call_context::meet_with): When an outer context is
NULL, call make_speculative on the other one.
Tamar Christina [Fri, 27 Feb 2026 07:41:20 +0000 (07:41 +0000)]
AArch64: Don't enable ptest elimination for partial vectors [PR124162]
The following loop
char b = 41;
int main() {
signed char a[31];
#pragma GCC novector
for (int c = 0; c < 31; ++c)
a[c] = c * c + c % 5;
{
signed char *d = a;
#pragma GCC novector
for (int c = 0; c < 31; ++c, b += -16)
d[c] += b;
}
for (int c = 0; c < 31; ++c) {
signed char e = c * c + c % 5 + 41 + c * -16;
if (a[c] != e)
__builtin_abort();
}
}
compiled with -O2 -ftree-vectorize -msve-vector-bits=256 -march=armv8.2-a+sve
Which uses a predicate for the first iteration where all bits are 1. i.e. all
lanes active. This causes the result of the cmpne to set the wrong CC flags.
The second iteration uses
whilelo p7.s, w0, w2
which gives the correct mask layout going forward.
This is due to the CSE'ing code that tries to share predicates as much as
possible. In aarch64_expand_mov_immediate we do during predicate generation
/* Only the low bit of each .H, .S and .D element is defined,
so we can set the upper bits to whatever we like. If the
predicate is all-true in MODE, prefer to set all the undefined
bits as well, so that we can share a single .B predicate for
all modes. */
if (imm == CONSTM1_RTX (mode))
imm = CONSTM1_RTX (VNx16BImode);
which essentially maps all predicates to .b unless the predicate is created
outside the immediate expansion code.
It creates the sparse predicate for data lane VNx4QI from a VNx16QI and then
has a "conversion" operation. The conversion operation results in a simple copy:
mov p7.b, p6.b
because in the data model for partial vectors the upper lanes are *don't care*.
So computations using this vector are fine. However for comparisons, or any
operations setting flags the predicate value does matter otherwise we get the
wrong flags as the above.
Additionally we don't have a way to distinguish based on the predicate alone
whether the operation is partial or not. i.e. we have no "partial predicate"
modes.
two ways to solve this:
1. restore the ptest for partial vector compares. This would slow down the loop
though and introduce a second ptrue .s, VL8 predicate.
2. disable the sharing of partial vector predicates. This allows us to remove
the ptest. Since the ptest would introduce a second predicate here anyway
I'm leaning towards disabling sharing between partial and full predicates.
For the patch I ended up going with 1. The reason is that this is that
unsharing the predicate does end up being pessimistic loops that only operate on
full vectors only (which are the majority of the cases).
I also don't fully understand all the places we depend on this sharing (and
about 3600 ACLE tests fail assembler scans). I suspect one way to possibly
deal with this is to perform the sharing on GIMPLE using the new isel hook and
make RTL constant expansion not manually force it. Since in gimple it's easy to
follow compares from a back-edge to figure out if it's safe to share the
predicate.
I also tried changing it so that during cond_vec_cbranch_any we perform an AND
with the proper partial predicate. But unfortunately folding doesn't realize
that the and on the latch edge is useless (e.g. whilelo p7.s, w0, w2 makes it
a no-op) and that the AND should be moved outside the loop. This is something
that again isel should be able to do.
I also tried changing the
mov p7.b, p6.b
into an AND, while this worked, folding didn't quite get that the and can be
eliminated. And this also pessimists actual register copies.
So for now I just undo ptest elimination for partial vectors for GCC 16 and will
revisit it for GCC 17 when we extend ptest elimination.
gcc/ChangeLog:
PR target/124162
* config/aarch64/aarch64-sve.md (cond_vec_cbranch_any,
cond_vec_cbranch_all): Drop partial vectors support.
gcc/testsuite/ChangeLog:
PR target/124162
* gcc.target/aarch64/sve/vect-early-break-cbranch_16.c: New test.
Andrew Pinski [Thu, 26 Feb 2026 20:06:51 +0000 (12:06 -0800)]
phiopt: Reject hot/cold predictors for early phiopt [PR117935]
In this case, early phiopt would get rid of the user provided predicator
for hot/cold as it would remove the basic blocks. The easiest and best option is
for early phi-opt don't do phi-opt if the middle basic-block(s) have either
a hot or cold predict statement. Then after inlining, jump threading will most likely
happen and that will keep around the predictor.
Note this only needs to be done for match_simplify_replacement and not the other
phi-opt functions because currently only match_simplify_replacement is able to skip
middle bb with predicator statements in it.
This allows for MIN/MAX/ABS/NEG still even with the predicators there as those will
less likely be jump threaded later on. The main thing that is rejected is ssa names
that are alone where one of the comparisons operands is that one or if we produce
a comparison from the phiopt.
Changes since v1:
* v2: Only reject if the result was the comparison.
Bootstrapped and tested on x86_64-linux-gnu.
PR tree-optimization/117935
gcc/ChangeLog:
* tree-ssa-phiopt.cc (contains_hot_cold_predict): New function.
(match_simplify_replacement): Return early if early_p and one of
the middle bb(s) have a hot/cold predict statement.
gcc/testsuite/ChangeLog:
* gcc.dg/predict-24.c: New test.
* gcc.dg/predict-25.c: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Robert Dubner [Thu, 26 Feb 2026 19:42:51 +0000 (14:42 -0500)]
cobol: Fix FUNCTION TRIM.
The FUNCTION TRIM now works properly with UTF16 inputs.
According to the ISO specification, the return type of a number of
intrinsic functions is defined by the variable type of their first
parameter. A number of changes here cause more functions to honor that
requirement.
gcc/cobol/ChangeLog:
* parse.y: BASECONVERT and TRIM take their type from their first
parameter.
* parse_util.h (intrinsic_return_field): The function_descrs[] is
adjusted so that a number of functions take their return type from
their first calling parameter. intrinsic_return_field() has been
refined.
* symbols.cc (new_alphanumeric): Use set_explicit() instead of
set() in support of refined intrinsic function return type.
libgcobol/ChangeLog:
* intrinsic.cc (__gg__trim): Rewritten to work properly, and avoid
unnecessary variable codeset encoding translation.
Eric Botcazou [Thu, 26 Feb 2026 21:13:22 +0000 (22:13 +0100)]
Ada: Fix bogus visibility error for iterated element association with key
The problem is that the Resolve_Iterated_Association procedure, unlike its
sibling Resolve_Iterated_Component_Association, preanalyzes a copy of the
specification so, in a generic context, global references cannot later be
captured. This changes it to preanalyze the specification directly, which
requires a small adjustment during expansion.
gcc/ada/
PR ada/124201
* exp_aggr.adb (Expand_Iterated_Component): Replace the iteration
variable in the key expression and iterator filter, if any.
* sem_aggr.adb (Resolve_Iterated_Component_Association): Preanalyze
the specification and key expression directly.
gcc/testsuite/
* gnat.dg/generic_inst17.adb: New test.
Ruslan Valiyev [Thu, 26 Feb 2026 19:15:06 +0000 (19:15 +0000)]
libiberty: fix resource exhaustion in rust demangler (PR demangler/106641)
demangle_binder() parses the bound_lifetimes count as a base-62
integer with no upper bound. A crafted symbol can encode a huge
lifetime count in very few bytes, causing OOM or CPU hang.
Cap bound_lifetimes at 1024 and check rdm->errored in the loop
so it bails out early on errors during iteration.
libiberty/ChangeLog:
PR demangler/106641
* rust-demangle.c (demangle_binder): Reject bound_lifetimes
above 1024 to prevent resource exhaustion from crafted symbols.
Add rdm->errored check in the loop condition.
* testsuite/rust-demangle-expected: Add regression test.
Signed-off-by: Ruslan Valiyev <linuxoid@gmail.com>