aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2025-03-19gccrs: Fix the parser's operand and flags storagebadumbatish1-6/+15
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
2025-03-19gccrs: Add pop guard for binderbadumbatish1-1/+4
gcc/rust/ChangeLog: * typecheck/rust-hir-type-check.h: Add pop guard for binder
2025-03-19gccrs: Fix warnings from const auto& to const autobadumbatish1-1/+4
gcc/rust/ChangeLog: * resolve/rust-ast-resolve.cc (NameResolution::go): Fix warnings from const auto& to const auto
2025-03-19gccrs: emit error code for E0758Raiki Tamura2-7/+11
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>
2025-03-19gccrs: Add typecheck for path patterns.Raiki Tamura6-28/+175
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>
2025-03-19rust: Add checking for union patternsRaiki Tamura2-25/+76
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>
2025-03-19gccrs: feature-gate: Cleanup visitor and constructorArthur Cohen15-169/+90
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.
2025-03-19gccrs: attributes: Start handling prelude_import properlyArthur Cohen7-2/+29
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.
2025-03-19gccrs: Fix the disorder struct and class in inline asmbadumbatish2-2/+3
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
2025-03-19gccrs: ast: Introduce class hierarchy for lang item pathsArthur Cohen13-42/+294
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.
2025-03-19gccrs: ast: Remove PathExpr abstract classArthur Cohen2-7/+2
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.
2025-03-19gccrs: ast: PathPattern: Remove `remove_all_segments` methodArthur Cohen1-11/+6
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.
2025-03-19gccrs: Attempted to access a nonexistent field [E0609]Muhammad Mahad2-2/+19
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>
2025-03-19gccrs: Move errors with locationsKushal Pal3-10/+96
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>
2025-03-19gccrs: Subset errors with locationsKushal Pal3-9/+64
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>
2025-03-19gccrs: Map locations to placeholder regionsKushal Pal2-0/+24
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>
2025-03-19gccrs: Fixed testcaseKushal Pal1-2/+2
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>
2025-03-19gccrs: [gccrs#2324] Add error message for E0532Liam Naddell3-0/+63
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>
2025-03-19gccrs: Eager expansion for include* gccrs#1805 gccrs#1865Liam Naddell15-40/+170
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
2025-03-19gccrs: Simplify construction of BIR::StatementKushal Pal2-25/+51
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>
2025-03-19gccrs: Loan errors with locationsKushal Pal8-32/+295
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>
2025-03-19gccrs: Add location to BIR::Statement of kind RETURNKushal Pal4-7/+15
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>
2025-03-19gccrs: Implement resolve expr for inline asm astbadumbatish2-6/+63
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.
2025-03-19gccrs: Add location to BIR::LoanKushal Pal2-2/+4
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>
2025-03-19gccrs: Add location support to BIR::StatementKushal Pal6-121/+194
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>
2025-03-19gccrs: Turn to switch case, use new helper functionsbadumbatish1-70/+94
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.
2025-03-19gccrs: Set up the hir lowering for operandbadumbatish2-14/+343
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
2025-03-19gccrs: Improve compressed point bit manipulationKushal Pal2-3/+35
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>
2025-03-19gccrs: Use new constructors and control flow for operandbadumbatish2-84/+53
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
2025-03-19gccrs: Fix the parser's operand and flags storagebadumbatish5-28/+60
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
2025-03-19gccrs: Fixed bitwise operation in `extract_stmt`Kushal Pal1-1/+1
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>
2025-03-19gccrs: Move mbe macro tests to their own directoryPierre-Emmanuel Patry80-0/+35
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>
2025-03-19gccrs: Move builtin macro tests to their own directoryPierre-Emmanuel Patry16-31/+66
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>
2025-03-19gccrs: ffi-polonius: Remove usage of extern types.Arthur Cohen2-5/+8
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
2025-03-19gccrs: Move procedural macro test to their own directoryPierre-Emmanuel Patry22-0/+35
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>
2025-03-19gccrs: [gccrs#3045] #[may_dangle] in safe implLiam Naddell10-37/+122
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>
2025-03-19gccrs: Add rustc test directory for testsuite adaptorMuhammad Mahad2-0/+39
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>
2025-03-19gccrs: Properly striping struct fields when using attrsAntonio Gomes3-0/+55
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>
2025-03-19Fortran: Fix comp call in associate [PR119272]Andre Vehreschild2-2/+50
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.
2025-03-19i386: Fix up splitters into vptest [PR119357]Jakub Jelinek2-2/+18
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.
2025-03-19middle-end: update early-break tests for non-load-lanes targets [PR119286]Tamar Christina12-23/+23
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.
2025-03-19Remove mistakenly committed fileJakub Jelinek1-0/+0
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.
2025-03-19aarch64: Add +sve2p1 to -march=armv9.4-a flagsKyrylo Tkachov2-2/+2
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.
2025-03-19c++: Perform immediate invocation evaluation separately from cp_fold_r ↵Jakub Jelinek2-39/+52
[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.
2025-03-19Fix misoptimization at -O2 in LTO modeEric Botcazou1-0/+8
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.
2025-03-19c: Fix bug in typedef redefinitions of tagged types [PR118765]Martin Uecker2-2/+9
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.
2025-03-19c: Fix ICE in error recovery when checking struct compatibility [PR118061]Martin Uecker2-0/+11
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.
2025-03-19Fix spurious visibility error with partially parameterized formal packageEric Botcazou5-5/+91
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.
2025-03-19LoongArch: Add ABI names for FPRXi Ruoyao2-0/+46
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.
2025-03-18Mark gcc.target/i386/apx-ndd-tls-1b.c as xfail.liuhongt1-2/+5
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.