aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-08-03 15:28:40 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 19:00:32 +0100
commita7eacd8879e422485a0044be37d03a05d3ed262e (patch)
treef9851883cd196f74e47f3f0f5954b45e35693f31 /gcc
parentcdddf7baff74af1542788868d1cfab6dc435f2ef (diff)
downloadgcc-a7eacd8879e422485a0044be37d03a05d3ed262e.zip
gcc-a7eacd8879e422485a0044be37d03a05d3ed262e.tar.gz
gcc-a7eacd8879e422485a0044be37d03a05d3ed262e.tar.bz2
gccrs: fix lexer exponent output on tuple indices
The lexer did output a literal for values such as 42.e wich are invalid in rust. gcc/rust/ChangeLog: * lex/rust-lex.cc (Lexer::parse_decimal_int_or_float): Only accept digits after a dot instead of accepting any float member. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/lex/rust-lex.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/gcc/rust/lex/rust-lex.cc b/gcc/rust/lex/rust-lex.cc
index 53895c1..8142aa0 100644
--- a/gcc/rust/lex/rust-lex.cc
+++ b/gcc/rust/lex/rust-lex.cc
@@ -2295,7 +2295,17 @@ Lexer::parse_decimal_int_or_float (location_t loc)
length += std::get<1> (initial_decimal);
// detect float literal
- if (current_char == '.' && is_float_digit (peek_input (1).value))
+ //
+ // Note:
+ //
+ // We should not use is_float_digit () for this verification but instead
+ // directly ISDIGIT because rust does not support non digit values right after
+ // a dot.
+ // The following value is not legal in rust:
+ // let a = 3.e1;
+ // A `0` should be put between the dot and the exponent to be valid
+ // (eg. 3.0e1).
+ if (current_char == '.' && ISDIGIT (peek_input (1).value))
{
// float with a '.', parse another decimal into it