]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
11 months agoAdd pop guard for binder
badumbatish [Sat, 24 Aug 2024 05:21:05 +0000 (22:21 -0700)] 
Add pop guard for binder

gcc/rust/ChangeLog:

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

11 months agoAdd glibcxx_assertion check
badumbatish [Fri, 23 Aug 2024 04:46:05 +0000 (21:46 -0700)] 
Add glibcxx_assertion check

ChangeLog:

* .github/workflows/ccpp.yml:
Add glibcxx_assertion check

* .github/glibcxx_ubuntu64b_log_expected_warnings: New file.

11 months agoAdd running cicd 32bit
badumbatish [Sun, 4 Aug 2024 19:43:09 +0000 (12:43 -0700)] 
Add running cicd 32bit

ChangeLog:

* .github/alpine_32bit_log_warnings: New file.
* .github/workflows/ccpp32alpine.yml: New file.

gcc/rust/ChangeLog:

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

11 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>
11 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>
11 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>
11 months agofeature-gate: Cleanup visitor and constructor
Arthur Cohen [Wed, 21 Aug 2024 13:42:58 +0000 (15:42 +0200)] 
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.

11 months agoattributes: Start handling prelude_import properly
Arthur Cohen [Wed, 21 Aug 2024 13:09:23 +0000 (15:09 +0200)] 
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.

11 months agoFix the disorder struct and class in inline asm
badumbatish [Mon, 19 Aug 2024 23:39:11 +0000 (16:39 -0700)] 
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

11 months agoast: Introduce class hierarchy for lang item paths
Arthur Cohen [Mon, 24 Jun 2024 16:25:15 +0000 (18:25 +0200)] 
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.

11 months agoast: Remove PathExpr abstract class
Arthur Cohen [Mon, 24 Jun 2024 15:04:13 +0000 (17:04 +0200)] 
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.

11 months agoast: PathPattern: Remove `remove_all_segments` method
Arthur Cohen [Mon, 24 Jun 2024 14:50:43 +0000 (16:50 +0200)] 
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.

