diff options
author | Owen Avery <powerboat9.gamer@gmail.com> | 2023-04-30 02:57:15 -0400 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-01-16 18:37:21 +0100 |
commit | efc6c1aa3c8e78e69b96ac0240b3fb46ce8e284e (patch) | |
tree | 48bdbb5783eb931bb34112555f8ea3c58d8d2e6a /gcc/rust/parse/rust-parse-impl.h | |
parent | de8eed9b8efea12d5b7987206e8e9fb0109966ca (diff) | |
download | gcc-efc6c1aa3c8e78e69b96ac0240b3fb46ce8e284e.zip gcc-efc6c1aa3c8e78e69b96ac0240b3fb46ce8e284e.tar.gz gcc-efc6c1aa3c8e78e69b96ac0240b3fb46ce8e284e.tar.bz2 |
gccrs: Parse AttrInputMacro
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h
(Parser::parse_attr_input): Parse AttrInputMacro.
gcc/testsuite/ChangeLog:
* rust/compile/doc_macro.rs: New test.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Diffstat (limited to 'gcc/rust/parse/rust-parse-impl.h')
-rw-r--r-- | gcc/rust/parse/rust-parse-impl.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 5d48ba6..3f25006 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -793,6 +793,21 @@ Parser<ManagedTokenSource>::parse_attr_input () t = lexer.peek_token (); + // attempt to parse macro + // TODO: macros may/may not be allowed in attributes + // this is needed for "#[doc = include_str!(...)]" + if (is_simple_path_segment (t->get_id ())) + { + std::unique_ptr<AST::MacroInvocation> invoke + = parse_macro_invocation ({}); + + if (!invoke) + return nullptr; + + return std::unique_ptr<AST::AttrInput> ( + new AST::AttrInputMacro (std::move (invoke))); + } + /* Ensure token is a "literal expression" (literally only a literal * token of any type) */ if (!t->is_literal ()) |