[gcc r12-6237] [Ada] Simplify handling of user-defined numeric literals

Pierre-Marie de Rodat pmderodat@gcc.gnu.org
Wed Jan 5 11:34:28 GMT 2022


https://gcc.gnu.org/g:7c58372ad22f94d21b15ae2f2838e761b36b3486

commit r12-6237-g7c58372ad22f94d21b15ae2f2838e761b36b3486
Author: Piotr Trojanek <trojanek@adacore.com>
Date:   Wed Dec 1 15:53:45 2021 +0100

    [Ada] Simplify handling of user-defined numeric literals
    
    gcc/ada/
    
            * sem_util.adb (String_From_Numeric_Literal): Simplify using
            membership tests and ranges; fix whitespace.

Diff:
---
 gcc/ada/sem_util.adb | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 7064dfac8d8..bfe15fa96f6 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -28978,7 +28978,7 @@ package body Sem_Util is
                   Source_Text (Get_Source_File_Index (Loc));
       Src_Ptr : Source_Ptr := Loc;
 
-      C : Character  := Sbuffer (Src_Ptr);
+      C : Character := Sbuffer (Src_Ptr);
       --  Current source program character
 
       function Belongs_To_Numeric_Literal (C : Character) return Boolean;
@@ -28991,9 +28991,7 @@ package body Sem_Util is
       function Belongs_To_Numeric_Literal (C : Character) return Boolean is
       begin
          case C is
-            when '0' .. '9'
-               | '_' | '.' | 'e' | '#' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F'
-            =>
+            when '0' .. '9' | '_' | '.' | 'e' | '#' | 'A' .. 'F' =>
                return True;
 
             --  Make sure '+' or '-' is part of an exponent
@@ -29002,7 +29000,7 @@ package body Sem_Util is
                declare
                   Prev_C : constant Character := Sbuffer (Src_Ptr - 1);
                begin
-                  return Prev_C = 'e' or else Prev_C = 'E';
+                  return Prev_C in 'e' | 'E';
                end;
 
             --  Other characters cannot belong to a numeric literal


More information about the Gcc-cvs mailing list