11 months agoAttempted to access a nonexistent field [E0609]
Muhammad Mahad [Thu, 15 Aug 2024 16:44:55 +0000 (16:44 +0000)] 
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>
11 months agoMove errors with locations
Kushal Pal [Mon, 12 Aug 2024 05:48:27 +0000 (05:48 +0000)] 
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>
11 months agoSubset errors with locations
Kushal Pal [Fri, 26 Jul 2024 07:40:58 +0000 (07:40 +0000)] 
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>
11 months agoMap locations to placeholder regions
Kushal Pal [Thu, 25 Jul 2024 11:57:35 +0000 (11:57 +0000)] 
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>
11 months agoFixed testcase
Kushal Pal [Mon, 12 Aug 2024 05:48:27 +0000 (05:48 +0000)] 
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>
12 months ago[#2324] Add error message for E0532
Liam Naddell [Sat, 3 Aug 2024 05:36:06 +0000 (01:36 -0400)] 
[#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>
12 months agoborrowck: Avoid overloading issues on 32bit architectures
Arthur Cohen [Fri, 2 Aug 2024 09:18:51 +0000 (11:18 +0200)] 
borrowck: Avoid overloading issues on 32bit architectures

On architectures where `size_t` is `unsigned int`, such as 32bit x86,
we encounter an issue with `PlaceId` and `FreeRegion` being aliases to
the same types. This poses an issue for overloading functions for these
two types, such as `push_subset` in that case. This commit renames one
of these `push_subset` functions to avoid the issue, but this should be
fixed with a newtype pattern for these two types.

gcc/rust/ChangeLog:

* checks/errors/borrowck/rust-bir-fact-collector.h (points): Rename
`push_subset(PlaceId, PlaceId)` to `push_subset_place(PlaceId, PlaceId)`

12 months agoborrowck: Fix debug prints on 32-bits architectures
Arthur Cohen [Fri, 2 Aug 2024 09:10:52 +0000 (11:10 +0200)] 
borrowck: Fix debug prints on 32-bits architectures

gcc/rust/ChangeLog:

* checks/errors/borrowck/rust-bir-builder.h: Cast size_t values to unsigned
long before printing.
* checks/errors/borrowck/rust-bir-fact-collector.h: Likewise.

12 months agoEager expansion for include* #1805 #1865
Liam Naddell [Sat, 27 Jul 2024 04:28:13 +0000 (00:28 -0400)] 
Eager expansion for include* #1805 #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

12 months agorust: avoid clobbering LIBS
Marc Poulhiès [Mon, 5 Aug 2024 08:43:05 +0000 (10:43 +0200)] 
rust: avoid clobbering LIBS

Save LIBS around calls to AC_SEARCH_LIBS to avoid clobbering $LIBS.

ChangeLog:

* configure: Regenerate.
* configure.ac: Save LIBS around calls to AC_SEARCH_LIBS.

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
Reviewed-by: Thomas Schwinge <tschwinge@baylibre.com>
Tested-by: Thomas Schwinge <tschwinge@baylibre.com>
12 months agoSimplify construction of BIR::Statement
Kushal Pal [Wed, 31 Jul 2024 01:37:54 +0000 (01:37 +0000)] 
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>
12 months agoLoan errors with locations
Kushal Pal [Thu, 18 Jul 2024 08:12:49 +0000 (08:12 +0000)] 
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>
12 months agoAdd location to BIR::Statement of kind RETURN
Kushal Pal [Fri, 19 Jul 2024 07:30:03 +0000 (07:30 +0000)] 
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>
12 months agoImplement resolve expr for inline asm ast
badumbatish [Wed, 31 Jul 2024 03:22:48 +0000 (20:22 -0700)] 
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.

12 months agoAdd location to BIR::Loan
Kushal Pal [Tue, 9 Jul 2024 10:37:27 +0000 (10:37 +0000)] 
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>
12 months agoAdd location support to BIR::Statement
Kushal Pal [Thu, 27 Jun 2024 01:18:54 +0000 (01:18 +0000)] 
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>
12 months agoTurn to switch case, use new helper functions
badumbatish [Tue, 30 Jul 2024 16:13:15 +0000 (09:13 -0700)] 
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.

12 months agoSet up the hir lowering for operand
badumbatish [Sat, 27 Jul 2024 08:19:11 +0000 (01:19 -0700)] 
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

12 months agoImprove compressed point bit manipulation
Kushal Pal [Wed, 31 Jul 2024 10:53:35 +0000 (10:53 +0000)] 
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>
12 months agoUse new constructors and control flow for operand
badumbatish [Tue, 30 Jul 2024 02:00:47 +0000 (19:00 -0700)] 
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

12 months agoFix the parser's operand and flags storage
badumbatish [Wed, 24 Jul 2024 05:17:12 +0000 (22:17 -0700)] 
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

12 months agoFixed bitwise operation in `extract_stmt`
Kushal Pal [Fri, 26 Jul 2024 07:51:43 +0000 (07:51 +0000)] 
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>
12 months agoMove mbe macro tests to their own directory
Pierre-Emmanuel Patry [Mon, 29 Jul 2024 12:27:32 +0000 (14:27 +0200)] 
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>
12 months agoMove builtin macro tests to their own directory
Pierre-Emmanuel Patry [Mon, 29 Jul 2024 12:20:01 +0000 (14:20 +0200)] 
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>
12 months agogithub: Remove nightly Rust installation
Arthur Cohen [Fri, 26 Jul 2024 09:06:36 +0000 (11:06 +0200)] 
github: Remove nightly Rust installation

ChangeLog:

* .github/workflows/ccpp.yml: Install Rust 1.72 instead of nightly.
* .github/workflows/bootstrap.yml: Likewise.

12 months agoffi-polonius: Remove usage of extern types.
Arthur Cohen [Fri, 26 Jul 2024 09:04:46 +0000 (11:04 +0200)] 
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

12 months agoMove procedural macro test to their own directory
Pierre-Emmanuel Patry [Thu, 25 Jul 2024 12:27:41 +0000 (14:27 +0200)] 
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>
12 months ago[#3045] #[may_dangle] in safe impl
Liam Naddell [Sun, 7 Jul 2024 00:34:28 +0000 (20:34 -0400)] 
[#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>
12 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>
12 months agoProperly striping struct fields when using attrs
Antonio Gomes [Fri, 19 Jul 2024 01:50:54 +0000 (22:50 -0300)] 
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>
12 months agogccrs: [E0576] Associated `item` not found in given `type`
Muhammad Mahad [Fri, 19 Jul 2024 13:42:03 +0000 (13:42 +0000)] 
gccrs: [E0576] Associated `item` not found in given `type`

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit):
Add rich error message and error code similiar to rustc with
associaed type and trait name

gcc/testsuite/ChangeLog:

* rust/compile/unknown-associated-item.rs: New test.

Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
12 months agoChange bug report issue template
Pierre-Emmanuel Patry [Mon, 22 Jul 2024 13:00:55 +0000 (15:00 +0200)] 
Change bug report issue template

ChangeLog:

* .github/ISSUE_TEMPLATE/bug_report.yml: New file.
* .github/ISSUE_TEMPLATE/bug_report.md: Deleted old template.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
12 months ago[#2987] Patch ICE when deriving Clone and Copy
Liam Naddell [Fri, 19 Jul 2024 18:19:26 +0000 (14:19 -0400)] 
[#2987] Patch ICE when deriving Clone and Copy

gcc/rust/ChangeLog:
* expand/rust-expand-visitor.cc:
Fix ICE caused by unique_ptr UB and buggy iterator use

gcc/testsuite/ChangeLog:
* rust/compile/issue-2987.rs:
Add test for deriving Clone and Copy at the same time

Signed-off-by: Liam Naddell <liam.naddell@mail.utoronto.ca>
12 months agoFix ffi and enum conventions
badumbatish [Tue, 23 Jul 2024 20:21:31 +0000 (13:21 -0700)] 
Fix ffi and enum conventions

gcc/rust/ChangeLog:

* ast/rust-fmt.h (enum ParseMode):
Drop typedef in Cpp

libgrust/ChangeLog:

* libformat_parser/generic_format_parser/src/lib.rs:
Remove repr(C)
* libformat_parser/src/bin.rs: Use ffi
* libformat_parser/src/lib.rs: pub ffi, create ParseMode and match
rustc's parse mode

12 months agoAdded options for ParseMode
badumbatish [Sat, 20 Jul 2024 07:44:26 +0000 (00:44 -0700)] 
Added options for ParseMode

gcc/rust/ChangeLog:

* ast/rust-fmt.cc (Pieces::collect):
Added options for ParseMode
* ast/rust-fmt.h (collect_pieces): Likewise.
(struct Pieces): Likewise.
* expand/rust-macro-builtins-format-args.cc (MacroBuiltin::format_args_handler):
Likewise.

libgrust/ChangeLog:

* libformat_parser/generic_format_parser/src/lib.rs: Likewise.
* libformat_parser/src/bin.rs: Likewise.
* libformat_parser/src/lib.rs: Likewise.

12 months agoChange assertion of constructor
badumbatish [Sun, 21 Jul 2024 22:41:21 +0000 (15:41 -0700)] 
Change assertion of constructor

Change the assert of (expr != nullptr) to
(this->expr != nullptr) because we assigned (std::move(expr)) to
this->expr, no need to assert expr

gcc/rust/ChangeLog:

* ast/rust-expr.h (struct AnonConst):
Change assertion of constructor
(struct InlineAsmOperand):
Change assertion of constructor

12 months ago[#3046] ICE on failing to find enum variant
Liam Naddell [Sat, 13 Jul 2024 00:56:08 +0000 (20:56 -0400)] 
[#3046] ICE on failing to find enum variant

gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-expr.cc:
Fix ICE caused by not finding enum variant by adding new error
message

gcc/testsuite/ChangeLog:
* rust/compile/issue-3046.rs:
Add test for new error message

Signed-off-by: Liam Naddell <liam.naddell@mail.utoronto.ca>
12 months agoFix CI bootstrap build with a nightly rust compiler
Pierre-Emmanuel Patry [Thu, 18 Jul 2024 09:01:55 +0000 (11:01 +0200)] 
Fix CI bootstrap build with a nightly rust compiler

The CI failed to compile some recent code that requires a nightly
feature. This change allows the CI to use a nightly compiler instead.

ChangeLog:

* .github/workflows/bootstrap.yml: Install nightly rustc.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
12 months agoUpdate pattern with \r* for dg-output tests
badumbatish [Wed, 17 Jul 2024 19:00:44 +0000 (12:00 -0700)] 
Update pattern with \r* for dg-output tests

First scan with "rg -v '\\r' gcc/testsuite/rust | rg 'dg-output'"

gcc/testsuite/ChangeLog:

* rust/execute/torture/issue-2187.rs:
Update pattern with \r* for dg-output tests
* rust/execute/xfail/macro1.rs: Likewise

12 months agoImprove error messages for operator expressions
Antonio Gomes [Sun, 14 Jul 2024 04:45:24 +0000 (01:45 -0300)] 
Improve error messages for operator expressions

gcc/rust/ChangeLog:
* hir/tree/rust-hir-expr.h: Add new get_operator_str method in
ArithmeticOrLogicalExpr and CompoundAssignmentExpr
* hir/tree/rust-hir.cc: Likewise
* typecheck/rust-hir-type-check-expr.cc: Improve error message for
operator expressions to display the correct operator symbol

gcc/testsuite/ChangeLog:
* rust/compile/shadow1.rs: Fix test for new error message

Signed-off-by: Antonio Gomes <antoniospg100@gmail.com>
12 months agoIntroduce new class to handle borrow errors
Kushal Pal [Fri, 28 Jun 2024 06:25:52 +0000 (06:25 +0000)] 
Introduce new class to handle borrow errors

gcc/rust/ChangeLog:

* Make-lang.in: Compile new file.
* checks/errors/borrowck/rust-borrow-checker.cc (BorrowChecker::go):
Use new class to report errors.
* checks/errors/borrowck/rust-borrow-checker-diagnostics.cc: New file.
* checks/errors/borrowck/rust-borrow-checker-diagnostics.h:
New file, adds new class.

Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
12 months agoFix nightly rustc warnings
Kushal Pal [Mon, 24 Jun 2024 12:07:30 +0000 (12:07 +0000)] 
Fix nightly rustc warnings

libgrust/ChangeLog:

* libformat_parser/Cargo.toml:
Used crate-type instead of depricated crate_type.
* libformat_parser/generic_format_parser/src/lib.rs:
Remove dead code.
* libformat_parser/src/lib.rs: Likewise.

Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
12 months agoAdded FFIVector to get Polonius output on C++ side
Kushal Pal [Wed, 5 Jun 2024 11:09:10 +0000 (11:09 +0000)] 
Added FFIVector to get Polonius output on C++ side

ChangeLog:

* .github/workflows/ccpp.yml: Switch to nightly version of rustc
to use unstable features, namely extern types for FFI.

gcc/rust/ChangeLog:

* Make-lang.in: Compile new file, rust-polonius.cc
* checks/errors/borrowck/ffi-polonius/src/gccrs_ffi.rs: Opaque
type to represent FFIVector from C++.
* checks/errors/borrowck/ffi-polonius/src/gccrs_ffi_generated.rs:
Change types of fields in Output.
* checks/errors/borrowck/ffi-polonius/src/lib.rs: Added helper
functions to contruct Polonius output on C++ side,
used helpers to contruct Polonius output on C++ side.
* checks/errors/borrowck/polonius/rust-polonius-ffi.h (make_vector):
FFIVector is a wrapper around std::vector for transfering data
from Rust to C++.
(struct Output): Use pointers to FFIVector instead of bool to
store Polonius output data.
* checks/errors/borrowck/polonius/rust-polonius.h (FFIVector__new):
Helper function.
(FFIVector__new_vec_pair): Likewise.
(FFIVector__new_vec_triple): Likewise.
(FFIVector__push): Likewise.
(FFIVector__push_vec_pair): Likewise.
(FFIVector__push_vec_triple): Likewise.
* checks/errors/borrowck/rust-borrow-checker.cc (BorrowChecker::go):
Convert FFIVector to std::vector representation for easier
navigation.
* checks/errors/borrowck/polonius/rust-polonius.cc: New file,
implementation of helper functions.

Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
12 months agorust: fix HIR dump for MatchExpr
Marc Poulhiès [Sun, 30 Jun 2024 21:11:17 +0000 (23:11 +0200)] 
rust: fix HIR dump for MatchExpr

The visitor was still using the as_string() method.

gcc/rust/ChangeLog:

* hir/rust-hir-dump.cc (Dump::do_matcharm): New.
(Dump::do_matchcase): New.
(Dump::visit(MatchExpr)): Adjust, don't use as_string.
* hir/rust-hir-dump.h (Dump::do_matcharm, Dump::do_matchcase): New.

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
12 months ago[#3051] Remove unnecessary #include from rust-expr.h
Liam Naddell [Tue, 2 Jul 2024 11:44:47 +0000 (07:44 -0400)] 
[#3051] Remove unnecessary #include from rust-expr.h

gcc/rust/ChangeLog:
* ast/rust-expr.h:
Remove unnecessary include.

Signed-off-by: Liam Naddell <liam.naddell@mail.utoronto.ca>
12 months agoPin node16 by allowing old version
badumbatish [Wed, 10 Jul 2024 02:30:45 +0000 (19:30 -0700)] 
Pin node16 by allowing old version

ChangeLog:

* .github/workflows/ccpp.yml:
Pin node16 by allowing old version

13 months agoSafe-guard InlineAsm structs
badumbatish [Mon, 1 Jul 2024 00:37:58 +0000 (17:37 -0700)] 
Safe-guard InlineAsm structs

gcc/rust/ChangeLog:

* ast/rust-expr.h (struct AnonConst):
Safe-guard InlineAsm structs
(struct InlineAsmOperand): Likewise.
* expand/rust-macro-builtins-asm.cc (parse_reg_operand_in):
Likewise.
(parse_reg_operand_out): Likewise.
(parse_reg_operand_inout): Likewise.

Signed-off-by: badumbatish <tanghocle456@gmail.com>
13 months agoStore parse result of parse_format_string(s)
badumbatish [Sun, 30 Jun 2024 00:12:33 +0000 (17:12 -0700)] 
Store parse result of parse_format_string(s)

gcc/rust/ChangeLog:

* ast/rust-expr.h (struct TupleTemplateStr):
Store parse result of parse_format_string(s)
* expand/rust-macro-builtins-asm.cc (parse_format_strings):
Likewise

Signed-off-by: badumbatish <tanghocle456@gmail.com>
13 months agoClean up monadic operations on expected<>
jjasmine [Wed, 26 Jun 2024 14:39:00 +0000 (07:39 -0700)] 
Clean up monadic operations on expected<>

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parse_asm):
Clean up monadic operations on expected<>

Signed-off-by: badumbatish <tanghocle456@gmail.com>
13 months agoAddresses warning, put warn unused in right place
jjasmine [Wed, 26 Jun 2024 04:29:13 +0000 (21:29 -0700)] 
Addresses warning, put warn unused in right place

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parse_reg_operand):
Addresses warning, put warn unused in right place
(parse_reg_operand_inout): Likewise.
(parse_asm_arg): Likewise.
* expand/rust-macro-builtins-asm.h (enum WARN_UNUSED_RESULT): Likewise.
(enum InlineAsmParseError): Likewise.
(validate): Likewise.
(parse_asm_arg): Likewise.
(parse_format_strings): Likewise.
(parse_clobber_abi): Likewise.
(parse_reg_operand): Likewise.
(parse_reg_operand_in): Likewise.
(parse_reg_operand_out): Likewise.
(parse_reg_operand_lateout): Likewise.
(parse_reg_operand_inout): Likewise.
(parse_reg_operand_inlateout): Likewise.
(parse_reg_operand_const): Likewise.
(parse_reg_operand_sym): Likewise.
(parse_reg_operand_unexpected): Likewise.
(parse_asm): Likewise.
(check_and_set): Likewise.
(parse_options): Likewise.
(parse_reg): Likewise.
(parse_format_string): Likewise.

Signed-off-by: badumbatish <tanghocle456@gmail.com>
13 months agoAdd WARN_UNUSED_RESULT parse error
jjasmine [Wed, 26 Jun 2024 03:33:22 +0000 (20:33 -0700)] 
Add WARN_UNUSED_RESULT parse error

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.h (enum InlineAsmParseError):
Add WARN_UNUSED_RESULT parse error
(enum WARN_UNUSED_RESULT): Likewise.

Signed-off-by: badumbatish <tanghocle456@gmail.com>
13 months agoAdded a test that is expected to fail
jjasmine [Mon, 17 Jun 2024 04:23:21 +0000 (21:23 -0700)] 
Added a test that is expected to fail

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parse_clobber_abi):
added comments
(parse_options): Likewise
(parse_asm_arg): Likewise
(parse_asm): Likewise
* expand/rust-macro-builtins-asm.h: Likewise

gcc/testsuite/ChangeLog:

* rust/compile/inline_asm_illegal_options.rs: new test
* rust/compile/inline_asm_illegal_operands.rs: New test.
This is expected to fail but we couldn't resolve parse_expr()'s
general functionality yet

Signed-off-by: badumbatish <tanghocle456@gmail.com>
13 months agoAdded tl::expected to parse_operand
jjasmine [Mon, 17 Jun 2024 03:40:06 +0000 (20:40 -0700)] 
Added tl::expected to parse_operand

Added tl::expected to parse_operand by implementing the validation
inside the parse_reg_operand function.

gcc/rust/ChangeLog:

* ast/rust-expr.h:
Added tl::expected to parse_operand
* expand/rust-macro-builtins-asm.cc (parse_reg): Likewise.
(parse_reg_operand): Likewise.
(parse_reg_operand_const): Likewise.
(parse_reg_operand_inout): Likewise.
(parse_asm_arg): Likewise.
* expand/rust-macro-builtins-asm.h: Likewise.

Signed-off-by: badumbatish <tanghocle456@gmail.com>
13 months agoScaffold expected on parse_options and asm_arg
jjasmine [Sun, 16 Jun 2024 18:03:23 +0000 (11:03 -0700)] 
Scaffold expected on parse_options and asm_arg

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (check_and_set):
Scaffold expected on parse_options and asm_arg
(parse_options): Likewise
(parse_asm_arg): Likewise
* expand/rust-macro-builtins-asm.h (check_and_set): Likewise
(parse_label): Likewise

Signed-off-by: badumbatish <tanghocle456@gmail.com>
13 months agoFinish expected parse_reg_operand
jjasmine [Sun, 16 Jun 2024 05:18:22 +0000 (22:18 -0700)] 
Finish expected parse_reg_operand

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parse_reg_operand_in):
Finish expected parse_reg_operand
(parse_reg_operand_unexpected): Likewise
* expand/rust-macro-builtins-asm.h (parse_reg_operand_unexpected): Likewise

Signed-off-by: badumbatish <tanghocle456@gmail.com>
13 months agoFinish incorporating expected of parse_reg_operand
jjasmine [Fri, 14 Jun 2024 06:06:01 +0000 (23:06 -0700)] 
Finish incorporating expected of parse_reg_operand

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parse_clobber_abi):
Finish incorporating expected of parse_reg_operand
(parse_reg): Likewise.
(parse_reg_operand): Likewise.
(parse_reg_operand_in): Likewise.
(parse_reg_operand_out): Likewise.
(parse_reg_operand_lateout): Likewise.
(parse_reg_operand_const): Likewise.
(parse_reg_operand_inout): Likewise.
(parse_reg_operand_sym): Likewise.
(MacroBuiltin::asm_handler): Likewise.
(parse_asm_arg): Likewise.
(parse_asm): Likewise.
(parse_format_strings): Likewise.
(validate): Likewise.
* expand/rust-macro-builtins-asm.h (class InlineAsmParseError): Likewise.
(enum InlineAsmParseError): Likewise.
(validate): Likewise.
(parse_format_strings): Likewise.
(parse_reg_operand_in): Likewise.
(parse_reg_operand_out): Likewise.
(parse_reg_operand_lateout): Likewise.
(parse_reg_operand_inout): Likewise.
(parse_reg_operand_inlateout): Likewise.
(parse_reg_operand_const): Likewise.
(parse_reg_operand_sym): Likewise.

13 months agoAdd RAW_STRING_LITERAL
ansh [Mon, 24 Jun 2024 11:01:53 +0000 (04:01 -0700)] 
Add RAW_STRING_LITERAL

gcc/rust/ChangeLog:

* ast/rust-ast-collector.cc (TokenCollector::visit):
Handle case for RAW_STRING_LITERAL.
* ast/rust-ast.cc (AttributeParser::parse_meta_item_inner):
Likewise.
(AttributeParser::parse_literal): Likewise.
* ast/rust-ast.h: Likewise.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_literal):
Likewise.
* lex/rust-lex.cc (Lexer::parse_raw_string): Likewise.
* lex/rust-token.cc (Token::as_string): Likewise.
* lex/rust-token.h (enum PrimitiveCoreType): Likewise.
* parse/rust-parse-impl.h (Parser::parse_attr_input): Likewise.
(Parser::parse_literal_expr): Likewise.
(Parser::parse_pattern_no_alt): Likewise.

Signed-off-by: ansh <anshmalik2002@gmail.com>
13 months agoAdded ExprType::InlineAsm
jjasmine [Sun, 23 Jun 2024 18:00:58 +0000 (11:00 -0700)] 
Added ExprType::InlineAsm

gcc/rust/ChangeLog:

* hir/tree/rust-hir-expr.h:
Added ExprType::InlineAsm
* hir/tree/rust-hir.h:
Added ExprType::InlineAsm

13 months agoAdd test case for using asm! outside of unsafe {}
jjasmine [Sat, 22 Jun 2024 06:38:10 +0000 (23:38 -0700)] 
Add test case for using asm! outside of unsafe {}

gcc/testsuite/ChangeLog:

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

13 months agoexpand: Switch semicolon boolean to an enum instead.
Arthur Cohen [Tue, 18 Jun 2024 11:47:57 +0000 (13:47 +0200)] 
expand: Switch semicolon boolean to an enum instead.

gcc/rust/ChangeLog:

* ast/rust-ast-fragment.h (enum class): Add InvocKind and AsmKind enums.
* ast/rust-macro.h: Switch semicolon boolean to InvocKind enum.
* expand/rust-expand-visitor.cc (ExpandVisitor::visit): Likewise.
* expand/rust-macro-builtins-asm.cc (MacroBuiltin::asm_handler): Likewise.
(parse_asm): Likewise.
* expand/rust-macro-builtins-asm.h (parse_asm): Likewise.
* expand/rust-macro-builtins-format-args.cc (MacroBuiltin::format_args_handler): Likewise.
* expand/rust-macro-builtins-include.cc (MacroBuiltin::include_bytes_handler): Likewise.
(MacroBuiltin::include_str_handler): Likewise.
(MacroBuiltin::include_handler): Likewise.
* expand/rust-macro-builtins-location.cc (MacroBuiltin::file_handler): Likewise.
(MacroBuiltin::column_handler): Likewise.
(MacroBuiltin::line_handler): Likewise.
* expand/rust-macro-builtins-log-debug.cc (MacroBuiltin::assert_handler): Likewise.
* expand/rust-macro-builtins-utility.cc (MacroBuiltin::compile_error_handler): Likewise.
(MacroBuiltin::concat_handler): Likewise.
(MacroBuiltin::env_handler): Likewise.
(MacroBuiltin::cfg_handler): Likewise.
(MacroBuiltin::stringify_handler): Likewise.
* expand/rust-macro-builtins.cc (format_args_maker): Likewise.
(enum class): Likewise.
(inline_asm_maker): Likewise.
(MacroBuiltin::sorry): Likewise.
(MacroBuiltin::proc_macro_builtin): Likewise.
* expand/rust-macro-builtins.h: Likewise.
* expand/rust-macro-expand.cc (MacroExpander::expand_decl_macro): Likewise.
(MacroExpander::expand_eager_invocations): Likewise.
(MacroExpander::expand_invoc): Likewise.
* expand/rust-macro-expand.h (struct MacroExpander): Likewise.

13 months agoexpand: Keep track of semicoloned builtin macros
Arthur Cohen [Fri, 14 Jun 2024 14:45:34 +0000 (16:45 +0200)] 
expand: Keep track of semicoloned builtin macros

This is quite a rough fix (like a lot of the macro expansion code...) but
it allows built-in macros to be treated as statements. I *think* asm!()
might be the only one where it really matters, but also doing something
like

{
    line!();
}

will now work, whereas before the macro invocation would not get expanded
properly and would be ignored.

gcc/rust/ChangeLog:

* ast/rust-ast-fragment.h: Pass `is_semicolon` information to builtin
macro transcribers.
* ast/rust-macro.h: Pass semicolon information to transcriber..
* expand/rust-macro-builtins-asm.cc (MacroBuiltin::asm_handler): Likewise.
(parse_asm): Likewise.
* expand/rust-macro-builtins-asm.h (parse_asm): Likewise.
* expand/rust-macro-builtins-format-args.cc (MacroBuiltin::format_args_handler): Likewise.
* expand/rust-macro-builtins-include.cc (MacroBuiltin::include_bytes_handler): Likewise.
(MacroBuiltin::include_str_handler): Likewise.
(MacroBuiltin::include_handler): Likewise.
* expand/rust-macro-builtins-location.cc (MacroBuiltin::file_handler): Likewise.
(MacroBuiltin::column_handler): Likewise.
(MacroBuiltin::line_handler): Likewise.
* expand/rust-macro-builtins-log-debug.cc (MacroBuiltin::assert_handler): Likewise.
* expand/rust-macro-builtins-utility.cc (MacroBuiltin::compile_error_handler): Likewise.
(MacroBuiltin::concat_handler): Likewise.
(MacroBuiltin::env_handler): Likewise.
(MacroBuiltin::cfg_handler): Likewise.
(MacroBuiltin::stringify_handler): Likewise.
* expand/rust-macro-builtins.cc (format_args_maker): Likewise.
(inline_asm_maker): Likewise.
(MacroBuiltin::sorry): Likewise.
(MacroBuiltin::proc_macro_builtin): Likewise.
* expand/rust-macro-builtins.h: Likewise.
* expand/rust-macro-expand.cc (MacroExpander::expand_decl_macro): Likewise.
(MacroExpander::expand_invoc): Likewise.
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Remove rust_unreachable.
* ast/rust-ast.cc (InlineAsm::accept_vis): Likewise.
* hir/tree/rust-hir.cc (InlineAsm::accept_vis): Likewise.

13 months agoFix optional trait parsing
dave [Wed, 15 Nov 2023 18:28:27 +0000 (12:28 -0600)] 
Fix optional trait parsing

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Check for ?Trait in visitor

gcc/testsuite/ChangeLog:

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

Signed-off-by: Dave Evans <dave@dmetwo.org>
13 months agoPartial second layer of expected in parsing asm
jjasmine [Wed, 12 Jun 2024 06:25:50 +0000 (23:25 -0700)] 
Partial second layer of expected in parsing asm

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parseDirSpec):
Partial second layer of expected in parsing asm
(parse_clobber_abi): Likewise
(parse_operand): Likewise
(parse_reg_operand): Likewise
(parse_asm_arg): Likewise
* expand/rust-macro-builtins-asm.h (parse_clobber_abi): Likewise
(parse_reg_operand): Likewise
(parse_operand): Likewise

13 months agoExpected first layer done
jjasmine [Wed, 12 Jun 2024 05:07:14 +0000 (22:07 -0700)] 
Expected first layer done

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parse_reg):
Expected first layer done
(parse_reg_operand): Likewise.
(parse_asm_arg): Likewise.
(parse_format_strings): Likewise.
(parse_asm): Likewise.
(validate): Likewise.
* expand/rust-macro-builtins-asm.h (parse_asm_arg): Likewise.
(validate): Likewise.
(parse_format_strings): Likewise.

13 months agoMove parser and last_token_id to InlineAsmCtx
jjasmine [Wed, 12 Jun 2024 00:56:20 +0000 (17:56 -0700)] 
Move parser and last_token_id to InlineAsmCtx

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parse_clobber_abi):
Move parser and last_token_id to InlineAsmCtx to prepapre
for tl::expected.
(parse_reg): Likewise.
(parse_operand): Likewise.
(parse_reg_operand): Likewise.
(check_and_set): Likewise.
(parse_options): Likewise.
(parse_format_string): Likewise.
(parse_asm_arg): Likewise.
(parse_asm): Likewise.
* expand/rust-macro-builtins-asm.h (class InlineAsmParseError): Likewise.
(parse_asm_arg): Likewise.
(check_and_set): Likewise.
(parse_operand): Likewise.
(parse_reg_operand): Likewise.
(parse_options): Likewise.
(parse_reg): Likewise.
(parse_clobber_abi): Likewise.
(parse_format_string): Likewise.

