exp_aggr.adb (Build_Record_Aggr_Code): Add implicit call to the C++ constructor in case of aggregates whose type is a...

2009-05-06  Javier Miranda  <miranda@adacore.com>

	* exp_aggr.adb (Build_Record_Aggr_Code): Add implicit call to the C++
	constructor in case of aggregates whose type is a CPP_Class type.

From-SVN: r147151
This commit is contained in:
Javier Miranda 2009-05-06 08:28:40 +00:00 committed by Arnaud Charlet
parent 55c078acd9
commit 2854148891
2 changed files with 24 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2009-05-06 Javier Miranda <miranda@adacore.com>
* exp_aggr.adb (Build_Record_Aggr_Code): Add implicit call to the C++
constructor in case of aggregates whose type is a CPP_Class type.
2009-05-06 Robert Dewar <dewar@adacore.com>
* sem_ch13.adb: Minor comment additions

View File

@ -2765,6 +2765,18 @@ package body Exp_Aggr is
end if;
end if;
-- For CPP types we generate an implicit call to the C++ default
-- constructor to ensure the proper initialization of the _Tag
-- component.
if Is_CPP_Class (Typ) then
pragma Assert (Present (Base_Init_Proc (Typ)));
Append_List_To (L,
Build_Initialization_Call (Loc,
Id_Ref => Lhs,
Typ => Typ));
end if;
-- Generate the assignments, component by component
-- tmp.comp1 := Expr1_From_Aggr;
@ -3129,6 +3141,13 @@ package body Exp_Aggr is
if Ancestor_Is_Expression then
null;
-- For CPP types we generated a call to the C++ default constructor
-- before the components have been initialized to ensure the proper
-- initialization of the _Tag component (see above).
elsif Is_CPP_Class (Typ) then
null;
elsif Is_Tagged_Type (Typ) and then VM_Target = No_VM then
Instr :=
Make_OK_Assignment_Statement (Loc,