]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
13 days agotestsuite: Require hard_float eff. target and use -frounding-math in bitint-31.c
Jakub Jelinek [Wed, 15 Apr 2026 07:54:55 +0000 (09:54 +0200)] 
testsuite: Require hard_float eff. target and use -frounding-math in bitint-31.c

Other tests which use fesetround and test rounding behavior use both
fenv and hard_float effective targets and -frounding-math in dg-options.

This patch adjusts bitint-31.c to do the same.

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

* gcc.dg/bitint-31.c: Require hard_float effective target, add
-frounding-math to dg-options.

13 days agolibstdc++: Implement LWG4403: CTAD misses difference type casting
Matthias Kretz [Tue, 14 Apr 2026 12:54:03 +0000 (14:54 +0200)] 
libstdc++: Implement LWG4403: CTAD misses difference type casting

libstdc++-v3/ChangeLog:

* include/bits/simd_vec.h (basic_vec deduction guide): Explicit
cast to simd-size-type from range size type.

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
13 days agoc++: Implement CWG3149 - Rvalues in destructuring expansion statements
Jakub Jelinek [Wed, 15 Apr 2026 07:02:06 +0000 (09:02 +0200)] 
c++: Implement CWG3149 - Rvalues in destructuring expansion statements

The following patch implements CWG3149.  If expansion_init
is not an lvalue in destructiring expansion stmt, init is wrapped
in a static_cast to decltype(u_i)&&.

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

* pt.cc (finish_expansion_stmt): Implement CWG3149 - Rvalues in
destructuring expansion statements.  For esk_destructuring, if
expansion_init is not lvalue_p, wrap init into a static_cast
to decltype of destruct_decls[i].

* g++.dg/cpp26/expansion-stmt39.C: New test.
* g++.dg/reflect/cwg3149.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
13 days agoc++: Fix up type alias reflection mangling
Jakub Jelinek [Wed, 15 Apr 2026 06:59:43 +0000 (08:59 +0200)] 
c++: Fix up type alias reflection mangling

As discussed earlier, including in the
https://github.com/itanium-cxx-abi/cxx-abi/issues/208
issue, we should include the underlying type in the mangling of
type aliases in addition to mangling the name of the type alias,
because in different TUs the type alias could have different underlying
types.
Just adding write_char ('_'); write_type (DECL_ORIGINAL_TYPE (arg));
is not enough though, because write_prefix (arg); is subject of
substitutions and we treat the underlying type and type alias as
similar types for substitution purposes.
So, I think we have to avoid that, we can remember for substitutions
decl_mangling_prefix of the type alias TYPE_DECL, but I think we need
to then emit the unqualified name and optionally template arguments
if it is an alias template.

The following patch implements that.

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

* mangle.cc (write_reflection): Adjust grammar for type alias
reflections.  Don't use write_prefix on arg, instead
write_prefix its mangling context, write_unqualified_name of
the alias, optionally write_template_args, append underscore
and write_type the original type.

* g++.dg/reflect/mangle1.C: Adjust expected mangling of type
aliases.

Reviewed-by: Jason Merrill <jason@redhat.com>
13 days agoc++: Check base accessibility in cp_decomp_size [PR124862]
Jakub Jelinek [Wed, 15 Apr 2026 06:57:23 +0000 (08:57 +0200)] 
c++: Check base accessibility in cp_decomp_size [PR124862]

clang in __builtin_structured_binding_size checks whether base which
contains the destructible members is accessible.
In cp_finish_decomp we call:
      if (type != btype)
        {
          t = convert_to_base (t, btype, /*check_access*/true,
                               /*nonnull*/false, tf_warning_or_error);
          type = btype;
        }
which calls lookup_base which diagnoses that.  The following patch
just calls lookup_base in that case.

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

PR c++/124862
* decl.cc (cp_decomp_size): If btype is different from type,
check if it is accessible.

* g++.dg/ext/builtin-structured-binding-size5.C: New test.
* g++.dg/ext/builtin-structured-binding-size6.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
13 days agoc++: Mark in cxx_mark_addressable DECL_VALUE_EXPR of DECL_ANON_UNION_VAR_P too [PR124850]
Jakub Jelinek [Wed, 15 Apr 2026 06:55:48 +0000 (08:55 +0200)] 
c++: Mark in cxx_mark_addressable DECL_VALUE_EXPR of DECL_ANON_UNION_VAR_P too [PR124850]

The following testcase ICEs since my PR53932 change in checking,
because it sees address of the unnamed anon union VAR_DECL taken
but without having TREE_ADDRESSABLE set.

The following patch sets it during cxx_mark_addressable.  I'm wondering
how we can get away with not marking other DECL_VALUE_EXPR cases,
but couldn't come up with a testcase where it would be needed (e.g. for
structured bindings, etc.).  So just doing it for anon union vars seems
safer to me at least for now.

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

PR c++/124850
* typeck.cc (cxx_mark_addressable): For DECL_ANON_UNION_VAR_P vars
also mark their DECL_VALUE_EXPR.

* g++.dg/other/anon-union8.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
13 days agoc++, libstdc++: Implement LWG4483 - Multidimensional arrays are not supported by...
Jakub Jelinek [Wed, 15 Apr 2026 06:52:17 +0000 (08:52 +0200)] 
c++, libstdc++: Implement LWG4483 - Multidimensional arrays are not supported by meta::reflect_constant_array and related functions