13 months agoUpdate parser to parse strings in the first stage
jjasmine [Tue, 11 Jun 2024 23:57:48 +0000 (16:57 -0700)] 
Update parser to parse strings in the first stage

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parse_reg_operand):
Update parser to parse strings in the first stage
(parse_label): not needed right now

13 months agoScaffolding validation of asm!
jjasmine [Tue, 11 Jun 2024 01:08:42 +0000 (18:08 -0700)] 
Scaffolding validation of asm!

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parse_asm):
Scaffolding validation of asm!
(validate): Likewise
* expand/rust-macro-builtins-asm.h (validate): Likewise

13 months agoPartial support for operand
jjasmine [Mon, 10 Jun 2024 23:54:34 +0000 (16:54 -0700)] 
Partial support for operand

gcc/rust/ChangeLog:

* ast/rust-expr.h (struct InlineAsmOperand):
Partial support for operand
* expand/rust-macro-builtins-asm.cc (parse_reg_operand): Likewise.
(parse_label): Likewise.
* expand/rust-macro-builtins-asm.h (parse_label): Likewise.

13 months agoRefactoring and supporting more parse_reg_operand
jjasmine [Mon, 10 Jun 2024 21:04:11 +0000 (14:04 -0700)] 
Refactoring and supporting more parse_reg_operand

