aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2021-05-21 23:36:36 +0200
committerMarc Poulhiès <dkm@kataplop.net>2021-05-23 16:21:05 +0200
commit5467ac12d7bfd204cd4f1712ecefcbb9bcab6af8 (patch)
tree59a6832709427ef6a721c212051cd26cb8eaec5a /gcc/rust
parent99b73780e6e30f962c01532d3ec189ceeecf7f93 (diff)
downloadgcc-5467ac12d7bfd204cd4f1712ecefcbb9bcab6af8.zip
gcc-5467ac12d7bfd204cd4f1712ecefcbb9bcab6af8.tar.gz
gcc-5467ac12d7bfd204cd4f1712ecefcbb9bcab6af8.tar.bz2
Fix raw identifier parsing.
Lexer::parse_raw_identifier added the first character twice. Adds tests for a simple raw identifier, a keyword as raw identifier and xfail tests for a single underscore and forbidden keyword (crate) as raw identifier. To help error diagnostics continue after parse_raw_identifier failed in Lexer::build_token. Fixes: https://github.com/Rust-GCC/gccrs/issues/426
Diffstat (limited to 'gcc/rust')
-rw-r--r--gcc/rust/lex/rust-lex.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/gcc/rust/lex/rust-lex.cc b/gcc/rust/lex/rust-lex.cc
index f95a47d..16fb1ad 100644
--- a/gcc/rust/lex/rust-lex.cc
+++ b/gcc/rust/lex/rust-lex.cc
@@ -743,6 +743,9 @@ Lexer::build_token ()
TokenPtr raw_ident_ptr = parse_raw_identifier (loc);
if (raw_ident_ptr != nullptr)
return raw_ident_ptr;
+ else
+ continue; /* input got parsed, it just wasn't valid. An error
+ was produced. */
}
else
{
@@ -1523,11 +1526,9 @@ Lexer::parse_raw_identifier (Location loc)
current_column += 2;
- str += current_char;
-
bool first_is_underscore = current_char == '_';
- int length = 1;
+ int length = 0;
current_char = peek_input ();
// loop through entire name
while (ISALPHA (current_char) || ISDIGIT (current_char)