The following patch attempts to implement LWG4483.  As written in the
approved resolution, some checks are done on strip_array_types (valuet)
rather than on valuet and one is skipped.  Tomasz on IRC reasoned why
input_range should otherwise already ensure we see similar type, so just
for the possibility of fuzzed <meta> the patch adds some verification.
And as the array cases are contiguous, instead of actually recursing (for
which we'd need to have lvalue of the *it rather than prvalue) it just
walks the CONSTRUCTORs for the arrays and handles the elts in there
recursively.
The <meta> changes do exactly what the LWG4483 change says to do.

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

* reflect.cc (adjust_array_elt): New function.
(get_range_elts): Implement LWG4483 - Multidimensional arrays are not
supported by meta::reflect_constant_array and related functions.
Handle ARRAY_TYPE valuet.  Don't unshare_expr in the class valuet case,
get_template_param_object will unshare.

* g++.dg/reflect/reflect_constant_array9.C: New test.
* g++.dg/reflect/reflect_constant_array10.C: New test.
* g++.dg/reflect/reflect_constant_array11.C: New test.
* g++.dg/reflect/define_static_array6.C: New test.
* g++.dg/reflect/define_static_object2.C: Uncomment older tests and
fix them, add tests for unions.

* include/std/meta (define_static_object): Adjust for LWG4483 changes
- handle unions and arrays differently.

Reviewed-by: Jason Merrill <jason@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
13 days agox86: Fix a typo in comments
H.J. Lu [Wed, 15 Apr 2026 05:40:18 +0000 (13:40 +0800)] 
x86: Fix a typo in comments

Since x86_64_preserve_none_int_parameter_registers is used in
ix86_function_arg_regno_p, not ix86_function_value_regno_p, replace
ix86_function_value_regno_p with ix86_function_arg_regno_p in comments.

* config/i386/i386.cc
(x86_64_preserve_none_int_parameter_registers): Replace
ix86_function_value_regno_p with ix86_function_arg_regno_p in
comments.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
13 days agogcov: return failure if malloc fails
Torbjörn SVENSSON [Thu, 26 Mar 2026 18:02:16 +0000 (19:02 +0100)] 
gcov: return failure if malloc fails

Don't assume that malloc always returns a non-null pointer.

xmalloc is sometimes an alias for malloc due to this in libgcc/libgcov.h:

  /* work around the poisoned malloc/calloc in system.h.  */
  #ifndef xmalloc
  #define xmalloc malloc
  #endif

libgcc/ChangeLog:

* libgcov-driver-system.c (gcov_exit_open_gcda_file): Handle
potential NULL value from malloc.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
13 days agotestsuite: add missing override to member function
Torbjörn SVENSSON [Tue, 14 Apr 2026 13:11:02 +0000 (15:11 +0200)] 
testsuite: add missing override to member function

Without this patch, this ends up in the logs with llvm as the default
compiler for the host:

/build/gcc_src/gcc/testsuite/gcc.dg/plugin/analyzer_known_fns_plugin.cc:122:8: warning: 'matches_call_types_p' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
  122 |   bool matches_call_types_p (const call_details &cd) const
      |        ^
/build/r16-8473-g5cc0ead3625fe6/bin/../lib/gcc/arm-none-eabi/16.0.1/plugin/include/analyzer/common.h:301:16: note: overridden virtual function is here
  301 |   virtual bool matches_call_types_p (const call_details &cd) const = 0;
      |                ^
1 warning generated.

gcc/testsuite/ChangeLog:

* gcc.dg/plugin/analyzer_known_fns_plugin.cc: Add missing
override to member function.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
13 days agotestsuite: add explicit comparison to if statement
Torbjörn SVENSSON [Tue, 14 Apr 2026 13:18:57 +0000 (15:18 +0200)] 
testsuite: add explicit comparison to if statement

Without this patch, this ends up in the logs with llvm as the default
compiler for the host:

/build/gcc_src/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.cc:484:17: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
  484 |               if (call = check_for_named_call (stmt, "acquire_lock_a", 0))
      |                   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/build/gcc_src/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.cc:484:17: note: place parentheses around the assignment to silence this warning
  484 |               if (call = check_for_named_call (stmt, "acquire_lock_a", 0))
      |                        ^
      |                   (                                                      )
/build/gcc_src/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.cc:484:17: note: use '==' to turn this assignment into an equality comparison
  484 |               if (call = check_for_named_call (stmt, "acquire_lock_a", 0))
      |                        ^
      |                        ==
...
2 warnings generated.

gcc/testsuite/ChangeLog:

* gcc.dg/plugin/diagnostic_plugin_test_paths.cc: Compare with
NULL in if statement.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
13 days agogccrs: backend: Prevent error_mark_node from leaking into const context
jayant chauhan [Sat, 14 Feb 2026 18:59:26 +0000 (00:29 +0530)] 
gccrs: backend: Prevent error_mark_node from leaking into const context

Fixes Rust-GCC#3910

gcc/rust/ChangeLog:

* backend/rust-compile-item.cc (CompileItem::visit): Do not insert
const_expr into the context if it is an error_mark_node.
* backend/rust-compile-implitem.cc (CompileTraitItem::visit): Likewise.

gcc/testsuite/ChangeLog:

* rust/compile/issue-3910.rs: New test.

Signed-off-by: jayant chauhan <0001jayant@gmail.com>
13 days agogccrs: Added test case for global import all
AhmedSaid3617 [Sat, 11 Apr 2026 09:41:47 +0000 (11:41 +0200)] 
gccrs: Added test case for global import all

gcc/testsuite/ChangeLog:

* rust/compile/glob-import-all.rs: New test.

Signed-off-by: AhmedSaid3617 <said.ahmed3617@gmail.com>
13 days agogccrs: Fixed glob-import all ICE
AhmedSaid3617 [Sat, 11 Apr 2026 09:35:56 +0000 (11:35 +0200)] 
gccrs: Fixed glob-import all ICE

Modified toplevel name resolver to recognize use ::*; and use *; as valid import statements, to prevent ICE.

gcc/rust/ChangeLog:

* ast/rust-item.h:(PathType::get_glob_type): Added const qualifier to allow
function call from const objects.
* resolve/rust-forever-stack.hxx:
(ForeverStack<N>::resolve_path): Check for empty segments vector and
return starting point.
* resolve/rust-toplevel-name-resolver-2.0.cc (flatten_glob): Preserve the
opening scope resolution property of the use statement.

Signed-off-by: AhmedSaid3617 <said.ahmed3617@gmail.com>
13 days agogccrs: Fix ICE in unused var when we hit unit const type
Islam-Imad [Thu, 9 Apr 2026 13:09:10 +0000 (15:09 +0200)] 
gccrs: Fix ICE in unused var when we hit unit const type

the problem is compiling if-expr doesn't set translated to unit type.

gcc/rust/ChangeLog:

* backend/rust-compile-expr.cc (CompileExpr::visit): set unit type.

gcc/testsuite/ChangeLog:

* rust/compile/issue-4517.rs: New test.

Signed-off-by: Islam-Imad <islamimad404@gmail.com>
13 days agogccrs: intrinsic: Add tests for cttz and cttz_nonzero
Mohamed Ali [Wed, 1 Apr 2026 17:38:13 +0000 (19:38 +0200)] 
gccrs: intrinsic: Add tests for cttz and cttz_nonzero

gcc/testsuite/ChangeLog:

* rust/compile/cttz.rs: New test.
* rust/compile/cttz_nonzero.rs: New test.
* rust/execute/torture/cttz.rs: New test.
* rust/execute/torture/cttz_nonzero.rs: New test.

Signed-off-by: Mohamed Ali <mohmedali1462005@gmail.com>
13 days agogccrs: intrinsic: Add cttz and cttz_nonzero intrinsics
Mohamed Ali [Wed, 1 Apr 2026 17:26:25 +0000 (19:26 +0200)] 
gccrs: intrinsic: Add cttz and cttz_nonzero intrinsics

This commit introduces the cttz and cttz_nonzero intrinsics for counting leading zeros
in integer types.

The implementation includes handlers for both intrinsics, which validate input types and utilize

Addresses: Rust-GCC#658

gcc/rust/ChangeLog:

* backend/rust-compile-intrinsic.cc: Register cttz and cttz_nonzero intrinsics.
* backend/rust-intrinsic-handlers.cc (cttz_handler): Implemnt cttz_handler.
(cttz_nonzero_handler): Implemnt cttz_nonzero_handler.
* backend/rust-intrinsic-handlers.h (cttz_handler): Add decl for cttz_handler.
(cttz_nonzero_handler): Add decl for cttz_handler.
* util/rust-intrinsic-values.h: map cttz_nonzero to its name.

Signed-off-by: Mohamed Ali <mohmedali1462005@gmail.com>
13 days agogccrs: Replace usages of chainon
Owen Avery [Mon, 30 Mar 2026 02:21:20 +0000 (22:21 -0400)] 
gccrs: Replace usages of chainon

gcc/rust/ChangeLog:

* backend/rust-compile-asm.cc: Include "rust-ggc.h".
(chain_asm_operand): Use GGC::ChainList.
(CompileAsm::asm_construct_outputs): Likewise.
(CompileAsm::asm_construct_inputs): Likewise.
(CompileLlvmAsm::construct_operands): Likewise.
(CompileLlvmAsm::construct_clobbers): Likewise.
* util/rust-ggc.h (class ChainList): New class.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
13 days agogccrs: refactor function qualifier parsing
Philipp Gesang [Thu, 12 Mar 2026 19:59:15 +0000 (20:59 +0100)] 
gccrs: refactor function qualifier parsing

gcc/rust/ChangeLog
* parse/rust-parse-impl.hxx: Refactor qualifier parsing
* parse/rust-parse.h: (parse_function_qualifiers) Likewise

Signed-off-by: Philipp Gesang <phg@phi-gamma.net>
13 days agogccrs: parse all function qualifiers before generating error
Philipp Gesang [Fri, 30 Jan 2026 19:14:24 +0000 (20:14 +0100)] 
gccrs: parse all function qualifiers before generating error

Instead of erroring out on the first misplaced qualifier, parse
as many qualifiers as possible to allow for more helpful error
message giving the correct order the qualifiers should be in.
Duplicate qualifiers are a kind of a special case and generate a
separate error message.

gcc/rust/ChangeLog
* parse/rust-parse-impl.hxx (parse_function_qualifiers)
Collect qualifiers into vector before generating the
error message
* parse/rust-parse.h: (parse_function_qualifiers) Make
function fallible

gcc/testsuite/ChangeLog:
* rust/compile/func-qualifier-default.rs:
Adapt to change in compiler messages
* rust/compile/func-qualifier-order.rs: Renamed existing
test file for clarity (from)
* rust/compile/func-qualifier-order-1.rs: Renamed existing
test file (to)
* rust/compile/func-qualifier-order-2.rs: New test file
* rust/compile/func-qualifier-order-3.rs: New test file

Signed-off-by: Philipp Gesang <phg@phi-gamma.net>
13 days agogccrs: add test cases for fn qualifiers, default keyword
Philipp Gesang [Thu, 29 Jan 2026 19:00:34 +0000 (20:00 +0100)] 
gccrs: add test cases for fn qualifiers, default keyword

gcc/testsuite/ChangeLog:

* rust/compile/func-qualifier-order.rs: New test file
* rust/compile/func-qualifier-default.rs: New test file

Signed-off-by: Philipp Gesang <phg@phi-gamma.net>
13 days agogccrs: Reject `default` functions after parsing.
Kushal Pal [Sat, 24 Feb 2024 11:55:48 +0000 (17:25 +0530)] 
gccrs: Reject `default` functions after parsing.

Functions with `default` qualifier outside of `impl` blocks should be
allowed to parse successfully and are later rejected during the
ASTValidation pass.

gcc/rust/ChangeLog:

* checks/errors/rust-ast-validation.cc (ASTValidation::visit):
Add error for functions with `default` qualifier outside of impl
blocks.
* parse/rust-parse-impl.hxx (Parser::parse_item):
Allow parsing of functions with `default` qualifier.
(Parser::parse_vis_item): Likewise.

Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
13 days agogccrs: Add `default` as function qualifier.
Kushal Pal [Sat, 24 Feb 2024 10:28:48 +0000 (15:58 +0530)] 
gccrs: Add `default` as function qualifier.

gcc/rust/ChangeLog:

* ast/rust-ast-builder.cc (AstBuilder::fn_qualifiers):
Add new parameter.
* ast/rust-ast-builder.h: Likewise.
* ast/rust-ast.cc (Function::Function):
Remove current default parameter.
(Function::operator=):
Remove current default parameter.
* ast/rust-item.h (class FunctionQualifiers):
Add data member to represent defaultness of a function.
(class Function):
Remove current default parameter.
* parse/rust-parse-impl.hxx (Parser::parse_function_qualifiers):
Parse function qualifiers in order.
* util/rust-common.h (enum class): Create enum to represent
defaultness of a function.

Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
13 days agogccrs: Fix ICE caused by TypeCheckBase::parse_repr_options
Yap Zhi Heng [Tue, 24 Mar 2026 13:23:24 +0000 (21:23 +0800)] 
gccrs: Fix ICE caused by TypeCheckBase::parse_repr_options

Fixes Rust-GCC/gccrs#3550. Previously parse_repr_options assumes that all attrs in its
params are token trees, but it is possible that already-parsed meta items can be passed
as params as well due to expansion of cfg_attr.

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::parse_repr_options):
Allow parsing of AttrInputMetaItemContainer.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
13 days agogccrs: Move attribute checker to it's own file
Pierre-Emmanuel Patry [Mon, 30 Mar 2026 09:00:36 +0000 (11:00 +0200)] 
gccrs: Move attribute checker to it's own file

Both attribute utility and attribute checker (pre-expansion) were mixed
within the same file/translation unit. Splitting them apart will allow
a shorter header to include and make both file easier to navigate.

gcc/rust/ChangeLog:

* Make-lang.in: Add a new rust-attribute-checker file.
* checks/errors/rust-builtin-attribute-checker.h (check_valid_attribute_for_item):
Change BuiltinAttributeChecker doc comment.
* rust-session-manager.cc: Include the new rust-attribute-checker
header.
* util/rust-attributes.cc (AttributeChecker::AttributeChecker): Move to
rust-attribute-checker.cc.
(AttributeChecker::go): Likewise.
(is_proc_macro_type): Likewise.
(check_proc_macro_non_function): Likewise.
(check_proc_macro_non_root): Likewise.
(AttributeChecker::visit): Likewise.
* util/rust-attributes.h (class AttributeChecker): Move to
rust-attribute-checker.h.
* checks/errors/rust-attribute-checker.cc: New file.
* checks/errors/rust-attribute-checker.h: New file.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
13 days agogccrs: Add additional builtin attribute values
Pierre-Emmanuel Patry [Mon, 30 Mar 2026 08:20:49 +0000 (10:20 +0200)] 
gccrs: Add additional builtin attribute values

Add deny, warn and forbid attribute values.

gcc/rust/ChangeLog:

* checks/errors/rust-builtin-attribute-checker.cc (std::function<void):
Use the new attribute value variables instead of raw values.
* util/rust-attribute-values.h: Add deny, warn and forbid values.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
13 days agogccrs: Clean up internal attribute checking
Pierre-Emmanuel Patry [Sun, 29 Mar 2026 03:24:30 +0000 (05:24 +0200)] 
gccrs: Clean up internal attribute checking

Move all internal attribute structure checking within specific handler
functions called from the attribute visit function instead of multiple
duplicated sources in the various items. Store those handlers in a map
to avoid the expensive string switch comparisons.

gcc/rust/ChangeLog:

* checks/errors/rust-builtin-attribute-checker.cc (check_doc_attribute):
Move from here...
(doc): ...to here.
(check_deprecated_attribute): Move from here...
(deprecated): ...to here.
(check_link_section_attribute): Move from here...
(link_section): ... to here.
(check_export_name_attribute): Move from here...
(export_name): ... to here.
(check_no_mangle_function): Remove internal structure checking and move
it to no_mangle handler.
(check_lint_attribute): Move from here...
(lint): ... to here.
(link_name): Likewise with link_name.
(check_crate_type): Move to anonymous namespace within the handler
namespace.
(proc_macro_derive): Add proc macro specific handler.
(proc_macro): Likewise.
(target_feature): Likewise.
(no_mangle): Add specific handler for no_mangler attribute internal
structure checking.
(std::function<void): Add map with attribute name to handler matching.
(tl::optional<std::function<void): Likewise.
(lookup_handler): Add an helper function to retrieve the handler of any
builtin attribute.
(BuiltinAttributeChecker::visit): Change attribute visitor call with
new handler call.
* checks/errors/rust-builtin-attribute-checker.h (check_valid_attribute_for_item):
Add prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
13 days agogccrs: Add a function for default outer attribute checks
Pierre-Emmanuel Patry [Sun, 29 Mar 2026 01:57:10 +0000 (03:57 +0200)] 
gccrs: Add a function for default outer attribute checks

Add an helper function to keep most of the attribute checking short.

gcc/rust/ChangeLog:

* checks/errors/rust-builtin-attribute-checker.cc (BuiltinAttributeChecker::visit):
Deduplicate lines using the new templated function within the visitor
functions.
* checks/errors/rust-builtin-attribute-checker.h (class BuiltinAttributeChecker):
Create a new templated function that achieves the default attribute
checking operations.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
13 days agogccrs: Add macro_export to concat macro
Pierre-Emmanuel Patry [Mon, 30 Mar 2026 10:39:32 +0000 (12:39 +0200)] 
gccrs: Add macro_export to concat macro

This macro export is required with recent rust versions but not version
1.49. Since the test was not trying to highlight this rust 1.49 behavior
this commit put the least constrained version of the code.

gcc/testsuite/ChangeLog:

* rust/compile/doc_macro.rs: Add macro_export on macro.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
13 days agogccrs: Update test with builtin macro definition
Pierre-Emmanuel Patry [Sat, 28 Mar 2026 18:27:04 +0000 (19:27 +0100)] 
gccrs: Update test with builtin macro definition

Those test contain builtin macros that were not correctly defined. This
was mostly fine because the compiler emitted attribute errors before the
expansion step but now that the new builtin attribute checking is
executed after the expansion we cannot ignore those missing definitions.

gcc/testsuite/ChangeLog:

* rust/compile/doc_macro.rs: Add concat builtin macro definition.
* rust/compile/early_feature_gate_in_macro.rs: Add stringify builtin
macro definition.
* rust/compile/issue-3661.rs: Likewise.
* rust/compile/parse_time_feature_gate.rs: Add concat and stringify
builtin macro definition.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
13 days agogccrs: Flatten AttrInputExpr literals to AttrInputLiteral
Pierre-Emmanuel Patry [Fri, 27 Mar 2026 14:30:31 +0000 (15:30 +0100)] 
gccrs: Flatten AttrInputExpr literals to AttrInputLiteral