gcc/rust/ChangeLog:

* ast/rust-expr.h (struct InlineAsmOperand):
Refactoring and supporting more parse_reg_operand
* expand/rust-macro-builtins-asm.cc (parse_reg_operand):
Likewise.
(rust_debug): Likewise.

13 months agoFix visitor-related warnings
jjasmine [Thu, 6 Jun 2024 01:12:49 +0000 (18:12 -0700)] 
Fix visitor-related warnings

gcc/rust/ChangeLog:

* ast/rust-ast-collector.cc (TokenCollector::visit):
Fix visitor-related warnings
* ast/rust-ast-collector.h: Likewise.
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Likewise.
* ast/rust-ast-visitor.h: Likewise.
* checks/errors/borrowck/rust-bir-builder-struct.h: Likewise.
* checks/errors/borrowck/rust-function-collector.h: Likewise.
* checks/errors/rust-const-checker.cc (ConstChecker::visit): Likewise.
* checks/errors/rust-const-checker.h: Likewise.
* expand/rust-derive.h: Likewise.
* expand/rust-macro-builtins-asm.cc (parse_reg_operand): Likewise.
* hir/rust-hir-dump.cc (Dump::visit): Likewise.
* hir/rust-hir-dump.h: Likewise.
* hir/tree/rust-hir-visitor.h: Likewise.
* resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Likewise.
* resolve/rust-ast-resolve-base.h: Likewise.

