]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
3 months agogccrs: Put intrinsics in their own namespace and TU
Pierre-Emmanuel Patry [Wed, 4 Mar 2026 16:43:41 +0000 (17:43 +0100)] 
gccrs: Put intrinsics in their own namespace and TU

gcc/rust/ChangeLog:

* Make-lang.in: Add rust-intrinsic-handlers.cc.
* backend/rust-compile-intrinsic.cc (get_identifier): Move function
to handlers namespace.
(is_basic_integer_type): Likewise.
(check_for_basic_integer_type): Likewise.
(offset_handler): Likewise.
(sizeof_handler): Likewise.
(transmute_handler): Likewise.
(rotate_handler): Likewise.
(wrapping_op_handler_inner): Likewise.
(op_with_overflow_inner): Likewise.
(uninit_handler): Likewise.
(move_val_init_handler): Likewise.
(assume_handler): Likewise.
(discriminant_value_handler): Likewise.
(variant_count_handler): Likewise.
(enum class): Likewise.
(prefetch_data_handler): Likewise.
(rotate_left_handler): Likewise.
(rotate_right_handler): Likewise.
(std::function<tree): Likewise.
(wrapping_op_handler): Likewise.
(op_with_overflow): Likewise.
(prefetch_read_data): Likewise.
(prefetch_write_data): Likewise.
(atomic_store_handler_inner): Likewise.
(atomic_load_handler_inner): Likewise.
(atomic_store_handler): Likewise.
(atomic_load_handler): Likewise.
(unchecked_op_inner): Likewise.
(unchecked_op_handler): Likewise.
(copy_handler_inner): Likewise.
(copy_handler): Likewise.
(expect_handler_inner): Likewise.
(expect_handler): Likewise.
(try_handler_inner): Likewise.
(try_handler): Likewise.
(sorry_handler): Likewise.
(check_for_cached_intrinsic): Likewise.
(maybe_override_ctx): Likewise.
(compile_fn_params): Likewise.
(compile_intrinsic_function): Likewise.
(enter_intrinsic_block): Likewise.
(finalize_intrinsic_block): Likewise.
(make_unsigned_long_tree): Likewise.
(build_atomic_builtin_name): Likewise.
* backend/rust-intrinsic-handlers.cc: New file.
* backend/rust-intrinsic-handlers.h: New file.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Add additional test for wildcard special identifier
Pierre-Emmanuel Patry [Wed, 4 Mar 2026 12:19:57 +0000 (13:19 +0100)] 
gccrs: Add additional test for wildcard special identifier

gcc/testsuite/ChangeLog:

* rust/compile/wildcard_items.rs: Move to...
* rust/compile/wildcard_const.rs: ...here.
* rust/compile/wildcard_enum.rs: New test.
* rust/compile/wildcard_enum_variant.rs: New test.
* rust/compile/wildcard_static.rs: New test.
* rust/compile/wildcard_struct.rs: New test.
* rust/compile/wildcard_variable.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Remove duplicated error message.
Pierre-Emmanuel Patry [Wed, 4 Mar 2026 12:16:25 +0000 (13:16 +0100)] 
gccrs: Remove duplicated error message.

The expect token function already emits an error message for malformed
struct.

gcc/rust/ChangeLog:

* parse/rust-parse-impl.hxx: Remove additional error message.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Do not warn on unused function with "_" prefix
Pierre-Emmanuel Patry [Wed, 4 Mar 2026 12:13:13 +0000 (13:13 +0100)] 
gccrs: Do not warn on unused function with "_" prefix

The compiler should not emit any unused function warning on function name
prefixed with an underscore.

gcc/rust/ChangeLog:

* checks/lints/rust-lint-scan-deadcode.h: Add additional condition
to prevent warning emission. Check for underscore prefix.

gcc/testsuite/ChangeLog:

* rust/compile/issue-3947.rs: Do not expect a warning on this
underscore prefixed function.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Use custom error type for enum variants parsing
Pierre-Emmanuel Patry [Mon, 2 Mar 2026 13:46:56 +0000 (14:46 +0100)] 
gccrs: Use custom error type for enum variants parsing

gcc/rust/ChangeLog:

* parse/rust-parse-error.h (struct EnumVariant): Add error for enum
variant.
* parse/rust-parse-impl.hxx: Use new error type instead of nullptr.
* parse/rust-parse.h: Update function prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Change variable underscore detection
Pierre-Emmanuel Patry [Tue, 3 Mar 2026 11:23:42 +0000 (12:23 +0100)] 
gccrs: Change variable underscore detection

gcc/rust/ChangeLog:

* checks/lints/rust-lint-unused-var.cc (starts_with_underscore): Add
function to detect underscore within symbol name.
(check_decl): Call new function for underscore checking.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Prevent error emission with multiple wildcards
Pierre-Emmanuel Patry [Wed, 25 Feb 2026 17:19:23 +0000 (18:19 +0100)] 
gccrs: Prevent error emission with multiple wildcards

Every wildcard should be considered different and no error should be
emitted when multiple wildcards are used within the same rib.

gcc/rust/ChangeLog:

* resolve/rust-toplevel-name-resolver-2.0.cc(TopLevel::visit): Insert
constant item only if now wildcard.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Fix match arm scope
Owen Avery [Tue, 3 Mar 2026 06:04:34 +0000 (01:04 -0500)] 
gccrs: Fix match arm scope

gcc/rust/ChangeLog:

* resolve/rust-default-resolver.cc (DefaultResolver::visit):
Override MatchCase visiting function.
* resolve/rust-default-resolver.h (DefaultResolver::visit):
Likewise.

gcc/testsuite/ChangeLog:

* rust/execute/torture/match-structpattern-tuplefield.rs: Fix
test.
* rust/compile/match-scope.rs: New test.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
3 months agogccrs: expand: Fix ICE on unimplemented RustcEncodable/Decodable derives
jayant chauhan [Sat, 14 Feb 2026 15:44:21 +0000 (21:14 +0530)] 
gccrs: expand: Fix ICE on unimplemented RustcEncodable/Decodable derives

When encountering `#[derive(RustcEncodable)]` or `RustcDecodable`, the
`DeriveVisitor` previously fell through to `rust_unreachable ()`,
causing an Internal Compiler Error.

This patch adds cases for these built-in macros to explicitly emit a
"sorry, unimplemented" message instead of crashing.

Fixes Rust-GCC#3951

gcc/rust/ChangeLog:

* expand/rust-derive.cc (DeriveVisitor::derive): Handle
`BuiltinMacro::RustcEncodable` and `BuiltinMacro::RustcDecodable`.

gcc/testsuite/ChangeLog:

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

Signed-off-by: jayant chauhan <0001jayant@gmail.com>
3 months agogccrs: refactor: update constructor to initialize ExternalItem base class
vibhatsu [Fri, 6 Feb 2026 07:58:48 +0000 (13:28 +0530)] 
gccrs: refactor: update constructor to initialize ExternalItem base class

In full constructor, add initialization for ExternalItem base class. Use
the node id inside ExternalItem to populate member node id.

gcc/rust/ChangeLog:

* ast/rust-macro.h: add initialization for ExternalItem base
class in full construtor and use node id inside ExternalItem
to populate memeber node id.

Signed-off-by: vibhatsu <maulikbarot2915@gmail.com>
3 months agogccrs: refactor: use MacroInvocation's node id everywhere for consistency
vibhatsu [Fri, 6 Feb 2026 07:47:32 +0000 (13:17 +0530)] 
gccrs: refactor: use MacroInvocation's node id everywhere for consistency

gcc/rust/ChangeLog:

* ast/rust-macro.h: remove get_macro_node_id and propagate
MacroInvocation's node id through get_node_id for consistency
* util/rust-hir-map.cc (Mappings::insert_macro_invocation): replace
all get_macro_node_id calls with get_node_id calls
(Mappings::lookup_macro_invocation): likewise
(Mappings::insert_bang_proc_macro_invocation): likewise
(Mappings::lookup_bang_proc_macro_invocation): likewise

Signed-off-by: vibhatsu <maulikbarot2915@gmail.com>
3 months agogccrs: ast: Implement reconstruct() logic for Path hierarchy
Jayant Chauhan [Fri, 16 Jan 2026 17:34:00 +0000 (23:04 +0530)] 
gccrs: ast: Implement reconstruct() logic for Path hierarchy

This patch implements the `reconstruct` pattern for the `Path` hierarchy and its
constituents (segments, generic args, qualified paths).

Previously, derive expansion macros (like `derive(PartialEq)`) had to manually
rebuild paths field-by-field to ensure fresh NodeIDs. This change moves that
logic into the AST classes themselves, allowing paths to be deeply reconstructed
uniformly. This ensures that expanded code has unique NodeIDs, which is critical
for correct name resolution.

gcc/rust/ChangeLog:

* ast/rust-path.h (GenericArgsBinding::reconstruct): New method.
(GenericArg::reconstruct): New method.
(GenericArgs::reconstruct): New method.
(PathExprSegment::reconstruct): New method.
(PathInExpression::reconstruct): New method.
(TypePathSegmentGeneric::reconstruct_impl): New method.
(TypePathFunction::reconstruct): New method.
(TypePathSegmentFunction::reconstruct_impl): New method.
(QualifiedPathType::reconstruct): New method.
(QualifiedPathInExpression::reconstruct): New method.
(QualifiedPathInType::reconstruct_impl): New method.
* expand/rust-derive-cmp-common.cc (EnumMatchBuilder::tuple): Use path.reconstruct().
(EnumMatchBuilder::strukt): Use path.reconstruct().

Signed-off-by: Jayant Chauhan <0001jayant@gmail.com>
3 months agogccrs: Add no_std attribute
Pierre-Emmanuel Patry [Wed, 25 Feb 2026 00:52:20 +0000 (01:52 +0100)] 
gccrs: Add no_std attribute

Add a no_std attribute, when both no_std and no_core attributes are
missing, inject an external std crate.

gcc/rust/ChangeLog:

* rust-session-manager.cc (Session::compile_crate): Inject std crate
when both no_std and no_core attributes are missing.
* util/rust-attribute-values.h: Add no_std attribute value.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Remove duplicated visit within early name res
Pierre-Emmanuel Patry [Tue, 24 Feb 2026 11:47:24 +0000 (12:47 +0100)] 
gccrs: Remove duplicated visit within early name res

Attribute content was checked twice within the early name resolution,
from outside the attribute and then using the default visitor. Remove
the first one visit. Also fix the wrong locus on trait resolution.

gcc/rust/ChangeLog:

* resolve/rust-early-name-resolver-2.0.cc (Early::visit_derive_attribute):
Change from attribute locus to trait locus.
(Early::visit_attributes): Remove function.
(Early::visit): Remove functions.
* resolve/rust-early-name-resolver-2.0.h: Remove unused prototypes.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Correctly emit warning on invalid attributes
Pierre-Emmanuel Patry [Mon, 23 Feb 2026 14:08:10 +0000 (15:08 +0100)] 
gccrs: Correctly emit warning on invalid attributes

We were emitting warning even on attribute that were then removed by
the cfgstrip pass. We cannot move the cfg strip pass before the attribute
checking because we need to first emit malformed input error messages.
This means the attribute checking pass must know if an attribute input
may be removed later down the line.

gcc/rust/ChangeLog:

* ast/rust-ast.cc (MetaItemPathExpr::to_attribute): Remove cast to
literal.
(AttrInputMetaItemContainer::separate_cfg_attrs): Remove PathExpr
specific code.
* expand/rust-cfg-strip.cc (expand_cfg_attrs): Remove the whole
attribute if condition's result is false.
* util/rust-attributes.cc (AttributeChecker::visit): Remove specific
code section for meta item container. Do not check input if
configuration does not match condition.

gcc/testsuite/ChangeLog:

* rust/compile/attr_malformed_path.rs: Filter existing test to x86_64
exclusively, add two new tests that appear when visiting the resulting
expression.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Add AttrInputExpr node
Pierre-Emmanuel Patry [Mon, 23 Feb 2026 10:31:08 +0000 (11:31 +0100)] 
gccrs: Add AttrInputExpr node

We will require expr within attribute input in the future in order to be
able to handle some nightly features. Even, the current macro attribute
input could be converted to an expression attribute input.

gcc/rust/ChangeLog:

* ast/rust-ast-collector.cc (TokenCollector::visit): Add visitor
implementation.
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Likewise.
* ast/rust-ast-collector.h: Add function prototype.
* ast/rust-ast-visitor.h: Likewise.
* expand/rust-derive.h: Likewise.
* hir/rust-ast-lower-base.h: Likewise.
* ast/rust-ast.cc (Attribute::get_traits_to_derive): Handle EXPR
variant.
(AttrInputExpr::AttrInputExpr): Add constructor.
(AttrInputExpr::operator=): Add assignment operator implementation.
(AttrInputExpr::as_string): Add a string conversion member function.
(AttrInputExpr::accept_vis): Add visitor function.
* ast/rust-ast.h: Add EXPR type variant to AttrInput.
* util/rust-attributes.cc (check_doc_attribute): Handle expr variant.
* ast/rust-expr.h (class AttrInputExpr): Add class definition with
member function prototypes.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Add empty
visitor implementation.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Add global scope debug function for crate
Pierre-Emmanuel Patry [Mon, 23 Feb 2026 10:23:08 +0000 (11:23 +0100)] 
gccrs: Add global scope debug function for crate

A crate is not a visitable and thus cannot be used with the debug
function. Until it is made visitable this commit provides a function
to dump the content of a crate.

gcc/rust/ChangeLog:

* ast/rust-ast-dump.cc (debug): Add debug function which calls debug
on every crate field.
* ast/rust-ast-dump.h (debug): Add function prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Use Attribute node status for AttributeChecker
Pierre-Emmanuel Patry [Thu, 19 Feb 2026 14:47:11 +0000 (15:47 +0100)] 
gccrs: Use Attribute node status for AttributeChecker

Remove attribute specific checking, use default ast visitor instead.

gcc/rust/ChangeLog:

* util/rust-attributes.cc (AttributeChecker::visit): Rename function
and make call to ast default visitor.
(AttributeChecker::check_attribute): Remove function.
* util/rust-attributes.h: Add function prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Make Attribute parent class Visitable public
Pierre-Emmanuel Patry [Wed, 18 Feb 2026 13:55:55 +0000 (14:55 +0100)] 
gccrs: Make Attribute parent class Visitable public

These changes allows interfacing with attributes as a Visitable node.

gcc/rust/ChangeLog:

* ast/rust-ast.h (class Attribute): Make visitable parent class public.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Add node id to attribute node.
Pierre-Emmanuel Patry [Wed, 11 Feb 2026 16:49:41 +0000 (17:49 +0100)] 
gccrs: Add node id to attribute node.

gcc/rust/ChangeLog:

* ast/rust-ast.h (class Attribute): Add a node id member.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Make attribute a proper AST node
Pierre-Emmanuel Patry [Wed, 11 Feb 2026 16:42:22 +0000 (17:42 +0100)] 
gccrs: Make attribute a proper AST node

Attribute have always been a bit weird, they were part of the AST but did
not have any visitor function, this create a lot of friction around them
as their input which may be an expression, a literal and even an
expression in the future didn't get visited properly during the different
passes of the compiler.

gcc/rust/ChangeLog:

* ast/rust-ast-full-decls.h (struct Attribute): Change from here...
(class Attribute): ...to a class here.
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Add a default
visit function for the attributes.
* ast/rust-ast-visitor.h: Add a proper visit function declaration for
attributes.
* ast/rust-ast.cc (Attribute::accept_vis): Add a function to accept a
visitor within the attributes.
* ast/rust-ast.h (struct Attribute): Add the accept_vis function
prototype.
(class Attribute): Rename from struct to class.
* expand/rust-derive.h: Add an empty implementation for visits to
prevent the visitor from recursing into the attributes.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Add missing
implementation for attribute visit function. Add a check for derive
attributes that would have slipped through the passes.
* hir/rust-ast-lower-base.h: Add function prototype.
* resolve/rust-early-name-resolver-2.0.cc (Early::visit_attributes):
Split the function into two halves.
(Early::visit_derive_attribute): Specialized function from
visit_attribute for derive attributes.
(Early::visit_non_builtin_attribute): Likewise for non builtin
attributes.
(Early::visit): Rename visit_attributes to visit.
* resolve/rust-early-name-resolver-2.0.h (class Early): Update function
prototypes.

gcc/testsuite/ChangeLog:

* rust/compile/issue-4212.rs: Update test with the new errors.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Add multiple missing builtin attribute values
Pierre-Emmanuel Patry [Tue, 10 Feb 2026 12:57:42 +0000 (13:57 +0100)] 
gccrs: Add multiple missing builtin attribute values

Those attributes should be considered as builtin attributes but were
missing from the list of builtin attributes.

gcc/rust/ChangeLog:

* util/rust-attributes.cc: Add "feature", "no_core", "doc",
"crate_name", "crate_type" and "may_dandle" to the list of builtin
attributes.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Add crate_name and crate_type to attribute values
Pierre-Emmanuel Patry [Tue, 10 Feb 2026 12:56:08 +0000 (13:56 +0100)] 
gccrs: Add crate_name and crate_type to attribute values

gcc/rust/ChangeLog:

* rust-session-manager.cc (Session::handle_crate_name): Use the new
constexpr instead of a raw string value.
* util/rust-attribute-values.h: Add crate_name and crate_type values.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Move early gate feature store to it's own TU
Pierre-Emmanuel Patry [Sat, 7 Feb 2026 15:51:37 +0000 (16:51 +0100)] 
gccrs: Move early gate feature store to it's own TU

Move the early feature gate store to it's own translation unit. This
will reduces the size of included headers within the parser.

gcc/rust/ChangeLog:

* Make-lang.in: Add new specific feature store file.
* checks/errors/feature/rust-feature-gate.cc (EarlyFeatureGateStore::get):
Move from here to rust-feature-store.cc.
(EarlyFeatureGateStore::add): Likewise.
(EarlyFeatureGateStore::get_error): Likewise.
(FeatureGate::check): Likewise.
* checks/errors/feature/rust-feature-gate.h (class EarlyFeatureGateStore):
Move class declaration to rust-feature-store.h header.
* parse/rust-parse.h: Change included header.
* checks/errors/feature/rust-feature-store.cc: New file.
* checks/errors/feature/rust-feature-store.h: New file.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Collect early feature gating errors in a store
Pierre-Emmanuel Patry [Sat, 7 Feb 2026 01:02:28 +0000 (02:02 +0100)] 
gccrs: Collect early feature gating errors in a store

We use multiple parsers and can't retrieve all early feature gating
errors within the usual gating pass. This commit introduces a store to
collect all early gating errors in the same place from multiple parsers.
The features are then checked as usual within the feature gate checker.

gcc/rust/ChangeLog:

* checks/errors/feature/rust-feature-gate.cc (EarlyFeatureGateStore::get):
Add function to retrieve singleton instance.
(EarlyFeatureGateStore::add): New function to add an error and the
corresponding feature in the store.
(EarlyFeatureGateStore::get_error): Add new function to retrieve the
oldest error.
(FeatureGate::check): Update the function to retrieve the errors from
the store instead of getting it from the parameters.
* checks/errors/feature/rust-feature-gate.h (class EarlyFeatureGateStore):
Add a new class to collect all early feature gating errors.
* parse/rust-parse.h: Use store instead of keeping the errors within
the parser instance.
* rust-session-manager.cc (Session::compile_crate): Remove old early
error collection from the main parser.
* rust-system.h: Include queue header.

gcc/testsuite/ChangeLog:

* rust/compile/issue-3661.rs: Add key_value_attribute feature to
prevent error on stringify macro.
* rust/compile/early_feature_gate_in_macro.rs: Add test to highlight
early feature gate error collection within macros.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Collect feature gate error at parse time
Pierre-Emmanuel Patry [Fri, 6 Feb 2026 13:21:29 +0000 (14:21 +0100)] 
gccrs: Collect feature gate error at parse time

Some nightly features change the parser's behavior, it may accepts syntax
that should be rejected when the feature is missing. But the complete
list of enabled features can only be found once the parsing is complete.
We should therefore not emit any error at parse time and instead collect
a potential error and emit it later during the feature gating step.

gcc/rust/ChangeLog:

* checks/errors/feature/rust-feature-gate.cc (FeatureGate::check):
Check all parse time errors.
* checks/errors/feature/rust-feature-gate.h: Update function prototype
with parse time errors.
* parse/rust-parse-impl-attribute.hxx: Collect potential gating error
with non literal attribute values. Remove error emission.
* parse/rust-parse.h: Add a function to gather potential feature gating
errors as well as a getter for collected errors.
* rust-session-manager.cc (Session::compile_crate): Retrieve potential
feature gating errors and check them later during the feature gating
step.
* util/rust-attributes.cc (check_export_name_attribute): Change
attribute checking error emission to prevent errors with macro inputs.

gcc/testsuite/ChangeLog:

* rust/compile/doc_macro.rs: Enable feature to use a macro within an
attribute input.
* rust/compile/parse_time_feature_gate.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Bump feature definition version
Pierre-Emmanuel Patry [Fri, 6 Feb 2026 13:07:21 +0000 (14:07 +0100)] 
gccrs: Bump feature definition version

rust-for-linux uses some nightly features that appeared with rust 1.50,
this patch provides a new mechanism dedicated to features required for
rfl that were not available back then.

gcc/rust/ChangeLog:

* checks/errors/feature/contrib/fetch: Bump version from 1.49.0 to
1.50.0. Change brace expansion to explicit file fetch.
* checks/errors/feature/rust-feature-defs.h: Regenerate.
* checks/errors/feature/contrib/copyright-stub.h: Add rfl include
directive.
* checks/errors/feature/rust-feature-defs-rfl.h: New file.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Add early cfg strip step before feature collection
Pierre-Emmanuel Patry [Thu, 5 Feb 2026 12:58:11 +0000 (13:58 +0100)] 
gccrs: Add early cfg strip step before feature collection

Features are now collected early rather than later during the feature
gating visitor. This requires the introduction of an early cfg strip
in order to collect #![cfg(xxxx), feature(yyyy)] correctly.

gcc/rust/ChangeLog:

* Make-lang.in: Add rust-early-cfg-strip object file.
* expand/rust-cfg-strip.h (expand_cfg_attrs): Declare function prototype.
* rust-session-manager.cc (Session::compile_crate): Reorder feature
collection and add early cfg strip.
* expand/rust-early-cfg-strip.cc: New file.
* expand/rust-early-cfg-strip.h: New file.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Remove unused function
Pierre-Emmanuel Patry [Wed, 4 Feb 2026 22:38:13 +0000 (23:38 +0100)] 
gccrs: Remove unused function

