From: Tonu Naks <n...@adacore.com>

Underscore is allowed only between digits. The current implementattion
was considering 'E' as a digit even if it was not in the range of
Base and could denote exponent only.

gcc/ada/ChangeLog:

        * libgnat/s-valuer.adb (Scan_Decimal_Digits,
        Scan_Integral_Digits): fix condition for rejecting
        underscore.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/libgnat/s-valuer.adb | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/gcc/ada/libgnat/s-valuer.adb b/gcc/ada/libgnat/s-valuer.adb
index b8073c060b4..961dda47d77 100644
--- a/gcc/ada/libgnat/s-valuer.adb
+++ b/gcc/ada/libgnat/s-valuer.adb
@@ -287,7 +287,9 @@ package body System.Value_R is
             if Digit = Underscore and then Index + 1 <= Max then
 
                Digit := As_Digit (Str (Index + 1));
-               if Digit in Valid_Digit then
+               if Digit in Valid_Digit and then
+                  (Digit /= E_Digit or else Base > E_Digit)
+               then
                   Index := Index + 1;
                else
                   return;
@@ -437,7 +439,9 @@ package body System.Value_R is
 
             if Digit = Underscore and then Index + 1 <= Max then
                Digit := As_Digit (Str (Index + 1));
-               if Digit in Valid_Digit then
+               if Digit in Valid_Digit and then
+                  (Digit /= E_Digit or else Base > E_Digit)
+               then
                   Index := Index + 1;
                else
                   return;
-- 
2.43.0

Reply via email to