13 months agoAdd potentially_nonpromoted_keywords set str
jjasmine [Wed, 5 Jun 2024 15:24:50 +0000 (08:24 -0700)] 
Add potentially_nonpromoted_keywords set str

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parse_reg_operand):
Add potentially_nonpromoted_keywords set str
(check_identifier): likewise
* expand/rust-macro-builtins-asm.h (parse_format_string):
likewise

gcc/testsuite/ChangeLog:

* rust/compile/inline_asm_parse_operand.rs: fix warnings

13 months agoSuccessful parse of in and inout, albeit with str
jjasmine [Wed, 5 Jun 2024 06:14:19 +0000 (23:14 -0700)] 
Successful parse of in and inout, albeit with str

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parse_reg_operand):
Successful parse of in and inout, albeit with str
(check_identifier): Likewise.
(parse_asm_arg): Likewise.
* expand/rust-macro-builtins-asm.h (parse_format_string): Likewise.

gcc/testsuite/ChangeLog:

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

13 months agoScaffolding HIRFullVisitor for inline asm
jjasmine [Wed, 5 Jun 2024 03:17:23 +0000 (20:17 -0700)] 
Scaffolding HIRFullVisitor for inline asm

gcc/rust/ChangeLog:

* ast/rust-ast-visitor.h:
Scaffolding HIRFullVisitor for inline asm
* ast/rust-ast.cc (InlineAsm::accept_vis): Likewise.
* hir/tree/rust-hir-visitor.h (RUST_HIR_VISITOR_H): Likewise.
* hir/tree/rust-hir.cc (InlineAsm::accept_vis): Likewise.