gcc/rust/ChangeLog:

* expand/rust-cfg-strip.cc (CfgStrip::fails_cfg): Remove function.
* expand/rust-cfg-strip.h: Remove function prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Split feature collection from feature gating
Pierre-Emmanuel Patry [Fri, 30 Jan 2026 16:54:10 +0000 (17:54 +0100)] 
gccrs: Split feature collection from feature gating

Feature collection should happen before expansion because some feature
gating happens with macros. This commit does no move the feature
collection before the expansion pass, it simply split the collection part
from the gating part.

gcc/rust/ChangeLog:

* Make-lang.in: Add new feature collector file.
* checks/errors/feature/rust-feature-gate.cc (FeatureGate::visit):
Remove feature collection from gating visitor.
(FeatureGate::gate): Use features from the crate feature entity instead
of old class members.
* checks/errors/feature/rust-feature-gate.h: Get features from a
separate CrateFeatures struct instead of keeping them in the class.
* rust-session-manager.cc (Session::compile_crate): Collect features
before gating them.
* util/rust-attribute-values.h: Add feature attribute value.
* checks/errors/feature/rust-feature-collector.cc: New file.
* checks/errors/feature/rust-feature-collector.h: New file.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Rename is_builtin and change return type
Pierre-Emmanuel Patry [Fri, 30 Jan 2026 15:26:35 +0000 (16:26 +0100)] 
gccrs: Rename is_builtin and change return type

Rename is_builtin to identify_builtin and change prototype to return the
builtin when found.

gcc/rust/ChangeLog:

* util/rust-attributes.cc (is_builtin): Rename from here ...
(identify_builtin): ... to here.
(is_proc_macro_type): Handle new return value.
(AttributeChecker::check_inner_attribute): Likewise.
(AttributeChecker::check_attribute): Likewise.
(AttributeChecker::visit): Likewise.
* util/rust-attributes.h (identify_builtin): Update function prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: testsuite: Add test case for macro missing body
Harishankar [Wed, 25 Feb 2026 09:29:45 +0000 (14:59 +0530)] 
gccrs: testsuite: Add test case for macro missing body

Fixes Rust-GCC/gccrs#4413

gcc/testsuite/ChangeLog:

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

Signed-off-by: Harishankar <harishankarpp7@gmail.com>
3 months agogccrs: ast: Fix missing location info in derive macros
jayant chauhan [Thu, 12 Feb 2026 22:19:23 +0000 (03:49 +0530)] 
gccrs: ast: Fix missing location info in derive macros

Fixes Rust-GCC#4433

gcc/rust/ChangeLog:

* ast/rust-ast.cc (Attribute::get_traits_to_derive): Propagate location
info from MetaWord to SimplePath.

gcc/testsuite/ChangeLog:

* rust/compile/issue-4433.rs: Update test to expect valid line numbers.

Signed-off-by: Jayant Chauhan <0001jayant@gmail.com>
3 months agogccrs: Add wrapper class for automatic node cloning
Owen Avery [Sat, 3 Jan 2026 00:16:24 +0000 (19:16 -0500)] 
gccrs: Add wrapper class for automatic node cloning

This patch adds a wrapper class called Cloneable, which can be used to
automatically perform polymorphic copying. This should greatly reduce
the need for error-prone user defined copy constructors and assignment
operators.

As a demonstration/first step, this patch also uses Cloneable to
simplify the pattern nodes described in gcc/rust/ast/rust-pattern.h.

gcc/rust/ChangeLog:

* ast/rust-ast.h: Include "rust-cloneable.h".
(struct CloneableDelegate<std::unique_ptr<AST::Pattern>>): Add
specialization.
* ast/rust-pattern.cc (IdentifierPattern::as_string): Handle
field type changes.
(RangePattern::as_string): Likewise.
(ReferencePattern::as_string): Likewise.
(StructPatternFieldTuplePat::as_string): Likewise.
(StructPatternFieldIdentPat::as_string): Likewise.
(StructPatternElements::as_string): Likewise.
(TupleStructItemsNoRest::as_string): Likewise.
(TupleStructItemsHasRest::as_string): Likewise.
(TupleStructPattern::as_string): Likewise.
(TuplePatternItemsNoRest::as_string): Likewise.
(TuplePatternItemsHasRest::as_string): Likewise.
(TuplePattern::as_string): Likewise.
(SlicePatternItemsNoRest::as_string): Likewise.
(SlicePatternItemsHasRest::as_string): Likewise.
(SlicePattern::as_string): Likewise.
(AltPattern::as_string): Likewise.
* ast/rust-pattern.h: Include "rust-cloneable.h".
(class IdentifierPattern): Use Cloneable to simplify copying.
(class RangePattern): Likewise.
(class ReferencePattern): Likewise.
(class StructPatternFieldTuplePat): Likewise.
(class StructPatternFieldIdentPat): Likewise.
(class StructPatternElements): Likewise.
(class TupleStructItemsNoRest): Likewise.
(class TupleStructItemsHasRest): Likewise.
(class TupleStructPattern): Likewise.
(class TuplePatternItemsNoRest): Likewise.
(class TuplePatternItemsHasRest): Likewise.
(class TuplePattern): Likewise.
(class GroupedPattern): Likewise.
(class SlicePatternItemsNoRest): Likewise.
(class SlicePatternItemsHasRest): Likewise.
(class SlicePattern): Likewise.
(class AltPattern): Likewise.
(struct
CloneableDelegate<std::unique_ptr<AST::RangePatternBound>>): Add
specialization.
(struct
CloneableDelegate<std::unique_ptr<AST::TupleStructItems>>):
Likewise.
(struct
CloneableDelegate<std::unique_ptr<AST::TuplePatternItems>>):
Likewise.
(struct
CloneableDelegate<std::unique_ptr<AST::SlicePatternItems>>):
Likewise.
(struct
CloneableDelegate<std::unique_ptr<AST::StructPatternField>>):
Likewise.
* util/rust-cloneable.h: New file.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
3 months agoaarch64: Set loop_align to 64:16 for NVIDIA Olympus
Kyrylo Tkachov [Tue, 17 Mar 2026 08:48:01 +0000 (01:48 -0700)] 
aarch64: Set loop_align to 64:16 for NVIDIA Olympus

The Olympus core benefits from a more relaxed bigger alignment on hot loops.

Bootstrapped and tested on aarch64-none-linux-gnu.
Pushing to trunk.

Signed-off-by: Kyrylo Tkachov <ktkachov@nvidia.com>
gcc/ChangeLog

* config/aarch64/tuning_models/olympus.h (olympus_tunings): Set
loop_align to 64:16.

3 months agoxtensa: Specify the pre-configured table array as const
Takayuki 'January June' Suwa [Thu, 19 Mar 2026 22:59:16 +0000 (07:59 +0900)] 
xtensa: Specify the pre-configured table array as const

gcc/ChangeLog:

* config/xtensa/xtensa.cc (gen_int_relational):
Specify the table array "info" and the pointer to its elements
as const.

3 months agolibstdc++: Fix chrono::current_zone() for three-level names [PR122567]
Jonathan Wakely [Fri, 9 Jan 2026 13:39:49 +0000 (13:39 +0000)] 
libstdc++: Fix chrono::current_zone() for three-level names [PR122567]

chrono::current_zone() fails if /etc/localtime is a symlink to a zone
with three components, like "America/Indiana/Indianapolis", because we
only try to find "Indianapolis" and "Indiana/Indianapolis" but neither
of those is a valid zone name.

We need to try up to three components to handle all valid cases, such as
"UTC", "America/Indianapolis", and "America/Indiana/Indianapolis". It's
also possible that users could provide a custom tzdata.zi file which
includes zones with names using more than three levels, so loop over all
filename components of the path that /etc/localtime points to.

This also replaces std::filesystem::read_symlink with a plain readlink
call and find+substr operations on a std::string_view, which is
approximately twice as fast as using std::filesystem::path and
std::string.

By default we use a fixed char[128] buffer for readlink to write into,
but if that doesn't fit we use a std::string as a dynamic buffer that
grows as needed. We could use ::stat to find the exact length of the
symlink and avoid looping with an increasingly large std::string
capacity, but it's already expected to be rare for the char[128] buffer
to be exceeded, so needing to double the std::string capacity more than
once (i.e. to 512 or more) should be exceedingly rare. Adding a call to
::stat would perform a third filesystem operation when two readlink
calls should be sufficient for the vast majority of realistic cases.

One consequence of not using filesystem::path is that redundant
consecutive slashes in the pathname aren't automatically ignored, e.g.
/usr/share/zoneinfo/Europe//London worked fine with the old
implementation because we manually concatenated the path components,
i.e. "Europe" + '/' + "London". So that this continues to work there is
a new loop to remove redundant slashes from the string being processed.
That adds a slower, allocating path, but is unlikely to be needed in
practice (the systemd spec for /etc/localtime explicitly says it should
end with a time zone name, so "Europe//London" would be invalid anyway,
even if it points to a valid file). Again, this loop is expected to be
rare so optimizing this case further isn't important.

While manually testing this I noticed that we will interpret a bogus
symlink such as /usr/share/zoneinfo/America/Europe/London as a valid
timezone, even though it's a dangling symlink. We find a name match for
"Europe/London" before we get to the "America" component. This seems
unlikely to matter in practice, and was a pre-existing problem.

There's no testcase for current_zone() correctly handling three-level
names or symlinks with unusual targets. It cannot be tested without
changing the target of /etc/localtime which requires root access.

I'm still considering whether we want to cache the result of
current_zone(), either globally or in the tzdb object. Just returning a
cached variable takes 20-30ns instead of more than 700ns to access the
filesystem and read the symlink. Using ::lstat to check the symlink's
mtime would add some overhead though.

libstdc++-v3/ChangeLog:

PR libstdc++/122567
* src/c++20/tzdb.cc (tzdb::current_zone): Loop over all trailing
components of /etc/localtime path. Use readlink instead of
std::filesystem::read_symlink.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 months agolibstdc++: Fix preprocessor condition for AIX
Jonathan Wakely [Fri, 20 Mar 2026 00:01:12 +0000 (00:01 +0000)] 
libstdc++: Fix preprocessor condition for AIX

Only AIX uses getenv, so including <cstdlib> should be done when _AIX is
defined, not when it's undefined.

libstdc++-v3/ChangeLog:

* src/c++20/tzdb.cc [_AIX]: Change #ifndef to #ifdef.

3 months agolibstdc++: Disable PCH for failing test [PR124568]
Jonathan Wakely [Fri, 20 Mar 2026 11:35:14 +0000 (11:35 +0000)] 
libstdc++: Disable PCH for failing test [PR124568]

The diagnostic pragmas that suppress the warning in this test don't seem
to work with PCH. Let's just disable PCH for that test.

libstdc++-v3/ChangeLog:

PR libstdc++/124568
* testsuite/24_iterators/istreambuf_iterator/105580.cc: Add
no_pch option.

3 months agolibstdc++: Optimize fs::path::operator+=(const path&) alias check
Jonathan Wakely [Tue, 17 Mar 2026 15:58:10 +0000 (15:58 +0000)] 
libstdc++: Optimize fs::path::operator+=(const path&) alias check

Instead of a loop that compares &p to the address of each path
component, we can just do two pointer comparisons to see if &p is within
the contiguous array of components.

