aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2022-01-19 13:35:46 +0100
committerPierre-Marie de Rodat <derodat@adacore.com>2022-05-10 08:19:22 +0000
commitd979a676fde85a362cb8d7b142300a494370f3e9 (patch)
tree95175516735f2af45962b97a05b4d797620d5443 /gcc
parent5046228671e991170c19c1c0d9f70a51026e2cab (diff)
downloadgcc-d979a676fde85a362cb8d7b142300a494370f3e9.zip
gcc-d979a676fde85a362cb8d7b142300a494370f3e9.tar.gz
gcc-d979a676fde85a362cb8d7b142300a494370f3e9.tar.bz2
[Ada] Replace variables with constants in expanded code for task names
Using constants instead of variables is cleaner both in human-written and auto-generated code. Cleanup related to handling of character values in SPARK counterexamples, which just like the code for names of tasks create N_Character_Literal nodes. gcc/ada/ * exp_util.adb (Build_Task_Array_Image): Declare expanded objects as constants. (Build_Task_Image_Prefix): Likewise. (Build_Task_Record_Image): Likewise.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/exp_util.adb18
1 files changed, 12 insertions, 6 deletions
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
index b3d1fdf..c28723c 100644
--- a/gcc/ada/exp_util.adb
+++ b/gcc/ada/exp_util.adb
@@ -4049,11 +4049,13 @@ package body Exp_Util is
-- function F return String is
-- Pref : String renames Task_Name;
- -- T1 : String := Index1'Image (Val1);
+ -- T1 : constant String := Index1'Image (Val1);
-- ...
- -- Tn : String := Indexn'Image (Valn);
- -- Len : Integer := Pref'Length + T1'Length + ... + Tn'Length + n + 1;
+ -- Tn : constant String := Indexn'Image (Valn);
+ -- Len : constant Integer :=
+ -- Pref'Length + T1'Length + ... + Tn'Length + n + 1;
-- -- Len includes commas and the end parentheses
+ --
-- Res : String (1 .. Len);
-- Pos : Integer := Pref'Length;
--
@@ -4124,8 +4126,9 @@ package body Exp_Util is
Append_To (Decls,
Make_Object_Declaration (Loc,
Defining_Identifier => Pref,
- Object_Definition => New_Occurrence_Of (Standard_String, Loc),
- Expression =>
+ Constant_Present => True,
+ Object_Definition => New_Occurrence_Of (Standard_String, Loc),
+ Expression =>
Make_String_Literal (Loc,
Strval => String_From_Name_Buffer)));
@@ -4148,6 +4151,7 @@ package body Exp_Util is
Make_Object_Declaration (Loc,
Defining_Identifier => T,
Object_Definition => New_Occurrence_Of (Standard_String, Loc),
+ Constant_Present => True,
Expression =>
Make_Attribute_Reference (Loc,
Attribute_Name => Name_Image,
@@ -4425,6 +4429,7 @@ package body Exp_Util is
Append_To (Decls,
Make_Object_Declaration (Loc,
Defining_Identifier => Len,
+ Constant_Present => True,
Object_Definition => New_Occurrence_Of (Standard_Integer, Loc),
Expression => Sum));
@@ -4530,7 +4535,8 @@ package body Exp_Util is
Append_To (Decls,
Make_Object_Declaration (Loc,
Defining_Identifier => Pref,
- Object_Definition => New_Occurrence_Of (Standard_String, Loc),
+ Constant_Present => True,
+ Object_Definition => New_Occurrence_Of (Standard_String, Loc),
Expression =>
Make_String_Literal (Loc,
Strval => String_From_Name_Buffer)));