Some macros may be expanded to literals within attribute input. This
this means they could be converted to AttrInputLiteral and properly
differentiate both expr and literal in the builtin attribute checker to
emit an error message when a real expr remains within an attribute.

gcc/rust/ChangeLog:

* expand/rust-expand-visitor.cc (ExpandVisitor::visit): Flatten
AttrInputExpr containing a literal to an AttrInputLiteral.
* expand/rust-expand-visitor.h: Add function prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
13 days agogccrs: Visit builtin attributes within the expand visitor
Pierre-Emmanuel Patry [Fri, 27 Mar 2026 11:15:13 +0000 (12:15 +0100)] 
gccrs: Visit builtin attributes within the expand visitor

Those attribute may contain macros within their input that must be
expanded, hence why we must visit them.

gcc/rust/ChangeLog:

* ast/rust-ast.h: Add helper to set a new attribute input.
* expand/rust-expand-visitor.cc (ExpandVisitor::expand_inner_stmts):
Visit builtin attributes.
(ExpandVisitor::visit): Likewise.
* resolve/rust-early-name-resolver-2.0.cc (Early::visit): Expand
attribute input expr.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
13 days agogccrs: Move builtin attribute checking to its own pass
Pierre-Emmanuel Patry [Thu, 26 Mar 2026 15:53:26 +0000 (16:53 +0100)] 
gccrs: Move builtin attribute checking to its own pass

Builtin attribute checking should be done after macro expansion because
we want to support macros within attributes.

gcc/rust/ChangeLog:

* Make-lang.in: Add file for builtin attribute checking.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::handle_doc_item_attribute):
Remove error emission and replace it with an assert. The error message
will now be emitted from the builtin attribute checking pass.
* rust-session-manager.cc (Session::compile_crate): Add builtin
attribute checking step after expansion.
* util/rust-attributes.cc (Attributes::is_known): Move down.
(Attributes::extract_string_literal): Likewise.
(Attributes::valid_outer_attribute): Add a function to retrieve outer/
inner status for a given builtin attribute value.
(AttributeChecker::visit): Move some checking to builtin attribute
checker.
(identify_builtin): Rename function from here ...
(lookup_builtin): ... to here.
(check_doc_alias): Move to builtin attribute checker.
(check_doc_attribute): Likewise.
(check_deprecated_attribute): Likewise.
(check_valid_attribute_for_item): Likewise.
(AttributeChecker::check_inner_attribute): Likewise.
(check_link_section_attribute): Likewise.
(check_export_name_attribute): Likewise.
(check_lint_attribute): Likewise.
(check_no_mangle_function): Likewise.
(is_proc_macro_type): Update function call name.
* util/rust-attributes.h (identify_builtin): Update prototype.
(lookup_builtin): Likewise.
* checks/errors/rust-builtin-attribute-checker.cc: New file.
* checks/errors/rust-builtin-attribute-checker.h: New file.

gcc/testsuite/ChangeLog:

* rust/compile/issue-4226.rs: Update text to match error message from
attribute checking pass that was not triggered before.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
13 days agogccrs: Remove AttrInputMacro attribute input kind
Pierre-Emmanuel Patry [Wed, 25 Mar 2026 15:51:42 +0000 (16:51 +0100)] 
gccrs: Remove AttrInputMacro attribute input kind

This attribute kind is being replaced with AttrInputExpr attributes.

gcc/rust/ChangeLog:

* ast/rust-ast-collector.cc (TokenCollector::visit): Remove
AttrInputMacro handling.
* ast/rust-ast-collector.h: Remove function prototype.
* ast/rust-ast-full-decls.h (class AttrInputMacro): Remove forward
declaration.
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Remove function.
* ast/rust-ast-visitor.h: Remove function prototypes.
* ast/rust-ast.cc (Attribute::get_traits_to_derive): Remove handling of
macros.
(AttrInputMacro::as_string): Remove function.
(AttrInputMacro::AttrInputMacro): Likewise.
(AttrInputMacro::operator=): Likewise.
(AttrInputMacro::accept_vis): Likewise.
* ast/rust-ast.h: Remove MACRO kind.
* ast/rust-expr.h (class AttrInputMacro): Add getter for expr pointer.
Remove AttrInputMacro class.
* expand/rust-derive.h: Remove function prototype.
* expand/rust-expand-visitor.cc (ExpandVisitor::visit): Change function
to AttrInputExpr.
* expand/rust-expand-visitor.h: Update prototype.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Remove function.
* hir/rust-ast-lower-base.h: Remove function prototype.
* parse/rust-parse-impl-attribute.hxx: Parse the attribute content as
AttrInputExpr instead.
* util/rust-attributes.cc (check_doc_attribute): Remove MACRO kind
handling.
(check_export_name_attribute): Remove switch and only handle literals.
(AttributeChecker::visit): Remove function.
* util/rust-attributes.h: Remove function prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
13 days agogccrs: rust: Fix ICE in function_set_parameters
Egas Ribeiro [Wed, 25 Mar 2026 10:18:01 +0000 (10:18 +0000)] 
gccrs: rust: Fix ICE in function_set_parameters

When lowering a function to HIR with a refutable pattern in its
parameter pattern, we were ICE'ing due to a lack of checks for invalid
refutable patterns. Fix this by erroring on invalid patterns while
lowering a function.

Fixes Rust-GCC/gccrs#3919

gcc/rust/ChangeLog:

* hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): added
refutable pattern checks for function params.

gcc/testsuite/ChangeLog:

* rust/compile/issue-3919-ice-func-parms.rs: New test.

Signed-off-by: Egas Ribeiro <egas.g.ribeiro@tecnico.ulisboa.pt>
13 days agogccrs: Disambiguate identifier and path patterns
Owen Avery [Sun, 22 Mar 2026 22:48:57 +0000 (18:48 -0400)] 
gccrs: Disambiguate identifier and path patterns

gcc/rust/ChangeLog:

* Make-lang.in (GRS_OBJS): Add rust-identifier-path.o.
* resolve/rust-early-name-resolver-2.0.cc: Include
"rust-identifier-path.h".
(Early::go): Use IdentifierPathPass.
(Early::visit): Handle identifier patterns which should be path
patterns.
* resolve/rust-early-name-resolver-2.0.h: Include
"rust-pattern.h".
(Early::visit): Add visiting function declaration for
IdentifierPattern.
(Early::ident_path_to_convert): New member variable.
* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit):
Call Mappings::add_function_node.
* util/rust-hir-map.cc (Mappings::add_function_node): New
member function definition.
(Mappings::is_function_node): Likewise.
* util/rust-hir-map.h (Mappings::add_function_node): New
member function declaration.
(Mappings::is_function_node): Likewise.
(Mappings::function_nodes): New member variable.
* resolve/rust-identifier-path.cc: New file.
* resolve/rust-identifier-path.h: New file.

gcc/testsuite/ChangeLog:

* rust/execute/ident_pat_vs_path_1.rs: New test.
* rust/execute/ident_pat_vs_path_2.rs: New test.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
13 days agogccrs: expand: Added a more complete test
Jayant Chauhan [Tue, 6 Jan 2026 10:09:23 +0000 (15:39 +0530)] 
gccrs: expand: Added a more complete test

This patch adds a regression test ensuring that deriving on invalid items
(such as functions or traits) triggers a diagnostic error instead of an
Internal Compiler Error (ICE). It also verifies that Tuple Structs are
accepted as valid targets for derivation.

Fixes Rust-GCC#3875

gcc/testsuite/ChangeLog:

* rust/compile/issue-3875.rs: New test.

Signed-off-by: Jayant Chauhan <0001jayant@gmail.com>
13 days agogccrs: Deduplicate some functions within PointerVisitor
Pierre-Emmanuel Patry [Fri, 13 Mar 2026 14:50:27 +0000 (15:50 +0100)] 
gccrs: Deduplicate some functions within PointerVisitor

Some functions within the PointerVisitor were obvious duplicate from the
inherited DefaultASTVisitor.

gcc/rust/ChangeLog:

* ast/rust-ast-pointer-visitor.cc (PointerVisitor::visit): Remove
duplicated functions.
* ast/rust-ast-pointer-visitor.h: Remove duplicated function
prototypes.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
13 days agogccrs: Strip down 1.0 resolver
Owen Avery [Fri, 27 Mar 2026 03:20:27 +0000 (23:20 -0400)] 
gccrs: Strip down 1.0 resolver

gcc/rust/ChangeLog:

* expand/rust-macro-expand.cc (MacroExpander::expand_crate):
Remove usage of Resolver::get_macro_scope.
* resolve/rust-name-resolver.cc (Resolver::Resolver): Handle
removal of member variables.
(Resolver::push_new_name_rib): Remove function definition.
(Resolver::push_new_type_rib): Likewise.
(Resolver::push_new_label_rib): Likewise.
(Resolver::push_new_macro_rib): Likewise.
(Resolver::find_name_rib): Likewise.
(Resolver::find_type_rib): Likewise.
(Resolver::find_macro_rib): Likewise.
(Resolver::insert_builtin_types): Likewise.
(Resolver::get_builtin_types): Likewise.
(Resolver::generate_builtins): Likewise.
(Resolver::setup_builtin): Likewise.
(Resolver::insert_resolved_label): Likewise.
(Resolver::lookup_resolved_label): Likewise.
(Resolver::insert_resolved_macro): Likewise.
(Resolver::lookup_resolved_macro): Likewise.
(Resolver::push_closure_context): Likewise.
(Resolver::pop_closure_context): Likewise.
(Resolver::insert_captured_item): Likewise.
(Resolver::decl_needs_capture): Likewise.
(Resolver::get_captures): Likewise.
(Resolver::insert_resolved_name): Replace function
implementation with rust_unreachable call.
(Resolver::lookup_resolved_name): Likewise.
(Resolver::insert_resolved_type): Likewise.
(Resolver::lookup_resolved_type): Likewise.
(Resolver::insert_resolved_misc): Likewise.
(Resolver::lookup_resolved_misc): Likewise.
* resolve/rust-name-resolver.h (Resolver::insert_builtin_types):
Remove member function declaration.
(Resolver::get_builtin_types): Likewise.
(Resolver::push_new_name_rib): Likewise.
(Resolver::push_new_type_rib): Likewise.
(Resolver::push_new_label_rib): Likewise.
(Resolver::push_new_macro_rib): Likewise.
(Resolver::find_name_rib): Likewise.
(Resolver::find_type_rib): Likewise.
(Resolver::find_label_rib): Likewise.
(Resolver::find_macro_rib): Likewise.
(Resolver::insert_resolved_label): Likewise.
(Resolver::lookup_resolved_label): Likewise.
(Resolver::insert_resolved_macro): Likewise.
(Resolver::lookup_resolved_macro): Likewise.
(Resolver::get_name_scope): Likewise.
(Resolver::get_type_scope): Likewise.
(Resolver::get_label_scope): Likewise.
(Resolver::get_macro_scope): Likewise.
(Resolver::get_global_type_node_id): Likewise.
(Resolver::set_unit_type_node_id): Likewise.
(Resolver::get_unit_type_node_id): Likewise.
(Resolver::set_never_type_node_id): Likewise.
(Resolver::get_never_type_node_id): Likewise.
(Resolver::push_new_module_scope): Likewise.
(Resolver::pop_module_scope): Likewise.
(Resolver::peek_current_module_scope): Likewise.
(Resolver::peek_crate_module_scope): Likewise.
(Resolver::peek_parent_module_scope): Likewise.
(Resolver::push_closure_context): Likewise.
(Resolver::pop_closure_context): Likewise.
(Resolver::insert_captured_item): Likewise.
(Resolver::get_captures): Likewise.
(Resolver::as_debug_string): Likewise.
(Resolver::decl_needs_capture): Likewise.
(Resolver::generate_builtins): Likewise.
(Resolver::setup_builtin): Likewise.
(Resolver::mappings): Remove member variable.
(Resolver::tyctx): Likewise.
(Resolver::builtins): Likewise.
(Resolver::name_scope): Likewise.
(Resolver::type_scope): Likewise.
(Resolver::label_scope): Likewise.
(Resolver::macro_scope): Likewise.
(Resolver::global_type_node_id): Likewise.
(Resolver::unit_ty_node_id): Likewise.
(Resolver::never_ty_node_id): Likewise.
(Resolver::name_ribs): Likewise.
(Resolver::type_ribs): Likewise.
(Resolver::label_ribs): Likewise.
(Resolver::macro_ribs): Likewise.
(Resolver::resolved_names): Likewise.
(Resolver::resolved_types): Likewise.
(Resolver::resolved_labels): Likewise.
(Resolver::resolved_macros): Likewise.
(Resolver::misc_resolved_items): Likewise.
(Resolver::current_module_stack): Likewise.
(Resolver::closure_context): Likewise.
(Resolver::closures_capture_mappings): Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
13 days agogccrs: nr1.0: Remove support in checking phases
Owen Avery [Thu, 28 Aug 2025 01:20:16 +0000 (21:20 -0400)] 
gccrs: nr1.0: Remove support in checking phases