We don't need to make the same change to experimental::filesystem::path
because as noted in r15-9709-gbeb0ffd36eedf0 the TS implementation
doesn't attempt to optimize operator+= so doesn't care if the parameter
aliases *this.

libstdc++-v3/ChangeLog:

* src/c++17/fs_path.cc (path::operator+=): Use pointer
comparison to detect aliasing instead of a loop.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 months agolibstdc++: Micro-optimization for std::generator helper concept
Jonathan Wakely [Wed, 18 Mar 2026 22:24:24 +0000 (22:24 +0000)] 
libstdc++: Micro-optimization for std::generator helper concept

The default_initializable concept is defined in terms of some builtins
which should be cheap to evaluate. Check that before instantiating the
allocator_traits class template.

libstdc++-v3/ChangeLog:

* include/std/generator (_Stateless_alloc): Swap order of
constraints.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Arsen Arsenović <arsen@aarsen.me>
3 months agoi386: Set TREE_PUBLIC on TYPE_NAME of __va_list_tag [PR124565]
Jakub Jelinek [Fri, 20 Mar 2026 08:11:28 +0000 (09:11 +0100)] 
i386: Set TREE_PUBLIC on TYPE_NAME of __va_list_tag [PR124565]

 module;
 #include <cstdarg>
 export module pr124565;
 export namespace std {
   using std::va_list;
 }
fails on alpha-linux with -fmodules:
pr124565.cc:5:14: error: exporting ‘typedef __gnuc_va_list va_list’ that does not have external linkage
<built-in>: note: ‘typedef struct __va_list_tag __va_list_tag’ declared here with internal linkage

It doesn't fail on x86_64-linux because there va_list is __va_list_tag[]
(i.e. array type), while on alpha-linux it is __va_list_tag itself; and the
module code calls decl_linkage on it and returns lk_internal for C++11 and
later.

Now, decl_linkage on x86_64-linux on __va_list_tag directly also returns
incorrectly lk_internal, and as I have no way to test alpha, I've
bootstrapped/regtested on x86_64-linux and i686-linux the following patch.

IMHO it is still desirable even there even when it is just a latent issue.

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

PR target/124565
* config/i386/i386.cc (ix86_build_builtin_va_list_64): Set TREE_PUBLIC
on type_decl.

3 months agosh: Set TREE_PUBLIC on TYPE_NAME of __va_list_tag [PR124566]
Jakub Jelinek [Fri, 20 Mar 2026 08:10:25 +0000 (09:10 +0100)] 
sh: Set TREE_PUBLIC on TYPE_NAME of __va_list_tag [PR124566]

Same problem as in PR124565 on alpha,
 module;
 #include <cstdarg>
 export module pr124565;
 export namespace std {
   using std::va_list;
 }
fails on sh4-linux with -fmodules:
pr124565.cc:5:14: error: exporting ‘typedef __gnuc_va_list va_list’ that does not have external linkage
<built-in>: note: ‘typedef struct __va_list_tag __va_list_tag’ declared here with internal linkage

Same fix, tested again with a cross on that testcase.
E.g. the just posted g++.dg/plugin/std-module-exports* tests would
FAIL because of this on sh4-linux.

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

PR target/124566
* config/sh/sh.cc (sh_build_builtin_va_list): Set TREE_PUBLIC
on type_decl.

3 months agotree-optimization/124578 - fix copy&pasto
Richard Biener [Fri, 20 Mar 2026 07:30:06 +0000 (08:30 +0100)] 
tree-optimization/124578 - fix copy&pasto

The following fixes a check on vro1->opcode to properly check
vro2->opcode.  This is actually a harmless copy&paste issue since
a previous check guarnateed equality of both.  Still it's less
confusing when fixed.

PR tree-optimization/124578
* tree-ssa-sccvn.cc (vn_reference_eq): Consistently check
fields from vro2.

3 months agofmv: Check DECL_VIRTUAL_P for virtual functions for LTO handling
Yangyu Chen [Mon, 23 Feb 2026 10:27:25 +0000 (18:27 +0800)] 
fmv: Check DECL_VIRTUAL_P for virtual functions for LTO handling

When building with LTO, DECL_VINDEX is not always set for virtual
functions, which allows virtual functions to be incorrectly treated as
non-virtual and then being multi-versioned, and causes errors sometimes.

This patch addresses the issue by ensuring that we check DECL_VIRTUAL_P
instead of DECL_VINDEX when handling virtual functions during
multiversioning.

Signed-off-by: Yangyu Chen <cyy@cyyself.name>
gcc/ChangeLog:

* config/aarch64/aarch64.cc (aarch64_generate_version_dispatcher_body):
Check DECL_VIRTUAL_P for virtual functions for LTO handling.
* config/i386/i386-features.cc (ix86_generate_version_dispatcher_body):
Ditto.
* config/riscv/riscv.cc (riscv_generate_version_dispatcher_body): Ditto.
* config/rs6000/rs6000.cc (rs6000_generate_version_dispatcher_body):
Ditto.
* config/loongarch/loongarch.cc
(loongarch_generate_version_dispatcher_body): Ditto.

gcc/testsuite/ChangeLog:

* g++.target/aarch64/virtual-lto.C: New test.

3 months agofortran: Add testcase [PR84779]
Christopher Albert [Tue, 10 Mar 2026 23:19:25 +0000 (00:19 +0100)] 
fortran: Add testcase [PR84779]

The reproducer from the bug report compiles cleanly on current
trunk.  Add a testcase to prevent future regressions.

PR fortran/84779

gcc/testsuite/ChangeLog:

PR fortran/84779
* gfortran.dg/pr84779.f90: New test.

Signed-off-by: Christopher Albert <albert@tugraz.at>
3 months agofortran: Fix scalar OpenACC attach/detach lowering [PR120723]
Christopher Albert [Tue, 10 Mar 2026 22:26:13 +0000 (23:26 +0100)] 
fortran: Fix scalar OpenACC attach/detach lowering [PR120723]

Lower bare scalar OpenACC attach/detach clauses as direct attach operations instead of emitting standalone pointer-mapping nodes.

PR fortran/120723

gcc/fortran/ChangeLog:

* trans-openmp.cc (gfc_trans_omp_clauses): Handle bare scalar
OpenACC attach/detach clauses without pointer-mapping nodes.

gcc/testsuite/ChangeLog:

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

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

3 months agolibstdc++: [_GLIBCXX_DEBUG] Minor optimization on safe iterator detach
François Dumont [Mon, 16 Mar 2026 18:37:50 +0000 (19:37 +0100)] 
libstdc++: [_GLIBCXX_DEBUG] Minor optimization on safe iterator detach

An iterator cannot be at the same time const and mutable so it cannot be
at the same time in both list of iterators maintained at debug container
level.

libstdc++-v3/ChangeLog:

* src/c++11/debug.cc (_Safe_sequence_base::_M_detach_single): Do not
check if input iterator is equal to _M_iterators if already equals to
_M_const_iterators.
(_Safe_unordered_container_base::_M_detach_local_single): Do not check
if input local iterator is equal to _M_local_iterators if already equals
to _M_const_local_iterators.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
3 months agolibstdc++: Export std::enable_nonlocking_formatter_optimization in std.cc [PR121790]
Jakub Jelinek [Thu, 19 Mar 2026 16:37:39 +0000 (17:37 +0100)] 
libstdc++: Export std::enable_nonlocking_formatter_optimization in std.cc [PR121790]

On Thu, Mar 19, 2026 at 03:03:38PM +0000, Jonathan Wakely wrote:
> > enable_nonlocking_formatter_optimization has been added in PR121790 P3235R3
> > r16-4351, though bits/formatfwd.h hunk already in
> > PR121790 P3107R5 r16-4350.  I wonder why it shows up for C++23 though.
>
> P3235R3 was approved as a DR for C++23, at the 2024-06 meeting:
> "8. Accept as a Defect Report and apply the changes in P3235R3
> (std::print more types faster with less memory) to the C++ working
> paper. "
> The committee kept approving a LOT of std::format and std::print changes as DRs.
> So it's enabled in the header for C++23, and so it should also be
> exported from the module for C++23.

Ok, in that case here is another patch to export it.

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

PR libstdc++/121790
* src/c++23/std.cc.in: Add enable_nonlocking_formatter_optimization.

3 months agoc++: enable contracts under -std=c++26
Jason Merrill [Thu, 19 Mar 2026 16:14:20 +0000 (12:14 -0400)] 
c++: enable contracts under -std=c++26

Enabling contracts by default in C++26 mode doesn't seem to cause any
trouble in the testsuite.

gcc/c-family/ChangeLog:

* c-opts.cc (c_common_post_options): Enable -fcontracts
in C++26 mode unless -fno-contracts was specified.

3 months agolibstdc++: Export std::allocation_result in std.cc [PR118030]
Jakub Jelinek [Thu, 19 Mar 2026 15:11:14 +0000 (16:11 +0100)] 
libstdc++: Export std::allocation_result in std.cc [PR118030]

allocation_result has been added in PR118030 P0401 r16-7986 but
not exported in std module.

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

PR libstdc++/118030
* src/c++23/std.cc.in: Add allocation_result.

3 months agolibstdc++: Export std::is_{reflection,consteval_only}{,_v} in std.cc [PR120775]
Jakub Jelinek [Thu, 19 Mar 2026 15:09:10 +0000 (16:09 +0100)] 
libstdc++: Export std::is_{reflection,consteval_only}{,_v} in std.cc [PR120775]

is_{reflection,consteval_only}{,_v} were added in P120775 r16-6808
but not exported from std module.

Note, perhaps we'll remove is_consteval_only* again in a week or two,
who knows what is approved in Croydon.

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

PR c++/120775
* src/c++23/std.cc.in: Add is_reflection{,_v} and
is_consteval_only{,_v}.

3 months agoalpha: Set TREE_PUBLIC on TYPE_NAME of __va_list_tag [PR124565]
Jakub Jelinek [Thu, 19 Mar 2026 14:49:51 +0000 (15:49 +0100)] 
alpha: Set TREE_PUBLIC on TYPE_NAME of __va_list_tag [PR124565]

 module;
 #include <cstdarg>
 export module pr124565;
 export namespace std {
   using std::va_list;
 }
fails on alpha-linux with -fmodules:
pr124565.cc:5:14: error: exporting ‘typedef __gnuc_va_list va_list’ that does not have external linkage
<built-in>: note: ‘typedef struct __va_list_tag __va_list_tag’ declared here with internal linkage

It doesn't fail on x86_64-linux because there va_list is __va_list_tag[]
(i.e. array type), while on alpha-linux it is __va_list_tag itself; and the
module code calls decl_linkage on it and returns lk_internal for C++11 and
later.

As I have no way to test this on alpha, I've just bootstrapped/regtested
similar change (just posted) on x86_64-linux and verified on the above
testcase that it fixes the problem in a cross to alpha-linux.

Not adding a testcase as any test which tries to compile bits/std.cc should
already catch it.

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

PR target/124565
* config/alpha/alpha.cc (alpha_build_builtin_va_list): Set TREE_PUBLIC
on type_decl.

3 months agolibstdc++: Export std::philox{_engine,4x{32,64}} in std.cc [PR119794]
Jakub Jelinek [Thu, 19 Mar 2026 14:47:57 +0000 (15:47 +0100)] 
libstdc++: Export std::philox{_engine,4x{32,64}} in std.cc [PR119794]

