public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-228] [Ada] Replace variables with constants in expanded code for task names
@ 2022-05-10 8:21 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-05-10 8:21 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:d979a676fde85a362cb8d7b142300a494370f3e9
commit r13-228-gd979a676fde85a362cb8d7b142300a494370f3e9
Author: Piotr Trojanek <trojanek@adacore.com>
Date: Wed Jan 19 13:35:46 2022 +0100
[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.
Diff:
---
gcc/ada/exp_util.adb | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
index b3d1fdf3cdf..c28723c35e0 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)));
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-10 8:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-10 8:21 [gcc r13-228] [Ada] Replace variables with constants in expanded code for task names Pierre-Marie de Rodat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).