aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorOwen Avery <powerboat9.gamer@gmail.com>2023-04-30 02:57:15 -0400
committerCohenArthur <arthur.cohen@embecosm.com>2023-05-18 20:44:20 +0000
commitc7b7e297ea4b688ef9fb51a8aee2a8b2af39ac1c (patch)
treefddf230a0837b26bd663fd5e741e282eb3f5afbb /gcc
parent4ddb7d143bc30fe65b29954ff8c911f7ed38b6fb (diff)
downloadgcc-c7b7e297ea4b688ef9fb51a8aee2a8b2af39ac1c.zip
gcc-c7b7e297ea4b688ef9fb51a8aee2a8b2af39ac1c.tar.gz
gcc-c7b7e297ea4b688ef9fb51a8aee2a8b2af39ac1c.tar.bz2
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')
-rw-r--r--gcc/rust/parse/rust-parse-impl.h15
-rw-r--r--gcc/testsuite/rust/compile/doc_macro.rs1
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 dbb322b..af967b5 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")]