philox{_engine,4x32,4x64} is PR119794 P2075 r16-4062 but without
these exports.

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

PR libstdc++/119794
* src/c++23/std.cc.in: Add philox_engine and philox4x{32,64}.

3 months agolibstdc++: Export std::ranges::views::indices in std.cc
Jakub Jelinek [Thu, 19 Mar 2026 14:47:06 +0000 (15:47 +0100)] 
libstdc++: Export std::ranges::views::indices in std.cc

views::indices were added P3060R3 r16-4511, but not exported.

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

* src/c++23/std.cc.in: Export views::indices.

3 months agoAutoFDO: Update common.opt.urls with new option
Dhruv Chawla [Thu, 19 Mar 2026 13:14:38 +0000 (06:14 -0700)] 
AutoFDO: Update common.opt.urls with new option

I had missed updating this earlier while adding the
--print-autofdo-gcov-version option. Pushing as obvious.

Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>
gcc/ChangeLog:

* common.opt.urls: Added missing entry.

3 months agolibstdc++: Fix parsing of UNTIL times in tzdata.zi [PR124513]
Jonathan Wakely [Thu, 19 Mar 2026 11:42:48 +0000 (11:42 +0000)] 
libstdc++: Fix parsing of UNTIL times in tzdata.zi [PR124513]

Zone lines ending with a plain number as the time for the DST transition
(e.g. "2026 Mar 16 2") were incorrectly parsed as changing at midnight.
The problem was that eofbit got set after extracting the "2" from the
stream using `in >> i`, then the `in >> at.indicator` expression
failed and set failbit, so that the `if (in >> at.indicator)` condition
was always false and so the assignment to at.time guarded by that
condition was never performed. So the at.time member was always left
equal to zero, i.e. midnight. Suffixed times such as "2s" or "2u" were
parsed correctly.

This commit fixes the operator>> overload for the Indicator enum to not
cause failbit to be set if eofbit is already set. This means that the
`in >> at.indicator` expression yields true when converted to bool, and
the assignment to at.time happens. Not trying to extract an Indicator
when eofbit is already set is correct, because it's valid for there to
be no indicator suffix on an AT time (that just means the time should be
interpreted as wall time).

There was also a bug in the handling of a "-" value for the time, which
is supposed to mean midnight but was not being parsed due to failing to
skip leading whitespace. That did no harm in most cases, because the "-"
would not be extracted from the stream but would then cause a failure to
parse an integer number of hours, and no time would be set, causing it
to default to midnight, which is what "-" means anyway. However, a value
of "-u" is supposed to mean midnight UTC and "-s" is supposed to mean
midnight standard time, and the indicators for UTC or standard were not
being set in those cases. This fix uses std::ws to skip initial
whitespace, and then correctly handles "-" followed by EOF.

libstdc++-v3/ChangeLog:

PR libstdc++/124513
* src/c++20/tzdb.cc (operator>>(istream&, at_time::Indicator&)):
Do not peek at the next character if eofbit is already set.
(istream& operator>>(istream&, at_time&)): Skip whitespace
before the first character. Handle EOF when parsing "-" as time.
Do not peek for ":" or "." if eofbit already set.
* testsuite/std/time/time_zone/116110.cc (test_apia): Remove
offset of 24h now that the UNTIL time is parsed correctly.
* testsuite/std/time/time_zone/124513.cc: New test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 months agolibstdc++: Partial fix for interpretation of non-UTC UNTIL times in tzdata.zi [PR116110]
Jonathan Wakely [Mon, 16 Mar 2026 21:48:30 +0000 (21:48 +0000)] 
libstdc++: Partial fix for interpretation of non-UTC UNTIL times in tzdata.zi [PR116110]

This is a partial fix for PR 116110, so that zone changes that occur at
a time specified as standard time will be parsed correctly. Previously
all UNTIL times were assumed to be UTC, which is incorrect according to
the spec. Only times with a 'u' suffix (or the equivalent 'g' or 'z')
are UTC times. An 's' suffix means standard time (i.e. the zone's usual
offset from UTC, without any DST adjustment) and a 'w' suffix (or no
suffix) means wall time, so the offset and any DST adjustment. This
commit fixes the handling of 's' suffixes, so that the ZoneInfo::m_until
member is set correctly. It also fixes the handling of some UNTIL times
using wall time, specifically those where the DST adjustment is known
during parsing of the tzdata.zi file.

This is not a complete fix, because as noted in PR 116110 a Zone line
that refers to a named Rule and uses wall time cannot be determined
while parsing tzdata.zi. We need to remember that the m_until member is
not correct, and then adjust it later when we find the rule that applies
at a given time point. That requires more work.

Some existing tests need to be adjusted due to the fixes in this commit.
The std/time/time_zone/get_info_sys.cc and std/time/zoned_time/1.cc
tests are corrected to check that the changes happens at midnight local
time, not midnight UTC as previously assumed.

One of the FIXME comments in std/time/time_zone/116110.cc can be removed
now, because the UNTIL time is correctly interpreted as midnight local
time. The other FIXME needs to be changed to midnight at the local
standard time, which is still wrong but we don't currently adjust it for
the DST save time of one hour. It also still needs the incorrect +24h
due to Bug 124513.

libstdc++-v3/ChangeLog:

PR libstdc++/116110
* src/c++20/tzdb.cc (operator>>(istream&, ZoneInfo&)): Adjust
inf.m_until according to indicator suffix on AT time in UNTIL.
* testsuite/std/time/time_zone/116110.cc (test_kiritimati):
Remove FIXME now that the UNTIL time is adjusted for STDOFF.
(test_apia): Adjust FIXME now that UNTIL time is adusted for
STDOFF.
* testsuite/std/time/time_zone/get_info_sys.cc: Adjust expected
results to account for corrected logic.
* testsuite/std/time/zoned_time/1.cc: Likewise.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 months agolibstdc++: Fix time zone transitions for Rule changes during DST [PR116110]
Jonathan Wakely [Sat, 14 Mar 2026 10:32:11 +0000 (10:32 +0000)] 
libstdc++: Fix time zone transitions for Rule changes during DST [PR116110]

The Australia/Broken_Hill example in PR libstdc++/116110 demonstrates a
bug in the time zone code. The current code gives incorrect results when
a zone changes from one named Rule to another during DST, e.g. the
Broken_Hill time zone uses:

  9:30    AN    AC%sT  2000
  9:30    AS    AC%sT

So the AS Rules take effect on 2000 Jan 1 which is during DST (which
runs from October to March).

The fix for this is to update info.offset and info.save when we find an
active rule, instead of only updating the 'letters' variable.

The new tests for Pacific/Kiritimati and Pacific/Apia have some FIXME
comments. The UNTIL times of the zone changes are incorrectly
interpreted as UTC not wall time (due to the main topic of Bug 116110),
and the "24" time for the Pacific/Apia zone is incorrectly ignored so
that the change happens 24h too early (due to Bug 124554). Those tests
will need to be adjusted later when the bugs are fixed.

libstdc++-v3/ChangeLog:

PR libstdc++/116110
* src/c++20/tzdb.cc (time_zone::_M_get_sys_info): Update
info.offset and info.save to values from the active rule.
* testsuite/std/time/time_zone/116110.cc: New test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 months agoFortran: Fix regression due to r16-669 [PR124161]
Paul Thomas [Thu, 19 Mar 2026 11:37:40 +0000 (11:37 +0000)] 
Fortran: Fix regression due to r16-669 [PR124161]

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

gcc/fortran
PR fortran/124161
* resolve.cc (resolve_symbol): Do not apply the default
initializer if the symbol is used in a submodule.

gcc/testsuite/
PR fortran/124161
* gfortran.dg/pr124161.f90: New test.

3 months agolibcpp: Handle macro locations in linemap_location_from_module_p [PR124466]
Nathaniel Shead [Fri, 13 Mar 2026 06:31:52 +0000 (17:31 +1100)] 
libcpp: Handle macro locations in linemap_location_from_module_p [PR124466]

The testcase crashed because in warn-spec-5_b.C we were writing
diagnostic classifications for pops but not for the things they were
ignoring.  We should have been writing neither, as they all came from an
imported location, but linemap_location_from_module_p was returning
false for locations that originated from macros in a module.

PR c++/124466

libcpp/ChangeLog:

* line-map.cc (linemap_location_from_module_p): Resolve loc in
case it's a macro location.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
3 months agotestsuite: Clean up the weak declaration scanning
feedable [Tue, 24 Feb 2026 00:36:49 +0000 (02:36 +0200)] 
testsuite: Clean up the weak declaration scanning

Add scan-weak function to testsuite, which would work like scan-hidden,
and allow for format-specific regexes

gcc/testsuite/ChangeLog:

* gcc.dg/weak/weak-1.c: Use a function to scan
for weak symbols instead of a regex.
* gcc.dg/weak/weak-10.c: Likewise.
* gcc.dg/weak/weak-11.c: Likewise.
* gcc.dg/weak/weak-12.c: Likewise.
* gcc.dg/weak/weak-15.c: Likewise.
* gcc.dg/weak/weak-16.c: Likewise.
* gcc.dg/weak/weak-2.c: Likewise.
* gcc.dg/weak/weak-3.c: Likewise.
* gcc.dg/weak/weak-4.c: Likewise.
* gcc.dg/weak/weak-5.c: Likewise.
* gcc.dg/weak/weak-9.c: Likewise.
* lib/scanasm.exp: Implement the weak-scanning function.

3 months agoc++: contracts and -fimplicit-constexpr
Jason Merrill [Thu, 5 Mar 2026 22:54:30 +0000 (17:54 -0500)] 
c++: contracts and -fimplicit-constexpr

Several of the contracts tests were failing with -fimplicit-constexpr.  Some
of this was just needing to handle some additional tree codes, but there
were more significant issues with the handling of failed contracts in
speculative (i.e. non-manifestly-constant-evaluated) constant evaluation,
leading to additional errors and/or emitting a constant value despite its
evaluation involving a failed contract.

I've addressed this by making non-MCE evaluation silently fail (and so fall
back to run-time evaluation) if we encountered a contract that is not known
to be satisfied.  We could consider an optional warning if we encounter a
predicate that evaluates to false, but that seems like a follow-on
enhancement.

gcc/cp/ChangeLog:

* constexpr.cc (build_constexpr_constructor_member_initializers):
Handle TRY_FINALLY_EXPR.
(potential_constant_expression_1): Handle EH_ELSE_EXPR.
(check_for_failed_contracts): Handle non-MCE case.
(cxx_eval_outermost_constant_expr): Call it sooner.

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

3 months agolibstdc++: Add tests for recently-fixed non-uglified names
Jonathan Wakely [Wed, 18 Mar 2026 10:54:56 +0000 (10:54 +0000)] 
libstdc++: Add tests for recently-fixed non-uglified names

Extend names.cc to check the names that Jakub's plugin found.

libstdc++-v3/ChangeLog:

* testsuite/17_intro/names.cc (ext, max_iter, ret, subs, Rg, Rs):
Define macros.
[__cplusplus < 201103] (mutex): Define macro.

3 months agolibstdc++: Fix more non-uglified names
Jonathan Wakely [Tue, 17 Mar 2026 15:37:24 +0000 (15:37 +0000)] 
libstdc++: Fix more non-uglified names

The r16-8143-g62dec39dbd6724 change to bits/fs_path.h is also needed for
the corresponding functions in experimental/bits/fs_path.h.