13 months agoScaffolding ast visitor for InlineAsm
jjasmine [Wed, 5 Jun 2024 02:34:58 +0000 (19:34 -0700)] 
Scaffolding ast visitor for InlineAsm

gcc/rust/ChangeLog:

* ast/rust-ast-visitor.h:
Scaffolding ast visitor for InlineAsm
* ast/rust-ast.cc (InlineAsm::accept_vis): Likewise.
* ast/rust-expr.h: Likewise.

13 months agoFix warnings
jjasmine [Sat, 1 Jun 2024 02:34:49 +0000 (19:34 -0700)] 
Fix warnings

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parse_reg_operand):
Fix compile warnings.
(parse_options): Likewise.
(parse_asm): Likewise.

gcc/testsuite/ChangeLog:

* rust/compile/inline_asm_illegal_options.rs:

13 months agoPartial unsafe support for inline asm
jjasmine [Fri, 31 May 2024 23:09:40 +0000 (16:09 -0700)] 
Partial unsafe support for inline asm

gcc/rust/ChangeLog:

* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit):
Partial unsafe support for inline asm
* checks/errors/rust-unsafe-checker.h: Likewise.
* hir/tree/rust-hir-expr.h: Likewise.
* hir/tree/rust-hir.cc (InlineAsm::accept_vis): Likewise.

