diff options
author | Javier Miranda <miranda@adacore.com> | 2009-05-06 08:28:40 +0000 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2009-05-06 10:28:40 +0200 |
commit | 28541488914f27ad9763a02c2cc786cf786399d2 (patch) | |
tree | fbbb37ac3dfe0f7306941ecae6e7e8b1b112430c | |
parent | 55c078acd90197b56835f0a16ec13c278b73c78e (diff) | |
download | gcc-28541488914f27ad9763a02c2cc786cf786399d2.zip gcc-28541488914f27ad9763a02c2cc786cf786399d2.tar.gz gcc-28541488914f27ad9763a02c2cc786cf786399d2.tar.bz2 |
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
-rw-r--r-- | gcc/ada/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/ada/exp_aggr.adb | 19 |
2 files changed, 24 insertions, 0 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index f5da41e..4d7bb56 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -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 diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 516905f..6645bea 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -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, |