aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2024-07-30Move 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>
2024-07-29ffi-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
2024-07-26Move 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>
2024-07-25[#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>
2024-07-25gccrs: 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>
2024-07-25Properly 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>
2024-07-24gccrs: [E0576] Associated `item` not found in given `type`Muhammad Mahad2-1/+21
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>
2024-07-24[#2987] Patch ICE when deriving Clone and CopyLiam Naddell2-8/+26
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>
2024-07-24Fix ffi and enum conventionsbadumbatish1-3/+3
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
2024-07-24Added options for ParseModebadumbatish3-6/+17
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.
2024-07-24Change assertion of constructorbadumbatish1-11/+14
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
2024-07-18[#3046] ICE on failing to find enum variantLiam Naddell2-1/+31
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>
2024-07-18Update pattern with \r* for dg-output testsbadumbatish2-3/+2
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
2024-07-17Improve error messages for operator expressionsAntonio Gomes4-6/+25
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>
2024-07-16Introduce new class to handle borrow errorsKushal Pal4-17/+142
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>
2024-07-16Added FFIVector to get Polonius output on C++ sideKushal Pal8-13/+258
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>
2024-07-15rust: fix HIR dump for MatchExprMarc Poulhiès2-7/+38
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>
2024-07-11[#3051] Remove unnecessary #include from rust-expr.hLiam Naddell1-2/+0
gcc/rust/ChangeLog: * ast/rust-expr.h: Remove unnecessary include. Signed-off-by: Liam Naddell <liam.naddell@mail.utoronto.ca>
2024-07-03Safe-guard InlineAsm structsbadumbatish2-66/+53
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>
2024-07-01Store parse result of parse_format_string(s)badumbatish2-3/+21
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>
2024-06-28Clean up monadic operations on expected<>jjasmine1-5/+3
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parse_asm): Clean up monadic operations on expected<> Signed-off-by: badumbatish <tanghocle456@gmail.com>
2024-06-28Addresses warning, put warn unused in right placejjasmine2-11/+34
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>
2024-06-28Add WARN_UNUSED_RESULT parse errorjjasmine1-1/+2
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>
2024-06-28Added a test that is expected to failjjasmine4-31/+60
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>
2024-06-28Added tl::expected to parse_operandjjasmine3-16/+82
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>
2024-06-28Scaffold expected on parse_options and asm_argjjasmine2-16/+28
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>
2024-06-28Finish expected parse_reg_operandjjasmine2-36/+35
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>
2024-06-28Finish incorporating expected of parse_reg_operandjjasmine2-97/+180
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.
2024-06-27Add RAW_STRING_LITERALansh8-1/+45
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>
2024-06-24Added ExprType::InlineAsmjjasmine2-2/+2
gcc/rust/ChangeLog: * hir/tree/rust-hir-expr.h: Added ExprType::InlineAsm * hir/tree/rust-hir.h: Added ExprType::InlineAsm
2024-06-24Add test case for using asm! outside of unsafe {}jjasmine1-0/+11
gcc/testsuite/ChangeLog: * rust/compile/inline_asm_outside_unsafe.rs: New test.
2024-06-18expand: Switch semicolon boolean to an enum instead.Arthur Cohen14-73/+105
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.
2024-06-18expand: Keep track of semicoloned builtin macrosArthur Cohen15-64/+94
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.
2024-06-17Fix optional trait parsingdave2-0/+21
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>
2024-06-13Partial second layer of expected in parsing asmjjasmine2-69/+37
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
2024-06-13Expected first layer donejjasmine2-36/+61
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.
2024-06-13Move parser and last_token_id to InlineAsmCtxjjasmine2-69/+70
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.
2024-06-13Update parser to parse strings in the first stagejjasmine1-49/+13
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
2024-06-13Scaffolding validation of asm!jjasmine2-7/+27
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
2024-06-13Partial support for operandjjasmine3-7/+97
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.
2024-06-13Refactoring and supporting more parse_reg_operandjjasmine2-52/+144
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.
2024-06-13Fix visitor-related warningsjjasmine15-6/+54
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.
2024-06-13Add potentially_nonpromoted_keywords set strjjasmine3-84/+110
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
2024-06-13Successful parse of in and inout, albeit with strjjasmine3-10/+130
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.
2024-06-13Scaffolding HIRFullVisitor for inline asmjjasmine4-3/+11
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.
2024-06-13Scaffolding ast visitor for InlineAsmjjasmine3-1/+10
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.
2024-06-13Fix warningsjjasmine2-3/+10
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:
2024-06-13Partial unsafe support for inline asmjjasmine4-2/+23
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.
2024-06-13Add support for AST to HIR inline asm translationjjasmine6-2/+89
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.
2024-06-13Slim down the test casesjjasmine5-36/+3
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.