13 months agoAdd support for AST to HIR inline asm translation
jjasmine [Fri, 31 May 2024 21:55:45 +0000 (14:55 -0700)] 
Add support for AST to HIR inline asm translation

gcc/rust/ChangeLog:

* ast/rust-expr.h:
Add support for AST to HIR inline asm translation
* hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Likewise.
* hir/rust-ast-lower-base.h: Likewise.
* hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Likewise.
* hir/rust-ast-lower-expr.h: Likewise.
* hir/tree/rust-hir-expr.h (class InlineAsm): Likewise.

13 months agoSlim down the test cases
jjasmine [Fri, 31 May 2024 09:06:18 +0000 (02:06 -0700)] 
Slim down the test cases

gcc/testsuite/ChangeLog:

* rust/compile/inline_asm_faulty_clobber.rs: compress
the test
* rust/compile/inline_asm_nop.rs: compress
the test
* rust/compile/inline_asm_faulty_clobber_1.rs: Removed.
* rust/compile/inline_asm_faulty_clobber_2.rs: Removed.
* rust/compile/inline_asm_nop_2.rs: Removed.

13 months agoRefactoring for inline asm pr
jjasmine [Fri, 31 May 2024 09:01:18 +0000 (02:01 -0700)] 
Refactoring for inline asm pr

gcc/rust/ChangeLog:

* ast/rust-expr.h (struct AnonConst):
major refactoring of inline asm, mostly concerns
naming convention, trinary conditionals, warnings,
adding rust_unreachables in not-yet supported errors.
(struct InlineAsmRegOrRegClass): Likewise.
(struct InlineAsmOperand): Likewise.
* expand/rust-macro-builtins-asm.cc (parse_clobber_abi): Likewise.
(parse_reg): Likewise.
(parse_operand): Likewise.
(parse_reg_operand): Likewise.
(check_and_set): Likewise.
(parse_options): Likewise.
(parse_format_string): Likewise.
(parse_asm_arg): Likewise.
(parse_asm): Likewise.
* expand/rust-macro-builtins-asm.h (parse_asm_arg): Likewise.
(check_identifier): Likewise.
(check_and_set): Likewise.
(parse_operand): Likewise.
(parse_reg_operand): Likewise.
(parse_options): Likewise.
(parse_reg): Likewise.
(parse_clobber_abi): Likewise.
* expand/rust-macro-builtins.cc (enum class): Likewise.
(inline_asm_maker): Likewise.
* checks/errors/borrowck/ffi-polonius/Cargo.lock: Removed. Likewise.

