aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2024-11-08 11:01:11 +0100
committerMarc Poulhiès <dkm@gcc.gnu.org>2024-11-18 15:06:55 +0100
commitb4fd15d8bea6224a431e062d846459cc57724e41 (patch)
tree6583e930aab0593a9a09828ace27a35900899da7 /gcc
parent1b24e30cabbe2d796dc12afbcccfe849b0b9eb92 (diff)
downloadgcc-b4fd15d8bea6224a431e062d846459cc57724e41.zip
gcc-b4fd15d8bea6224a431e062d846459cc57724e41.tar.gz
gcc-b4fd15d8bea6224a431e062d846459cc57724e41.tar.bz2
ada: Fix another minor fallout of previous changes to aggregate expansion
This is another glitch associated with Initialization_Statements. gcc/ada/ChangeLog: * exp_util.adb (Remove_Init_Call): Rewrite a compound statement in the Initialization_Statements of the variable as a null statement instead of removing it. * freeze.adb (Explode_Initialization_Compound_Statement): Small comment tweaks.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/exp_util.adb16
-rw-r--r--gcc/ada/freeze.adb4
2 files changed, 18 insertions, 2 deletions
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
index 7671910..e4397fe 100644
--- a/gcc/ada/exp_util.adb
+++ b/gcc/ada/exp_util.adb
@@ -12124,6 +12124,22 @@ package body Exp_Util is
Init_Call := Initialization_Statements (Var);
Set_Initialization_Statements (Var, Empty);
+ -- Note that we rewrite Init_Call into a null statement, rather than
+ -- just removing it, because Freeze_All may rely on this particular
+ -- node still being present in the enclosing list to know where to
+ -- stop freezing (see Explode_Initialization_Compound_Statement).
+
+ if Nkind (Init_Call) = N_Compound_Statement then
+ declare
+ Init_Actions : constant List_Id := Actions (Init_Call);
+ Loc : constant Source_Ptr := Sloc (Init_Call);
+
+ begin
+ Rewrite (Init_Call, Make_Null_Statement (Loc));
+ return Make_Compound_Statement (Loc, Init_Actions);
+ end;
+ end if;
+
elsif not Has_Non_Null_Base_Init_Proc (Typ) then
-- No init proc for the type, so obviously no call to be found
diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb
index 3b781f7..67a5189 100644
--- a/gcc/ada/freeze.adb
+++ b/gcc/ada/freeze.adb
@@ -2471,9 +2471,9 @@ package body Freeze is
Insert_List_Before (Init_Stmts, Actions (Init_Stmts));
end if;
- -- Note that we rewrite Init_Stmts into a NULL statement, rather than
+ -- Note that we rewrite Init_Stmts into a null statement, rather than
-- just removing it, because Freeze_All may rely on this particular
- -- Node_Id still being present in the enclosing list to know where to
+ -- node still being present in the enclosing list to know where to
-- stop freezing.
Rewrite (Init_Stmts, Make_Null_Statement (Sloc (Init_Stmts)));