diff options
author | Marc Poulhiès <poulhies@adacore.com> | 2024-03-05 15:16:59 +0100 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2024-05-17 10:21:01 +0200 |
commit | 93035031c5045255c7248576cc5750c1cb3dfd15 (patch) | |
tree | f9cf73298b8dcfe536c9e24826a7db35f789dcda | |
parent | cb71c251d846032cfb31e86c8e4d678c58a90ecc (diff) | |
download | gcc-93035031c5045255c7248576cc5750c1cb3dfd15.zip gcc-93035031c5045255c7248576cc5750c1cb3dfd15.tar.gz gcc-93035031c5045255c7248576cc5750c1cb3dfd15.tar.bz2 |
ada: Fix crash caused by missing New_Copy_tree
Since a recent refactor ("Factor common processing in expansion of
aggregates") where Initialize_Array_Component and
Initialize_Record_Component are merged, the behavior has slightly
changed. In the case of the expansion of an aggregate initialization
where the number of 'others' components is <= 3, the initialization
expression is not duplicated anymore, causing some incorrect multiple
definition when said expression is later transformed with
Expressions_With_Action that declares an object. The simple fix is to
add the now missing New_Copy_Tree where the assignments are created.
gcc/ada/
* exp_aggr.adb (Build_Array_Aggr_Code) <Gen_Loop>: Copy the
initialization expression when unrolling the loop.
-rw-r--r-- | gcc/ada/exp_aggr.adb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index cff04fc..9c5944a 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -1649,11 +1649,14 @@ package body Exp_Aggr is and then Local_Expr_Value (H) - Local_Expr_Value (L) <= 2 and then not Is_Iterated_Component then - Append_List_To (S, Gen_Assign (New_Copy_Tree (L), Expr)); - Append_List_To (S, Gen_Assign (Add (1, To => L), Expr)); + Append_List_To + (S, Gen_Assign (New_Copy_Tree (L), New_Copy_Tree (Expr))); + Append_List_To + (S, Gen_Assign (Add (1, To => L), New_Copy_Tree (Expr))); if Local_Expr_Value (H) - Local_Expr_Value (L) = 2 then - Append_List_To (S, Gen_Assign (Add (2, To => L), Expr)); + Append_List_To + (S, Gen_Assign (Add (2, To => L), New_Copy_Tree (Expr))); end if; return S; |