gcc/rust/ChangeLog:

* checks/errors/rust-const-checker.cc: Remove inclusion of
"options.h".
(ConstChecker::ConstChecker): Initialize 2.0 resolver.
(ConstChecker::visit): Assume nr2.0 is enabled.
* checks/errors/rust-const-checker.h: Adjust includes.
(ConstChecker::resolver): Change type to 2.0 resolver.
* checks/errors/rust-unsafe-checker.cc: Remove inclusion of
"options.h".
(UnsafeChecker::UnsafeChecker): Initialize 2.0 resolver.
(UnsafeChecker::visit): Assume nr2.0 is enabled.
* checks/errors/rust-unsafe-checker.h: Adjust includes.
(UnsafeChecker::resolver): Change type to 2.0 resolver.
* checks/lints/rust-lint-marklive.cc
(MarkLive::visit_path_segment): Assume nr2.0 is enabled.
(MarkLive::visit): Likewise.
(MarkLive::find_ref_node_id): Likewise.
* checks/lints/rust-lint-marklive.h: Include
"rust-immutable-name-resolution-context.h".
(MarkLive::resolver): Change type to 2.0 resolver, as a
reference instead of a pointer.
(MarkLive::MarkLive): Initialize 2.0 resolver.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
13 days agogccrs: Remove redundant expand visitor overloads
Owen Avery [Sun, 22 Mar 2026 18:57:02 +0000 (14:57 -0400)] 
gccrs: Remove redundant expand visitor overloads

gcc/rust/ChangeLog:

* expand/rust-expand-visitor.cc (ExpandVisitor::visit): Remove
some redundant function overloads.
* expand/rust-expand-visitor.h (ExpandVisitor::visit): Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
13 days agogccrs: Add no_builtins attribute to list of builtins
Pierre-Emmanuel Patry [Thu, 12 Mar 2026 16:34:41 +0000 (17:34 +0100)] 
gccrs: Add no_builtins attribute to list of builtins

gcc/rust/ChangeLog:

* util/rust-attribute-values.h: Add "no_builtins"
attribute value.
* util/rust-attributes.cc: Add "no_builtins" to
the list of builtin attributes.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
13 days agogccrs: Accepts "compiler_builtins" attribute
Pierre-Emmanuel Patry [Thu, 12 Mar 2026 15:52:15 +0000 (16:52 +0100)] 
gccrs: Accepts "compiler_builtins" attribute

This attribute shall be accepted/rejected depending on the feature
activation status.

gcc/rust/ChangeLog:

* checks/errors/feature/rust-feature-gate.cc (FeatureGate::visit):
Rework visit to avoid multiple iterations. Add check for
"compiler_builtins" attribute.
(FeatureGate::check_no_core_attribute): Remove loop.
* checks/errors/feature/rust-feature-gate.h: Update function prototype.
* util/rust-attribute-values.h: Add "compiler_builtins" attribute
value.
* util/rust-attributes.cc: Add "compiler_builtins" to the list of
builtin attributes.

gcc/testsuite/ChangeLog:

* rust/compile/compiler_builtins_gate.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
13 days agogccrs: intrinsic: Add separated tests for each type
Mohamed Ali [Thu, 19 Mar 2026 12:58:45 +0000 (14:58 +0200)] 
gccrs: intrinsic: Add separated tests for each type

gcc/testsuite/ChangeLog:

* rust/execute/torture/ctlz_i16.rs: New test.
* rust/execute/torture/ctlz_i32.rs: New test.
* rust/execute/torture/ctlz_i64.rs: New test.
* rust/execute/torture/ctlz_i8.rs: New test.
* rust/execute/torture/ctlz_nonzero_i16.rs: New test.
* rust/execute/torture/ctlz_nonzero_i32.rs: New test.
* rust/execute/torture/ctlz_nonzero_i64.rs: New test.
* rust/execute/torture/ctlz_nonzero_i8.rs: New test.
* rust/execute/torture/ctlz_nonzero_u16.rs: New test.
* rust/execute/torture/ctlz_nonzero_u32.rs: New test.
* rust/execute/torture/ctlz_nonzero_u64.rs: New test.
* rust/execute/torture/ctlz_nonzero_u8.rs: New test.
* rust/execute/torture/ctlz_u16.rs: New test.
* rust/execute/torture/ctlz_u32.rs: New test.
* rust/execute/torture/ctlz_u64.rs: New test.
* rust/execute/torture/ctlz_u8.rs: New test.

Signed-off-by: Mohamed Ali <mohmedali1462005@gmail.com>
13 days agogccrs: intrinsic: Add ctlz and ctlz_nonzero intrinsics
Mohamed Ali [Sat, 7 Mar 2026 06:15:48 +0000 (08:15 +0200)] 
gccrs: intrinsic: Add ctlz and ctlz_nonzero intrinsics

This commit introduces the `ctlz` and `ctlz_nonzero` intrinsics for counting leading zeros
in integer types.
The implementation includes handlers for both intrinsics, which validate input types and utilize
GCC built-ins for the actual computation.

Addresses: Rust-GCC#658

gcc/rust/ChangeLog:

* backend/rust-compile-intrinsic.cc: Register ctlz and ctlz_nonzero intrinsics.
* backend/rust-intrinsic-handlers.cc (ctlz_handler): Implement ctlz_handler.
(ctlz_nonzero_handler): Implement ctlz_nonzero_handler.
* backend/rust-intrinsic-handlers.h (ctlz_handler): Add decl for ctlz_handler.
(ctlz_nonzero_handler): Add decl for ctlz_nonzero_handler.
* util/rust-intrinsic-values.h: map ctlz_nonzero to its name.

gcc/testsuite/ChangeLog:

* rust/compile/ctlz.rs: New test.
* rust/compile/ctlz_nonzero.rs: New test.
* rust/execute/torture/ctlz.rs: New test.
* rust/execute/torture/ctlz_nonzero.rs: New test.

Signed-off-by: Mohamed Ali <mohmedali1462005@gmail.com>
13 days agogccrs: Fix 128-bit non-decimal integer literal saturation
Enes Cevik [Sat, 28 Feb 2026 16:37:32 +0000 (19:37 +0300)] 
gccrs: Fix 128-bit non-decimal integer literal saturation

This patch replaces std::strtol with GNU MP (GMP) for arbitrary-precision
parsing to properly support 128-bit literals.

Additionally, it refactors the lexer by removing the redundant
`existent_str` parameter from `parse_non_decimal_int_literal`. The base
is now passed directly, and the parsed digits are collected internally,
making the previous prefix-passing logic ("0x", "0b", "0o") obsolete
and ensuring cleaner compatibility with mpz_set_str.

gcc/rust/ChangeLog:

* lex/rust-lex.cc (Lexer::parse_non_decimal_int_literal): Use GMP
for base conversion to support 128-bit literals. Remove existent_str
parameter.
(Lexer::parse_non_decimal_int_literals): Remove prefix string
initialization and update function calls.
* lex/rust-lex.h (Lexer::parse_non_decimal_int_literal): Update
function signature to remove existent_str.

gcc/testsuite/ChangeLog:

* rust/execute/non_decimal_128_saturation.rs: New test.

Signed-off-by: Enes Cevik <nsvke@proton.me>
13 days agogccrs: Improve unit struct matching
Owen Avery [Mon, 23 Mar 2026 01:00:16 +0000 (21:00 -0400)] 
gccrs: Improve unit struct matching

Unit structs weren't *actually* working in match statements -- we don't
currently handle identifier pattern vs path pattern disambiguation.

gcc/rust/ChangeLog:

* checks/errors/rust-hir-pattern-analysis.cc
(PlaceInfo::specialize): Handle VariantType::UNIT.
(WitnessPat::to_string): Likewise.
(WitnessMatrix::apply_constructor): Likewise.
* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit):
Conditionally create VariantType::UNIT variants.
* typecheck/rust-hir-type-check-pattern.cc
(TypeCheckPattern::visit): Fix typo, handle VariantType::UNIT.
* typecheck/rust-tyty-variance-analysis.cc
(GenericTyVisitorCtx::process_type): Handle VariantType::UNIT.
* typecheck/rust-tyty.cc (BaseType::contains_infer): Likewise.
(BaseType::is_concrete): Likewise.
(VariantDef::variant_type_string): Likewise.
(VariantDef::VariantDef): Likewise.
* typecheck/rust-tyty.h (VariantDef::VariantType::UNIT): New
enumerator.

gcc/testsuite/ChangeLog:

* rust/compile/match-struct-path.rs: Increase test coverage.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
13 days agogccrs: Add enum items to value namespace as well
Owen Avery [Mon, 9 Mar 2026 04:24:22 +0000 (00:24 -0400)] 
gccrs: Add enum items to value namespace as well

gcc/rust/ChangeLog:

* resolve/rust-finalize-imports-2.0.cc
(GlobbingVisitor::visit_enum_container): Conditionally insert
into value namespace as well.
* resolve/rust-forever-stack.hxx (ForeverStack::insert_variant):
Add template specialization for value namespace.
* resolve/rust-name-resolution-context.cc
(NameResolutionContext::insert_variant): Allow insertion into
value namespace.
* resolve/rust-name-resolution-context.h
(NameResolutionContext::insert_variant): Likewise.
* resolve/rust-toplevel-name-resolver-2.0.cc
(TopLevel::insert_enum_variant_or_error_out): Likewise.
(TopLevel::visit): Use tweaked insert_enum_variant_or_error_out
properly for all enum item kinds.
* resolve/rust-toplevel-name-resolver-2.0.h
(TopLevel::insert_enum_variant_or_error_out): Tweak function
signature.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
13 days agogccrs: Fix a typo
Owen Avery [Sun, 22 Mar 2026 19:43:16 +0000 (15:43 -0400)] 
gccrs: Fix a typo

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-pattern.cc
(TypeCheckPattern::visit): Fix typo "constatnt".

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
13 days agogccrs: rust: Explicitly instantiate FFIVec<Piece> for C-linkage
hriztam [Thu, 26 Feb 2026 13:19:20 +0000 (18:49 +0530)] 
gccrs: rust: Explicitly instantiate FFIVec<Piece> for C-linkage

gcc/rust/ChangeLog:

* ast/rust-fmt.h: Explicitly instantiate FFIVec<Piece>.

Signed-off-by: Hritam Shrivastava <hritamstark05@gmail.com>
13 days agogccrs: Use pretty printer instead ofcall to open_memstream
Andrew Pinski [Wed, 11 Mar 2026 15:01:00 +0000 (16:01 +0100)] 
gccrs: Use pretty printer instead ofcall to open_memstream

open_memstream is a POSIX call which is not available on mingw platform.

gcc/rust/ChangeLog:

* typecheck/rust-tyty.cc (generate_tree_str): Remove opem_memstream
and print_generic_stmt call with call to dump_generic_node.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
13 days agogccrs: Add new test cases for old issues
Yap Zhi Heng [Thu, 19 Mar 2026 11:45:00 +0000 (19:45 +0800)] 
gccrs: Add new test cases for old issues

