aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/parse/rust-parse.cc
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-03-25 07:55:29 +0000
committerGitHub <noreply@github.com>2022-03-25 07:55:29 +0000
commit89ad4f21f25a2501bb9bb96338be4a6edb89bbcd (patch)
tree710a2d0cf0111d2a8a47afde891012d766adbb74 /gcc/rust/parse/rust-parse.cc
parent0fa882160df40cee56b5cdd0a2953b4abb4b9d18 (diff)
parent912b04216d71a2cd95001cfb0570095db1824207 (diff)
downloadgcc-89ad4f21f25a2501bb9bb96338be4a6edb89bbcd.zip
gcc-89ad4f21f25a2501bb9bb96338be4a6edb89bbcd.tar.gz
gcc-89ad4f21f25a2501bb9bb96338be4a6edb89bbcd.tar.bz2
Merge #1062
1062: Properly perform follow set checking on matcher r=CohenArthur a=CohenArthur Addresses #947 Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
Diffstat (limited to 'gcc/rust/parse/rust-parse.cc')
-rw-r--r--gcc/rust/parse/rust-parse.cc22
1 files changed, 19 insertions, 3 deletions
diff --git a/gcc/rust/parse/rust-parse.cc b/gcc/rust/parse/rust-parse.cc
index 50d2efe..ec633f3 100644
--- a/gcc/rust/parse/rust-parse.cc
+++ b/gcc/rust/parse/rust-parse.cc
@@ -227,9 +227,25 @@ peculiar_fragment_match_compatible (AST::MacroMatchFragment &last_match,
}
case AST::MacroMatch::Matcher: {
auto matcher = static_cast<AST::MacroMatcher *> (&match);
- auto &matches = matcher->get_matches ();
- if (!matches.empty ())
- error_locus = matches.front ()->get_match_locus ();
+ auto first_token = matcher->get_delim_type ();
+ TokenId delim_id;
+ switch (first_token)
+ {
+ case AST::PARENS:
+ delim_id = LEFT_PAREN;
+ break;
+ case AST::SQUARE:
+ delim_id = LEFT_SQUARE;
+ break;
+ case AST::CURLY:
+ delim_id = LEFT_CURLY;
+ break;
+ }
+ if (contains (allowed_toks, delim_id))
+ return true;
+ kind_str = "token `" + std::string (get_token_description (delim_id))
+ + "` at start of matcher";
+ error_locus = matcher->get_match_locus ();
break;
}
case AST::MacroMatch::Fragment: {