]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Disallow underscore before exponent
authorTonu Naks <naks@adacore.com>
Thu, 22 May 2025 13:07:08 +0000 (13:07 +0000)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 1 Jul 2025 08:29:44 +0000 (10:29 +0200)
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.

gcc/ada/libgnat/s-valuer.adb

index b8073c060b47a2312313aed932db0b35af84a4de..961dda47d771c0c474a79e88ebbf979c4b0c902d 100644 (file)
@@ -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;