]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: fix lexer exponent output on tuple indices
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Thu, 3 Aug 2023 13:28:40 +0000 (15:28 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 18:00:32 +0000 (19:00 +0100)
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>
gcc/rust/lex/rust-lex.cc

index 53895c1419921fabaaa962eaed787d986191efd4..8142aa0cf7829c93d8bb168784d79920a0e2a952 100644 (file)
@@ -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