aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/expand/rust-macro-expand.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/rust/expand/rust-macro-expand.cc')
-rw-r--r--gcc/rust/expand/rust-macro-expand.cc14
1 files changed, 9 insertions, 5 deletions
diff --git a/gcc/rust/expand/rust-macro-expand.cc b/gcc/rust/expand/rust-macro-expand.cc
index a214ca9..df258bd 100644
--- a/gcc/rust/expand/rust-macro-expand.cc
+++ b/gcc/rust/expand/rust-macro-expand.cc
@@ -435,7 +435,7 @@ MacroExpander::match_fragment (Parser<MacroInvocLexer> &parser,
bool
MacroExpander::match_matcher (Parser<MacroInvocLexer> &parser,
- AST::MacroMatcher &matcher)
+ AST::MacroMatcher &matcher, bool in_repetition)
{
if (depth_exceeds_recursion_limit ())
{
@@ -485,8 +485,12 @@ MacroExpander::match_matcher (Parser<MacroInvocLexer> &parser,
// matched fragment get the offset in the token stream
size_t offs_end = source.get_offs ();
- sub_stack.insert_metavar (
- MatchedFragment (fragment->get_ident (), offs_begin, offs_end));
+ if (in_repetition)
+ sub_stack.append_fragment (
+ MatchedFragment (fragment->get_ident (), offs_begin, offs_end));
+ else
+ sub_stack.insert_metavar (
+ MatchedFragment (fragment->get_ident (), offs_begin, offs_end));
}
break;
@@ -509,7 +513,7 @@ MacroExpander::match_matcher (Parser<MacroInvocLexer> &parser,
AST::MacroMatcher *m
= static_cast<AST::MacroMatcher *> (match.get ());
expansion_depth++;
- if (!match_matcher (parser, *m))
+ if (!match_matcher (parser, *m, in_repetition))
{
expansion_depth--;
return false;
@@ -619,7 +623,7 @@ MacroExpander::match_n_matches (Parser<MacroInvocLexer> &parser,
case AST::MacroMatch::MacroMatchType::Matcher: {
AST::MacroMatcher *m
= static_cast<AST::MacroMatcher *> (match.get ());
- valid_current_match = match_matcher (parser, *m);
+ valid_current_match = match_matcher (parser, *m, true);
}
break;
}