diff options
author | jjasmine <tanghocle456@gmail.com> | 2024-06-10 18:08:42 -0700 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-17 16:35:47 +0100 |
commit | 2e62553cb02afc77d40c0f55c08bae26cd3a0b32 (patch) | |
tree | 7ea62979309855eef5449da957271615f3a8ff5e /gcc/rust/expand/rust-macro-builtins-asm.cc | |
parent | c1662670f70e8c06164da58a2b020dcd89ae75d6 (diff) | |
download | gcc-2e62553cb02afc77d40c0f55c08bae26cd3a0b32.zip gcc-2e62553cb02afc77d40c0f55c08bae26cd3a0b32.tar.gz gcc-2e62553cb02afc77d40c0f55c08bae26cd3a0b32.tar.bz2 |
gccrs: 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
Diffstat (limited to 'gcc/rust/expand/rust-macro-builtins-asm.cc')
-rw-r--r-- | gcc/rust/expand/rust-macro-builtins-asm.cc | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/gcc/rust/expand/rust-macro-builtins-asm.cc b/gcc/rust/expand/rust-macro-builtins-asm.cc index 47a4760..3073761 100644 --- a/gcc/rust/expand/rust-macro-builtins-asm.cc +++ b/gcc/rust/expand/rust-macro-builtins-asm.cc @@ -703,13 +703,26 @@ parse_asm (location_t invoc_locus, AST::MacroInvocData &invoc, // operands stream, also handles the optional "," parse_asm_arg (parser, last_token_id, inline_asm_ctx); - AST::SingleASTNode single = AST::SingleASTNode ( - inline_asm_ctx.inline_asm.clone_expr_without_block ()); - std::vector<AST::SingleASTNode> single_vec = {single}; + // TODO: I'm putting the validation here because the rust reference put it + // here Per Arthur's advice we would actually do the validation in a different + // stage. and visit on the InlineAsm AST instead of it's context. + auto is_valid = validate (inline_asm_ctx); - AST::Fragment fragment_ast - = AST::Fragment (single_vec, std::vector<std::unique_ptr<AST::Token>> ()); - return fragment_ast; + if (is_valid) + { + AST::SingleASTNode single = AST::SingleASTNode ( + inline_asm_ctx.inline_asm.clone_expr_without_block ()); + std::vector<AST::SingleASTNode> single_vec = {single}; + + AST::Fragment fragment_ast + = AST::Fragment (single_vec, + std::vector<std::unique_ptr<AST::Token>> ()); + return fragment_ast; + } + else + { + return tl::nullopt; + } } tl::optional<std::string> @@ -749,4 +762,10 @@ parse_label (Parser<MacroInvocLexer> &parser, TokenId last_token_id, return tl::nullopt; } } + +bool +validate (InlineAsmContext &inline_asm_ctx) +{ + return true; +} } // namespace Rust |