aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/expand/rust-macro-expand.cc
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-03-31 08:28:42 +0000
committerGitHub <noreply@github.com>2022-03-31 08:28:42 +0000
commitf9c1a14dab4c47c774f9c7661afc4bb2176eb9bb (patch)
tree3dd88710ab2a9e14b11af931fed15f4637ab4a48 /gcc/rust/expand/rust-macro-expand.cc
parentbd1f435b2310e61ed76d69063004c2aadb496255 (diff)
parent6bf428379d138f0efe7e72bff11bffa348eb8932 (diff)
downloadgcc-f9c1a14dab4c47c774f9c7661afc4bb2176eb9bb.zip
gcc-f9c1a14dab4c47c774f9c7661afc4bb2176eb9bb.tar.gz
gcc-f9c1a14dab4c47c774f9c7661afc4bb2176eb9bb.tar.bz2
Merge #1069
1069: Handle macro invocations in type contexts r=CohenArthur a=CohenArthur Closes #1067 This highlighted two issues where parsing types is not entirely correct, which I'll raise. The code necessary to handle macro invocations in these two places should already be implemented. Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
Diffstat (limited to 'gcc/rust/expand/rust-macro-expand.cc')
-rw-r--r--gcc/rust/expand/rust-macro-expand.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/rust/expand/rust-macro-expand.cc b/gcc/rust/expand/rust-macro-expand.cc
index 2620fea..852e619 100644
--- a/gcc/rust/expand/rust-macro-expand.cc
+++ b/gcc/rust/expand/rust-macro-expand.cc
@@ -909,6 +909,19 @@ transcribe_expression (Parser<MacroInvocLexer> &parser)
return {AST::SingleASTNode (std::move (expr))};
}
+/**
+ * Transcribe one type from a macro invocation
+ *
+ * @param parser Parser to extract statements from
+ */
+static std::vector<AST::SingleASTNode>
+transcribe_type (Parser<MacroInvocLexer> &parser)
+{
+ auto expr = parser.parse_type ();
+
+ return {AST::SingleASTNode (std::move (expr))};
+}
+
static std::vector<AST::SingleASTNode>
transcribe_on_delimiter (Parser<MacroInvocLexer> &parser, bool semicolon,
AST::DelimType delimiter, TokenId last_token_id)
@@ -957,6 +970,9 @@ transcribe_context (MacroExpander::ContextType ctx,
case MacroExpander::ContextType::EXTERN:
return transcribe_many_ext (parser, last_token_id);
break;
+ case MacroExpander::ContextType::TYPE:
+ return transcribe_type (parser);
+ break;
default:
return transcribe_on_delimiter (parser, semicolon, delimiter,
last_token_id);