libstdc++-v3/ChangeLog:

* include/experimental/bits/fs_path.h (path::stem)
(path::extension, path::has_stem, path::has_extension): Uglify
ext variable name.

3 months agod: Remove gdc.test/runnable/dbitfieldsdm.d [PR124158]
Rainer Orth [Wed, 18 Mar 2026 20:07:33 +0000 (21:07 +0100)] 
d: Remove gdc.test/runnable/dbitfieldsdm.d [PR124158]

The gdc.test/runnable/dbitfieldsdm.d test FAILs on SPARC:

FAIL: gdc.test/runnable/dbitfieldsdm.d   execution test

As described in the PR, it dies with SIGBUS due to an unaligned access,
which doesn't work on a strict-alignment CPU.

However, the test has a comment

Note that this test is for win32 only

and should already be disabled on various systems:

DISABLED: win32mscoff win64 linux freebsd osx

The DISABLED annotation isn't handled by the gdc DejaGnu framework and
there's no support for the usual dg-* annotations, so this patch removes
the test.

Tested on sparc-sun-solaris2.11 and i386-pc-solaris2.11.

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

gcc/testsuite:
PR d/124158
* gdc.test/runnable/dbitfieldsdm.d: Remove.

3 months ago[PR124041, PR124439, LRA]: Check hard_regno_mode_ok for hard reg subreg to satisfy...
Vladimir N. Makarov [Wed, 18 Mar 2026 19:12:00 +0000 (15:12 -0400)] 
[PR124041, PR124439, LRA]: Check hard_regno_mode_ok for hard reg subreg to satisfy reg constraint

Patch for PR124041 resulted in wrong code generation and in new
PR124439 as the patch prevented equivalence substitution when
equivalence initialization insn was removed.

This patch implements another fix for PR124041 and this fixes
PR124439.

gcc/ChangeLog:

PR rtl-optimization/124041
PR rtl-optimization/124439
* lra-constraints.cc (process_alt_operands): Check hard reg subreg
mode by hard_regno_mode_ok.
(curr_insn_transform): Always subsitute equivalence for hard reg
subreg.

3 months agolibstdc++: Uglify another variable name
Jakub Jelinek [Wed, 18 Mar 2026 14:40:51 +0000 (15:40 +0100)] 
libstdc++: Uglify another variable name

This is needed to make the latest version of the uglification plugin
I'm about to send PASS.

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

* include/bits/regex_compiler.h (_Compiler::_M_pop): Uglify ret
variable name.

3 months agolibstdc++: Properly handle forwarding references in __mdspan::__index_type_cast.
Tomasz Kamiński [Tue, 10 Mar 2026 14:57:35 +0000 (15:57 +0100)] 
libstdc++: Properly handle forwarding references in __mdspan::__index_type_cast.

The _OIndexType template parameter will maybe deduced to reference, when
invoked from constructor and operator[]/at (after r16-7645-g66e60479e97640)
accepting array or span. We need to use forward for class-type and
remove_cvref_t for is_integral checks.

This resolves LWG4020: extents::index-cast weirdness.

libstdc++-v3/ChangeLog:

* include/std/mdspan (__mdspan::__index_type_cast): Handle
forwarding referene and use forward for class types.
* testsuite/23_containers/mdspan/int_like.h (ConstLValueInt)
(CustomIndexKind::ConstLValue): Define.
(CustomIndexType): Handle CustomIndexKind::ConstLValue.
* testsuite/23_containers/mdspan/at.cc: Test with ConstLValueInt.
* testsuite/23_containers/mdspan/extents/custom_integer.cc: Likewise.
* testsuite/23_containers/mdspan/mdspan.cc: Likewise.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 months agotree-optimization/124555 - guard abs patterns for vector support
Richard Biener [Wed, 18 Mar 2026 09:15:00 +0000 (10:15 +0100)] 
tree-optimization/124555 - guard abs patterns for vector support

The following adds missing vector support checks to abs producing
match.pd patterns.  The g++.dg/absvect.C shows that we previously
then lowered this to non-vector unless you add -msse4 on x86_64
at least.

PR tree-optimization/124555
* match.pd ((A - B) >=/> 0 ? (A - B) : (B - A) -> abs (A - B)):
Guard the vector case with target_supports_op_p checks.
((A - B) <=/< 0 ? (A - B) : (B - A) -> -abs (A - B)): Likewise.
((type)A >=/> 0 ? A : -A -> abs (A)): Likewise.
((type)A <=/< 0 ? A : -A -> -abs (A)): Likewise.

* gcc.dg/torture/pr124555.c: New testcase.
* g++.dg/absvect.C: Restrict dump scan to x86-64 and force
-msse4 there.

3 months agoAutoFDO: Add --print-autofdo-gcov-version
Dhruv Chawla [Mon, 12 Jan 2026 12:07:03 +0000 (04:07 -0800)] 
AutoFDO: Add --print-autofdo-gcov-version

This option prints the current version of GCOV that is being used by the
AutoFDO infrastructure. This avoids the need to bump the number across
multiple files in the build system for future increments to it.

Bootstrapped and regtested on aarch64-linux-gnu.

Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>
gcc/ChangeLog:

* Makefile.in (all.fda): Add `--print-autofdo-gcov-version` to
profile_merger invocation.
* auto-profile.cc (AUTO_PROFILE_VERSION): Move from here ...
* auto-profile.h (AUTO_PROFILE_VERSION): ... to here.
* common.opt: Add -print-autofdo-gcov-version and
--print-autofdo-gcov-version.
* doc/invoke.texi: Document the options.
* gcc.cc: Add include for auto-profile.h.
(driver_handle_option): Add OPT_print_autofdo_gcov_version.
(driver::maybe_print_and_exit): Handle the option.

gcc/c/ChangeLog:

* Make-lang.in (cc1.fda): Add `--print-autofdo-gcov-version` to
profile_merger invocation.
(create_fdas_for_cc1): Add `--print-autofdo-gcov-version` to
create_gcov invocations.

gcc/cp/ChangeLog:

* Make-lang.in (cc1plus.fda): Add `--print-autofdo-gcov-version` to
profile_merger invocation.
(create_fdas_for_cc1plus): Add `--print-autofdo-gcov-version` to
create_gcov invocations.

gcc/lto/ChangeLog:

* Make-lang.in (lto1.fda): Add `--print-autofdo-gcov-version` to
profile_merger invocation.
(create_fdas_for_lto1): Add `--print-autofdo-gcov-version` to
create_gcov invocations.

gcc/testsuite/ChangeLog:

* lib/profopt.exp: Invoke $GCC_UNDER_TEST with
`--print-autofdo-gcov-version` before running create_gcov to get
the GCOV version.

3 months agolibgomp/gcn: cache kernel argument allocations
Arsen Arsenović [Fri, 13 Feb 2026 11:19:52 +0000 (11:19 +0000)] 
libgomp/gcn: cache kernel argument allocations

On AMD GCN, for each kernel that we execute on the GPUs, the vast
majority of the time preparing the kernel for execution is spent in
memory allocation and deallocation for the kernel arguments.  Out of the
total execution time of run_kernel, which is the GCN plugin function
that actually performs launching a kernel, ~83.5% of execution time is
spent in these (de)allocation routines.

Obviously, then, these calls should be elliminated.  However, it is not
possible to avoid needing to allocate kernel arguments.

To this end, this patch implements a cache of kernel argument
allocations.

We expect this cache to be of size T where T is the maximum number of
kernels being launched in parallel.  This should be a fairly small
number, as there isn't much benefit to (or, to my awareness, real world
code that) executing very many kernels in parallel.

In my experiments (with BabelStream, though this should by no means be
improvements specific to it as run_kernel is used for all kernels and
branches very little), this was able to cut the non-kernel-wait runtime
of run_kernel by a factor of 5.5x.

libgomp/ChangeLog:

* plugin/plugin-gcn.c (struct kernel_dispatch): Add a field to
hold a pointer to the allocation cache node this dispatch is
holding for kernel arguments, replacing kernarg_address.
(print_kernel_dispatch): Print the allocation pointer from that
node as kernargs address.
(struct agent_info): Add in an allocation cache field.
(alloc_kernargs_on_agent): New function.  Pulls kernel arguments
from the cache, or, if no appropriate node is found, allocates
new ones.
(create_kernel_dispatch): Use alloc_kernargs_on_agent to
allocate kernargs.
(release_kernel_dispatch): Use release_alloc_cache_node to
release kernargs.
(run_kernel): Update usages of kernarg_address to use the kernel
arguments cache node.
(GOMP_OFFLOAD_fini_device): Clean up kernargs cache.
(GOMP_OFFLOAD_init_device): Initialize kernargs cache.
* alloc_cache.h: New file.
* testsuite/libgomp.c/alloc_cache-1.c: New test.

3 months agomiddle-end/124552 - release hierarchical discriminator copyid allocator
Richard Biener [Wed, 18 Mar 2026 07:04:27 +0000 (08:04 +0100)] 
middle-end/124552 - release hierarchical discriminator copyid allocator

The following releases it when the CFG is released.

PR middle-end/124552
* function.cc (free_after_compilation): Free the copyid
allocator.

3 months agotestsuite: Fix up a few tests for i686-linux
Jakub Jelinek [Wed, 18 Mar 2026 07:59:26 +0000 (08:59 +0100)] 
testsuite: Fix up a few tests for i686-linux

Some of these tests need -Wno-psabi to pass on ia32, forwprop-43.c
uses the vect* effective targets which rely on vect.exp added options
but doesn't provide those (added -msse2 for ia32).
And lastly, part-vect-absnegbf.c is a really weird test, it needs
at least -msse2 to pass on ia32 obviously (otherwise it is an error
to even use __bf16 or _Float16), but doesn't use -mavx512bf16 but
has avx512bf16 runtime check.  No idea what was meant, perhaps we
need 2 copies of the test, one with plain -msse2 and just requiring
sse2 at runtime and another wiht -mavx512bf16 requiring that?  Just
added -msse2 for now.

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

* gcc.dg/tree-ssa/forwprop-42.c: Add -Wno-psabi to dg-options.
* gcc.dg/tree-ssa/forwprop-43.c: Likewise.  For ia32 add -msse2 as
dg-additional-options.
* gcc.dg/torture/pr65270-3.c: Add -Wno-psabi to dg-options.
* gcc.target/i386/part-vect-absnegbf.c: Add -msse2 to dg-options.

3 months agoonfigure: Partial fix for the {gas,gnu_ld}{,_flag} breakage [PR124547]
Jakub Jelinek [Wed, 18 Mar 2026 07:41:13 +0000 (08:41 +0100)] 
onfigure: Partial fix for the {gas,gnu_ld}{,_flag} breakage [PR124547]

Here is a partial fix for the PR124547 breakages.
Setting {gas,gnu_ld}_flag to no when user didn't specify any of
--with{,out}-gnu-{as,ld} nor --with-gnu-{as,ld}={yes,no} seems wrong
when we want to later override it based on
 # Check if we are using GNU ld if not already set.
 if test -z "$gnu_ld_flag"; then
   if $gcc_cv_ld --version 2>/dev/null | grep GNU > /dev/null; then
     gnu_ld_flag=yes
   else
     gnu_ld_flag=no
   fi
 fi
 or
 # Check if we are using GNU as if not already set.
 if test -z "$gas_flag"; then
   if $gcc_cv_as --version 2>/dev/null | grep GNU > /dev/null; then
     gas_flag=yes
   else
     gas_flag=no
   fi
 fi