rust-GCC/gccrs#3555, rust-GCC/gccrs#3591, rust-GCC/gccrs#3597,
rust-GCC/gccrs#3651, rust-GCC/gccrs#3670 & rust-GCC/gccrs#3672 were all
fixed long ago by some of my older patches, adding test cases to conclude
the issues properly.

gcc/testsuite/ChangeLog:

* rust/compile/issue-3555.rs: New test case.
* rust/compile/issue-3591.rs: New test case.
* rust/compile/issue-3597.rs: New test case.
* rust/compile/issue-3651.rs: New test case.
* rust/compile/issue-3670.rs: New test case.
* rust/compile/issue-3672.rs: New test case.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
13 days agogccrs: Improve path resolution
Owen Avery [Sat, 7 Feb 2026 01:11:20 +0000 (20:11 -0500)] 
gccrs: Improve path resolution

This makes path resolution less dependent on templates for path
handling.

gcc/rust/ChangeLog:

* resolve/rust-forever-stack.h: Include more headers.
(class ResolutionPath): New class for representing paths.
(ForeverStack::resolve_path): Change function signature.
(ForeverStack::find_starting_point): Likewise.
(ForeverStack::resolve_segments): Likewise.
(ForeverStack::SegIterator): Change type alias.
* resolve/rust-forever-stack.hxx (check_leading_kw_at_start):
Change function signature.
(ForeverStack::find_starting_point): Likewise.
(ForeverStack::resolve_segments): Likewise.
(ForeverStack::resolve_path): Likewise.
* resolve/rust-name-resolution-context.h: Tweak include guard,
include "rust-name-resolution.h".
(NameResolutionContext::resolve_path): Use ResolutionPath and
ResolutionBuilder.
(class NameResolutionContext::ResolutionBuilder): New class.
(class Usage): Move this...
(class Definition): ...and this...
* resolve/rust-name-resolution.h: ...to new file.
* util/rust-unwrap-segment.h: Add include guard.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
13 days agogccrs: testsuite:Add a testcase for setup_associated_types
Harishankar [Wed, 11 Mar 2026 00:04:25 +0000 (05:34 +0530)] 
gccrs: testsuite:Add a testcase for setup_associated_types

Fixes Rust-GCC/gccrs#3931
gcc/testsuite/ChangeLog:

* rust/compile/issue-3931.rs: New test.

Signed-off-by: Harishankar <harishankarpp7@gmail.com>
2 weeks agoc++: identity of A<^^alias> [PR124544]
Patrick Palka [Tue, 14 Apr 2026 19:32:13 +0000 (15:32 -0400)] 
c++: identity of A<^^alias> [PR124544]

Since a reflection of an alias represents the alias itself, not the
underlying type, cp_tree_equal needs to compensate for that since it
otherwise generally looks through aliases.  And strip_typedefs_expr
needs to not strip the alias in e.g. A<^^alias>.

PR c++/124544

gcc/cp/ChangeLog:

* tree.cc (strip_typedefs_expr) <case REFLECT_EXPR>: Don't
recurse into a type operand.
(cp_tree_equal) <case REFLECT_EXPR>: For a reflection of an
alias, also compare TYPE_NAMEs directly.

gcc/testsuite/ChangeLog:

* g++.dg/reflect/alias1.C: New test.
* g++.dg/reflect/alias2.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
2 weeks agoAArch64: Add -mcpu=armagicpu definition
Tamar Christina [Tue, 14 Apr 2026 19:05:56 +0000 (20:05 +0100)] 
AArch64: Add -mcpu=armagicpu definition

This adds the -mcpu=armagicpu for the Arm AGI CPU.

gcc/ChangeLog:

* config/aarch64/aarch64-cores.def (armagicpu): New.
* config/aarch64/aarch64-tune.md: Renegerate
* doc/invoke.texi: Document it.

2 weeks agoRegister equivalences only once per statement.
Andrew MacLeod [Mon, 13 Apr 2026 17:37:36 +0000 (13:37 -0400)] 
Register equivalences only once per statement.

When a copy statement is rewritten, do not register a new equivalence between
the LHS and RHS.

PR tree-optimization/124809
gcc/
* value-relation.cc (equiv_oracle::equiv_oracle): Allocate lhs
equivalence bitmap.
(relation_oracle::record): Check if LHS has already created an
equivalence record.
* value-relation.h (relation_oracle::relation_oracle): New.
(relation_oracle::m_lhs_equiv_set_p): New.

gcc/testsuite/
* gcc.dg/pr124809.c: New.

2 weeks agoFortran: fix possible null pointer dereference [PR124807]
Harald Anlauf [Tue, 14 Apr 2026 18:53:15 +0000 (20:53 +0200)] 
Fortran: fix possible null pointer dereference [PR124807]

PR fortran/124807

gcc/fortran/ChangeLog:

* decl.cc (add_init_expr_to_sym): Suggested by Coverity:
Check sym->as != NULL before dereferencing it.

2 weeks agoc++: introduce reflection_function_template_p
Marek Polacek [Tue, 14 Apr 2026 14:13:11 +0000 (10:13 -0400)] 
c++: introduce reflection_function_template_p

As discussed in
<https://gcc.gnu.org/pipermail/gcc-patches/2026-April/712156.html>,
this patch introduces a new predicate to be used instead of
really_overloaded_fn when we're checking for a function template in the
Reflection code.

gcc/cp/ChangeLog:

* cp-tree.h (reflection_function_template_p): Declare.
* parser.cc (cp_parser_splice_expression): Use
reflection_function_template_p instead of really_overloaded_fn.
* reflect.cc (check_splice_expr): Likewise.
(reflection_function_template_p): New.

Reviewed-by: Jason Merrill <jason@redhat.com>
2 weeks agoarm: apply stronger checks on conditional-compare patterns [PR123102]
Richard Earnshaw [Tue, 14 Apr 2026 13:45:38 +0000 (14:45 +0100)] 
arm: apply stronger checks on conditional-compare patterns [PR123102]

If a conditional compare operation is generated during expand, then
combine may try to substitute into it in order to generate better code;
but if it does so, we need to validate that the optimized sequence is
still a valid conditional compare.  We were skipping those checks and
that can lead to wrong code being generated.

gcc/ChangeLog:
PR target/123102
* config/arm/arm.md (*cmp_ite0): Apply stricter checks on the
comparison mode.
(*cmp_ite1, *cmp_and, *cmp_ior): Likewise.

2 weeks agolibstdc++: Define __cpp_lib_stdbit_h and __cpp_lib_stdckdint_h feature test macros.
Tomasz Kamiński [Tue, 14 Apr 2026 14:30:36 +0000 (16:30 +0200)] 
libstdc++: Define __cpp_lib_stdbit_h and __cpp_lib_stdckdint_h feature test macros.

This implements LWG4550: Need new feature test macros for <stdckdint.h>
and <stdbit.h>.

libstdc++-v3/ChangeLog:

* include/bits/version.def (stdbit_h, stdckdint_h): Define.
* include/bits/version.h: Regenerate.
* include/c_compatibility/stdbit.h (__cpp_lib_stdbit_h): Define
and use it in guards.
* include/c_compatibility/stdckdint.h (__cpp_lib_stdckdint_h):
Define and use it in guards.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 weeks agoipa: Type-convert constants in jump functions during inlining (PR124777)
Martin Jambor [Tue, 14 Apr 2026 15:00:05 +0000 (17:00 +0200)] 
ipa: Type-convert constants in jump functions during inlining (PR124777)

PR 124777 revealed that update_jump_functions_after_inlining does not
properly fold_convert constants when it propagates them from constant
jump functions to formerly pass-through ones, leading to expectations
of wrong constants in parameters leading to inserting bogus
builtin_unreachables during inlining.

This patch fixes it by calling ipacp_value_safe_for_type which is what
IPA-CP uses during its propagation and moved handling of the case to a
separate function.

gcc/ChangeLog:

2026-04-07  Martin Jambor  <mjambor@suse.cz>

PR ipa/124777
* ipa-cp.h (ipacp_value_safe_for_type): Declare.
* ipa-cp.cc (ipacp_value_safe_for_type): Make public.
* ipa-prop.cc (ipa_set_jf_cst_copy): Fix comment.
(ipa_convert_prop_cst_jf): New function.
(update_jump_functions_after_inlining): Handle the constant to
pass-through case by calling ipa_convert_prop_cst_jf.

gcc/testsuite/ChangeLog:

2026-04-07  Martin Jambor  <mjambor@suse.cz>

PR ipa/124777
* gcc.dg/ipa/pr124777.c: New test.

2 weeks agolibstdc++: Test for using non-ascii unicode fill with non-unicode encoding.
Tomasz Kamiński [Fri, 10 Apr 2026 08:24:19 +0000 (10:24 +0200)] 
libstdc++: Test for using non-ascii unicode fill with non-unicode encoding.

This checks if format string using as fill character an Unicode code-point,
that is encoded as multiple code units, is rejected when literal encoding
is not Unicode.

libstdc++-v3/ChangeLog:

* testsuite/std/format/fill.cc: New test.
* testsuite/std/format/fill_nonunicode.cc: New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 weeks agoPR modula2/105408 ICE in output_constructor_regular_field, at varasm.cc:5515
Gaius Mulley [Tue, 14 Apr 2026 12:49:07 +0000 (13:49 +0100)] 
PR modula2/105408 ICE in output_constructor_regular_field, at varasm.cc:5515

This patch fixes an ICE reported as PR modula2/105408.  It manifests on
big endian system when an ISO WORD is assigned a constant.  An ISO WORD
is an array of LOC and the constant array elements are created in reverse
indice order (for big endian).  This fix corrects the indice order and
also fixes calls to builtin_memcpy when used during assignment.  It uses
memcpy during assignment for arrays of constants.
Bootstrapped on sparc64, aarch64, x86_64 and POWER10.

gcc/m2/ChangeLog:

PR modula2/105408
* Make-lang.in (GM2-COMP-BOOT-MODS): Remove duplicate NameKey.mod.
* gm2-compiler/M2GenGCC.mod (import): Remove BuildAssignmentTree.
Add CopyMemcpy.
(IsSystemTypeBecomes): New procedure function.
(CodeAssignment): Rewrite using CopyMemcpy and IsSystemTypeBecomes.
* gm2-gcc/m2convert.cc (const_to_ISO_aggregate_type): Reverse
array elements if BYTES_BIG_ENDIAN.
* gm2-gcc/m2pp.cc (ps): New function.
* gm2-gcc/m2pp.h (pf): Added comment.
(pe): Ditto.
(pt): Ditto.
(ptl): Ditto.
(pv): Ditto.
(ptcl): Ditto.
* gm2-gcc/m2statement.cc (copy_memcpy): Replace with ...
(m2statement_CopyMemcpy): ... this.
(CopyByField_Lower): Call m2statement_CopyMemcpy instead of copy_memcpy.
(m2statement_BuildAssignmentTree): Tidied up comment.
Add test for ARRAY_TYPE CONSTRUCTOR expr and use
m2statement_CopyMemcpy.
Return type changed to void.
* gm2-gcc/m2statement.def (BuildAssignmentTree): Rewrite declaration.
(CopyMemcpy): New procedure declaration.
* gm2-gcc/m2statement.h (m2statement_BuildAssignmentTree): Replace
return type with void.
(m2statement_CopyMemcpy): New function declaration.
* gm2-gcc/m2type.cc (m2type_ReverseArrayConstructorElements): New
function.
* gm2-gcc/m2type.def (ReverseArrayConstructorElements): New
procedure function declaration.
* gm2-gcc/m2type.h (m2type_ReverseArrayConstructorElements): New
function declaration.

gcc/testsuite/ChangeLog:

PR modula2/105408
* gm2/iso/run/pass/testgeneric.mod: Corrected printf arguments.
* gm2/iso/run/pass/printsize.mod: New test.
* gm2/iso/run/pass/testgeneric2.mod: New test.
* gm2/iso/run/pass/testgeneric3.mod: New test.
* gm2/iso/run/pass/testgeneric4.mod: New test.
* gm2/iso/run/pass/testgeneric5.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2 weeks agolibstdc++: Fix constant_wrapper compile-time test for COW strings.
Tomasz Kamiński [Tue, 14 Apr 2026 12:31:24 +0000 (14:31 +0200)] 
libstdc++: Fix constant_wrapper compile-time test for COW strings.

