https://gcc.gnu.org/g:898335111604872d7b5634bf631c10ac3cd88786
commit r16-8979-g898335111604872d7b5634bf631c10ac3cd88786 Author: Javier Miranda <[email protected]> Date: Thu Jan 15 20:49:28 2026 +0000 ada: Unsupported C++ constructor call in array aggregate This patch adds support for C++ constructor calls in array aggregates. gcc/ada/ChangeLog: * exp_ch5.adb (Expand_N_Assignment_Statement): Handle internally generated initialization invoking a C++ constructor. Diff: --- gcc/ada/exp_ch5.adb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb index d08c8c4a59d4..c75cfc174d21 100644 --- a/gcc/ada/exp_ch5.adb +++ b/gcc/ada/exp_ch5.adb @@ -32,6 +32,7 @@ with Einfo.Entities; use Einfo.Entities; with Einfo.Utils; use Einfo.Utils; with Elists; use Elists; with Exp_Aggr; use Exp_Aggr; +with Exp_Ch3; use Exp_Ch3; with Exp_Ch6; use Exp_Ch6; with Exp_Ch7; use Exp_Ch7; with Exp_Ch11; use Exp_Ch11; @@ -2412,6 +2413,26 @@ package body Exp_Ch5 is if Componentwise_Assignment (N) then Expand_Assign_Record (N); return; + + -- Another special case: internally generated initialization invoking + -- a C++ constructor. This case corresponds with the initialization + -- of an aggregate component. + + elsif not Comes_From_Source (N) + and then (No_Ctrl_Actions (N) or else No_Finalize_Actions (N)) + and then Is_CPP_Constructor_Call (Rhs) + then + declare + Expr : constant Node_Id := Relocate_Node (Rhs); + Id_Ref : constant Node_Id := Relocate_Node (Lhs); + + begin + Insert_List_Before_And_Analyze (N, + Build_Initialization_Call (N, Id_Ref, Typ, + Constructor_Ref => Expr)); + Rewrite (N, Make_Null_Statement (Loc)); + return; + end; end if; -- Defend against invalid subscripts on left side if we are in standard
