https://gcc.gnu.org/g:a9ba0f18bded853cc6504b0843fe05c99c2f03fc

commit r16-1880-ga9ba0f18bded853cc6504b0843fe05c99c2f03fc
Author: Tonu Naks <n...@adacore.com>
Date:   Thu May 22 13:07:08 2025 +0000

    ada: Disallow underscore before exponent
    
    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.

Diff:
---
 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 b8073c060b47..961dda47d771 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;

Reply via email to