]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
4 months agogccrs: Setting up interfaces for codegen
jjasmine [Mon, 24 Jun 2024 02:47:17 +0000 (19:47 -0700)] 
gccrs: Setting up interfaces for codegen

gcc/rust/ChangeLog:

* backend/rust-compile-expr.cc (CompileExpr::visit):
Setting up interfaces for codegen
* hir/tree/rust-hir-expr.h: Likewise.

4 months agogccrs: Local testing for build_string and debug()
jjasmine [Sun, 23 Jun 2024 17:39:12 +0000 (10:39 -0700)] 
gccrs: Local testing for build_string and debug()

gcc/rust/ChangeLog:

* backend/rust-compile-expr.cc (CompileExpr::visit):
Local testing for build_string and debug()

4 months agogccrs: Make sure CompileExpr::visit is reached
jjasmine [Sat, 22 Jun 2024 21:33:47 +0000 (14:33 -0700)] 
gccrs: Make sure CompileExpr::visit is reached

gcc/rust/ChangeLog:

* hir/tree/rust-hir.cc (InlineAsm::accept_vis):
Make sure CompileExpr::visit is reached
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
Likewise
gcc/testsuite/ChangeLog:

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

4 months agogccrs: Scaffolding asm codegen
jjasmine [Sat, 22 Jun 2024 18:56:50 +0000 (11:56 -0700)] 
gccrs: Scaffolding asm codegen

gcc/rust/ChangeLog:

* backend/rust-compile-block.h:
Scaffolding asm codegen
* backend/rust-compile-expr.cc (CompileExpr::visit): Likewise.
* backend/rust-compile-expr.h: Likewise.
* checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit): Likewise.
* checks/errors/borrowck/rust-bir-builder-expr-stmt.h: Likewise.
* checks/errors/borrowck/rust-bir-builder-lazyboolexpr.h: Likewise.
* checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): Likewise.
* checks/errors/privacy/rust-privacy-reporter.h: Likewise.
* hir/tree/rust-hir-expr.h: Likewise.
* hir/tree/rust-hir-visitor.h: Likewise.
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise.
* typecheck/rust-hir-type-check-expr.h: Likewise.

4 months agogccrs: Fix the parser's operand and flags storage
badumbatish [Wed, 24 Jul 2024 05:17:12 +0000 (22:17 -0700)] 
gccrs: Fix the parser's operand and flags storage

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parse_reg_operand):
Fix parsing logic & reassignment logic
(parse_reg_operand_in): Fix parsing
(parse_reg_operand_out): Fix parsing
(parse_reg_operand_inout): Fix parsing
(parse_reg_operand_unexpected): Remove rust_unreachable()
(parse_asm_arg): Fix parsing logic

4 months agogccrs: Add pop guard for binder
badumbatish [Sat, 24 Aug 2024 05:21:05 +0000 (22:21 -0700)] 
gccrs: Add pop guard for binder

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check.h:
Add pop guard for binder

4 months agogccrs: Fix warnings from const auto& to const auto
badumbatish [Sun, 4 Aug 2024 19:43:09 +0000 (12:43 -0700)] 
gccrs: Fix warnings from const auto& to const auto

gcc/rust/ChangeLog:

* resolve/rust-ast-resolve.cc (NameResolution::go):
Fix warnings from const auto& to const auto

4 months agogccrs: emit error code for E0758
Raiki Tamura [Wed, 28 Aug 2024 17:48:29 +0000 (02:48 +0900)] 
gccrs: emit error code for E0758

gcc/rust/ChangeLog:

* lex/rust-lex.cc (Lexer::build_token): Emit error code.
* lex/rust-lex.h: Fix comment.

Signed-off-by: Raiki Tamura <tamaron1203@gmail.com>
4 months agogccrs: Add typecheck for path patterns.
Raiki Tamura [Fri, 9 Aug 2024 14:56:55 +0000 (23:56 +0900)] 
gccrs: Add typecheck for path patterns.

gcc/rust/ChangeLog:

* hir/tree/rust-hir.cc (Item::item_kind_string): New function.
* hir/tree/rust-hir.h: New function.
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
Modify to check all arms in match expressions even if some of them
has errors.
* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit):
Add and fix check for path patterns.

gcc/testsuite/ChangeLog:

* rust/compile/issue-2324-2.rs: Fix error message.
* rust/compile/match9.rs: New test.

Signed-off-by: Raiki Tamura <tamaron1203@gmail.com>
4 months agorust: Add checking for union patterns
Raiki Tamura [Wed, 31 Jul 2024 07:09:30 +0000 (16:09 +0900)] 
rust: Add checking for union patterns

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit):
Add check for union patterns.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Raiki Tamura <tamaron1203@gmail.com>
4 months agogccrs: feature-gate: Cleanup visitor and constructor
Arthur Cohen [Wed, 21 Aug 2024 13:42:58 +0000 (15:42 +0200)] 
gccrs: feature-gate: Cleanup visitor and constructor

This commit turns a few of the fields into `tl::optional<T>` and cleanups
the constructor with a couple default parameters. We can also reuse the
variable that we are `switch`ing on, instead of repeating the enum variants
each time.

Most importantly, the `FeatureGate` visitor now uses the `DefaultAstVisitor`
correctly, and will now visit nested items. This means that we have to
fix a bunch of the testsuite as some feature attributes were missing.

gcc/rust/ChangeLog:

* checks/errors/rust-feature.cc (Feature::create): Reuse variable,
remove now optional parameters from constructor.
* checks/errors/rust-feature.h: Cleanup class definition.
* checks/errors/rust-feature-gate.cc (FeatureGate::gate): Use optional.
* checks/errors/rust-feature-gate.h: Cleanup visitor implementation.

gcc/testsuite/ChangeLog:

* rust/compile/assume.rs: Add missing feature attribute.
* rust/compile/issue-1901.rs: Likewise.
* rust/compile/issue-1981.rs: Likewise.
* rust/compile/sizeof-stray-infer-var-bug.rs: Likewise.
* rust/compile/torture/intrinsics-8.rs: Likewise.
* rust/compile/torture/transmute-size-check-1.rs: Likewise.
* rust/compile/torture/transmute1.rs: Likewise.
* rust/compile/torture/uninit-intrinsic-1.rs: Likewise.
* rust/execute/torture/issue-1436.rs: Likewise.
* rust/execute/torture/issue-2583.rs: Likewise.

4 months agogccrs: attributes: Start handling prelude_import properly
Arthur Cohen [Wed, 21 Aug 2024 13:09:23 +0000 (15:09 +0200)] 
gccrs: attributes: Start handling prelude_import properly

This commit adds basic handling for the `#[prelude_import]` attribute,
without doing anything functionality wise.

gcc/rust/ChangeLog:

* checks/errors/rust-feature-gate.cc (FeatureGate::visit): Add base
feature gating for `#[feature(prelude_import)]`.
* checks/errors/rust-feature-gate.h: Likewise.
* checks/errors/rust-feature.cc (Feature::create): Likewise.
* checks/errors/rust-feature.h: Likewise.
* util/rust-attribute-values.h: Add base handling for `#[prelude_import]`
attribute.
* util/rust-attributes.cc: Likewise.

gcc/testsuite/ChangeLog:

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

4 months agogccrs: Fix the disorder struct and class in inline asm
badumbatish [Mon, 19 Aug 2024 23:39:11 +0000 (16:39 -0700)] 
gccrs: Fix the disorder struct and class in inline asm

gcc/rust/ChangeLog:

* ast/rust-ast-full-decls.h (struct InlineAsmOperand):
Change to class
(class InlineAsmOperand): Change from struct
* hir/tree/rust-hir-full-decls.h (struct InlineAsmRegOrRegClass):
Removed from decl, used from AST
(struct AnonConst): new decl from rust-hir-expr.h
(class InlineAsmOperand): new decl from rust-hir-expr.h

4 months agogccrs: ast: Introduce class hierarchy for lang item paths
Arthur Cohen [Mon, 24 Jun 2024 16:25:15 +0000 (18:25 +0200)] 
gccrs: ast: Introduce class hierarchy for lang item paths

Create a base Path class which is derived into two children classes for
regular paths and lang item paths. This allows it to hold either the
segments of a fully formed path, or the node ID of a lang-item path.
This is required in order to create these special paths
which do not have segments, and do not necessarily have a canonical
form - they only depend on where the item was defined.

gcc/rust/ChangeLog:

* ast/rust-ast-full-decls.h (class PathPattern): Rename PathPattern to...
(class Path): ...Path
* ast/rust-ast-collector.cc (TokenCollector::visit): Add required methods
for LangItemPath and RegularPath.
* ast/rust-ast-collector.h: Likewise.
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Likewise.
* ast/rust-ast-visitor.h: Likewise.
* ast/rust-path.cc (PathPattern::as_string): Likewise.
(RegularPath::as_string): Likewise.
(LangItemPath::as_string): Likewise.
(PathPattern::convert_to_simple_path): Likewise.
(RegularPath::convert_to_simple_path): Likewise.
(RegularPath::accept_vis): Likewise.
(LangItemPath::accept_vis): Likewise.
(PathInExpression::as_string): Likewise.
(QualifiedPathInExpression::as_string): Likewise.
* ast/rust-path.h (class PathPattern): Likewise.
(class Path): Likewise.
(class RegularPath): Likewise.
(class LangItemPath): Likewise.
(class PathInExpression): Likewise.
(class QualifiedPathInExpression): Likewise.
* ast/rust-pattern.h (class PathPattern): Likewise.
(class Path): Likewise.
* expand/rust-derive.h: Likewise.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Likewise.
* hir/rust-ast-lower-base.h: Likewise.
* resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Likewise.
* resolve/rust-ast-resolve-base.h: Likewise.

4 months agogccrs: ast: Remove PathExpr abstract class
Arthur Cohen [Mon, 24 Jun 2024 15:04:13 +0000 (17:04 +0200)] 
gccrs: ast: Remove PathExpr abstract class

Inherit directly from ExprWithoutBlock instead.

gcc/rust/ChangeLog:

* ast/rust-ast.h (class PathExpr): Remove class.
* ast/rust-path.h (class PathInExpression): Inherit from ExprWithoutBlock.
(class QualifiedPathInExpression): Likewise.

4 months agogccrs: ast: PathPattern: Remove `remove_all_segments` method
Arthur Cohen [Mon, 24 Jun 2024 14:50:43 +0000 (16:50 +0200)] 
gccrs: ast: PathPattern: Remove `remove_all_segments` method

This method was used only for stripping PathPattern AST nodes during
`cfg-strip`, which seems like a misnomer and makes it a good candidate
for simplification.

gcc/rust/ChangeLog:

* ast/rust-path.h (class PathInExpression): Remove `remove_all_segments`
method, add a `marked_for_strip` flag instead.

4 months agogccrs: Attempted to access a nonexistent field [E0609]
Muhammad Mahad [Thu, 15 Aug 2024 16:44:55 +0000 (16:44 +0000)] 
gccrs: Attempted to access a nonexistent field [E0609]

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
Add error code and update error message

gcc/testsuite/ChangeLog:

* rust/compile/nonexistent-field.rs: New test.

Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
4 months agogccrs: Move errors with locations
Kushal Pal [Mon, 12 Aug 2024 05:48:27 +0000 (05:48 +0000)] 
gccrs: Move errors with locations

gcc/rust/ChangeLog:

* checks/errors/borrowck/rust-borrow-checker-diagnostics.cc
(BorrowCheckerDiagnostics::report_move_errors): Specify
locations for code causing errors and related moves.

gcc/testsuite/ChangeLog:

* rust/borrowck/test_move.rs: Test rich-errors related to moves.
* rust/borrowck/test_move_conditional.rs: Likewise.

Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
4 months agogccrs: Subset errors with locations
Kushal Pal [Fri, 26 Jul 2024 07:40:58 +0000 (07:40 +0000)] 
gccrs: Subset errors with locations

gcc/rust/ChangeLog:

* checks/errors/borrowck/rust-borrow-checker-diagnostics.cc
(BorrowCheckerDiagnostics::report_subset_errors): Highlight
lifetime locations while reporting subset errors.
(BorrowCheckerDiagnostics::get_lifetime_param): Helper function
to fetch HIR::Lifetime node from Polonius::Origin.
* checks/errors/borrowck/rust-borrow-checker-diagnostics.h:
Definition of helper function.

gcc/testsuite/ChangeLog:

* rust/borrowck/subset.rs: Better subset errors.

Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
4 months agogccrs: Map locations to placeholder regions
Kushal Pal [Thu, 25 Jul 2024 11:57:35 +0000 (11:57 +0000)] 
gccrs: Map locations to placeholder regions