So, this patch unsets it if not explicitly specified so that the later
overriding works.

On x86_64-linux it restores the auto-host.h and Makefile differences:
-LD_VERSION_SCRIPT_OPTION =
-LD_SONAME_OPTION =
+LD_VERSION_SCRIPT_OPTION = --version-script
+LD_SONAME_OPTION = -soname
and
-#define HAVE_AS_IX86_GOT32X 0
+#define HAVE_AS_IX86_GOT32X 1
 #endif
-#define HAVE_AS_IX86_TLSLDM 0
+#define HAVE_AS_IX86_TLSLDM 1
-#define HAVE_AS_IX86_TLS_GET_ADDR_GOT 0
+#define HAVE_AS_IX86_TLS_GET_ADDR_GOT 1
-/* #undef HAVE_LD_DEMANGLE */
+#define HAVE_LD_DEMANGLE 1

I agree with Andreas in the PR that after including config.gcc configure
should be using gas and gnu_ld vars rather than gas_flag and gnu_ld_flag,
but this patch doesn't implement that (yet).  I think to do that,
it would need to move the
 AS_VAR_SET_IF(gcc_cv_as,, [
 AC_MSG_CHECKING(Solaris assembler)
 # Check if we are using GNU as if not already set.
and
 AC_MSG_CHECKING(Solaris linker)
 # Identify the linker which will work hand-in-glove with the newly
 # Check if we are using GNU ld if not already set.
hunks in configure.ac from where they are to before config.gcc inclusion,
and sed s/\(gnu_ld\|gas\)_flag/\1/g after the config.gcc inclusion.
I can prepare/test the patch tomorrow, but IMHO this patch is a good start.

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

PR bootstrap/124547
* configure.ac (--with-gnu-ld): Set gnu_ld_flag= instead of
gnu_ld_flag=no if not explicitly specified.
(--with-gnu-as): Similarly for gas_flag.
(DEFAULT_ASSEMBLER): Use wording without GNU as whenever gas_flag
is not yes rather than when it is no.
* configure: Regenerate.

3 months agoFix typo in -fpost-ipa-mem-report help text
Richard Biener [Wed, 18 Mar 2026 07:41:06 +0000 (08:41 +0100)] 
Fix typo in -fpost-ipa-mem-report help text

* common.opt (fpost-ipa-mem-report): Fix typo.

3 months agoFix leak of edge vector in IPA CP
Richard Biener [Tue, 17 Mar 2026 14:27:38 +0000 (15:27 +0100)] 
Fix leak of edge vector in IPA CP

The following makes gather_edges_for_value return an auto_vec,
simplifying the single caller decide_about_value and fixing the
leak of the callers vector upon early return.

* ipa-cp.cc (gather_edges_for_value): Return an auto_vec.
(decide_about_value): Simplify, fixing leak of callers.

3 months ago[PATCH] ipa-reorder-for-locality - Fix PR123749 avoid creating new partition if no...
Prachi Godbole [Wed, 18 Mar 2026 05:24:00 +0000 (22:24 -0700)] 
[PATCH] ipa-reorder-for-locality - Fix PR123749 avoid creating new partition if no more nodes left to process

This patch fixes PR123749 which caused by an empty partition created in WPA
partitioning pass as a result of -fipa-reorder-for-locality creating one.
This also fixes an indentation issue.

Bootstrapped and regtested on aarch64-none-linux-gnu. OK for mainline?

Signed-off-by: Prachi Godbole <pgodbole@nvidia.com>
gcc/Changelog:

PR target/123749
* ipa-locality-cloning.cc (partition_callchain): Start new partition
if no. of insns exceeds size and if there are nodes to process.

3 months agoc++: Fix up reflect/init11.C on cdtor_returns_this targets [PR124474]
Jakub Jelinek [Wed, 18 Mar 2026 05:36:15 +0000 (06:36 +0100)] 
c++: Fix up reflect/init11.C on cdtor_returns_this targets [PR124474]

On arm*-linux-gnueabi init11.C emits extra diagnostics which the testcase
doesn't expect.
E.g. it emits
init11.C: At global scope:
init11.C:19:13: error: function of consteval-only type must be declared ‘consteval’
   19 |   constexpr C() : i{} {}  // { dg-error "function of consteval-only type must be declared .consteval." }
      |             ^
init11.C: In constructor ‘constexpr C::C()’:
init11.C:19:24: error: consteval-only expressions are only allowed in a constant-evaluated context
   19 |   constexpr C() : i{} {}  // { dg-error "function of consteval-only type must be declared .consteval." }
      |                        ^
while on most other targets only the first error from these and not
the second is emitted.
This is because of targetm.cxx.cdtor_returns_this (), the error is emitted
on the constructor declaration and then again during
check_out_of_consteval_use on its body, when walking RETURN_EXPR (which
normally isn't there).

The following patch arranges diagnostics parity.

Though, as I wrote in the PR, I wonder if it makes sense to report
any errors on bodies of functions for which we've already diagnosed
function of consteval-only type must be declared ‘consteval’.
Especially for methods of consteval-only types, any use of this keyword
will result in an extra error (sure, only the first occurrence in a
function).  But even if a function has only some other consteval-only
argument and that argument is used somewhere in the body.  Though, wonder
if it is worth trying to improve that now when we don't know if
consteval-only will not be removed completely or changed significantly.

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

PR c++/124474
* reflect.cc (check_out_of_consteval_use_r): Don't walk subtrees
of RETURN_EXPR on cdtor_returns_this targets in cdtors.

3 months agoRTEMS: Add leon5 multilibs
Sebastian Huber [Mon, 2 Mar 2026 00:24:13 +0000 (01:24 +0100)] 
RTEMS: Add leon5 multilibs

gcc/ChangeLog:

* config/sparc/t-rtems: Add leon5 multilibs.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
3 months agoDaily bump.
GCC Administrator [Wed, 18 Mar 2026 00:16:29 +0000 (00:16 +0000)] 
Daily bump.

3 months agolibstdc++: Fix some non-uglified names
Jonathan Wakely [Tue, 17 Mar 2026 15:37:24 +0000 (15:37 +0000)] 
libstdc++: Fix some non-uglified names

Jakub wrote a plugin which identified some non-reserved names being used
in our headers. The "count" one is actually a reserved name (there's
std::set::count and std::count and std::bitset::count) but we might as
well uglify it when used as a function parameter name. I think the "ext"
ones must have happened when moving function definitions from fs_path.cc
to fs_path.h and I forgot to change them.

The __cond::wait and __cond::wait_recursive member functions are using
non-reserved names, so that should be changed too, but this patch
doesn't fix that. I don't think we use the __gnu_cxx::__cond type in any
headers, so maybe that should just be moved into libsupc++/guard.cc or a
new header which is not installed and only used while building the
library.

libstdc++-v3/ChangeLog:

* include/bits/chrono_io.h (__formatter_duration::_S_subseconds):
Uglify subs variable name.
* include/bits/fs_path.h (path::stem, path::extension)
(path::has_stem, path::has_extension): Uglify ext parameter
name.
* include/ext/concurrence.h (__cond::wait, __cond::wait_recursive):
Uglify mutex parameter names.
* include/pstl/glue_algorithm_defs.h (generate_n): Uglify count
parameter name.
* include/std/ranges (zip_transform_view): Uglify Rs template
parameter name.
(__cartesian_is_sized_sentinel): Uglify FirstSent template
parameter name.
* include/tr1/riemann_zeta.tcc: Uglify max_size variable name.

3 months agolibstdc++: Optimize __uninitialized_copy_a for std::deque iterators [PR124463]
Jonathan Wakely [Fri, 13 Mar 2026 17:11:04 +0000 (17:11 +0000)] 
libstdc++: Optimize __uninitialized_copy_a for std::deque iterators [PR124463]

I reimplemented uninitialized_copy and uninitialized_move in
r15-4473-g3abe751ea86e34 so that they no longer delegate to std::copy,
but that meant that they were no longer optimized for std::deque
iterators, leading to performance regressions for operations on a
std::deque with trivial element types. This adds new overloads of
__uninitialized_copy_a and __uninitialized_move_a to handle std::deque
iterators, restoring the lost performance.

There are also overloads of std::fill for deque iterators which are no
longer used for std::uninitialized_fill. This does not add replacements
for those, so there will still be lost performance for std::deque
operations that depend on std::uninitialized_fill. Similarly, inserting
or assigning from istreambuf_iterator into a std::deque no longer uses
the std::copy overloads for those types, and that isn't fixed by this
patch either.

libstdc++-v3/ChangeLog:

PR libstdc++/124463
* include/bits/deque.tcc (__uninitialized_copy_a): Define
overloads for input and output iterators being std::deque
iterators, and for only the output iterator being a std::deque
iterator.
(__uninitialized_move_a): Overload for input and output
iterators being std::deque iterators.
* include/bits/stl_uninitialized.h (__uninitialized_copy_a)
(__uninitialized_move_a): Declare overloads for std::deque
iterators.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 months agoc++/reflection: add var tmpl to inform_tree_category [PR124493]
Marek Polacek [Tue, 17 Mar 2026 16:34:28 +0000 (12:34 -0400)] 
c++/reflection: add var tmpl to inform_tree_category [PR124493]

Modifying the recently added crash22.C test to use a variable template
shows that inform_tree_category doesn't say reflection of what we
actually got.  With this patch we say:

  • but 'Y<T>' is a variable template
    crash23.C:6:13:
6 | constexpr T Y{};
  |             ^

I couldn't figure out a test for alias templates so I'm not adding
that now.

PR c++/124493

gcc/cp/ChangeLog:

* error.cc (inform_tree_category): Handle variable templates.

gcc/testsuite/ChangeLog:

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

Reviewed-by: Jason Merrill <jason@redhat.com>
3 months agofortran: Delete pr120286.f90 from gfortran testsuite. [PR120286]
Jerry DeLisle [Tue, 17 Mar 2026 18:09:12 +0000 (11:09 -0700)] 
fortran: Delete pr120286.f90 from gfortran testsuite. [PR120286]

PR fortran/120286

gcc/testsuite/ChangeLog:

* gfortran.dg/pr120286.f90: Removed.

libgomp/ChangeLog:

* testsuite/libgomp.fortran/pr120286.f90: New test.

3 months agoaarch64: Disallow movprfx before revd
Alice Carlotti [Thu, 12 Mar 2026 17:45:37 +0000 (17:45 +0000)] 
aarch64: Disallow movprfx before revd

An architectural relaxation in 2024 (listed in the "Known issues in
Issue K.a" of the Arm ARM) removed support for revd to be prefixed by a
movprfx instruction.  This patch removes this (now invalid) codegen.

The patch also makes identical changes to each revd* testsuite file.
Interestingly, this actually improves codegen for one of the three
functions.

gcc/ChangeLog:

* config/aarch64/aarch64-sve2.md (@aarch64_pred_revd<mode>):
Remove movprfx alternative.
(@cond_revd<mode>): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/sme/acle-asm/revd_bf16.c: Update checks.
* gcc.target/aarch64/sme/acle-asm/revd_f16.c: Likewise.
* gcc.target/aarch64/sme/acle-asm/revd_f32.c: Likewise.
* gcc.target/aarch64/sme/acle-asm/revd_f64.c: Likewise.
* gcc.target/aarch64/sme/acle-asm/revd_mf8.c: Likewise.
* gcc.target/aarch64/sme/acle-asm/revd_s16.c: Likewise.
* gcc.target/aarch64/sme/acle-asm/revd_s32.c: Likewise.
* gcc.target/aarch64/sme/acle-asm/revd_s64.c: Likewise.
* gcc.target/aarch64/sme/acle-asm/revd_s8.c: Likewise.
* gcc.target/aarch64/sme/acle-asm/revd_u16.c: Likewise.
* gcc.target/aarch64/sme/acle-asm/revd_u32.c: Likewise.
* gcc.target/aarch64/sme/acle-asm/revd_u64.c: Likewise.
* gcc.target/aarch64/sme/acle-asm/revd_u8.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revd_bf16.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revd_f16.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revd_f32.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revd_f64.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revd_mf8.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revd_s16.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revd_s32.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revd_s64.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revd_s8.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revd_u16.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revd_u32.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revd_u64.c: Likewise.
* gcc.target/aarch64/sve2/acle/asm/revd_u8.c: Likewise.

3 months agoc++: add fixed test [PR109521]
Marek Polacek [Tue, 17 Mar 2026 17:49:02 +0000 (13:49 -0400)] 
c++: add fixed test [PR109521]

Fixed by r16-4212.

PR c++/109521

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wuninitialized-35.C: New test.

3 months agoc++: add fixed test [PR115852]
Marek Polacek [Tue, 17 Mar 2026 17:38:10 +0000 (13:38 -0400)] 
c++: add fixed test [PR115852]

Fixed by r16-2490.

PR c++/115852

gcc/testsuite/ChangeLog:

* g++.dg/cpp23/explicit-obj-lambda22.C: New test.

3 months agoc++: add fixed test [PR118482]
Marek Polacek [Tue, 17 Mar 2026 17:31:11 +0000 (13:31 -0400)] 
c++: add fixed test [PR118482]

Fixed by r15-9362.

PR c++/118482

gcc/testsuite/ChangeLog:

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

3 months agoavoid-store-forwarding: Reject overlapping stores [PR124476]
Philipp Tomsich [Fri, 13 Mar 2026 10:01:45 +0000 (11:01 +0100)] 
avoid-store-forwarding: Reject overlapping stores [PR124476]

The redundant-store tracking introduced in ec5349c37af replaced a
safe bitmap_bit_in_range_p check (which bailed on any overlap) with
bitmap_all_bits_in_range_p (which only removed fully redundant stores).
This broke "last writer wins" semantics for partially overlapping
stores: when an earlier store's BFI was applied after the base store's
value, it overwrote bytes that should have belonged to the later store.

Restore the original overlap check from 1d8de1e93ea: bail out of the
optimization when any bit in a store's byte range is already claimed
by a later store in program order.  Remove the now-unnecessary
redundant-store tracking (redundant_stores, store_ind_to_remove).

gcc/ChangeLog:

PR rtl-optimization/124476
* avoid-store-forwarding.cc
(store_forwarding_analyzer::process_store_forwarding): Replace
bitmap_all_bits_in_range_p with bitmap_any_bit_in_range_p and
return false on partial overlap.  Remove redundant-store vectors
and their associated removal, dump, and deletion logic.

gcc/testsuite/ChangeLog:

PR rtl-optimization/124476
* gcc.dg/pr124476.c: New test.

3 months agoRevert "libstdc++: Add module initialization functions to the library [PR124268]"
Jonathan Wakely [Tue, 17 Mar 2026 16:36:39 +0000 (16:36 +0000)] 
Revert "libstdc++: Add module initialization functions to the library [PR124268]"

This reverts commit c362a260ca203207309cf77a3928854cabf2ac01.

3 months agoc++/reflection: add test for ICE with ^^decltype [PR124494]
Marek Polacek [Mon, 16 Mar 2026 01:18:17 +0000 (21:18 -0400)] 
c++/reflection: add test for ICE with ^^decltype [PR124494]

This test with invalid ^^decltype crashes.  finish_decltype_type
got a USING_DECL because they sometimes aren't stripped when
using -freflection.  We should give an error like we do for TYPE_DECL,
otherwise finish_decltype_type returns NULL_TREE and eventually we
crash in cp_parser_qualifying_entity after calling cp_parser_decltype.

Fixed by r16-8132 which moved the cp_preserve_using_decl overriding.

PR c++/124494

gcc/testsuite/ChangeLog:

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

3 months agoc++/reflection: bogus error with targ and using-decl [PR124472]
Marek Polacek [Sun, 15 Mar 2026 21:05:57 +0000 (17:05 -0400)] 
c++/reflection: bogus error with targ and using-decl [PR124472]

Here we emit a bogus "type/value mismatch" error because
convert_template_argument gets a USING_DECL instead of an expected
TYPE_DECL.  When we are parsing a reflect-expression we set
cp_preserve_using_decl not to strip USING_DECLs.  The flag should
probably go, subject to 124169, but meanwhile we can at least move
overriding cp_preserve_using_decl below, just before the call to
cp_parser_lookup_name_simple, where it actually matters.  The wrong
error comes from _reflection_name -> _nested_name_specifier_opt
which happens before cp_parser_identifier.

PR c++/124472

gcc/cp/ChangeLog:

* parser.cc (cp_parser_reflection_name): Move the
cp_preserve_using_decl overriding below, before
cp_parser_lookup_name_simple.

gcc/testsuite/ChangeLog:

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

Reviewed-by: Jason Merrill <jason@redhat.com>
3 months agoc++/reflection: ICE with invalid splice-spec-spec [PR124493]
Marek Polacek [Fri, 13 Mar 2026 20:25:00 +0000 (16:25 -0400)] 
c++/reflection: ICE with invalid splice-spec-spec [PR124493]

This is a crash on invalid [:X:]<args> where [:X:] doesn't
designate a template.  Like in cp_parser_template_id, we should
check that we have an appropriate template before calling
finish_template_type on it.

PR c++/124493

gcc/cp/ChangeLog:

* pt.cc (tsubst) <case TEMPLATE_ID_EXPR>: Check that templ is
either DECL_TYPE_TEMPLATE_P or DECL_TEMPLATE_TEMPLATE_PARM_P.

gcc/testsuite/ChangeLog:

* g++.dg/reflect/crash19.C: New test.
* g++.dg/reflect/crash22.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
3 months agoFix memory leak in vect_analyze_slp
Richard Biener [Tue, 17 Mar 2026 13:42:43 +0000 (14:42 +0100)] 
Fix memory leak in vect_analyze_slp

When I made the function to fail when SLP discovery fails I failed
to release the BST map.

* tree-vect-slp.cc (vect_analyze_slp): Release BST map when
returning.

3 months agoFix uninitialized LOOP_VINFO_LOOP_IV_COND
Richard Biener [Tue, 17 Mar 2026 12:54:37 +0000 (13:54 +0100)] 
Fix uninitialized LOOP_VINFO_LOOP_IV_COND

With uncounted loop support we can leave LOOP_VINFO_LOOP_IV_COND
uninitialized but that's accessed from vect_stmt_relevant_p,
unlikely to match by chance, but the following fixes it nevertheless.

* tree-vect-loop.cc (_loop_vec_info::_loop_vec_info):
Initialize loop_iv_cond given it's no longer always
initialized ...
(vect_create_loop_vinfo): ... here.  Fix formatting.

3 months agotree-optimization/122380 - avoid PRE/hoisting of incompatible access-path
Richard Biener [Fri, 13 Mar 2026 12:11:56 +0000 (13:11 +0100)] 
tree-optimization/122380 - avoid PRE/hoisting of incompatible access-path

This decouples the PRE reference IL from the VN hash tables, following
the corresponding PR103037 fix for nary expressions in r12-7389 to avoid
correctness issues regarding to access paths when inserting expressions.

Unfortunately this makes existing workarounds for alignment and alias
mismatches ineffective so those have to be re-implemented.  Instead
of going back to implement canonexpr() during the ANTIC dataflow the
following does this at insertion time, hoping all relevant reaching
expressions will survive.  A convenient place to do this is
sorted_array_from_bitmap_set, the actual magic worker is 'prefer',
for the moment handling alignment and innermost access size only,
as those are the cases we have test coverage.  In particular the
access path difference seen in this PR is not covered - it is enough
to fix the AVAIL_OUT computation in compute_avail for this.

Where the old fixup code massaged the expressions the new code selects
from existing expressions or as fallback makes sure to not perform
code insertion when two incompatible expressions met.

PR tree-optimization/122380
* tree-ssa-sccvn.h (copy_reference_ops_from_ref): Declare.
(vn_reference_compute_hash): Likewise.
(vn_reference_eq): Add parameter indicating lexical equivalence,
defaulted to false.
* tree-ssa-sccvn.cc (vn_reference_eq): Likewise.
(print_vn_reference_ops): Print alias type and alignment.
(vn_reference_compute_hash): Export.
(copy_reference_ops_from_ref): Likewise.
* tree-ssa-pre.cc (pre_expr_d::equal): Use lexical equivalence.
(get_or_alloc_expr_for_reference): Also get value-id, upon
zero assign a new value-id if the expression is unknown.
(expr_cmp): New helper.
(prefer): Likewise.
(pre_expr_DFS): Get expression exclusion bitmap and honor it.
(sorted_array_from_bitmap_set): If done for insertion, do limited
canonexpr() via pairwise prefer on expression pairs with the same
value, populating an exclution bitmap.
(phi_translate_1): Do not use the VN hashtable expressions
or insert there.  Instead maintain a PRE view of expressions.
(clean): Adjust.
(do_hoist_insertion): Likewise.
(insert): Likewise.
(compute_avail): Use gimple_could_trap_p_1
on the original stmt rather than vn_reference_may_trap on
the VN leader.  Use the original stmt operands for the PRE
view of reference expressions, only use the value number from the VN
tables.  Remove no longer effective workarounds for semantically
different references with same value.
(fini_pre): Release operand vectors for PRE IL reference
expressions.

* g++.dg/torture/pr122380.C: New testcase.
* gcc.dg/torture/pr65270-3.c: Likewise.
* gcc.dg/tree-ssa/ssa-pre-30.c: XFAIL.

3 months agoi386: Fix ICE with target_clones inlining
Yangyu Chen [Mon, 2 Mar 2026 07:09:05 +0000 (15:09 +0800)] 
i386: Fix ICE with target_clones inlining

When a target_clones function is inlined, the resolver function's
assembler name must be properly registered in the symbol table.
Using SET_DECL_ASSEMBLER_NAME only updates the tree node without
notifying the symbol table, which can lead to an ICE during IPA
inlining when the assembler name hash becomes inconsistent.

Replace SET_DECL_ASSEMBLER_NAME with symtab->change_decl_assembler_name
in make_resolver_func to properly update the symbol table's assembler
name mapping.

This only happens on x86, other targets already uses
symtab->change_decl_assembler_name.

Fixes: b500cd2634 ("x86: fmv: Refactor FMV name mangling.")
gcc/ChangeLog:

* config/i386/i386-features.cc (make_resolver_func): Use
symtab->change_decl_assembler_name instead of
SET_DECL_ASSEMBLER_NAME to properly update the symbol table.

gcc/testsuite/ChangeLog:

* gcc.target/i386/tct-ipa-inline-ice.c: New test.

Signed-off-by: Yangyu Chen <cyy@cyyself.name>