Throwing std::invalid_argument at compile time is only supported for
SSO strings, replaced with custom class.

libstdc++-v3/ChangeLog:

* testsuite/20_util/constant_wrapper/generic.cc: Replace
std::std::invalid_argument with NegativeArgument and
removed <stdexcept> include.

2 weeks agolibstdc++: Runtime fallback for constant_wrapper subscript and call operators.
Tomasz Kamiński [Tue, 7 Apr 2026 15:03:25 +0000 (17:03 +0200)] 
libstdc++: Runtime fallback for constant_wrapper subscript and call operators.

This implements P3978R3: constant_wrapper should unwrap on call and subscript.

The operator() and operator[] are now fallback to calling corresponding
operation on value, if either arguments are not constant_wrapper like, or
the result of the invocation is not usable as non-type template argument
(non-constant). The call operator is also now defined in terms of invoke,
to support member pointers.

The noexcept specification is simplified, by observing that creating a
default constructed (constant_wrapper<value(....)>{}) is never throwing
operation. Nested requires expr is used for short-circuting, and thus
avoid checking viability of the operation on the value with
constant_wrapper only (see PoisonedAdd, PoisonedIndex in tests).

libstdc++-v3/ChangeLog:

* include/bits/version.def (constant_wrapped): Updated to 202603L.
* include/bits/version.h: Regenerate.
* include/bits/utility.h (_CwOperators::operator())
(_CwOperators:operator[]): Delete, they are now provided by...
(constant_wrapper::operator(), constant_wrapper::operator[]):
Define.
* testsuite/20_util/constant_wrapper/generic.cc: Add additional
test cases for invoke and subscript.
* testsuite/20_util/constant_wrapper/version.cc: Update tested
value.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 weeks agolibstdc++: Implement structured binding support for integer_sequence
Matthias Wippich [Thu, 9 Apr 2026 02:41:31 +0000 (04:41 +0200)] 
libstdc++: Implement structured binding support for integer_sequence

This implements P1789R3 Library Support for Expansion Statements.
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p1789r3.pdf

libstdc++-v3/ChangeLog:

* include/bits/utility.h (std::tuple_size, std::tuple_element):
Add partial specializations for integer_sequence.
(std::get(integer_sequence<_Tp, _Idx...>)): Define.
* include/bits/version.def (integer_sequence): Bump to 202511L.
* include/bits/version.h: Regenerate.
* testsuite/20_util/integer_sequence/tuple_access.cc: New test.
* testsuite/20_util/integer_sequence/tuple_access_neg.cc: New test.
* testsuite/experimental/feat-cxx14.cc: Updated check for
__cpp_lib_integer_sequence value.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Co-authored-by: Ivan Lazaric <ivan.lazaric1@gmail.com>
Signed-off-by: Matthias Wippich <mfwippich@gmail.com>
2 weeks agoaarch64: Regenerate aarch64.opt.urls after adding -mnarrow-gp-writes.
Soumya AR [Tue, 14 Apr 2026 09:55:57 +0000 (09:55 +0000)] 
aarch64: Regenerate aarch64.opt.urls after adding -mnarrow-gp-writes.

I missed regenerating aarch64.opt.urls after committing my previous patch to
narrow 64-bit gp writes to 32.

Adding it here.

Signed-off-by: Soumya AR <soumyaa@nvidia.com>
gcc/ChangeLog:

* config/aarch64/aarch64.opt.urls: Regenerate.

2 weeks agod: Merge upstream dmd, druntime e145b91245
Iain Buclaw [Tue, 14 Apr 2026 09:48:19 +0000 (11:48 +0200)] 
d: Merge upstream dmd, druntime e145b91245

Imports latest bug fixes from the v2.113.0 release branch.

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd e145b91245.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime e145b91245.

2 weeks agotree-optimization/124875 - re-instantiate alias-set code in PRE
Richard Biener [Tue, 14 Apr 2026 07:06:11 +0000 (09:06 +0200)] 
tree-optimization/124875 - re-instantiate alias-set code in PRE

The following re-instantiates the alias-set compatibility check in PRE
that I removed based on lack of test coverage.  As with the alignment
and access size compatibility checks this is now done in prefer
which is used to prune the expression set considered for PRE and
code hoisting.  Compared to the previous code this does not alter
expressions but instead ceases to do PRE or code hoisting if the
expressions representing the value can not be made compatible by
chosing one.

PR tree-optimization/124875
* tree-ssa-pre.cc (prefer): Also compare TBAA set and base_set.
Refactor computing the final prefered expression, do early outs
and allow same prefered expressions.
(sorted_array_from_bitmap_set): Fix thinko that prevented
the last expression in the set of being excluded.

* g++.dg/torture/pr124875.C: New testcase.

2 weeks agoaarch64: Add RTL pass to narrow 64-bit GP reg writes to 32-bit
Soumya AR [Tue, 10 Mar 2026 07:28:10 +0000 (07:28 +0000)] 
aarch64: Add RTL pass to narrow 64-bit GP reg writes to 32-bit

This patch adds a new AArch64 RTL pass that converts 64-bit X-register
operations to 32-bit W-register equivalents when the upper 32 bits are
provably zero.

This patch is active at O2 and above but not enabled by default, except for
-mcpu=olympus.

This is beneficial for the Olympus core, which benefits from using 32-bit
W-registers over 64-bit X-registers if possible. This is recommended by the
updated Olympus Software Optimization Guide, which will be published soon.

For example:
    uint64_t foo(uint64_t a) {
return (a & 255) + 3;
    }

Without this pass, compiles to:
    and x0, x0, 255
    add x0, x0, 3
    ret

But can be optimized to:
    and x0, x0, 255
    add w0, w0, 3
    ret

----

The pass makes a single forward sweep over EBBs in RPO:

   - Computes a nonzero-bit mask for every GP register definition using
   nonzero_bits().
   - At control-flow joins, combine_mask_from_phi ORs the masks of all phi
   inputs; inputs not yet processed (e.g. backedges) receive a conservative
   mode mask.
   - Instructions whose results fit in 32 bits are narrowed after verifying
   with rtl_ssa::recog and rtl_ssa::change_is_worthwhile.
   - Both plain SET and flag-setting PARALLEL patterns (ADDS, SUBS, ANDS,
   etc.) are handled.

----

nonzero_bits(src, DImode) is a function defined in rtlanal.cc that recursively
analyzes RTL expressions to compute a bitmask.  However, nonzero_bits has a
limitation: when it encounters a register, it conservatively returns the mode
mask (all bits potentially set).  Since this pass tracks masks for all GP
register definitions, this information can be used to refine the analysis.
The pass maintains a hash map of computed bit masks and overrides the
reg_nonzero_bits RTL hook to consult this map when encountering a register.

When a definition is in a narrower mode than its use, RTL semantics say the
upper bits are undefined.  The hook conservatively marks those bits as
potentially nonzero by ORing the mask with ~GET_MODE_MASK of the def's mode.

----

PHI nodes require special handling to merge masks from all inputs.  This is done
by combine_mask_from_phi, which ORs together the known masks from all phi
inputs.  For each input:
   1. If the input has a definition already in nzero_map, we use its mask.
   2. If the input has no definition or has not yet been processed
   (e.g. a backedge), we conservatively assume the full mode mask.

----

The pass handles two instruction forms:

Single SET instructions: if the nonzero-bit mask fits in 32 bits, the source
is narrowed to SImode via narrow_dimode_src (which recursively narrows operands
beyond a plain lowpart_subreg), then wrapped in a ZERO_EXTEND back to DImode.
This is needed because RTL semantics say an SImode write leaves the upper 32
bits undefined, even though AArch64 W-register writes zero them.  Without the
ZERO_EXTEND, a later pass could treat the narrowed write as redundant and
silently lose the upper-bit clearing.

simplify_gen_unary is used for the ZERO_EXTEND wrapping so the result is
canonical RTL.  For CONST_INT or ZERO_EXTEND sources, this effectively
round-trips back to the original instruction, and therefore they are skipped.

PARALLEL instructions (compare + arith): flag-setting patterns like ADDS, SUBS,
and ANDS are narrowed when the COMPARE operand matches the SET source.  The SET
part gets the same ZERO_EXTEND-to-DImode wrapping as single SET instructions.
The required mask depends on the condition code mode:
- CC_Zmode: upper 32 bits must be zero.
- CC_NZmode / CC_NZVmode: upper 33 bits must be zero (bit 31 included because
  narrowing moves the sign bit from bit 63 to bit 31, which would flip the N
  flag if bit 31 were set).

Both routines always track nonzero bits for GP register definitions before
checking whether narrowing applies. This ensures we get mask information for
all GP defs, even for instructions we don't end up narrowing.

----

The patch was bootstrapped and regtested on aarch64-linux-gnu, no regression.
OK for GCC16?

Signed-off-by: Soumya AR <soumyaa@nvidia.com>
Co-authored-by: Kyrylo Tkachov <ktkachov@nvidia.com>
gcc/ChangeLog:

* config.gcc: Add aarch64-narrow-gp-writes.o.
* config/aarch64/aarch64-passes.def (INSERT_PASS_BEFORE): Insert
pass_narrow_gp_writes before pass_cleanup_barriers.
* config/aarch64/aarch64-protos.h (make_pass_narrow_gp_writes): Declare.
* config/aarch64/aarch64-tuning-flags.def
(AARCH64_EXTRA_TUNING_OPTION): Add NARROW_GP_WRITES.
* config/aarch64/aarch64.opt (mnarrow-gp-writes): New option.
* config/aarch64/t-aarch64: Add aarch64-narrow-gp-writes.o rule.
* config/aarch64/tuning_models/olympus.h: Add
AARCH64_EXTRA_TUNE_NARROW_GP_WRITES to tune_flags.
* doc/invoke.texi: Document -mnarrow-gp-writes.
* config/aarch64/aarch64-narrow-gp-writes.cc: New file.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/narrow-gp-writes-1.c: New test.
* gcc.target/aarch64/narrow-gp-writes-2.c: New test.
* gcc.target/aarch64/narrow-gp-writes-3.c: New test.
* gcc.target/aarch64/narrow-gp-writes-4.c: New test.
* gcc.target/aarch64/narrow-gp-writes-5.c: New test.
* gcc.target/aarch64/narrow-gp-writes-6.c: New test.
* gcc.target/aarch64/narrow-gp-writes-7.c: New test.

2 weeks agobitintlower: Handle BIT_FIELD_REF load [PR124826]
Jakub Jelinek [Tue, 14 Apr 2026 07:27:09 +0000 (09:27 +0200)] 
bitintlower: Handle BIT_FIELD_REF load [PR124826]

The following testcase ends up with a BIT_FIELD_REF from a VECTOR_TYPE union
member to _BitInt(256).  gimple-lower-bitint.cc already contains code to
handle BIT_FIELD_REFs with SSA_NAME first operand to BITINT_TYPE (for
constant index limb access by adjusting the BIT_FIELD_REF to use different
bitsize and index, for variable index (huge _BitInt with limbs accessed in a loop)
by forcing the SSA_NAME into memory), but that doesn't trigger here, because
gimple_assign_load_p predicate is true on it and so it is handled as load
and not BIT_FIELD_REF.  Anyway, the problem is that we end up with
_7 = VIEW_CONVERT_EXPR<unsigned long[4]>(BIT_FIELD_REF <u.v, 256, 0>)[_2];
which tree-cfg.cc verifier doesn't like because BIT_FIELD_REF is not
toplevel reference in there.  The following patch just strips the
BIT_FIELD_REF away if it has zero bit offset, that is the only case I've
managed to reproduce, and in that case we are still later on using VCE to
convert to array and using ARRAY_REF on that.  If offset could be non-zero
but multiple of BITS_PER_UNIT, another approach would be to replace
BIT_FIELD_REF with a MEM_REF.  Anyway, as I haven't managed to reproduce
it with anything but 0, the following patch is enough.

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