gcc/testsuite/ChangeLog:
* rust/compile/inline_asm_faulty_clobber.rs: Likewise.
* rust/compile/inline_asm_faulty_clobber_1.rs: Likewise.
* rust/compile/inline_asm_faulty_clobber_2.rs: Likewise.
* rust/compile/inline_asm_illegal_options.rs: Likewise.

13 months agoGot AST::Fragment to be created from InlineAsm
jjasmine [Wed, 29 May 2024 04:56:19 +0000 (21:56 -0700)] 
Got AST::Fragment to be created from InlineAsm

gcc/rust/ChangeLog:

* ast/rust-expr.h (struct AnonConst):
Got AST::Fragment to be created from InlineAsm.
(struct InlineAsmOperand): Likewise.
(class InlineAsm): Likewise.
* expand/rust-macro-builtins-asm.cc (parse_reg_operand): Likewise.
(parse_asm): likewise

13 months agoWorking towards parse_reg and parse_reg_operand
jjasmine [Tue, 28 May 2024 08:21:07 +0000 (01:21 -0700)] 
Working towards parse_reg and parse_reg_operand

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parse_reg):
Working towards parse_reg and parse_reg_operand
(parse_reg_operand):
Working towards parse_reg and parse_reg_operand
(parse_asm_arg):
Add todo about errors
* expand/rust-macro-builtins-asm.h (parse_global_asm):
remove dead code.
(parse_nonglobal_asm):
remove dead code.

13 months agoRenamed parseAsmArg to conform to other function names
jjasmine [Tue, 28 May 2024 07:17:33 +0000 (00:17 -0700)] 
Renamed parseAsmArg to conform to other function names

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parseAsmArg):
Renamed parseAsmArg to conform to other function names
(parse_asm_arg): Likewise.
(parse_asm): Likewise.
* expand/rust-macro-builtins-asm.h (parseAsmArg): Likewise.
(parse_asm_arg): Likewise.

13 months agoBig Refactor after meeting
jjasmine [Tue, 28 May 2024 03:51:38 +0000 (20:51 -0700)] 
Big Refactor after meeting

gcc/rust/ChangeLog:

* ast/rust-expr.h (struct InlineAsmRegOrRegClass):
Remove union
(struct InlineAsmOperand): Make instances of inside struct.
* expand/rust-macro-builtins-asm.cc (parse_clobber_abi):
Change signature with inlineAsmCtx.
(parse_reg): Likewise.
(parse_operand): Likewise.
(parse_reg_operand): Likewise.
(check_and_set): Likewise.
(parse_options): Likewise.
(parse_format_string): Likewise.
(parseAsmArg): Likewise.
(parse_asm): Likewise.
* expand/rust-macro-builtins-asm.h (class InlineAsmContext): Likewise.
(parseAsmArg): Likewise.
(check_and_set): Likewise.
(parse_reg_operand): Likewise.
(parse_options): Likewise.
(parse_reg): Likewise.
(parse_clobber_abi): Likewise.

13 months agoRemove global_asm and non_global_asm handler
jjasmine [Fri, 24 May 2024 23:01:13 +0000 (16:01 -0700)] 
Remove global_asm and non_global_asm handler

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc
(MacroBuiltin::global_asm_handler):
Remove global_asm and non_global_asm handler
(MacroBuiltin::nonglobal_asm_handler): Likewise.
(MacroBuiltin::asm_handler): Likewise.
* expand/rust-macro-builtins.cc (enum class): Likewise.
(inline_asm_maker): Likewise.
* expand/rust-macro-builtins.h: Likewise.

13 months agoSafegaurd InlineAsm's clone_expr_...
jjasmine [Fri, 24 May 2024 22:35:16 +0000 (15:35 -0700)] 
Safegaurd InlineAsm's clone_expr_...

Safegaurd InlineAsm's clone_expr_... with unreachable since
we would never use them.

gcc/rust/ChangeLog:

* ast/rust-expr.h:
Safegaurd InlineAsm's clone_expr_... with unreachable.

13 months agoRename InlineAsmOptions to InlineAsmOption
jjasmine [Fri, 24 May 2024 22:31:48 +0000 (15:31 -0700)] 
Rename InlineAsmOptions to InlineAsmOption

Rename InlineAsmOptions to InlineAsmOption for clarity

gcc/rust/ChangeLog:

* ast/rust-ast-full-decls.h (enum class):
Rename InlineAsmOptions to InlineAsmOption for clarity
* ast/rust-expr.h (enum class): Likewise.
* expand/rust-macro-builtins-asm.cc (check_and_set): Likewise.
(parse_options): Likewise.
* expand/rust-macro-builtins-asm.h (check_and_set): Likewise.
* hir/tree/rust-hir-expr.h: Likewise.

13 months agoScaffolding parse_reg
jjasmine [Fri, 24 May 2024 22:18:45 +0000 (15:18 -0700)] 
Scaffolding parse_reg

gcc/rust/ChangeLog:

* ast/rust-expr.h (struct InlineAsmRegOrRegClass):
Scaffolding parse_reg
* expand/rust-macro-builtins-asm.cc (parse_reg): Likewise.
(parse_operand): Likewise.
(parseAsmArg): Likewise.

13 months agoResolve static decl warning
jjasmine [Wed, 22 May 2024 18:25:07 +0000 (11:25 -0700)] 
Resolve static decl warning

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.h (parseAsmArg):
Resolve static decl warning
(parse_nonglobal_asm):
Resolve static decl warning