From efc6c1aa3c8e78e69b96ac0240b3fb46ce8e284e Mon Sep 17 00:00:00 2001 From: Owen Avery Date: Sun, 30 Apr 2023 02:57:15 -0400 Subject: 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 --- gcc/rust/parse/rust-parse-impl.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'gcc/rust/parse/rust-parse-impl.h') 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::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 invoke + = parse_macro_invocation ({}); + + if (!invoke) + return nullptr; + + return std::unique_ptr ( + new AST::AttrInputMacro (std::move (invoke))); + } + /* Ensure token is a "literal expression" (literally only a literal * token of any type) */ if (!t->is_literal ()) -- cgit v1.1