diff options
-rw-r--r-- | gcc/rust/parse/rust-parse-impl.h | 15 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/doc_macro.rs | 1 |
2 files changed, 16 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 ()) diff --git a/gcc/testsuite/rust/compile/doc_macro.rs b/gcc/testsuite/rust/compile/doc_macro.rs new file mode 100644 index 0000000..6d76910 --- /dev/null +++ b/gcc/testsuite/rust/compile/doc_macro.rs @@ -0,0 +1 @@ +#![doc = concat!("AB")] |