From: Owen Avery Date: Sun, 30 Apr 2023 06:57:15 +0000 (-0400) Subject: gccrs: Parse AttrInputMacro X-Git-Tag: basepoints/gcc-15~2529 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=efc6c1aa3c8e78e69b96ac0240b3fb46ce8e284e;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 5d48ba637d7a..3f2500660df6 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 ()) diff --git a/gcc/testsuite/rust/compile/doc_macro.rs b/gcc/testsuite/rust/compile/doc_macro.rs new file mode 100644 index 000000000000..6d76910830c5 --- /dev/null +++ b/gcc/testsuite/rust/compile/doc_macro.rs @@ -0,0 +1 @@ +#![doc = concat!("AB")]