aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/exp_util.adb
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2022-01-19 14:05:16 +0100
committerPierre-Marie de Rodat <derodat@adacore.com>2022-05-10 08:19:20 +0000
commit0e38fbfe1415e29d98bcdadc7307d589f496546b (patch)
treef03ff8212273d48c471fbb8a6f3db2a28a057a95 /gcc/ada/exp_util.adb
parent60ab3d0f2d9f95045543fea361e976351e76b5a1 (diff)
downloadgcc-0e38fbfe1415e29d98bcdadc7307d589f496546b.zip
gcc-0e38fbfe1415e29d98bcdadc7307d589f496546b.tar.gz
gcc-0e38fbfe1415e29d98bcdadc7307d589f496546b.tar.bz2
[Ada] Simplify conversion from Character to Char_Code
Replace "Char_Code (Character'Pos (...))" with "Get_Char_Code (...)". The Get_Char_Code routine is inlined, so there is no performance penalty when it is called with static actual parameters. The N_Character_Literal has field Char_Literal_Value of type Unat, but we should really only store there values from Char_Code type (e.g. there are no characters with negative ASCII codes). It seems cleaner to use UI_From_CC and not a more general UI_From_Int when setting the character literal values. Cleanup related to handling of character values in SPARK counterexamples, which just like the code for names in task arrays create N_Character_Literal nodes. gcc/ada/ * exp_prag.adb (Expand_Pragma_Import_Or_Interface): Use Get_Char_Code. * exp_util.adb (Build_Task_Array_Image): Simplify conversion to Char_Code. (Build_Task_Image_Prefix): Likewise. (Build_Task_Record_Image): Likewise. * cstand.adb (Create_Standard): Use UI_From_Int instead of UI_From_CC. * exp_ch11.adb (Expand_N_Exception_Declaration): Likewise. * sem_res.adb (Patch_Up_Value): Likewise. * stringt.adb (Write_String_Table_Entry): Use Get_Char_Code.
Diffstat (limited to 'gcc/ada/exp_util.adb')
-rw-r--r--gcc/ada/exp_util.adb16
1 files changed, 8 insertions, 8 deletions
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
index 30c293c..263b42f 100644
--- a/gcc/ada/exp_util.adb
+++ b/gcc/ada/exp_util.adb
@@ -4183,7 +4183,7 @@ package body Exp_Util is
Build_Task_Image_Prefix (Loc, Len, Res, Pos, Pref, Sum, Decls, Stats);
- Set_Character_Literal_Name (Char_Code (Character'Pos ('(')));
+ Set_Character_Literal_Name (Get_Char_Code ('('));
Append_To (Stats,
Make_Assignment_Statement (Loc,
@@ -4194,7 +4194,7 @@ package body Exp_Util is
Expression =>
Make_Character_Literal (Loc,
Chars => Name_Find,
- Char_Literal_Value => UI_From_Int (Character'Pos ('(')))));
+ Char_Literal_Value => UI_From_CC (Get_Char_Code ('(')))));
Append_To (Stats,
Make_Assignment_Statement (Loc,
@@ -4244,7 +4244,7 @@ package body Exp_Util is
Expressions =>
New_List (Make_Integer_Literal (Loc, 1))))));
- Set_Character_Literal_Name (Char_Code (Character'Pos (',')));
+ Set_Character_Literal_Name (Get_Char_Code (','));
Append_To (Stats,
Make_Assignment_Statement (Loc,
@@ -4254,7 +4254,7 @@ package body Exp_Util is
Expression =>
Make_Character_Literal (Loc,
Chars => Name_Find,
- Char_Literal_Value => UI_From_Int (Character'Pos (',')))));
+ Char_Literal_Value => UI_From_CC (Get_Char_Code (',')))));
Append_To (Stats,
Make_Assignment_Statement (Loc,
@@ -4266,7 +4266,7 @@ package body Exp_Util is
end if;
end loop;
- Set_Character_Literal_Name (Char_Code (Character'Pos (')')));
+ Set_Character_Literal_Name (Get_Char_Code (')'));
Append_To (Stats,
Make_Assignment_Statement (Loc,
@@ -4277,7 +4277,7 @@ package body Exp_Util is
Expression =>
Make_Character_Literal (Loc,
Chars => Name_Find,
- Char_Literal_Value => UI_From_Int (Character'Pos (')')))));
+ Char_Literal_Value => UI_From_CC (Get_Char_Code (')')))));
return Build_Task_Image_Function (Loc, Decls, Stats, Res);
end Build_Task_Array_Image;
@@ -4569,7 +4569,7 @@ package body Exp_Util is
Build_Task_Image_Prefix (Loc, Len, Res, Pos, Pref, Sum, Decls, Stats);
- Set_Character_Literal_Name (Char_Code (Character'Pos ('.')));
+ Set_Character_Literal_Name (Get_Char_Code ('.'));
-- Res (Pos) := '.';
@@ -4582,7 +4582,7 @@ package body Exp_Util is
Make_Character_Literal (Loc,
Chars => Name_Find,
Char_Literal_Value =>
- UI_From_Int (Character'Pos ('.')))));
+ UI_From_CC (Get_Char_Code ('.')))));
Append_To (Stats,
Make_Assignment_Statement (Loc,