PR tree-optimization/124826
* gimple-lower-bitint.cc (bitint_large_huge::handle_load): Look through
BIT_FIELD_REF with zero bit offset.

* gcc.dg/bitint-128.c: New test.

Reviewed-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 weeks agoFix comment typo in process_symver_attribute
Jakub Jelinek [Tue, 14 Apr 2026 06:43:37 +0000 (08:43 +0200)] 
Fix comment typo in process_symver_attribute

I've noticed a typo in process_symver_attribute comment, fixed thusly.

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

* cgraphunit.cc (process_symver_attribute): Fix comment typo,
bintuils -> binutils.

2 weeks agotree-optimization/124868 - path isolation wrong-code
Richard Biener [Mon, 13 Apr 2026 11:18:00 +0000 (13:18 +0200)] 
tree-optimization/124868 - path isolation wrong-code

The path isolation code mishandles the case where in the same block
there's both a return of a local variable and a dereference of zero
but from different edges.  In this case we re-use the produced block
copy for both isolated paths, causing a trap on the path to the
return of a non-local.

The least intrusive change I came up with separates both causes
and transforms, first isolating NULL dereferences and then
isolating returns of non-NULL.  This will skip the latter transform
on paths which will now not return anyway.

To avoid duplicate diagnostics the handle_return_addr_local_phi_arg
only diagnoses cases in blocks dominated by the original block, not in
copies which still need SSA update and thus are falsely visited.

PR tree-optimization/124868
* gimple-ssa-isolate-paths.cc (handle_return_addr_local_phi_arg):
Do not diagnose returns in blocks not dominated by the PHI.
(find_implicit_erroneous_behavior): Do two sweeps over PHIs,
first for NULL dereferences and then for local address returns.

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

2 weeks agoRevert "rs6000: Add new builtin __builtin_ppc_atomic_cas_local"
Avinash Jayakar [Tue, 14 Apr 2026 05:29:11 +0000 (10:59 +0530)] 
Revert "rs6000: Add new builtin __builtin_ppc_atomic_cas_local"

This reverts commit d5fb79718b22207253d62c92dcf8b1c16e1ea370. Since a 32
bit failure in powerpc was reported in PR124800.

2 weeks agox86: Zero ZMM16-31 when zeroing all call used registers
H.J. Lu [Tue, 14 Apr 2026 03:06:31 +0000 (11:06 +0800)] 
x86: Zero ZMM16-31 when zeroing all call used registers

When zeroing all call used registers with AVX512F enabled, zero ZMM16-31
explicitly since vzeroall doesn't touch ZMM16-31.  Also add a test for
zeroing all call used registers with both AVX512F and APX enabled.

gcc/

PR target/124876
* config/i386/i386.cc (ix86_zero_call_used_regs): Zero ZMM16-31
if needed.

gcc/testsuite/

PR target/124876
* gcc.target/i386/zero-scratch-regs-23.c: Scan vpxord on ZMM16-31.
* gcc.target/i386/zero-scratch-regs-33.c: New test.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2 weeks agoc++/reflection: mangling dependent splices [PR123237]
Marek Polacek [Fri, 13 Mar 2026 12:19:26 +0000 (08:19 -0400)] 
c++/reflection: mangling dependent splices [PR123237]

This patch adds a mangling for dependent splices.  Since the ABI discussion
at <https://github.com/itanium-cxx-abi/cxx-abi/issues/208> hasn't gelled
yet, this mangling might change in the future.  In this patch I'm adding

  <splice> ::= DS <expression> [ <template-args> ] E

for all dependent splices.

When we have ^^T::x, we can't say what kind of reflection this
will be, so this patch emits the "de" prefix.  For template template
parameters we emit "tt".

PR c++/123237
PR c++/124771
PR c++/124842

gcc/cp/ChangeLog:

* mangle.cc (write_splice): New.
(write_prefix): Call write_splice for SPLICE_SCOPE.
(write_type): Likewise.
(write_expression): Call write_splice for dependent_splice_p.
(write_reflection): Handle the "tt" and "de" prefixes.
* reflect.cc (reflection_mangle_prefix): For
DECL_TEMPLATE_TEMPLATE_PARM_P, use the prefix "tt".  For
dependent reflections, use "de".

gcc/testsuite/ChangeLog:

