aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-03-21 12:41:52 +0000
committerGitHub <noreply@github.com>2022-03-21 12:41:52 +0000
commit32894e6986523cb6b0d4225f820d80a725546c3a (patch)
tree5835b6f393524237bd007ad21d9651fa584c8809 /gcc
parent1bb9a29688ab4ddfec7f8d36ca2cee63c5f258d2 (diff)
parent80d96902421579b2ca7458027a0003da0271b4de (diff)
downloadgcc-32894e6986523cb6b0d4225f820d80a725546c3a.zip
gcc-32894e6986523cb6b0d4225f820d80a725546c3a.tar.gz
gcc-32894e6986523cb6b0d4225f820d80a725546c3a.tar.bz2
Merge #1042
1042: Parse reserved keywords as valid fragments identifiers r=CohenArthur a=CohenArthur Per the reference, macro fragments actually accept all identifiers, not NON_KEYWORD_IDENTIFIERS Fixes #1013 Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/parse/rust-parse-impl.h62
1 files changed, 59 insertions, 3 deletions
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index 82e7e24..644e789 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -1832,6 +1832,56 @@ Parser<ManagedTokenSource>::parse_macro_match ()
const_TokenPtr t2 = lexer.peek_token (1);
switch (t2->get_id ())
{
+ case ABSTRACT:
+ case AS:
+ case ASYNC:
+ case BECOME:
+ case BOX:
+ case BREAK:
+ case CONST:
+ case CONTINUE:
+ case CRATE:
+ case DO:
+ case DYN:
+ case ELSE:
+ case ENUM_TOK:
+ case EXTERN_TOK:
+ case FALSE_LITERAL:
+ case FINAL_TOK:
+ case FN_TOK:
+ case FOR:
+ case IF:
+ case IMPL:
+ case IN:
+ case LET:
+ case LOOP:
+ case MACRO:
+ case MATCH_TOK:
+ case MOD:
+ case MOVE:
+ case MUT:
+ case OVERRIDE_TOK:
+ case PRIV:
+ case PUB:
+ case REF:
+ case RETURN_TOK:
+ case SELF_ALIAS:
+ case SELF:
+ case STATIC_TOK:
+ case STRUCT_TOK:
+ case SUPER:
+ case TRAIT:
+ case TRUE_LITERAL:
+ case TRY:
+ case TYPE:
+ case TYPEOF:
+ case UNSAFE:
+ case UNSIZED:
+ case USE:
+ case VIRTUAL:
+ case WHERE:
+ case WHILE:
+ case YIELD:
case IDENTIFIER:
// macro fragment
return parse_macro_match_fragment ();
@@ -1877,8 +1927,14 @@ Parser<ManagedTokenSource>::parse_macro_match_fragment ()
Location fragment_locus = lexer.peek_token ()->get_locus ();
skip_token (DOLLAR_SIGN);
- const_TokenPtr ident_tok = expect_token (IDENTIFIER);
- if (ident_tok == nullptr)
+ Identifier ident = "";
+ auto identifier = lexer.peek_token ();
+ if (identifier->has_str ())
+ ident = identifier->get_str ();
+ else
+ ident = std::string (token_id_to_str (identifier->get_id ()));
+
+ if (ident.empty ())
{
Error error (lexer.peek_token ()->get_locus (),
"missing identifier in macro match fragment");
@@ -1886,7 +1942,7 @@ Parser<ManagedTokenSource>::parse_macro_match_fragment ()
return nullptr;
}
- Identifier ident = ident_tok->get_str ();
+ skip_token (identifier->get_id ());
if (!skip_token (COLON))
{