aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/parse/rust-parse.cc
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2022-03-24 13:50:03 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2022-03-24 13:56:23 +0100
commit912b04216d71a2cd95001cfb0570095db1824207 (patch)
tree71c5fcd9398ab535680db27cd48d8155fa0e874d /gcc/rust/parse/rust-parse.cc
parent8283724bc24efc0c11960947f2d4e99bc20b3765 (diff)
downloadgcc-912b04216d71a2cd95001cfb0570095db1824207.zip
gcc-912b04216d71a2cd95001cfb0570095db1824207.tar.gz
gcc-912b04216d71a2cd95001cfb0570095db1824207.tar.bz2
macros: Check follow-set restrictions on matcher's first delimiter
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 0153b37..900964e 100644
--- a/gcc/rust/parse/rust-parse.cc
+++ b/gcc/rust/parse/rust-parse.cc
@@ -202,9 +202,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: {