* g++.dg/reflect/mangle2.C: New test.
* g++.dg/reflect/mangle3.C: New test.
* g++.dg/reflect/mangle4.C: New test.
* g++.dg/reflect/mangle5.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
2 weeks agofortran: Fix ICE in remap_type with deferred-length character in OMP target [PR101760...
Christopher Albert [Sat, 11 Apr 2026 13:13:19 +0000 (15:13 +0200)] 
fortran: Fix ICE in remap_type with deferred-length character in OMP target [PR101760, PR102314]

For deferred-length character types such as character(:), allocatable,
TYPE_SIZE and TYPE_SIZE_UNIT contain SAVE_EXPRs wrapping the string
length variable (created by variable_size in finalize_type_size).
In gfc_omp_finish_clause, when computing OMP_CLAUSE_SIZE for implicitly
mapped variables, the code previously used TYPE_SIZE_UNIT directly.
Gimplifying this shared SAVE_EXPR resolves it in place, embedding a
gimple temporary into the type's size expression.  When the enclosing
function is later inlined, remap_type_1 walks TYPE_SIZE and encounters
the stale temporary as an unmappable SSA name, causing an ICE in
make_ssa_name_fn.

Fix by computing the clause size from the array domain bounds and
element size rather than using the type's SAVE_EXPR directly, so
that the type's size expressions remain untouched.

PR fortran/101760
PR fortran/102314

gcc/fortran/ChangeLog:

* trans-openmp.cc (gfc_omp_finish_clause): Compute OMP_CLAUSE_SIZE
from the array domain bounds and element size for VLA types instead
of using TYPE_SIZE_UNIT directly, to avoid corrupting the type.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/pr101760.f90: New test.
* gfortran.dg/gomp/pr102314.f90: New test.

Signed-off-by: Christopher Albert <albert@tugraz.at>
2 weeks agoc++/reflection: fn call with splice in decltype rejected [PR124835]
Marek Polacek [Thu, 9 Apr 2026 23:52:15 +0000 (19:52 -0400)] 
c++/reflection: fn call with splice in decltype rejected [PR124835]

Here we reject the valid

  decltype([:^^foo<int>:](42))

saying that a ')' is expected.  [dcl.type.decltype] says "if E is an
unparenthesized splice-expression, decltype(E) is..." and we handle it
by calling _splice_expression and setting id_expression_or_member_access_p.

But for the code above we shouldn't do this, because the [: :] isn't
the sole operand of decltype.  _nth_token_starts_splice_without_nns_p
checks that there's no :: after the :] but here we want to check that
the [: :] is followed by a ')'.

PR c++/124835

gcc/cp/ChangeLog:

* parser.cc (cp_parser_decltype_expr): Check that [: :] is
followed by a close paren before declaring it an unparenthesized
splice-expression.

gcc/testsuite/ChangeLog:

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

Reviewed-by: Jason Merrill <jason@redhat.com>
2 weeks agolibstdc++: [_Hashtable] Use std::addressof in post-C++11 code
François Dumont [Mon, 13 Apr 2026 17:30:28 +0000 (19:30 +0200)] 
libstdc++: [_Hashtable] Use std::addressof in post-C++11 code

There is no need to use std::__addressof in post-C++11 code.

libstdc++-v3/ChangeLog:

* include/bits/hashtable.h: Replace usages of std::__addressof with
std::addressof.
* include/bits/hashtable_policy.h: Likewise.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2 weeks agoaarch64: testsuite: Fix pr123238.c [PR123238]
Andrew Pinski [Mon, 13 Apr 2026 17:55:38 +0000 (10:55 -0700)] 
aarch64: testsuite: Fix pr123238.c [PR123238]

This fixes the testcase as not matches "note" as in:
        .section        .note.GNU-stack,"",@progbits

Also let's match cmeq at the same time since we want to
make sure this is vectorized too.

Committed as obvious after testing to make sure the testcase passes now
(and fails before the backend change).

PR target/123238
gcc/testsuite/ChangeLog:

* gcc.target/aarch64/pr123238.c:

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 weeks agoc++: local class in lambda in default targ [PR123566]
Jason Merrill [Mon, 13 Apr 2026 16:46:33 +0000 (12:46 -0400)] 
c++: local class in lambda in default targ [PR123566]

Since we started to clear processing_template_parmlist within a lambda, we
started to ICE on a local class in such a lambda where previously we would
give a (wrong) error.  Let's sorry instead of ICE.

The failure mode is that in a parmlist current_template_args() is a 0-length
TREE_VEC, and so tsubst thinks that the type is not dependent, and returns
the type unchanged.  We need to overhaul our handling of local classes (and
enums) in lambdas so that they are regenerated along with the lamba itself;
instantiating them based on the surrounding template parms happens to
work in some cases but is generally wrong; see also PR100198.

PR c++/103901
PR c++/123566

gcc/cp/ChangeLog:

* pt.cc (push_template_decl): Sorry on local class in lambda in
template parm list.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/lambda-targ25.C: New test.

2 weeks agoc++: lambda capture pack and noexcept [PR122632]
Jason Merrill [Mon, 13 Apr 2026 06:12:22 +0000 (02:12 -0400)] 
c++: lambda capture pack and noexcept [PR122632]

This should have been fixed by the patch for 122884, except that we were
forgetting to treat the noexcept substitution as an unevaluated context.

PR c++/122632

gcc/cp/ChangeLog:

* pt.cc (tsubst_exception_specification): Add cp_unevaluated.

gcc/testsuite/ChangeLog:

* g++.dg/cpp23/lambda-scope11.C: New test.

2 weeks agotestsuite: Uncommented some type_trait13.C tests [PR124246]
Jakub Jelinek [Mon, 13 Apr 2026 11:28:34 +0000 (13:28 +0200)] 
testsuite: Uncommented some type_trait13.C tests [PR124246]

These were commented out because of bogus errors, but that was fixed by
r16-8132-g8655ef0b65515b8 PR124472 fix.

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

PR c++/124246
* g++.dg/reflect/type_trait13.C: Uncomment commented out is_swappable_type and
is_nothrow_swappable_type assertions with std::priority_queue.

2 weeks agoRevert "rs6000: Disassemble opaque modes using subregs to allow
Surya Kumari Jangala [Sat, 11 Apr 2026 17:19:45 +0000 (12:19 -0500)] 
Revert "rs6000: Disassemble opaque modes using subregs to allow
optimizations"

This reverts commit 69a2c243dd2cf9f77150c0eb86dfbc0931876bc1 to resolve
the issue reported in PR124804.

2 weeks agolibstdc++: Define __cpp_lib_replaceable_contract_violation_handler.
Tomasz Kamiński [Wed, 8 Apr 2026 13:46:28 +0000 (15:46 +0200)] 
libstdc++: Define __cpp_lib_replaceable_contract_violation_handler.

This implements P3886R0: Wording for AT1-057, by defining the
__cpp_lib_replaceable_contract_violation_handler. The macro is defined
only if contracts are supported (i.e. under same conditions as
__cpp_lib_contracts).

GCC supports providing custom violation handler by providing an separate
defintion of handle_contract_violation. This is supported on the targets
that uses ELF format, so the macro is defined for with non-zero value
for them.

libstdc++-v3/ChangeLog:

* include/bits/version.def (replaceable_contract_violation_handler)
[(__cplusplus > 202302L) && (__cpp_contracts >= 202502L)]:
Define to 202603 for ELF targets, and 0 otherwise.
* include/bits/version.h: Regenerate.
* include/std/contracts: Define
__cpp_lib_replaceable_contract_violation_handler.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 weeks agolibstdc++: Fix duplicated export on basic_string::_M_disjunct on Solaris.
Tomasz Kamiński [Wed, 8 Apr 2026 20:42:12 +0000 (22:42 +0200)] 
libstdc++: Fix duplicated export on basic_string::_M_disjunct on Solaris.

The patterns for cow_string that were split to exclude starts_with,
ends_with, did not include name starting with _:
 _ZNKSs[0-9][0-9][a-z]*;
 _ZNKSbIwSt11char_traitsIwESaIwEE[0-9][0-9][a-z]*;

This was not caught on x86_64-linux as _M_disjunt was already exported
in 3.4 version (when HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT
is defined).

libstdc++-v3/ChangeLog:

* config/abi/pre/gnu.ver (GLIBCXX_3.4): Remove _ZNKSs11_[MS]_*
and _ZNKSbIwSt11char_traitsIwESaIwEE11_[MS]_* patterns.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 weeks agoAda: Fix spurious overflow in the Heapsort implementations
Eric Botcazou [Mon, 13 Apr 2026 10:51:06 +0000 (12:51 +0200)] 
Ada: Fix spurious overflow in the Heapsort implementations

This just adds the missing guard.

gcc/ada/
PR ada/95452
* libgnat/g-heasor.adb (Sort.Sift): Add guard against overflow.
* libgnat/g-hesorg.adb (Sort.Sift): Likewise.
* libgnat/g-hesora.adb (Sort.Sift): Likewise.  Restore consistency.

2 weeks agoAda: Fix invalid memory accesses in GNAT.Perfect_Hash_Generators
Eric Botcazou [Mon, 13 Apr 2026 10:44:14 +0000 (12:44 +0200)] 
Ada: Fix invalid memory accesses in GNAT.Perfect_Hash_Generators

They occur with non-1-based strings used as input.

gcc/ada/
PR ada/77535
* libgnat/s-pehage.adb (New_Word): Rebase the input.

2 weeks agolibstdc++: Update __cpp_lib_function_ref value for P3948R1.
Tomasz Kamiński [Wed, 8 Apr 2026 15:35:46 +0000 (17:35 +0200)] 
libstdc++: Update __cpp_lib_function_ref value for P3948R1.

SG-10 agreed on using 202604L value for paper P3961R0 that
also updates __cpp_lib_function_ref macro.

libstdc++-v3/ChangeLog:

* include/bits/version.def (function_ref): Bump to 202603L.
* include/bits/version.h: Regenerate.
* testsuite/20_util/function_ref/assign.cc: Remove repeated
check for feature test macro.
* testsuite/20_util/function_ref/cons.cc: Updated checked
value.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 weeks agoipa/124700: Fix rebuild_references for callback functions
Josef Melcr [Mon, 13 Apr 2026 07:44:34 +0000 (09:44 +0200)] 
ipa/124700: Fix rebuild_references for callback functions

This patch deals with the following situation:

template<typename T>
void foo () {
  GOMP_parallel (foo._omp_fn, ...);
}

Before callback edges were implemented, if foo got put into a COMDAT
group and subsequently virtually cloned (by ipa-cp, for example), then
the OpenMP kernel wouldn't be put into the same COMDAT group, since it
would be referred to by functions both inside and outside said COMDAT
group.

With callback edges, the kernel may be cloned as well.  If both foo and
foo._omp_fn get cloned, foo's clone will be redirected to the cloned
kernel.  This allows us to put foo._omp_fn into the same COMDAT group as
foo via ipa-comdat.  As the kernel is artificial, it becomes
comdat-local.

However, this redirection is not immediate, leading to the situation in
the PR, where the clones are properly redirected in the call graph, but
the corresponding gimple call is not yet updated.  If one calls
rebuild_references during this time on cloned foo, the reference that
gets rebuilt will still point to the old kernel, which is now in a
COMDAT group, thus creating a reference to a comdat-local symbol outside
of its COMDAT group, leading to a checking ICE.  This patch remedies
that by checking for this case and building a reference to the correct
kernel.

PR ipa/124700

gcc/ChangeLog:

* cgraph.cc (cgraph_node::is_clone_of): New method, determines
whether a node is a descendant of another in the clone tree.
* cgraph.h (struct cgraph_node): Add decl of is_clone_of.
* cgraphbuild.cc (mark_address): Fix reference creation for
cloned callback functions.

gcc/testsuite/ChangeLog:

* g++.dg/gomp/pr124700.C: New test.

Signed-off-by: Josef Melcr <josef.melcr@suse.com>
2 weeks agoi386: Fix Intel syntax memory operand modifiers for AVX10.2 saturation conversions
Hu, Lin1 [Wed, 1 Apr 2026 02:14:30 +0000 (10:14 +0800)] 
i386: Fix Intel syntax memory operand modifiers for AVX10.2 saturation conversions

The AVX10.2 saturation conversion instructions vcvttps2[u]qqs,
vcvttsd2[u]sis and vcvttss2[u]sis are missing operand size modifiers in
their Intel syntax output templates.  This causes assembler errors when
using -masm=intel with memory operands, because Intel Syntax output
wrong memory size.

gcc/ChangeLog:

PR target/124710
* config/i386/sse.md (iptrps2qq): New mode attribute for
ps2qq Intel syntax memory operand size override.
(avx10_2_vcvttps2<sat_cvt_sign_prefix>qqs<mode><mask_name><round_saeonly_name>):
Use %<iptrps2qq>1 in Intel syntax to emit qword ptr for V2DI (128-bit)
memory operands.
(avx10_2_vcvttsd2<sat_cvt_sign_prefix>sis<mode><round_saeonly_name>):
Use %q1 in Intel syntax to emit qword ptr for scalar double memory
operands.
(avx10_2_vcvttss2<sat_cvt_sign_prefix>sis<mode><round_saeonly_name>):
Use %k1 in Intel syntax to emit dword ptr for scalar single memory
operands.

gcc/testsuite/ChangeLog:

PR target/124710
* gcc.target/i386/pr124710-1.c: New test.
* gcc.target/i386/pr124710-2.c: Ditto.

2 weeks agoc++: lambda capture scope and requires [PR122884]
Jason Merrill [Mon, 13 Apr 2026 06:04:35 +0000 (02:04 -0400)] 
c++: lambda capture scope and requires [PR122884]

I spent quite a while working on improving our representation of early
capture proxies, which was enough to make the noexcept work, but eventually
realized that for constraints, since they are substituted before we start to
build the actual function declaration, we need to handle reconstructing
capture proxies during substitution like we already do for parameters.  So
this patch only does that; the early proxy representation changes can wait
for stage 1.

PR c++/122884

gcc/cp/ChangeLog:

* pt.cc (reconstruct_lambda_capture_pack): New.
(tsubst_pack_expansion): Use it.
(tsubst_decl): Handle capture proxy.
(tsubst): Handle lambda closure.
(tsubst_expr): Handle closure field.
(tsubst_lambda_expr): Copy closure location.
* constraint.cc (satisfy_declaration_constraints): Set up
local_specializations for a lambda.

gcc/testsuite/ChangeLog:

* g++.dg/cpp23/lambda-scope10.C: New test.
* g++.dg/cpp23/lambda-scope10a.C: New test.

2 weeks agoconfig: increase stack reserve to 64MB for the toolchain on Windows [PR69639]
Torbjörn SVENSSON [Wed, 1 Apr 2026 12:24:36 +0000 (14:24 +0200)] 
config: increase stack reserve to 64MB for the toolchain on Windows [PR69639]

This fixes fails like below on Windows.

FAIL: gcc.c-torture/compile/limits-exprparen.c   -O0  (test for excess errors)

On Linux, maybe also other targets, the stack limit is dynamically
changed when the application launches.

Regtested with arm-none-eabi on Windows on top of
r16-8253-geb50d28a9353e9.

config/ChangeLog:

PR target/69639
* mh-cygwin: Increase to 64MB stack reserve.
* mh-mingw: Likewise.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
2 weeks agoDaily bump.
GCC Administrator [Mon, 13 Apr 2026 00:16:22 +0000 (00:16 +0000)] 
Daily bump.

2 weeks agoAda: Fix maximum path length regression on Windows
Eric Botcazou [Sun, 12 Apr 2026 08:59:52 +0000 (10:59 +0200)] 
Ada: Fix maximum path length regression on Windows

That's a regression present on all active branches, whereby GNAT uses a
maximum path length of 256 instead of 260 bytes on Windows.

gcc/ada/
PR ada/124836
* adaint.c [__MINGW32__]: Do not include mingw32.h twice, and also
include sys/param.h.

2 weeks agoDaily bump.
GCC Administrator [Sun, 12 Apr 2026 00:16:23 +0000 (00:16 +0000)] 
Daily bump.

2 weeks agofortran: Fix ICE in expand_oacc_for with private derived type [PR93554]
Christopher Albert [Fri, 3 Apr 2026 16:37:54 +0000 (18:37 +0200)] 
fortran: Fix ICE in expand_oacc_for with private derived type [PR93554]

Using a derived type with an allocatable component in a private clause
on an OpenACC loop caused an ICE in expand_oacc_for because the
finalization code for the allocatable component inserted additional
basic blocks between the loop's continuation/entry blocks and the exit
block, violating the strict CFG assertions.

The assertions checked that BRANCH_EDGE(entry_bb)->dest == exit_bb and
FALLTHRU_EDGE(cont_bb)->dest == exit_bb, but with finalization blocks
these edges can point to intermediate blocks rather than directly to
the exit.  Relax the assertions to only verify the expected edge count
(two successors) without requiring specific destinations.

PR fortran/93554

gcc/ChangeLog:

* omp-expand.cc (expand_oacc_for): Relax entry_bb and cont_bb
assertions to allow intermediate blocks from finalization code.
Remove exit_bb predecessor count assertion.

gcc/testsuite/ChangeLog:

* gfortran.dg/goacc/pr93554.f90: New test.

Signed-off-by: Christopher Albert <albert@tugraz.at>
2 weeks agofortran: Fix ICE in build_entry_thunks with CHARACTER bind(c) ENTRY [PR93814]
Christopher Albert [Tue, 31 Mar 2026 06:45:28 +0000 (08:45 +0200)] 
fortran: Fix ICE in build_entry_thunks with CHARACTER bind(c) ENTRY [PR93814]

When a CHARACTER function with bind(c) has an ENTRY also with bind(c),
the entry master function returns CHARACTER by reference (void return,
result passed as pointer + length arguments), but the individual bind(c)
entry thunks return CHARACTER(1) by value and have no such arguments.

build_entry_thunks unconditionally forwarded result-reference arguments
from the thunk's own parameter list to the master call.  For bind(c)
CHARACTER thunks this accessed DECL_ARGUMENTS of a function with no
arguments, causing a segfault.

Create local temporaries for the result buffer and character length in
the thunk when the master returns by reference but the thunk does not.
After calling the master (which writes through the reference), load
the character value from the local buffer and return it by value.

PR fortran/93814

gcc/fortran/ChangeLog:

* trans-decl.cc (build_entry_thunks): Create local result buffer
and length temporaries for bind(c) CHARACTER entry thunks when the
master returns by reference but the thunk returns by value.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Christopher Albert <albert@tugraz.at>
2 weeks agoFortran: defined assignment and vector subscripts [PR120140]
Harald Anlauf [Fri, 10 Apr 2026 21:01:49 +0000 (23:01 +0200)] 
Fortran: defined assignment and vector subscripts [PR120140]

Fortran allows array sections with vector subscripts as actual arguments to
elemental procedures (e.g. F2023: 15.5.2.5):

  (21) If the procedure is nonelemental, the dummy argument does not have
   the VALUE attribute, and the actual argument is an array section having
   a vector subscript, the dummy argument is not definable and shall not
   have the ASYNCHRONOUS, INTENT (OUT), INTENT (INOUT), or VOLATILE
   attributes.

Adjust the checking accordingly to allow vector subscripts in defined
assignment.

PR fortran/120140

gcc/fortran/ChangeLog:

* dependency.cc (gfc_check_argument_var_dependency): For elemental
subroutines skip the dependency check for array references.
Correct description of function return value.
* interface.cc (gfc_compare_actual_formal): Allow array sections
with vector subscripts as actual arguments to elemental procedures
in accordance with the Fortran standard.

gcc/testsuite/ChangeLog:

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

Co-authored-by: Mikael Morin <mikael@gcc.gnu.org>