]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Simplify construction of internal string from characters
authorPiotr Trojanek <trojanek@adacore.com>
Sun, 17 May 2026 11:39:12 +0000 (13:39 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 4 Jun 2026 08:42:19 +0000 (10:42 +0200)
Reuse a variant of Store_String_Char routine that accepts a Character parameter
and internally calls Get_Char_Code. Code cleanup.

gcc/ada/ChangeLog:

* exp_attr.adb (Expand_N_Attribute_Reference): Store chars without
converting the actual parameters.
* exp_ch11.adb (Null_String): Likewise.
* exp_disp.adb (Make_DT): Likewise.
* exp_util.adb (Fully_Qualified_Name_String): Likewise.
* sem_attr.adb (Analyze_Attribute): Likewise.
* sem_dist.adb (Full_Qualified_Name): Likewise.
* sem_prag.adb (Process_Interface_Name, Set_Encoded_Interface_Name):
Likewise.
* stringt.adb (Store_String_Chars): Likewise.

gcc/ada/exp_attr.adb
gcc/ada/exp_ch11.adb
gcc/ada/exp_disp.adb
gcc/ada/exp_util.adb
gcc/ada/sem_attr.adb
gcc/ada/sem_dist.adb
gcc/ada/sem_prag.adb
gcc/ada/stringt.adb

index d1b9510ce1205c9fec93af0f9ac545fe5dfcddbd..e5bd95d5a525e347005c0e080e8f48bf0073b658 100644 (file)
@@ -3391,7 +3391,7 @@ package body Exp_Attr is
                   if Name_Buffer (J) = '.' then
                      Store_String_Chars ("__");
                   else
-                     Store_String_Char (Get_Char_Code (Name_Buffer (J)));
+                     Store_String_Char (Name_Buffer (J));
                   end if;
                end loop;
 
index 2210437cfe952597c4d9cea63fa58317380150aa..ff312ec77009c772948244c358e51aac927df746 100644 (file)
@@ -1087,7 +1087,7 @@ package body Exp_Ch11 is
       function Null_String return String_Id is
       begin
          Start_String;
-         Store_String_Char (Get_Char_Code (ASCII.NUL));
+         Store_String_Char (ASCII.NUL);
          return End_String;
       end Null_String;
 
index 13fc8158e781468ac7275c78aa59398a76d14cc8..93bc7aef653dc46ad3480abadff996d32456db21 100644 (file)
@@ -5345,7 +5345,7 @@ package body Exp_Disp is
                   New_Val := Old_Val;
                else
                   Start_String (Old_Val);
-                  Store_String_Char (Get_Char_Code (ASCII.NUL));
+                  Store_String_Char (ASCII.NUL);
                   New_Val := End_String;
                end if;
 
index 172039b3a716ac19ab19b2faa73f5d0d23f02baf..842ed5998a35df755398ae02cd2588c654a3220a 100644 (file)
@@ -7401,7 +7401,7 @@ package body Exp_Util is
 
          if Present (Scope (Scope (Ent))) then
             Internal_Full_Qualified_Name (Scope (Ent));
-            Store_String_Char (Get_Char_Code ('.'));
+            Store_String_Char ('.');
          end if;
 
          --  Every entity should have a name except some expanded blocks
@@ -7426,7 +7426,7 @@ package body Exp_Util is
       Internal_Full_Qualified_Name (E);
 
       if Append_NUL then
-         Store_String_Char (Get_Char_Code (ASCII.NUL));
+         Store_String_Char (ASCII.NUL);
       end if;
 
       return End_String;
index 171dce197eaf9fc08269340f4c898e78311d23f7..dc6104602a35548c49609fae97f59d18f2e81c34 100644 (file)
@@ -7400,9 +7400,7 @@ package body Sem_Attr is
 
          --  Copy all characters in Full_Name
 
-         for J in 1 .. String_Length (Full_Name) loop
-            Store_String_Char (Get_String_Char (Full_Name, Pos (J)));
-         end loop;
+         Store_String_Chars (Full_Name);
 
          --  Compute CRC and convert it to string one character at a time, so
          --  as not to use Image within the compiler.
@@ -7501,14 +7499,14 @@ package body Sem_Attr is
                Start_String;
 
                if Negative then
-                  Store_String_Char (Get_Char_Code ('-'));
+                  Store_String_Char ('-');
                end if;
 
                S := Sloc (Expr);
                Src := Source_Text (Get_Source_File_Index (S));
 
                while Src (S) /= ';' and then Src (S) /= ' ' loop
-                  Store_String_Char (Get_Char_Code (Src (S)));
+                  Store_String_Char (Src (S));
                   S := S + 1;
                end loop;
 
index 05a6777dc2f5575dfdcf81e7abd53e9a1131c11c..c1efc696e8d5170ca506974f2746fb546fd2cad8 100644 (file)
@@ -188,7 +188,7 @@ package body Sem_Dist is
 
       if Parent_Name /= No_String then
          Start_String (Parent_Name);
-         Store_String_Char (Get_Char_Code ('.'));
+         Store_String_Char ('.');
       else
          Start_String;
       end if;
index 18c3315bcee75eb214e873ccf852d23ff547c837..24d61afd7e166177dc13dd957666b1a2d53ed515 100644 (file)
@@ -11540,7 +11540,7 @@ package body Sem_Prag is
 
          else
             Start_String;
-            Store_String_Char (Get_Char_Code ('*'));
+            Store_String_Char ('*');
             String_Val := Strval (Expr_Value_S (Link_Nam));
             Store_String_Chars (String_Val);
             Link_Nam :=
@@ -35827,15 +35827,11 @@ package body Sem_Prag is
 
       procedure Encode is
       begin
-         Store_String_Char (Get_Char_Code ('_'));
-         Store_String_Char
-           (Get_Char_Code (Hex (Integer (CC / 2 ** 12))));
-         Store_String_Char
-           (Get_Char_Code (Hex (Integer (CC / 2 ** 8 and 16#0F#))));
-         Store_String_Char
-           (Get_Char_Code (Hex (Integer (CC / 2 ** 4 and 16#0F#))));
-         Store_String_Char
-           (Get_Char_Code (Hex (Integer (CC and 16#0F#))));
+         Store_String_Char ('_');
+         Store_String_Char (Hex (Integer (CC / 2 ** 12)));
+         Store_String_Char (Hex (Integer (CC / 2 ** 8 and 16#0F#)));
+         Store_String_Char (Hex (Integer (CC / 2 ** 4 and 16#0F#)));
+         Store_String_Char (Hex (Integer (CC and 16#0F#)));
       end Encode;
 
    --  Start of processing for Set_Encoded_Interface_Name
index d9853140c7b973a295721c430b3dcc2719b583c8..6a9c448b8cc4bd97099e6c9c6e94d3796c24a997 100644 (file)
@@ -214,7 +214,7 @@ package body Stringt is
    procedure Store_String_Chars (S : String) is
    begin
       for J in S'First .. S'Last loop
-         Store_String_Char (Get_Char_Code (S (J)));
+         Store_String_Char (S (J));
       end loop;
    end Store_String_Chars;