Mapped placeholder regions to their respective HIR nodes so we can fetch
locations during error reporting.

gcc/rust/ChangeLog:

* checks/errors/borrowck/rust-bir-builder.h: Map regions to
their respective HIR nodes.
* checks/errors/borrowck/rust-bir.h (struct Function):
Add unordered_map to maintain the mapping.

Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
4 months agogccrs: Fixed testcase
Kushal Pal [Mon, 12 Aug 2024 05:48:27 +0000 (05:48 +0000)] 
gccrs: Fixed testcase

gcc/testsuite/ChangeLog:

* rust/borrowck/test_move.rs: Assigning `a` to `c` is the
correct way to test the behaviour.

Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
4 months agogccrs: [gccrs#2324] Add error message for E0532
Liam Naddell [Sat, 3 Aug 2024 05:36:06 +0000 (01:36 -0400)] 
gccrs: [gccrs#2324] Add error message for E0532

gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-pattern.cc:
Emit E0532 when trying to reference a Tuple or Struct variant
using a non Tuple or Struct pattern.

gcc/testsuite/ChangeLog:
* rust/compile/issue-2324-1.rs:
add test for E0532 with tuple enum variant
* rust/compile/issue-2324-2.rs:
add test for E0532 with struct enum variant

Signed-off-by: Liam Naddell <liam.naddell@mail.utoronto.ca>
4 months agogccrs: Eager expansion for include* gccrs#1805 gccrs#1865
Liam Naddell [Sat, 27 Jul 2024 04:28:13 +0000 (00:28 -0400)] 
gccrs: Eager expansion for include* gccrs#1805 gccrs#1865

gcc/rust/ChangeLog:

* expand/rust-expand-visitor.h:
remove auto keyword
* expand/rust-macro-builtins-helpers.cc:
allow for changing macro invoc types on eager expansions to
semicoloned macros
* expand/rust-macro-builtins-helpers.h:
add default semicoloned argument
* expand/rust-macro-builtins-include.cc:
allow for eager expansion for include and include_bytes
allow for parsing include invocations as items instead of
expressions, which allows invocations at global scope
* expand/rust-macro-expand.cc:
push Expr type for eager invocations

gcc/testsuite/ChangeLog:

* rust/compile/macros/builtin/include1.rs:
add basic include test at global scope
* rust/compile/macros/builtin/include2.rs:
add basic include test at local scope with expression
* rust/compile/macros/builtin/include3.rs:
add eager expansion test at global scope
* rust/compile/macros/builtin/include4.rs:
add eager expansion test at local scope with expression
* rust/compile/macros/builtin/include_bytes.rs:
add eager expansion test at global scope
* rust/compile/macros/builtin/include_rs:
supporting test file with dummy function
* rust/compile/macros/builtin/include_rs2:
supporting test file with dummy string
* rust/compile/macros/builtin/include_str.rs:
add eager expansion test at global scope
* rust/execute/torture/builtin_macro_include_bytes.rs:
clean up old test logic, add permutations for eager expansion
* rust/execute/torture/builtin_macro_include_str.rs:
add eager expansion permutations

4 months agogccrs: Simplify construction of BIR::Statement
Kushal Pal [Wed, 31 Jul 2024 01:37:54 +0000 (01:37 +0000)] 
gccrs: Simplify construction of BIR::Statement

gcc/rust/ChangeLog:

* checks/errors/borrowck/rust-bir-builder-internal.h:
Use `make_*` functions to create BIR::Statements.
* checks/errors/borrowck/rust-bir.h: Make a complete constructor
and introduce `make_*` functions to create various
BIR::Statements.

Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
4 months agogccrs: Loan errors with locations
Kushal Pal [Thu, 18 Jul 2024 08:12:49 +0000 (08:12 +0000)] 
gccrs: Loan errors with locations

gcc/rust/ChangeLog:

* checks/errors/borrowck/rust-borrow-checker-diagnostics.cc
(BorrowCheckerDiagnostics::report_loan_errors): Add label to
where the borrow occurs and where the invalid access occurs.
(BorrowCheckerDiagnostics::get_statement):
Fetch BIR::Statement from Polonius::Point
(BorrowCheckerDiagnostics::get_loan):
Fetch BIR::Loan from Polonius::Loan
* checks/errors/borrowck/rust-borrow-checker-diagnostics.h:
Function definition of helpers.

gcc/testsuite/ChangeLog:

* rust/borrowck/reference.rs: Test rich errors for
borrow-checker.
* rust/borrowck/return_ref_to_local.rs: Likewise.
* rust/borrowck/tmp.rs: Likewise.
* rust/borrowck/use_while_mut.rs: Likewise.
* rust/borrowck/use_while_mut_fr.rs: Likewise.
* rust/borrowck/well_formed_function_inputs.rs: Likewise.

Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
4 months agogccrs: Add location to BIR::Statement of kind RETURN
Kushal Pal [Fri, 19 Jul 2024 07:30:03 +0000 (07:30 +0000)] 
gccrs: Add location to BIR::Statement of kind RETURN

This commit adds location_t to BIR::Statement where type is RETURN.

gcc/rust/ChangeLog:

* checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit):
Add location parameter.
* checks/errors/borrowck/rust-bir-builder.h: Likewise.
* checks/errors/borrowck/rust-bir-builder-internal.h: Add helper
function for pushing return statements.
* checks/errors/borrowck/rust-bir.h: Remove `expr` parameter as
it is only needed for ASSIGNMENT statements, for which we
already have a constructor.

Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
4 months agogccrs: Implement resolve expr for inline asm ast
badumbatish [Wed, 31 Jul 2024 03:22:48 +0000 (20:22 -0700)] 
gccrs: Implement resolve expr for inline asm ast

gcc/rust/ChangeLog:

* resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit):
Implement resolve expr for inline asm ast
(translate_operand): Likewise.
* resolve/rust-ast-resolve-expr.h: Likewise.

4 months agogccrs: Add location to BIR::Loan
Kushal Pal [Tue, 9 Jul 2024 10:37:27 +0000 (10:37 +0000)] 
gccrs: Add location to BIR::Loan

This commit adds location_t to BIR::Loan, this location will point to
location is source code where the borrow occured, this information will
be useful for reporting borrow-checking errors.

gcc/rust/ChangeLog:

* checks/errors/borrowck/rust-bir-builder-internal.h:
Fill location for loan.
* checks/errors/borrowck/rust-bir-place.h (struct Loan):
Add location field.

Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
4 months agogccrs: Add location support to BIR::Statement
Kushal Pal [Thu, 27 Jun 2024 01:18:54 +0000 (01:18 +0000)] 
gccrs: Add location support to BIR::Statement

This commit adds location_t to BIR::Statement where type is ASSIGNMENT
this information will be later used for reporting borrow-checking
errors.

gcc/rust/ChangeLog:

* checks/errors/borrowck/rust-bir-builder-expr-stmt.cc
(ExprStmtBuilder::visit): Added location parameter.
* checks/errors/borrowck/rust-bir-builder-internal.h: Likewise.
* checks/errors/borrowck/rust-bir-builder-lazyboolexpr.h:
Likewise.
* checks/errors/borrowck/rust-bir-builder-pattern.h: Likewise.
* checks/errors/borrowck/rust-bir-builder.h: Likewise.
* checks/errors/borrowck/rust-bir.h: Likewise.

Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
4 months agogccrs: Turn to switch case, use new helper functions
badumbatish [Tue, 30 Jul 2024 16:13:15 +0000 (09:13 -0700)] 
gccrs: Turn to switch case, use new helper functions

gcc/rust/ChangeLog:

* hir/rust-ast-lower-expr.cc (translate_operand_in):
Turn to switch case, use new helper functions
(translate_operand_out): Likewise.
(translate_operand_inout): Likewise.
(translate_operand_split_in_out): Likewise.
(translate_operand_const): Likewise.
(translate_operand_sym): Likewise.
(translate_operand_label): Likewise.
(from_operand): Likewise.
(ASTLoweringExpr::visit): Likewise.

4 months agogccrs: Set up the hir lowering for operand
badumbatish [Sat, 27 Jul 2024 08:19:11 +0000 (01:19 -0700)] 
gccrs: Set up the hir lowering for operand

gcc/rust/ChangeLog:

* hir/rust-ast-lower-expr.cc (from_operand):
Set up the lowering for operand
(ASTLoweringExpr::visit): Likewise
* hir/tree/rust-hir-expr.h (struct InlineAsmRegOrRegClass):
Not necessary, kept from ast
(struct AnonConst): Set up lowering for operand
(class InlineAsmOperand): Likewise, add getters

4 months agogccrs: Improve compressed point bit manipulation
Kushal Pal [Wed, 31 Jul 2024 10:53:35 +0000 (10:53 +0000)] 
gccrs: Improve compressed point bit manipulation

gcc/rust/ChangeLog:

* checks/errors/borrowck/polonius/rust-polonius.h (struct FullPoint):
Added comments and made extraction of statement more verbose for
better understanding.
* checks/errors/borrowck/ffi-polonius/src/lib.rs: Likewise.

Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
4 months agogccrs: Use new constructors and control flow for operand
badumbatish [Tue, 30 Jul 2024 02:00:47 +0000 (19:00 -0700)] 
gccrs: Use new constructors and control flow for operand

gcc/rust/ChangeLog:

* ast/rust-expr.h (struct InlineAsmOperand): changed to class
(class InlineAsmOperand): Have appropriate constructor,
and getter
* expand/rust-macro-builtins-asm.cc (parse_reg_operand):
Use the new implement constructors and new control flow.
(parse_reg_operand_in): Likewise
(parse_reg_operand_out): Likewise
(parse_reg_operand_inout): Likewise
(parse_reg_operand_const): Likewise

4 months agogccrs: Fix the parser's operand and flags storage
badumbatish [Wed, 24 Jul 2024 05:17:12 +0000 (22:17 -0700)] 
gccrs: Fix the parser's operand and flags storage

gcc/rust/ChangeLog:

* ast/rust-expr.h (struct InlineAsmOperand):
Add construction for register_type
* expand/rust-macro-builtins-asm.cc (parse_reg_operand):
Fix parsing logic & reassignment logic
(parse_reg_operand_in): Fix parsing
(parse_reg_operand_out): Fix parsing
(parse_reg_operand_inout): Fix parsing
(parse_reg_operand_unexpected): Remove rust_unreachable()
(parse_asm_arg): Fix parsing logic
* expand/rust-macro-builtins-asm.h: Add = operator overloading

gcc/testsuite/ChangeLog:

* rust/compile/inline_asm_illegal_operands.rs: Test now passing
* rust/compile/inline_asm_parse_operand.rs: Remove _, not
supported right now

4 months agogccrs: Fixed bitwise operation in `extract_stmt`
Kushal Pal [Fri, 26 Jul 2024 07:51:43 +0000 (07:51 +0000)] 
gccrs: Fixed bitwise operation in `extract_stmt`

gcc/rust/ChangeLog:

* checks/errors/borrowck/polonius/rust-polonius.h (struct FullPoint):
This is the correct way of extracting the required bits.

Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
4 months agogccrs: Move mbe macro tests to their own directory
Pierre-Emmanuel Patry [Mon, 29 Jul 2024 12:27:32 +0000 (14:27 +0200)] 
gccrs: Move mbe macro tests to their own directory

gcc/testsuite/ChangeLog:

* rust/compile/macro-delim.rs: Move to...
* rust/compile/macros/mbe/macro-delim.rs: ...here.
* rust/compile/macro-issue1053-2.rs: Move to...
* rust/compile/macros/mbe/macro-issue1053-2.rs: ...here.
* rust/compile/macro-issue1053.rs: Move to...
* rust/compile/macros/mbe/macro-issue1053.rs: ...here.
* rust/compile/macro-issue1224.rs: Move to...
* rust/compile/macros/mbe/macro-issue1224.rs: ...here.
* rust/compile/macro-issue1233.rs: Move to...
* rust/compile/macros/mbe/macro-issue1233.rs: ...here.
* rust/compile/macro-issue1395-2.rs: Move to...
* rust/compile/macros/mbe/macro-issue1395-2.rs: ...here.
* rust/compile/macro-issue1395.rs: Move to...
* rust/compile/macros/mbe/macro-issue1395.rs: ...here.
* rust/compile/macro-issue1400-2.rs: Move to...
* rust/compile/macros/mbe/macro-issue1400-2.rs: ...here.
* rust/compile/macro-issue1400.rs: Move to...
* rust/compile/macros/mbe/macro-issue1400.rs: ...here.
* rust/compile/macro-issue2092.rs: Move to...
* rust/compile/macros/mbe/macro-issue2092.rs: ...here.
* rust/compile/macro-issue2192.rs: Move to...
* rust/compile/macros/mbe/macro-issue2192.rs: ...here.
* rust/compile/macro-issue2194.rs: Move to...
* rust/compile/macros/mbe/macro-issue2194.rs: ...here.
* rust/compile/macro-issue2229.rs: Move to...
* rust/compile/macros/mbe/macro-issue2229.rs: ...here.
* rust/compile/macro-issue2264.rs: Move to...
* rust/compile/macros/mbe/macro-issue2264.rs: ...here.
* rust/compile/macro-issue2268.rs: Move to...
* rust/compile/macros/mbe/macro-issue2268.rs: ...here.
* rust/compile/macro-issue2273.rs: Move to...
* rust/compile/macros/mbe/macro-issue2273.rs: ...here.
* rust/compile/macro-issue2653.rs: Move to...
* rust/compile/macros/mbe/macro-issue2653.rs: ...here.
* rust/compile/macro-issue2983_2984.rs: Move to...
* rust/compile/macros/mbe/macro-issue2983_2984.rs: ...here.
* rust/compile/macro1.rs: Move to...
* rust/compile/macros/mbe/macro1.rs: ...here.
* rust/compile/macro10.rs: Move to...
* rust/compile/macros/mbe/macro10.rs: ...here.
* rust/compile/macro11.rs: Move to...
* rust/compile/macros/mbe/macro11.rs: ...here.
* rust/compile/macro12.rs: Move to...
* rust/compile/macros/mbe/macro12.rs: ...here.
* rust/compile/macro13.rs: Move to...
* rust/compile/macros/mbe/macro13.rs: ...here.
* rust/compile/macro14.rs: Move to...
* rust/compile/macros/mbe/macro14.rs: ...here.
* rust/compile/macro15.rs: Move to...
* rust/compile/macros/mbe/macro15.rs: ...here.
* rust/compile/macro16.rs: Move to...
* rust/compile/macros/mbe/macro16.rs: ...here.
* rust/compile/macro17.rs: Move to...
* rust/compile/macros/mbe/macro17.rs: ...here.
* rust/compile/macro18.rs: Move to...
* rust/compile/macros/mbe/macro18.rs: ...here.
* rust/compile/macro19.rs: Move to...
* rust/compile/macros/mbe/macro19.rs: ...here.
* rust/compile/macro2.rs: Move to...
* rust/compile/macros/mbe/macro2.rs: ...here.
* rust/compile/macro20.rs: Move to...
* rust/compile/macros/mbe/macro20.rs: ...here.
* rust/compile/macro21.rs: Move to...
* rust/compile/macros/mbe/macro21.rs: ...here.
* rust/compile/macro22.rs: Move to...
* rust/compile/macros/mbe/macro22.rs: ...here.
* rust/compile/macro23.rs: Move to...
* rust/compile/macros/mbe/macro23.rs: ...here.
* rust/compile/macro25.rs: Move to...
* rust/compile/macros/mbe/macro25.rs: ...here.
* rust/compile/macro26.rs: Move to...
* rust/compile/macros/mbe/macro26.rs: ...here.
* rust/compile/macro27.rs: Move to...
* rust/compile/macros/mbe/macro27.rs: ...here.
* rust/compile/macro28.rs: Move to...
* rust/compile/macros/mbe/macro28.rs: ...here.
* rust/compile/macro29.rs: Move to...
* rust/compile/macros/mbe/macro29.rs: ...here.
* rust/compile/macro3.rs: Move to...
* rust/compile/macros/mbe/macro3.rs: ...here.
* rust/compile/macro30.rs: Move to...
* rust/compile/macros/mbe/macro30.rs: ...here.
* rust/compile/macro31.rs: Move to...
* rust/compile/macros/mbe/macro31.rs: ...here.
* rust/compile/macro32.rs: Move to...
* rust/compile/macros/mbe/macro32.rs: ...here.
* rust/compile/macro33.rs: Move to...
* rust/compile/macros/mbe/macro33.rs: ...here.
* rust/compile/macro34.rs: Move to...
* rust/compile/macros/mbe/macro34.rs: ...here.
* rust/compile/macro35.rs: Move to...
* rust/compile/macros/mbe/macro35.rs: ...here.
* rust/compile/macro36.rs: Move to...
* rust/compile/macros/mbe/macro36.rs: ...here.
* rust/compile/macro37.rs: Move to...
* rust/compile/macros/mbe/macro37.rs: ...here.
* rust/compile/macro38.rs: Move to...
* rust/compile/macros/mbe/macro38.rs: ...here.
* rust/compile/macro39.rs: Move to...
* rust/compile/macros/mbe/macro39.rs: ...here.
* rust/compile/macro4.rs: Move to...
* rust/compile/macros/mbe/macro4.rs: ...here.
* rust/compile/macro40.rs: Move to...
* rust/compile/macros/mbe/macro40.rs: ...here.
* rust/compile/macro41.rs: Move to...
* rust/compile/macros/mbe/macro41.rs: ...here.
* rust/compile/macro42.rs: Move to...
* rust/compile/macros/mbe/macro42.rs: ...here.
* rust/compile/macro43.rs: Move to...
* rust/compile/macros/mbe/macro43.rs: ...here.
* rust/compile/macro44.rs: Move to...
* rust/compile/macros/mbe/macro44.rs: ...here.
* rust/compile/macro45.rs: Move to...
* rust/compile/macros/mbe/macro45.rs: ...here.
* rust/compile/macro46.rs: Move to...
* rust/compile/macros/mbe/macro46.rs: ...here.
* rust/compile/macro47.rs: Move to...
* rust/compile/macros/mbe/macro47.rs: ...here.
* rust/compile/macro48.rs: Move to...
* rust/compile/macros/mbe/macro48.rs: ...here.
* rust/compile/macro49.rs: Move to...
* rust/compile/macros/mbe/macro49.rs: ...here.
* rust/compile/macro5.rs: Move to...
* rust/compile/macros/mbe/macro5.rs: ...here.
* rust/compile/macro50.rs: Move to...
* rust/compile/macros/mbe/macro50.rs: ...here.
* rust/compile/macro51.rs: Move to...
* rust/compile/macros/mbe/macro51.rs: ...here.
* rust/compile/macro52.rs: Move to...
* rust/compile/macros/mbe/macro52.rs: ...here.
* rust/compile/macro53.rs: Move to...
* rust/compile/macros/mbe/macro53.rs: ...here.
* rust/compile/macro54.rs: Move to...
* rust/compile/macros/mbe/macro54.rs: ...here.
* rust/compile/macro55.rs: Move to...
* rust/compile/macros/mbe/macro55.rs: ...here.
* rust/compile/macro56.rs: Move to...
* rust/compile/macros/mbe/macro56.rs: ...here.
* rust/compile/macro57.rs: Move to...
* rust/compile/macros/mbe/macro57.rs: ...here.
* rust/compile/macro6.rs: Move to...
* rust/compile/macros/mbe/macro6.rs: ...here.
* rust/compile/macro7.rs: Move to...
* rust/compile/macros/mbe/macro7.rs: ...here.
* rust/compile/macro8.rs: Move to...
* rust/compile/macros/mbe/macro8.rs: ...here.
* rust/compile/macro9.rs: Move to...
* rust/compile/macros/mbe/macro9.rs: ...here.
* rust/compile/macro_call_statement.rs: Move to...
* rust/compile/macros/mbe/macro_call_statement.rs: ...here.
* rust/compile/macro_export_1.rs: Move to...
* rust/compile/macros/mbe/macro_export_1.rs: ...here.
* rust/compile/macro_return.rs: Move to...
* rust/compile/macros/mbe/macro_return.rs: ...here.
* rust/compile/macro_rules_macro_rules.rs: Move to...
* rust/compile/macros/mbe/macro_rules_macro_rules.rs: ...here.
* rust/compile/macro_use1.rs: Move to...
* rust/compile/macros/mbe/macro_use1.rs: ...here.
* rust/compile/macros/mbe/mbe_macro.exp: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Move builtin macro tests to their own directory
Pierre-Emmanuel Patry [Mon, 29 Jul 2024 12:20:01 +0000 (14:20 +0200)] 
gccrs: Move builtin macro tests to their own directory

We need a finer grain to filter tests and organise them.

gcc/testsuite/ChangeLog:

* rust/compile/builtin_macro_compile_error.rs: Move to...
* rust/compile/macros/builtin/compile_error.rs: ...here.
* rust/compile/builtin_macro_concat.rs: Move to...
* rust/compile/macros/builtin/concat.rs: ...here.
* rust/compile/builtin_macro_eager1.rs: Move to...
* rust/compile/macros/builtin/eager1.rs: ...here.
* rust/compile/builtin_macro_eager2.rs: Move to...
* rust/compile/macros/builtin/eager2.rs: ...here.
* rust/compile/builtin_macro_eager3.rs: Move to...
* rust/compile/macros/builtin/eager3.rs: ...here.
* rust/compile/builtin_macro_env.rs: Move to...
* rust/compile/macros/builtin/env.rs: ...here.
* rust/compile/builtin_macro_include_bytes.rs: Move to...
* rust/compile/macros/builtin/include_bytes.rs: ...here.
* rust/compile/builtin_macro_include_bytes_location_info.rs: Move to...
* rust/compile/macros/builtin/include_bytes_location_info.rs: ...here.
* rust/compile/builtin_macro_include_str.rs: Move to...
* rust/compile/macros/builtin/include_str.rs: ...here.
* rust/compile/builtin_macro_include_str_location_info.rs: Move to...
* rust/compile/macros/builtin/include_str_location_info.rs: ...here.
* rust/compile/builtin_macro_not_found.rs: Move to...
* rust/compile/macros/builtin/not_found.rs: ...here.
* rust/compile/builtin_macro_recurse2.rs: Move to...
* rust/compile/macros/builtin/recurse2.rs: ...here.
* rust/compile/macros/builtin/builtin_macro.exp: New test.
* rust/compile/invalid_utf8: Move invalid-utf8 data to...
* rust/compile/macros/builtin/invalid_utf8: ...here.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: ffi-polonius: Remove usage of extern types.
Arthur Cohen [Fri, 26 Jul 2024 09:04:46 +0000 (11:04 +0200)] 
gccrs: ffi-polonius: Remove usage of extern types.

This will allow us to revert our dependency on extern types, which would
help our godbolt build as well as our various builders.

gcc/rust/ChangeLog:

* checks/errors/borrowck/ffi-polonius/src/gccrs_ffi.rs: Remove extern
type feature.
* checks/errors/borrowck/ffi-polonius/src/lib.rs: Define FFIVector
per the nomicon's recommendation
https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs

4 months agogccrs: Move procedural macro test to their own directory
Pierre-Emmanuel Patry [Thu, 25 Jul 2024 12:27:41 +0000 (14:27 +0200)] 
gccrs: Move procedural macro test to their own directory

gcc/testsuite/ChangeLog:

* rust/compile/macros/proc/proc_macro.exp: New deja gnu file to execute
proc-macro tests.
* rust/compile/proc_macro_attribute_crate_type.rs: Move to...
* rust/compile/macros/proc/attribute_crate_type.rs: ...here.
* rust/compile/proc_macro_attribute_non_function.rs: Move to...
* rust/compile/macros/proc/attribute_non_function.rs: ...here.
* rust/compile/proc_macro_attribute_non_root_function.rs: Move to...
* rust/compile/macros/proc/attribute_non_root_function.rs: ...here.
* rust/compile/proc_macro_attribute_non_root_method.rs: Move to...
* rust/compile/macros/proc/attribute_non_root_method.rs: ...here.
* rust/compile/proc_macro_attribute_non_root_module.rs: Move to...
* rust/compile/macros/proc/attribute_non_root_module.rs: ...here.
* rust/compile/proc_macro_attribute_private.rs: Move to...
* rust/compile/macros/proc/attribute_private.rs: ...here.
* rust/compile/proc_macro_crate_type.rs: Move to...
* rust/compile/macros/proc/crate_type.rs: ...here.
* rust/compile/proc_macro_derive_crate_type.rs: Move to...
* rust/compile/macros/proc/derive_crate_type.rs: ...here.
* rust/compile/proc_macro_derive_malformed.rs: Move to...
* rust/compile/macros/proc/derive_malformed.rs: ...here.
* rust/compile/proc_macro_derive_non_function.rs: Move to...
* rust/compile/macros/proc/derive_non_function.rs: ...here.
* rust/compile/proc_macro_derive_non_root_function.rs: Move to...
* rust/compile/macros/proc/derive_non_root_function.rs: ...here.
* rust/compile/proc_macro_derive_non_root_module.rs: Move to...
* rust/compile/macros/proc/derive_non_root_module.rs: ...here.
* rust/compile/proc_macro_derive_private.rs: Move to...
* rust/compile/macros/proc/derive_private.rs: ...here.
* rust/compile/proc_macro_non_function.rs: Move to...
* rust/compile/macros/proc/non_function.rs: ...here.
* rust/compile/proc_macro_non_root_function.rs: Move to...
* rust/compile/macros/proc/non_root_function.rs: ...here.
* rust/compile/proc_macro_non_root_method.rs: Move to...
* rust/compile/macros/proc/non_root_method.rs: ...here.
* rust/compile/proc_macro_non_root_module.rs: Move to...
* rust/compile/macros/proc/non_root_module.rs: ...here.
* rust/compile/proc_macro_derive_non_root_method.rs: Move to...
* rust/compile/macros/proc/non_root_trait_method.rs: ...here.
* rust/compile/proc_macro_private.rs: Move to...
* rust/compile/macros/proc/private.rs: ...here.
* rust/compile/proc_macro_pub_function.rs: Move to...
* rust/compile/macros/proc/pub_function.rs: ...here.
* rust/compile/proc_macro_pub_module.rs: Move to...
* rust/compile/macros/proc/pub_module.rs: ...here.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: [gccrs#3045] #[may_dangle] in safe impl
Liam Naddell [Sun, 7 Jul 2024 00:34:28 +0000 (20:34 -0400)] 
gccrs: [gccrs#3045] #[may_dangle] in safe impl

gcc/rust/ChangeLog:
* ast/rust-ast.cc:
Fix Attribute constructors to copy inner_attribute
* checks/errors/rust-unsafe-checker.cc:
Add pass for #[may_dangle] in safe impl's
* hir/rust-ast-lower-item.cc:
Add support for unsafe impl's
* hir/rust-ast-lower-type.cc:
Lower attributes in impl's from AST to HIR
* hir/rust-hir-dump.cc:
Change single attribute to AttrVec
* hir/tree/rust-hir-item.h:
Add unsafe support to Impl blocks in HIR
* hir/tree/rust-hir.cc:
Change single attribute to AttrVec
* hir/tree/rust-hir.h:
Add has/get_outer_attribute to GenericParam

gcc/testsuite/ChangeLog:
* rust/compile/issue-3045-1.rs:
Add test for #[may_dangle] Generic Type triggering error
* rust/compile/issue-3045-2.rs:
Add test for #[may_dangle] Lifetime triggering error

Signed-off-by: Liam Naddell <liam.naddell@mail.utoronto.ca>
4 months agogccrs: Add rustc test directory for testsuite adaptor
Muhammad Mahad [Sun, 21 Jul 2024 17:35:46 +0000 (17:35 +0000)] 
gccrs: Add rustc test directory for testsuite adaptor

gcc/testsuite/ChangeLog:

* rust/rustc/README.md: information about
rustc external directory.
* rust/rustc/rustc.exp: New test.

Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
4 months agogccrs: Properly striping struct fields when using attrs
Antonio Gomes [Fri, 19 Jul 2024 01:50:54 +0000 (22:50 -0300)] 
gccrs: Properly striping struct fields when using attrs

gcc/rust/ChangeLog:
* expand/rust-cfg-strip.cc:
Strip struct expr fields and strip fields in struct definition
* expand/rust-cfg-strip.h:
Signatures for new function maybe_strip_struct_expr_fields

gcc/testsuite/ChangeLog:
* rust/compile/macro-issue2983_2984.rs:
Add test to check for correct stripped fields

Signed-off-by: Antonio Gomes <antoniospg100@gmail.com>
4 months agoFortran: Fix comp call in associate [PR119272]
Andre Vehreschild [Mon, 17 Mar 2025 07:24:04 +0000 (08:24 +0100)] 
Fortran: Fix comp call in associate [PR119272]

PR fortran/119272

gcc/fortran/ChangeLog:

* resolve.cc (resolve_compcall): Postpone error report when
symbol is not resolved yet for component call resolve.

gcc/testsuite/ChangeLog:

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

4 months agolibstdc++: Support maps deduction from_range of tuples.
Tomasz Kamiński [Wed, 19 Mar 2025 10:42:50 +0000 (11:42 +0100)] 
libstdc++: Support maps deduction from_range of tuples.

This implements part of LWG4223 that enables deduction for maps types
(map, unordered_map, flat_map and non-unique equivalent) from
(from_range, rg, ...) arguments, where rg is range of tuple
or other pair-like.

libstdc++-v3/ChangeLog:

* include/bits/ranges_base.h (__detail::__range_key_type):
Replace RV::first_type with tuple_element_t<0, RV>.
(__detail::__range_mapped_type) Replace RV::second_type
with tuple_element_t<1, RV>.
* testsuite/23_containers/flat_map/1.cc: New tests.
* testsuite/23_containers/flat_multimap/1.cc: New tests.
* testsuite/23_containers/map/cons/from_range.cc: New tests.
* testsuite/23_containers/multimap/cons/from_range.cc: New tests.
* testsuite/23_containers/unordered_map/cons/from_range.cc: New tests.
* testsuite/23_containers/unordered_multimap/cons/from_range.cc:
New tests.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 months agoi386: Fix up splitters into vptest [PR119357]
Jakub Jelinek [Wed, 19 Mar 2025 13:26:22 +0000 (14:26 +0100)] 
i386: Fix up splitters into vptest [PR119357]

The following testcase ICEs, because the splitters into vptest
create an invalid instruction.  The operands of all the UNSPEC_PTEST
using instructions use register_operand and vector_operand predicate,
these splitters use vector_operand predicate but create vptest
instruction which has the same argument twice, so one of them needs
to be in a register.
The following patch keeps vector_operand predicate on the splitters
but uses force_reg to force it into a REG if it was a MEM, that results
in better code generation e.g. on the included testcase, as combine
can match those even with MEM.
The difference on the testcase is
-       vpxor   %xmm0, %xmm0, %xmm0
-       vpcmpeqb        (%rdi), %xmm0, %xmm0
-       vpmovmskb       %xmm0, %eax
-       cmpl    $65535, %eax
+       vmovdqa (%rdi), %xmm0
+       vptest  %xmm0, %xmm0
(- for patch which changes the splitters to
s/vector_operand/register_operand/ and + for this patch).

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

PR target/119357
* config/i386/sse.md (pmovmskb 0xffff to ptest splitter,
*pmovsk_ptest_<mode>_avx512): Force operands[0] into a REG.

* gcc.target/i386/avx512vlbw-pr119357.c: New test.

4 months agomiddle-end: update early-break tests for non-load-lanes targets [PR119286]
Tamar Christina [Wed, 19 Mar 2025 12:58:14 +0000 (12:58 +0000)] 
middle-end: update early-break tests for non-load-lanes targets [PR119286]

Broadly speaking, these tests were failing because the BB limitation for SLP'ing
loads in an || in an early break makes the loads end up in different BBs and so
today we can't SLP them.  This results in load_lanes being required to vectorize
them because the alternative is loads with permutes which we don't allow.

The original checks were only checking partial vectors, which ended up working
because e.g. Adv. SIMD isn't a partial vector target, so it failed, and SVE was
a partial vector target but also has load lanes so it passes.

GCN however is a partial vector target without load lanes which makes the tests
fail.  As we require load_lanes for now, also check for them.

Bootstrapped Regtested on aarch64-none-linux-gnu,
arm-none-linux-gnueabihf, x86_64-pc-linux-gnu
-m32, -m64 and no issues.

Cross checked the failing cases on amdgcn-amdhsa
and all pass now.

gcc/testsuite/ChangeLog:

PR target/119286
* gcc.dg/vect/bb-slp-41.c: Add pragma novector.
* gcc.dg/vect/vect-early-break_133_pfa11.c: Should never vectorize today
as indexes can be out of range.
* gcc.dg/vect/vect-early-break_128.c: Require load_lanes as well.
* gcc.dg/vect/vect-early-break_133_pfa10.c: Likewise.
* gcc.dg/vect/vect-early-break_133_pfa8.c: Likewise.
* gcc.dg/vect/vect-early-break_133_pfa9.c: Likewise.
* gcc.dg/vect/vect-early-break_22.c: Likewise.
* gcc.dg/vect/vect-early-break_26.c: Likewise.
* gcc.dg/vect/vect-early-break_43.c: Likewise.
* gcc.dg/vect/vect-early-break_44.c: Likewise.
* gcc.dg/vect/vect-early-break_6.c: Likewise.
* gcc.dg/vect/vect-early-break_56.c: Expect failures on group misalign.

4 months agolibstdc++-v3: Implement allocator-aware from_range_t constructors for unordered conta...
Tomasz Kamiński [Tue, 18 Mar 2025 15:10:48 +0000 (16:10 +0100)] 
libstdc++-v3: Implement allocator-aware from_range_t constructors for unordered containers.

This patch implements part of LWG2713 covering the from_range
constructors, which makes std::ranges::to<std::unordered_set>(alloc)
well-formed. Likewise for rest of unordered containers.

As this consturctors were added to v15, this has no impact
on code that compiled with previous versions.

libstdc++-v3/ChangeLog:

* include/bits/unordered_map.h
(unordered_map(from_range_t, _Rg&&, const allocator_type&))
(unordered_multimap(from_range_t, _Rg&&, const allocator_type&)):
Define.
* include/bits/unordered_set.h
(unordered_set(from_range_t, _Rg&&, const allocator_type&))
(unordered_multiset(from_range_t, _Rg&&, const allocator_type&)):
Define.
* testsuite/23_containers/unordered_map/cons/from_range.cc: New tests.
New tests.
* testsuite/23_containers/unordered_multimap/cons/from_range.cc:
New tests.
* testsuite/23_containers/unordered_multiset/cons/from_range.cc:
New tests.
* testsuite/23_containers/unordered_set/cons/from_range.cc: New tests.
* testsuite/std/ranges/conv/1.cc: New tests.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 months agoRemove mistakenly committed file
Jakub Jelinek [Wed, 19 Mar 2025 10:24:56 +0000 (11:24 +0100)] 
Remove mistakenly committed file

r15-7222 added an empty file gcc.dg/pr not mentioned in the ChangeLog
nor used anywhere in that patch.
Removed as obvious.

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

* gcc.dg/pr: Remove.

4 months agolibstdc++: Cast difference_type for insert_range unordered non-unique containers...
Tomasz Kamiński [Tue, 18 Mar 2025 16:32:40 +0000 (17:32 +0100)] 
libstdc++: Cast difference_type for insert_range unordered non-unique containers [PR119358]

ranges::distance may produce an integer-like class type
(ranges::__detail::__max_diff_type) that is only explicitly convertible to
other integer types, so the result needs to be casted to containers size_type.

PR libstdc++/119358

libstdc++-v3/ChangeLog:

* include/bits/unordered_map.h (unordered_multimap::insert_range):
Cast ranges::distance to size_type before passing to _M_rehash_insert.
* include/bits/unordered_set.h (unordered_multiset::insert_range):
Same as unordered_multimap::insert_range.
* testsuite/23_containers/unordered_multimap/cons/from_range.cc:
New tests.
* testsuite/23_containers/unordered_multiset/cons/from_range.cc:
New tests.

4 months agoaarch64: Add +sve2p1 to -march=armv9.4-a flags
Kyrylo Tkachov [Mon, 17 Mar 2025 15:24:18 +0000 (08:24 -0700)] 
aarch64: Add +sve2p1 to -march=armv9.4-a flags

The ArmARM says:
"In an Armv9.4 implementation, if FEAT_SVE2 is implemented, FEAT_SVE2p1
is implemented."

We should enable +sve2p1 as part of -march=armv9.4-a, which this patch does.
This makes gcc consistent with gas.
Bootstrapped and tested on aarch64-none-linux-gnu.

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

* config/aarch64/aarch64-arches.def (...): Add SVE2p1.
* doc/invoke.texi (AArch64 Options): Document +sve2p1 in
-march=armv9.4-a.

4 months agoc++: Perform immediate invocation evaluation separately from cp_fold_r [PR118068]
Jakub Jelinek [Wed, 19 Mar 2025 08:34:10 +0000 (09:34 +0100)] 
c++: Perform immediate invocation evaluation separately from cp_fold_r [PR118068]

The r14-4140 change moved consteval evaluation from build_over_call to
cp_fold_r.

The following testcase is a regression caused by that change.  There
is a cast around immediate invocation, (int) foo (0x23)
where consteval for returns unsigned char.  When the consteval call
has been folded early to 0x23 (with unsigned char type), cp_fold sees
(int) 0x23 and folds that to 0x23 with int type.
But when the immediate invocation is handled only during cp_fold_r,
cp_fold_r first calls cp_fold on the NOP_EXPR, which calls cp_fold
on its operand, it is CALL_EXPR, nothing is folded at that point.
Then cp_fold_r continues to walk the NOP_EXPR's operand, sees it is
an immediate function invocation and cp_fold_immediate_r calls
cxx_constant_value on it and replaces the CALL_EXPR with the INTEGER_CST
0x23.  Nothing comes back to folding the containing NOP_EXPR though.
Sure, with optimizations enabled some GIMPLE optimization folds that later,
but e.g. with -O0 nothing does that.  I think there could be arbitrarily
complex expressions on top of the immediate invocation(s) that used to be
folded by cp_fold before and aren't folded anymore.

One possibility would be to do the immediate invocation evaluation in
cp_fold rather than cp_fold_r (or in addition to cp_fold_r).

The following patch instead first evaluates all immediate invocations and
does cp_fold_r in a separate step.  That not only allows the folding of
expressions which contain immediate invocations, but also simplifies some
of the quirks that had to be done when it was in cp_fold_r.
Though, I had to add an extra case to cp_genericize_r RETURN_EXPR handling
to avoid a regression where after emitting errors in RETURN_EXPR argument
we've emitted a -Wreturn-type false positive.  Previously we ended up with
RETURN_EXPR with CLEANUP_POINT_EXPR with INIT_EXPR of RESULT_DECL to
error_mark_node, now we fold it more and have RETURN_EXPR with
error_mark_node operand.  The former would result during gimplification
into something -Wresult-type was quiet about, the latter doesn't.

BTW, r14-4140 changed behavior on
consteval bool foo (bool x) { if (x) throw 1; return false; }

constexpr void
foo ()
{
  if constexpr (false)
    {
      bool a = foo (true);
    }
}
where GCC 13 emitted
error: expression ‘<throw-expression>’ is not a constant expression
error and GCC 14/trunk including the patch below doesn't reject it.
And clang++ trunk rejects it.  It isn't immediately clear to me what
is right, if immediate invocations in discarded statements should
be evaluated or not.

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

PR target/118068
gcc/cp/
* cp-gimplify.cc (cp_fold_immediate): Use cp_walk_tree rather than
cp_walk_tree_without_duplicates.
(cp_fold_immediate_r): For IF_STMT_CONSTEVAL_P IF_STMT don't walk
into THEN_CLAUSE subtree, only ELSE_CLAUSE.  For non-call related
stmts call data->pset.add and if it returns true, don't walk subtrees.
(cp_fold_r): Don't call cp_fold_immediate_r here.
(cp_fold_function): For C++20 or later call cp_walk_tree
with cp_fold_immediate_r callback first before calling cp_walk_tree
with cp_fold_r callback and call data.pset.empty () in between.
(cp_fully_fold_init): Likewise.
(cp_genericize_r) <case RETURN_EXPR>: Suppress -Wreturn-type warning
if RETURN_EXPR has erroneous argument.
gcc/testsuite/
* g++.target/i386/pr118068.C: New test.

4 months agoFix misoptimization at -O2 in LTO mode
Eric Botcazou [Wed, 19 Mar 2025 07:55:04 +0000 (08:55 +0100)] 
Fix misoptimization at -O2 in LTO mode

This is a regression in recent releases. The problem is that the IPA mod/ref
pass looks through the (nominal) type of a pointer-to-discriminated-type
parameter in a call to a subprogram in order to see the (actual) type used
for the dereferences of the parameter in the callee, which is a
pointer-to-constrained-subtype.

Historically the discriminated type is marked with the may_alias attribute
because of the symmetric effect for the argument in the caller, so we mark
the constrained subtype with the attribute now for the sake of the callee.

gcc/ada/
* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Record_Subtype>: Set
the may_alias attribute if a specific GCC type is built.

4 months agoc: Fix bug in typedef redefinitions of tagged types [PR118765]
Martin Uecker [Sat, 1 Mar 2025 20:32:21 +0000 (21:32 +0100)] 
c: Fix bug in typedef redefinitions of tagged types [PR118765]

When we redefine a tagged type we incorrectly update TYPE_STUB_DECL
of the previously defined type instead of the new one.  Because
TYPE_STUB_DECL is used when determining whether two such types are
the same, this can cause valid typedef redefinitions to be rejected
later. This is only a partial fix for PR118765.

PR c/118765

gcc/c/ChangeLog:
* c-decl.cc (finish_struct,finish_enum): Swap direction when
copying TYPE_STRUB_DECL in redefinitions.

gcc/testsuite/ChangeLog:
* gcc.dg/pr118765.c: New test.

4 months agoc: Fix ICE in error recovery when checking struct compatibility [PR118061]
Martin Uecker [Sat, 1 Mar 2025 16:21:25 +0000 (17:21 +0100)] 
c: Fix ICE in error recovery when checking struct compatibility [PR118061]

Return early when comparing two structures for compatibility
and the type of a member is erroneous.

PR c/118061

gcc/c/ChangeLog:
* c-typeck.cc (tagged_types_tu_compatible_p): Handle
errors in types of struct members.

gcc/testsuite/ChangeLog:
* gcc.dg/pr118061.c: New test.

4 months agoFix spurious visibility error with partially parameterized formal package
Eric Botcazou [Wed, 19 Mar 2025 07:22:33 +0000 (08:22 +0100)] 
Fix spurious visibility error with partially parameterized formal package

This is not a regression but the issue is quite annoying and the fix is
trivial.  The problem is that a formal parameter covered by a box in the
formal package is not visible in the instance when it comes after another
formal parameter that is also a formal package.

It comes from a discrepancy internal to Instantiate_Formal_Package, where
a specific construct (the abbreviated instance) built for the nested formal
package discombobulates the processing done for the outer formal package.

gcc/ada/
* gen_il-gen-gen_nodes.adb (N_Formal_Package_Declaration): Use
N_Declaration instead of Node_Kind as ancestor.
* sem_ch12.adb (Get_Formal_Entity): Remove obsolete alternative.
(Instantiate_Formal_Package): Take into account the abbreviated
instances in the main loop running over the actuals of the local
package created for the formal package.

gcc/testsuite/
* gnat.dg/generic_inst14.adb: New test.
* gnat.dg/generic_inst14_pkg.ads: New helper.
* gnat.dg/generic_inst14_pkg-child.ads: Likewise.

4 months agoLoongArch: Add ABI names for FPR
Xi Ruoyao [Sun, 16 Mar 2025 06:19:53 +0000 (14:19 +0800)] 
LoongArch: Add ABI names for FPR

We already allow the ABI names for GPR in inline asm clobber list, so
for consistency allow the ABI names for FPR as well.

Reported-by: Yao Zi <ziyao@disroot.org>
gcc/ChangeLog:

* config/loongarch/loongarch.h (ADDITIONAL_REGISTER_NAMES): Add
fa0-fa7, ft0-ft16, and fs0-fs7.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/regname-float-abi.c: New test.

4 months agoMark gcc.target/i386/apx-ndd-tls-1b.c as xfail.
liuhongt [Mon, 17 Mar 2025 05:28:44 +0000 (22:28 -0700)] 
Mark gcc.target/i386/apx-ndd-tls-1b.c as xfail.

It looks like the testcase is fragile, it's supposed to check the
compiler ability of generating code_6_gottpoff_reloc instruction, but
failed since there's a seg_prefixed memory
usage(r14-6242-gd564198f960a2f).

        mov     r13, QWORD PTR j@gottpoff[rip]
        mov     r12, QWORD PTR a@gottpoff[rip]
        mov     rbp, QWORD PTR [rsp+1040]
        lea     rbx, [rsp+1040]
        add     r14, QWORD PTR fs:0, r12

gcc/testsuite/ChangeLog:

PR target/117069
* gcc.target/i386/apx-ndd-tls-1b.c: Add xfail.

4 months agoDaily bump.
GCC Administrator [Wed, 19 Mar 2025 00:17:56 +0000 (00:17 +0000)] 
Daily bump.

4 months agoAVR: target/119355 - Fix ICE in pass avr-fuse-move / -mfuse-move.
Georg-Johann Lay [Tue, 18 Mar 2025 20:22:22 +0000 (21:22 +0100)] 
AVR: target/119355 - Fix ICE in pass avr-fuse-move / -mfuse-move.

This ICE only occurred when the compiler is built with, say
CXXFLAGS='-Wp,-D_GLIBCXX_ASSERTIONS'.  The problem was that
a value from an illegal REGNO was read.  The value was not
used in these cases, but the access triggered an assertion
due to reading past std::array.

gcc/
PR target/119355
* config/avr/avr-passes.cc (memento_t::apply): Only
read values[p.arg] when it is actually used.

4 months agoc++: ICE with ptr-to-member-fn [PR119344]
Marek Polacek [Mon, 17 Mar 2025 21:46:02 +0000 (17:46 -0400)] 
c++: ICE with ptr-to-member-fn [PR119344]

This ICE appeared with the removal of NON_DEPENDENT_EXPR.  Previously
skip_simple_arithmetic would get NON_DEPENDENT_EXPR<CAST_EXPR<>> and
since NON_DEPENDENT_EXPR is neither BINARY_CLASS_P nor UNARY_CLASS_P,
there was no problem.  But now we pass just CAST_EXPR<> and a CAST_EXPR
is a tcc_unary, so we extract its null operand and crash.

skip_simple_arithmetic is called from save_expr.  cp_save_expr already
avoids calling save_expr in a template, so that seems like an appropriate
way to fix this.

PR c++/119344

gcc/cp/ChangeLog:

* typeck.cc (cp_build_binary_op): Use cp_save_expr instead of save_expr.

gcc/testsuite/ChangeLog:

* g++.dg/conversion/ptrmem10.C: New test.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
4 months agoc++: constexpr ref template arg [PR119194]
Jason Merrill [Tue, 18 Mar 2025 18:44:08 +0000 (14:44 -0400)] 
c++: constexpr ref template arg [PR119194]

Here we were assuming that a constant variable appearing in a template
argument is used for its value.  We also need to handle seeing its address
taken.

PR c++/119194

gcc/cp/ChangeLog:

* decl2.cc (min_vis_expr_r) [ADDR_EXPR]: New case.

gcc/testsuite/ChangeLog:

* g++.dg/template/linkage7.C: New test.

4 months agoc++: ICE when substituting packs into type aliases [PR118104]
Marek Polacek [Mon, 17 Mar 2025 16:56:40 +0000 (12:56 -0400)] 
c++: ICE when substituting packs into type aliases [PR118104]

r12-1094 mentions that adding the assert didn't lead to any regressions
in the testsuite, but this test case demonstrates that we can reach it
with valid code.

Here we arrive in use_pack_expansion_extra_args_p with t which is an
expansion whose pattern is void(Ts, Us) and tparm packs are {Us, Ts},
and parm_packs is { Ts -> <int, int>, Us -> <A, P...> }.  We want to
expand the pack into void(int, A) and void(int, P...).  We compare
int to A, which is fine, but then int to P... which crashes.  But
the code is valid so this patch removes the assert.

PR c++/118104

gcc/cp/ChangeLog:

* pt.cc (use_pack_expansion_extra_args_p): Remove an assert.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/alias-decl-variadic3.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
4 months agocobol: Remove dead code from the driver.
Iain Sandoe [Sun, 16 Mar 2025 10:31:44 +0000 (10:31 +0000)] 
cobol: Remove dead code from the driver.

EXEC_LIB is no longer defined anywhere, so that the dependent code is
now dead.  The rpath code (if required) would need to be conditional
since rpath support is not available on all hosts.  Remove now and then
address if/when it is needed (other drivers do not do this).

gcc/cobol/ChangeLog:

* gcobolspec.cc (append_rpath): Remove.
(lang_specific_driver): Remove hard-wired rpath and library
names.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
4 months agogcc, cobol: Check for get_current_dir_name [PR119301]
Iain Sandoe [Sat, 15 Mar 2025 09:43:36 +0000 (09:43 +0000)] 
gcc, cobol: Check for get_current_dir_name [PR119301]

This adds a configure check for get_current_dir_name and falls back
to getcwd() if it is not available on the host.

PR cobol/119301

gcc/cobol/ChangeLog:

* util.cc: Check for the availability of get_current_dir_name
snf fall back to getcwd() if it is not present on the host.

gcc/ChangeLog:

* config.in: Regenerate.
* configure: Regenerate.
* configure.ac: Add check for get_current_dir_name.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
4 months agolibphobos: Fix std.getopt doesn't accept const(string)[] anymore
Iain Buclaw [Tue, 18 Mar 2025 18:15:40 +0000 (19:15 +0100)] 
libphobos: Fix std.getopt doesn't accept const(string)[] anymore

Instead of passing receiver into the conversion function, just return
the value and assign it to the receiver. Renamed the conversion function
and also cleaned up all the `typeof' calls, which were very verbose.

libphobos/ChangeLog:

* src/MERGE: Merge upstream phobos 79cbde1ab.

Reviewed-on: https://github.com/dlang/phobos/pull/10684

4 months agolibphobos: Avoid setting union members in std.json, set the whole union instead
Iain Buclaw [Tue, 18 Mar 2025 18:12:14 +0000 (19:12 +0100)] 
libphobos: Avoid setting union members in std.json, set the whole union instead

libphobos/ChangeLog:

* src/MERGE: Merge upstream phobos cafe86453.

Reviewed-on: https://github.com/dlang/phobos/pull/10683

4 months agorust: force cargo to build offline
Marc Poulhiès [Mon, 17 Mar 2025 18:23:50 +0000 (19:23 +0100)] 
rust: force cargo to build offline

gcc/rust/Changelog:
PR rust/119333

* Make-lang.in: Force offline mode for cargo

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
4 months agogccrs: polonius: Vendor Rust dependencies
Arthur Cohen [Tue, 18 Mar 2025 10:39:54 +0000 (11:39 +0100)] 
gccrs: polonius: Vendor Rust dependencies

This fixes PR #119333 by allowing our borrow-checker interface to be built
offline. This was already done for our components in libgrust/, but had never been
done for the borrow-checker.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119333

gcc/rust/ChangeLog:

* checks/errors/borrowck/ffi-polonius/.cargo/config.toml: New file, force vendored deps.
* checks/errors/borrowck/ffi-polonius/vendor/datafrog/.cargo-checksum.json: New file.
* checks/errors/borrowck/ffi-polonius/vendor/datafrog/CODE_OF_CONDUCT.md: New file.
* checks/errors/borrowck/ffi-polonius/vendor/datafrog/Cargo.toml: New file.
* checks/errors/borrowck/ffi-polonius/vendor/datafrog/LICENSE-APACHE: New file.
* checks/errors/borrowck/ffi-polonius/vendor/datafrog/LICENSE-MIT: New file.
* checks/errors/borrowck/ffi-polonius/vendor/datafrog/README.md: New file.
* checks/errors/borrowck/ffi-polonius/vendor/datafrog/RELEASES.md: New file.
* checks/errors/borrowck/ffi-polonius/vendor/datafrog/examples/borrow_check.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/datafrog/examples/graspan1.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/datafrog/src/join.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/datafrog/src/lib.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/datafrog/src/map.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/datafrog/src/test.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/datafrog/src/treefrog.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/.cargo-checksum.json: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/CHANGELOG.md: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/Cargo.toml: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/LICENSE-APACHE: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/LICENSE-MIT: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/README.md: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/benches/value.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/src/__private_api.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/src/kv/error.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/src/kv/key.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/src/kv/mod.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/src/kv/source.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/src/kv/value.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/src/lib.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/src/macros.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/src/serde.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/log/triagebot.toml: New file.
* checks/errors/borrowck/ffi-polonius/vendor/polonius-engine/.cargo-checksum.json: New file.
* checks/errors/borrowck/ffi-polonius/vendor/polonius-engine/Cargo.toml: New file.
* checks/errors/borrowck/ffi-polonius/vendor/polonius-engine/README.md: New file.
* checks/errors/borrowck/ffi-polonius/vendor/polonius-engine/src/facts.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/polonius-engine/src/lib.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/polonius-engine/src/output/datafrog_opt.rs:
New file.
* checks/errors/borrowck/ffi-polonius/vendor/polonius-engine/src/output/initialization.rs:
New file.
* checks/errors/borrowck/ffi-polonius/vendor/polonius-engine/src/output/liveness.rs:
New file.
* checks/errors/borrowck/ffi-polonius/vendor/polonius-engine/src/output/location_insensitive.rs:
New file.
* checks/errors/borrowck/ffi-polonius/vendor/polonius-engine/src/output/mod.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/polonius-engine/src/output/naive.rs: New file.
* checks/errors/borrowck/ffi-polonius/vendor/rustc-hash/.cargo-checksum.json: New file.
* checks/errors/borrowck/ffi-polonius/vendor/rustc-hash/CODE_OF_CONDUCT.md: New file.
* checks/errors/borrowck/ffi-polonius/vendor/rustc-hash/Cargo.toml: New file.
* checks/errors/borrowck/ffi-polonius/vendor/rustc-hash/LICENSE-APACHE: New file.
* checks/errors/borrowck/ffi-polonius/vendor/rustc-hash/LICENSE-MIT: New file.
* checks/errors/borrowck/ffi-polonius/vendor/rustc-hash/README.md: New file.
* checks/errors/borrowck/ffi-polonius/vendor/rustc-hash/src/lib.rs: New file.

4 months agoFortran: check type-spec in ALLOCATE of dummy with assumed length [PR119338]
Harald Anlauf [Mon, 17 Mar 2025 21:34:19 +0000 (22:34 +0100)] 
Fortran: check type-spec in ALLOCATE of dummy with assumed length [PR119338]

PR fortran/119338

gcc/fortran/ChangeLog:

* resolve.cc (resolve_allocate_expr): Check F2003:C626: Type-spec
in ALLOCATE of an assumed-length character dummy argument shall be
an asterisk.

gcc/testsuite/ChangeLog:

* gfortran.dg/deferred_character_18.f90: Adjust testcase.
* gfortran.dg/allocate_assumed_charlen_5.f90: New test.

4 months agod: Add missing Declaration bitfield setters/getters
Iain Buclaw [Tue, 18 Mar 2025 17:47:45 +0000 (18:47 +0100)] 
d: Add missing Declaration bitfield setters/getters

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd fde0f8c40a.

Reviewed-on: https://github.com/dlang/dmd/pull/21014

4 months agolibphobos: Merge changes in upstream druntime testsuite
Iain Buclaw [Sat, 15 Mar 2025 15:32:48 +0000 (16:32 +0100)] 
libphobos: Merge changes in upstream druntime testsuite

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime d2ee11364c.
* testsuite/libphobos.aa/test_aa.d: Add new test.
* testsuite/libphobos.betterc/test19933.d: Adjust imports.
* testsuite/libphobos.config/test22523.d: Likewise.
* testsuite/libphobos.exceptions/assert_fail.d: Adjust test.
* testsuite/libphobos.exceptions/chain.d: Adjust imports.
* testsuite/libphobos.exceptions/future_message.d: Likewise.
* testsuite/libphobos.exceptions/line_trace.d: Likewise.
* testsuite/libphobos.exceptions/long_backtrace_trunc.d: Likewise.
* testsuite/libphobos.exceptions/static_dtor.d: Likewise.
* testsuite/libphobos.gc/forkgc.d: Likewise.
* testsuite/libphobos.gc/precisegc.d: Likewise.
* testsuite/libphobos.gc/recoverfree.d: Likewise.
* testsuite/libphobos.hash/test_hash.d: Likewise.
* testsuite/libphobos.init_fini/custom_gc.d: Likewise.
* testsuite/libphobos.init_fini/thread_join.d: Likewise.
* testsuite/libphobos.thread/external_threads.d: Likewise.
* testsuite/libphobos.thread/fiber_guard_page.d: Likewise.
* testsuite/libphobos.thread/tlsgc_sections.d: Likewise.
* testsuite/libphobos.thread/tlsstack.d: Likewise.
* testsuite/libphobos.unittest/customhandler.d: Likewise.

4 months agod: Update the copyright years of dmd sources to 2025
Iain Buclaw [Sat, 15 Mar 2025 15:32:48 +0000 (16:32 +0100)] 
d: Update the copyright years of dmd sources to 2025

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd 51be8bb729.

Reviewed-on: https://github.com/dlang/dmd/pull/20958

4 months agoc: Fix handling of [[gnu::musttail] return in if and else bodies [PR119311]
Jakub Jelinek [Tue, 18 Mar 2025 17:51:48 +0000 (18:51 +0100)] 
c: Fix handling of [[gnu::musttail] return in if and else bodies [PR119311]

The following new testcase FAILs with C (and succeeds with C++).
c_parser_handle_musttail is used in c_parser_compound_statement_nostart
where it is directly passed to c_parser_statement_after_labels, and in
c_parser_all_labels where it is returned.  Now, out of the 3
c_parser_all_labels callers, c_parser_statement passes it down to
c_parser_statement_after_labels, but c_parser_if_body and c_parser_else_body
don't, so if there are return statements with [[gnu::musttail]] or
[[clang::musttail]] directly in if or else bodies rather than wrapped with
{}s, we throw that information away.

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

PR c/119311
* c-parser.cc (c_parser_if_body): Pass result of c_parser_all_labels
as last argument to c_parser_statement_after_labels.
(c_parser_else_body): Likewise.

* c-c++-common/musttail14.c: Use * instead of \* in the regexps.
* c-c++-common/musttail25.c: New test.

4 months agoc, c++: Support musttail attribute even using __attribute__ form [PR116545]
Jakub Jelinek [Tue, 18 Mar 2025 17:48:14 +0000 (18:48 +0100)] 
c, c++: Support musttail attribute even using __attribute__ form [PR116545]

Apparently some programs in the wild use
 #if __has_attribute(musttail)
   __attribute__((musttail)) return foo ();
 #else
   return foo ();
 #endif
clang supports musttail both as a standard attribute ([[clang::musttail]]
which we also support for compatibility) and the above worked just
fine with GCC 14 which had __has_attribute(musttail) 0.  Now that it is
0, this doesn't compile anymore.
So, either we need to ensure that __has_attribute(musttail) is 0
and just __has_c{,pp}_attribute({gnu,clang}::musttail) are non-zero,
or IMHO better we just make it work in the attribute form, especially for
C < C23 I can see why some projects would prefer that form.
While [[gnu::musttail]] is rejected as an error in C11 etc. before GCC 15,
rather than just handled as an unknown attribute.
I view this as both a regression and compatibility issue.
The patch handles it in similar spots to fallthrough/assume attributes
inside of __attribute__ for C, and for C++ enables mixing of standard [[]]
and GNU __attribute__(()) attributes at the start of statements in any order.

While working on it, I've noticed we weren't diagnosing arguments to the
clang::musttail attribute (fixed by the c-attribs.cc hunk) and newly
on the __attribute__ form attribute (in that case the arguments aren't just
skipped, they are always parsed and because we don't call decl_attributes
etc., it wouldn't be diagnosed without a manual check).

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

PR c/116545
gcc/
* doc/extend.texi (musttail statement attribute): Document
that musttail GNU attribute can be used as well.
gcc/c-family/
* c-attribs.cc (c_common_clang_attributes): Add musttail.
gcc/c/
* c-parser.cc (c_parser_declaration_or_fndef): Parse
__attribute__((musttail)) return.
(c_parser_handle_musttail): Diagnose attribute arguments.
(c_parser_statement_after_labels): Parse
__attribute__((musttail)) return.
gcc/cp/
* parser.cc (cp_parser_statement): Call cp_parser_attributes_opt
rather than cp_parser_std_attribute_spec_seq.
(cp_parser_jump_statement): Diagnose gnu::musttail attributes
with no arguments.
gcc/testsuite/
* c-c++-common/attr-fallthrough-2.c: Adjust expected diagnostics
for C++.
* c-c++-common/musttail15.c: New test.
* c-c++-common/musttail16.c: New test.
* c-c++-common/musttail17.c: New test.
* c-c++-common/musttail18.c: New test.
* c-c++-common/musttail19.c: New test.
* c-c++-common/musttail20.c: New test.
* c-c++-common/musttail21.c: New test.
* c-c++-common/musttail22.c: New test.
* c-c++-common/musttail23.c: New test.
* c-c++-common/musttail24.c: New test.
* g++.dg/musttail7.C: New test.
* g++.dg/musttail8.C: New test.
* g++.dg/musttail12.C: New test.
* g++.dg/musttail13.C: New test.
* g++.dg/musttail14.C: New test.
* g++.dg/ext/pr116545.C: New test.

4 months agoUpdate cpplib fr.po, sv.po
Joseph Myers [Tue, 18 Mar 2025 17:48:07 +0000 (17:48 +0000)] 
Update cpplib fr.po, sv.po

* fr.po, sv.po: Update.

4 months agoPopulate -original dump for Cobol
Richard Biener [Tue, 11 Mar 2025 12:19:55 +0000 (13:19 +0100)] 
Populate -original dump for Cobol

The following implements -fdump-tree-original dumping for cobol,
mimicing what the D frontend does.

gcc/cobol/
* gengen.cc (gg_finalize_function): Dump to TDI_original.

4 months agocobol: Fifteen new cobol.dg testscases.
Bob Dubner [Tue, 18 Mar 2025 01:47:05 +0000 (21:47 -0400)] 
cobol: Fifteen new cobol.dg testscases.

gcc/testsuite

* cobol.dg/group1/check_88.cob: New testcase.
* cobol.dg/group1/comp5.cob: Likewise.
* cobol.dg/group1/declarative_1.cob: Likewise.
* cobol.dg/group1/display.cob: Likewise.
* cobol.dg/group1/display2.cob: Likewise.
* cobol.dg/group1/line-sequential.cob: Likewise.
* cobol.dg/group1/multiple-compares.cob: Likewise.
* cobol.dg/group1/multiply2.cob: Likewise.
* cobol.dg/group1/packed.cob: Likewise.
* cobol.dg/group1/perform-nested-exit.cob: Likewise.
* cobol.dg/group1/pointer1.cob: Likewise.
* cobol.dg/group1/simple-arithmetic.cob: Likewise.
* cobol.dg/group1/simple-classes.cob: Likewise.
* cobol.dg/group1/simple-if.cob: Likewise.
* cobol.dg/group1/simple-perform.cob: Likewise.

4 months agodoc: regenerate rs6000/rs6000.opt.urls
Michael Matz [Tue, 18 Mar 2025 16:21:23 +0000 (17:21 +0100)] 
doc: regenerate rs6000/rs6000.opt.urls

which I forgot and the autobuilder complained.

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

4 months agocobol: Bring the code base into compliance with C++14
Bob Dubner [Tue, 18 Mar 2025 11:47:39 +0000 (07:47 -0400)] 
cobol: Bring the code base into compliance with C++14

gcc/cobol

* cdf.y: Make compatible with C++14.
* copybook.h: Likewise.
* dts.h: Likewise.
* except.cc: Likewise.
* genapi.cc: Likewise.
* genutil.cc: Likewise.
* genutil.h: Likewise.
* lexio.cc: Likewise.
* parse.y: Likewise.
* parse_ante.h: Likewise.
* show_parse.h: Likewise.
* symbols.cc: Likewise.
* symbols.h: Likewise.
* util.cc: Likewise.

4 months agotestsuite: Add support for dg-output-file directive
Jakub Jelinek [Tue, 18 Mar 2025 15:50:05 +0000 (16:50 +0100)] 
testsuite: Add support for dg-output-file directive

The COBOL tests has many tests which just dump emit lots of output
to stdout and want to compare it against expected output.
We have the dg-output directive, but if one needs more than dozens
of lines in the output, adding hundreds of dg-output directives to
each source uses too much memory and is harder to maintain.

The following patch offers an alternative, dg-output-file
directive where one can supply a text file with expected output
(no regexp matching in that case, just exact output, except that it
handles different line ending styles (for the expected file
using tcl gets, for the actual output skips over \n, \r\n or \r).
And a newline at the end of the whole output is optional (in the actual
output, because I think some boards get it eaten).

Also tested with addition or subtraction of some characters from the
expected output files and saw FAILs with appropriate messages.

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

* doc/sourcebuild.texi (dg-output-file): Document.

* lib/gcc-dg.exp (${tool}-load): If output-file is set, compare
combined output against content of the [lindex ${output-file} 1]
file.
(dg-output-file): New directive.
* lib/dg-test-cleanup.exp (cleanup-after-saved-dg-test): Clear
output-file variable.
* gcc.dg/dg-output-file-1.c: New test.
* gcc.dg/dg-output-file-1-lp64.txt: New test.
* gcc.dg/dg-output-file-1-ilp32.txt: New test.

4 months agoc++: memfn pointer as NTTP argument considered unused [PR119233]
Patrick Palka [Tue, 18 Mar 2025 15:38:33 +0000 (11:38 -0400)] 
c++: memfn pointer as NTTP argument considered unused [PR119233]

This is just the member function pointer version of PR c++/105848,
in which our non-dependent call pruning may cause us to not mark an
otherwise unused function pointer template argument as used.

PR c++/119233

gcc/cp/ChangeLog:

* pt.cc (mark_template_arguments_used): Also handle member
function pointers.

gcc/testsuite/ChangeLog:

* g++.dg/template/fn-ptr5.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
4 months agoBuild and install gcobol driver for the cross build
Matthias Klose [Tue, 18 Mar 2025 15:12:37 +0000 (16:12 +0100)] 
Build and install gcobol driver for the cross build

gcc/cobol/

2025-03-18  Matthias Klose  <doko@ubuntu.com>

* Make-lang.in (GCOBC_TARGET_INSTALL_NAME, gcobol-cross): New.
(cobol.all.cross): Depend on gcobol-cross.
(cobol.install-common): Adjust install for the cross build.
(cobol.uninstall): Use *_INSTALL_NAME for uninstall.

4 months agocobol: Avoid a use of auto.
Iain Sandoe [Mon, 17 Mar 2025 10:04:52 +0000 (10:04 +0000)] 
cobol: Avoid a use of auto.

In this case the deduction for Darwin's implementation is 'char *' which
then conflicts with the second use of data.initial in the find_if
callback.  Let's just specify it as 'const char *'.

gcc/cobol/ChangeLog:

* util.cc (cbl_field_t::report_invalid_initial_value): Avoid
auto here and specify const char *.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
4 months agoSCC-Copy: Add More Debug dumps
Andrew Pinski [Mon, 17 Mar 2025 18:28:16 +0000 (11:28 -0700)] 
SCC-Copy: Add More Debug dumps

While debugging a failure, I noticed that SCC copy didn't print
out what it was doing, e.g. replacing name1 with name 2.
This adds that dump.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* gimple-ssa-sccopy.cc (scc_copy_prop::replace_scc_by_value): Dump
what is being replaced with what.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
4 months agolibstdc++: Add P1206R7 from_range members to unordered maps [PR111055]
Tomasz Kamiński [Tue, 18 Mar 2025 10:08:19 +0000 (11:08 +0100)] 
libstdc++: Add P1206R7 from_range members to unordered maps [PR111055]

This is another piece of P1206R7, adding new members to std::unordered_map
and std::unordered_multimap.

PR libstdc++/111055

libstdc++-v3/ChangeLog:

* include/bits/unordered_map.h (unordered_map): Define from_range
constructors and insert_range member.
(unordered_multimap): Likewise.
* testsuite/23_containers/unordered_multimap/cons/from_range.cc:
New test.
* testsuite/23_containers/unordered_multimap/modifiers/insert_range.cc:
New test.
* testsuite/23_containers/unordered_map/cons/from_range.cc:
New test.
* testsuite/23_containers/unordered_map/modifiers/insert_range.cc:
New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 months agolibstdc++: Add P1206R7 from_range members to unordered sets [PR111055]
Tomasz Kamiński [Mon, 17 Mar 2025 13:30:35 +0000 (14:30 +0100)] 
libstdc++: Add P1206R7 from_range members to unordered sets [PR111055]

This is another piece of P1206R7, adding new members to std::unordered_set
and std::unordered_multiset.

PR libstdc++/111055

libstdc++-v3/ChangeLog:

* include/bits/hashtable.h (_M_rehash_insert)
(_M_insert_range_multi): Extracted rehashing for range insertion
to separate function.
* include/bits/unordered_set.h (unordered_set): Define from_range
constructors and insert_range member.
(unordered_multiset) Likewise.
* testsuite/23_containers/unordered_multiset/cons/from_range.cc:
New test.
* testsuite/23_containers/unordered_multiset/modifiers/insert_range.cc:
New test.
* testsuite/23_containers/unordered_set/cons/from_range.cc:
New test.
* testsuite/23_containers/unordered_set/modifiers/insert_range.cc:
New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 months agolra: Handle SUBREG in lra_rtx_hash [PR119307]
Jakub Jelinek [Tue, 18 Mar 2025 13:57:41 +0000 (14:57 +0100)] 
lra: Handle SUBREG in lra_rtx_hash [PR119307]

The following testcase ICEs starting with r15-3213 in
decompose_normal_address and starting with r15-3288 ICEs
in lra_rtx_hash, which since r8-5466 can't handle SUBREG
(previously SUBREG was "ei" and lra_rtx_hash can handle
that through
val += lra_rtx_hash (XEXP (x, i));
for e and
val += XINT (x, i);
for i, now it is "ep" where p stands for poly_uint16).

The following patch fixes it by handling SUBREG directly, a variant
could be instead add
        case 'p':
          for (int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
            val += SUBREG_BYTE (x).coeffs[i];
          break;
if you prefer that more (p is used solely for SUBREG and e.g. rtx_equal_p
has
        case 'p':
          if (maybe_ne (SUBREG_BYTE (x), SUBREG_BYTE (y)))
            return false;
          break;
).  Given the above rtx_equal_p snippet and that lra_rtx_hash
is solely used in invariant_hash (and recursion) and invariant_eq_p
uses rtx_equal_p we'll never consider different SUBREGs of the same thing
as the same invariant.

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

PR rtl-optimization/119307
* lra.cc (lra_rtx_hash): Handle SUBREG.

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

4 months agolibstdc++: Add P1206R7 from_range members to ordered sets [PR111055]
Tomasz Kamiński [Thu, 13 Mar 2025 17:24:38 +0000 (18:24 +0100)] 
libstdc++: Add P1206R7 from_range members to ordered sets [PR111055]

This is another piece of P1206R7, adding new members to std::set
and std::multiset.

PR libstdc++/111055

libstdc++-v3/ChangeLog:

* include/bits/stl_multiset.h: (inser_range)
(multiset(from_range_t, _Rg&&, const _Compare&, const _Alloc&))
(multiset(from_range_t, _Rg&&, const _Alloc&)): Define.
* include/bits/stl_set.h: (set(from_range_t, _Rg&&, const _Alloc&))
(set(from_range_t, _Rg&&, const _Compare&, const _Alloc&), insert_range):
Define.
* testsuite/23_containers/multiset/cons/from_range.cc: New test.
* testsuite/23_containers/multiset/modifiers/insert/insert_range.cc:
New test.
* testsuite/23_containers/set/cons/from_range.cc: New test.
* testsuite/23_containers/set/modifiers/insert/insert_range.cc:
New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 months agolibstdc++: Add P1206R7 from_range members to ordered maps [PR111055]
Tomasz Kamiński [Fri, 14 Mar 2025 15:04:11 +0000 (16:04 +0100)] 
libstdc++: Add P1206R7 from_range members to ordered maps [PR111055]

This is another piece of P1206R7, adding new members to std::map
and std::multimap.

PR libstdc++/111055

libstdc++-v3/ChangeLog:

* include/bits/ranges_base.h (__detail::__range_to_alloc_type):
Define.
* include/bits/stl_multimap.h: (inser_range)
(multimap(from_range_t, _Rg&&, const _Compare&, const _Alloc&))
(multimap(from_range_t, _Rg&&, const _Alloc&)): Define.
* include/bits/stl_map.h: (map(from_range_t, _Rg&&, const _Alloc&)) i
(map(from_range_t, _Rg&&, const _Compare&, const _Alloc&), insert_range):
Define.
* testsuite/23_containers/multimap/cons/from_range.cc: New test.
* testsuite/23_containers/multimap/modifiers/insert/insert_range.cc: New test.
* testsuite/23_containers/map/cons/from_range.cc: New test.
* testsuite/23_containers/map/modifiers/insert/insert_range.cc: New test.

4 months agocobol: use ldirname in cdf-copy.cc
Jose E. Marchesi [Mon, 17 Mar 2025 15:51:31 +0000 (16:51 +0100)] 
cobol: use ldirname in cdf-copy.cc

This patch changes gcc/cobol/cdf-copy.cc to use the new ldirname from
libibertay rather than the host's dirname.  This removes an include
for libgen.h.

Regtested in x86_64-linux-gnu by running make check-cobol.

gcc/cobol/ChangeLog

* cdf-copy.cc (copybook_elem_t::open_file): Use ldirname rather
than dirname.

4 months agolibiberty: add ldirname function
Jose E. Marchesi [Mon, 17 Mar 2025 11:47:40 +0000 (12:47 +0100)] 
libiberty: add ldirname function

This patch adds a function ldirname to libiberty.  It is implemented
in terms of lbasename.  Basically, given a given pathname, the dirname
part is what is not the basename minus the last directory separator
separating the dirname with the basename.

include/ChangeLog

* libiberty.h (ldirname): New function declaration.
(dos_ldirname): Likewise.
(unix_ldirname): Likewise.

libiberty/ChangeLog

* ldirname.c: New file.
* Makefile.in (CFILES): Add ldirname.c.
(REQUIRED_OFILES): Add ldirname.$(objext).
(./ldirname.$(objext)): New rule.
* makefile.vms (OBJS): Add ldirname.obj.
* configure.com (FILES): Add ldirname.

4 months agocobol: Do not include C++ headers after system.h.
Iain Sandoe [Sat, 15 Mar 2025 09:20:13 +0000 (09:20 +0000)] 
cobol: Do not include C++ headers after system.h.

The headers mentioned in parse.y are already unconditionally included
by system.h (via cobol-system.h).

gcc/cobol/ChangeLog:

* parse.y: Remove c++ header includes appearing after
system.h.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
4 months agodebug/101533 - ICE with variant typedef DIE generation
Richard Biener [Wed, 5 Mar 2025 13:24:50 +0000 (14:24 +0100)] 
debug/101533 - ICE with variant typedef DIE generation

There's a sanity check in gen_type_die_with_usage that trips
unnecessarily for a case where the relevant DIE has already been
generated successfully in other ways.  The following keys the
existing TREE_ASM_WRITTEN check on the correct object, honoring
this and does nothing instead of ICEing for the testcase at hand.

PR debug/101533
* dwarf2out.cc (gen_type_die_with_usage): When we have
output the typedef already do nothing for a typedef variant.
Do not set TREE_ASM_WRITTEN on the type.

* g++.dg/debug/pr101533.C: New testcase.

4 months agoi386: Remove XFAIL for pr103750 testcases
Haochen Jiang [Tue, 11 Mar 2025 02:52:46 +0000 (10:52 +0800)] 
i386: Remove XFAIL for pr103750 testcases

After commit r15-4510, the following testcases also do not need XFAIL.

gcc/testsuite/ChangeLog:

* gcc.target/i386/avx512f-pr103750-1.c: Remove XFAIL.
* gcc.target/i386/avx512f-pr103750-2.c: Ditto.
* gcc.target/i386/avx512fp16-pr103750-1.c: Ditto.
* gcc.target/i386/avx512fp16-pr103750-2.c: Ditto.

4 months ago[RISC-V] Fix another unreported code quality regression
Jeff Law [Tue, 18 Mar 2025 03:58:03 +0000 (21:58 -0600)] 
[RISC-V] Fix another unreported code quality regression

So here's the other case I was just looking at.  This is a slightly modified
version of some code from 500.perlbench which shows another nop logical
operation:

> void frob (void);
> typedef struct av AV;
> typedef unsigned int U32;
> struct av
> {
>   void *dummy;
>   U32 sv_refcnt;
>   U32 sv_flags;
> };
> void
> Perl_save_ary (AV *const oav)
> {
>   AV *av;
>   unsigned int x1 = oav->sv_flags;
>   unsigned int x2 = x1 & 3221225472;
>   if (x2 == 2147483648)
>     frob ();
> }

https://godbolt.org/z/941vqfGE6

It's not as obvious, but this is probably a regression as well.  I would expect
the gcc-14 code to execute in 1c faster than the current trunk code on a
superscalar design:

gcc-14:                               trunk:
        lw      a5,12(a0)                   lw      a5,12(a0)
        li      a3,-1073741824              li      a3,-2
        li      a4,-2147483648

        and     a5,a5,a3                    srai    a4,a5,30

        beq     a5,a4,.L4                   andi    a4,a4,-1

                                            beq     a4,a3,.L4

Essentially the "li" instrutions can execute in parallel with the lw. But the
rest of the sequence has data dependencies forcing the instructions to execute
serially.  Thus that extra andi extends the critical path by 1c.

Removing the useless andi should make the two sequences perform the same and
reduces the codesize.

Much like the prior case we walk backwards using -fdump-rtl-all -dp to find the
andi:

        andi    a4,a4,-1        # 26    [c=4 l=4]  *anddi3/1

The UID is 26.  And just like the prior case it first shows up in the .split2
dump:

grep insn\ 26 j.c.*
j.c.326r.split2:(insn 26 25 27 2 (set (reg:DI 14 a4 [144])
j.c.327r.ree:(insn 26 25 27 2 (set (reg:DI 14 a4 [144])
j.c.329r.pro_and_epilogue:(insn 26 25 27 2 (set (reg:DI 14 a4 [144])
j.c.330r.dse2:(insn 26 25 27 2 (set (reg:DI 14 a4 [144])

In the .split2 dump:

Splitting with gen_split_77 (riscv.md:3184)
scanning new insn with uid = 25.
scanning new insn with uid = 26.
scanning new insn with uid = 27.
scanning new insn with uid = 28.
deleting insn with uid = 12.
deleting insn with uid = 12.

So insn 12 is where we want to look.

> (jump_insn 12 6 13 2 (parallel [
>             (set (pc)
>                 (if_then_else (ne (and:DI (reg:DI 15 a5 [orig:138 oav_3(D)->sv_flags ] [138])
>                             (const_int -1073741824 [0xffffffffc0000000]))
>                         (const_int -2147483648 [0xffffffff80000000]))
>                     (label_ref:DI 18)
>                     (pc)))
>             (clobber (reg:DI 14 a4 [144]))
>             (clobber (reg:DI 13 a3 [145]))
>         ]) "j.c":16:6 361 {*branchdi_shiftedarith_ne_shifted}
>      (int_list:REG_BR_PROB 856416484 (nil))
>  -> 18)

So that's a conditional branch with the condition

(a5 & 0xffffffffc0000000) != 0xffffffff80000000

Note how those instructions have many low bits as zeros and that the constants
likely require some kind of constant synthesis.  We can conceptually do an
arithmetic right shift of a5 and both constants and get the same result, likely
making the constants easier to synthesize.

And that's precisely what this pattern is designed to do:

> (define_insn_and_split "*branch<ANYI:mode>_shiftedarith_<optab>_shifted"
>   [(set (pc)
>         (if_then_else (any_eq
>                     (and:ANYI (match_operand:ANYI 1 "register_operand" "r")
>                           (match_operand 2 "shifted_const_arith_operand" "i"))
>                     (match_operand 3 "shifted_const_arith_operand" "i"))
>          (label_ref (match_operand 0 "" ""))
>          (pc)))
>    (clobber (match_scratch:X 4 "=&r"))
>    (clobber (match_scratch:X 5 "=&r"))]
>   "!SMALL_OPERAND (INTVAL (operands[2]))
>     && !SMALL_OPERAND (INTVAL (operands[3]))
>     && SMALL_AFTER_COMMON_TRAILING_SHIFT (INTVAL (operands[2]),
>                                              INTVAL (operands[3]))"
>   "#"
>   "&& reload_completed"
>   [(set (match_dup 4) (ashiftrt:X (match_dup 1) (match_dup 7)))
>    (set (match_dup 4) (and:X (match_dup 4) (match_dup 8)))
>    (set (match_dup 5) (match_dup 9))
>    (set (pc) (if_then_else (any_eq (match_dup 4) (match_dup 5))
>                            (label_ref (match_dup 0)) (pc)))]
> {
>   HOST_WIDE_INT mask1 = INTVAL (operands[2]);
>   HOST_WIDE_INT mask2 = INTVAL (operands[3]);
>   int trailing_shift = COMMON_TRAILING_ZEROS (mask1, mask2);
>
>   operands[7] = GEN_INT (trailing_shift);
>   operands[8] = GEN_INT (mask1 >> trailing_shift);
>   operands[9] = GEN_INT (mask2 >> trailing_shift);
> }
It finds the number of low bits in both that must be zero.  In this case it's
30 bits.  So it shifts the register right by 30 bits.  Then constructs the two
new constants, one of which is -1 after shifting. And we emit (set (match_dup
4) (and (match_dup 4) (const_int -1))

And since this splits after register allocation nothing eliminates the useless
and dest,src,-1 and boom we have a regression.

The fix this time is a bit different.  I really don't want to open code the new
RTL.  So instead I create a new operand for the source of the AND statement.
If the constant is going to be -1 then that operand has the same value as the
destination operand (ie, a nop move).  Otherwise it is the appropriate AND
expression.

The nop-move will get eliminated thus resolving the regression.

I suspect some of the other patterns in riscv.md are subject to similar issues,
though I haven't seem them trigger, so I'm leaving them alone for now.

This has been tested in my tester and it'll obviously go through the upstream
CI flow before I push it to the trunk.

gcc/
* config/riscv/riscv.md (equality shifted-arith splitter): Do not
create op AND -1 as it won't be cleaned up post-reload.

gcc/testsuite
* gcc.target/riscv/redundant-andi-2.c: New test.

4 months agoFix r15-8073 (Pass -macos_version_min to the linker)
Andrew Pinski [Tue, 18 Mar 2025 01:16:56 +0000 (18:16 -0700)] 
Fix r15-8073 (Pass -macos_version_min to the linker)

With r15-8073-g952e17223d3a98, gcc_cv_ld64_macosx_version_min is being
used for the replacement and being set in a few locations but
gcc_cv_ld64_macos_version_min is set in others.
Since the auto-host.h variable is named LD64_HAS_MACOS_VERSION_MIN,
I changed over to remove the x from the name.

Committed as obvious after a quick test to make sure LD64_HAS_MACOS_VERSION_MIN
was not set to empty.

gcc/ChangeLog:

* configure: Regenerate.
* configure.ac: s/gcc_cv_ld64_macosx_version_min/gcc_cv_ld64_macos_version_min/.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
4 months agoDaily bump.
GCC Administrator [Tue, 18 Mar 2025 00:19:44 +0000 (00:19 +0000)] 
Daily bump.

4 months agoUpdate .po files
Joseph Myers [Mon, 17 Mar 2025 23:45:57 +0000 (23:45 +0000)] 
Update .po files

gcc/po/
* be.po, da.po, de.po, el.po, es.po, fi.po, fr.po, hr.po, id.po,
ja.po, ka.po, nl.po, ru.po, sr.po, sv.po, tr.po, uk.po, vi.po,
zh_CN.po, zh_TW.po: Update.

libcpp/po/
* be.po, ca.po, da.po, de.po, el.po, eo.po, es.po, fi.po, fr.po,
id.po, ja.po, ka.po, nl.po, pt_BR.po, ro.po, ru.po, sr.po, sv.po,
tr.po, uk.po, vi.po, zh_CN.po, zh_TW.po: Update.

4 months ago[RISC-V] Fix unreported code quality regression with single bit manipulations
Jeff Law [Mon, 17 Mar 2025 23:29:42 +0000 (17:29 -0600)] 
[RISC-V] Fix unreported code quality regression with single bit manipulations

I was reviewing some code recently and spotted an oddity.  In a few places we
were emitting andi dst,src,-1 and in others [x]ori dst,src,0. Those are
obviously nops and we should get rid of them.

Most of these are coming from a split part of a couple define_insn_and_split
patterns added back in late 2022, so this is an unreported 13, 14 & 15 code
quality regression (verified on godbolt, https://godbolt.org/z/EPszox5Kd).
Essentially the split part is matching over-aggressively and splitting what
should be a trivial bitmanip insn such as bset, bclr or binv into a nop logical
with a bit twiddle.

Since the split portions trigger post-reload nothing comes along to remove the
nop logical operations.

The fix is trivial.  Just refine the condition.  I considered refining the
operand predicates too.  Both are valid approaches.  I noticed the formatting
was goofy, so fixed that while I was in there.

I'm aware of one other similar case, but I haven't concluded if it's a
regression or not.

Tested in my tester.  Waiting for pre-commit CI to do its thing.

Jeff

gcc/
* config/riscv/bitmanip.md (*<or_optab>i<mode>_extrabit): Reject cases
where we only need to twiddle one bit.  Fix formatting.
(*andi<mode>extrabit): Likewise.

gcc/testsuite/

* gcc.target/riscv/redundant-andi.c: New test.
* gcc.target/riscv/redundant-ori.c: Likewise

4 months agogcc.dg/pr90838-2.c: Replace long with long long
H.J. Lu [Mon, 17 Mar 2025 22:02:35 +0000 (15:02 -0700)] 
gcc.dg/pr90838-2.c: Replace long with long long

Since gcc.dg/pr90838-2.c is only for 64-bit integer, replace long with
long long for ILP32 targets.

* gcc.dg/pr90838-2.c (ctz4): Replace long with long long.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>