diff options
author | Javier Miranda <miranda@adacore.com> | 2009-04-29 13:29:08 +0000 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2009-04-29 15:29:08 +0200 |
commit | 236fecbf44a87814987887e5d3f03c4b8bf0c294 (patch) | |
tree | 11c0c448c05a05a2157e938de8190ca731911a8b /gcc/ada/exp_aggr.adb | |
parent | 0ec21a5bb7586e74425f162f1527b508309f3345 (diff) | |
download | gcc-236fecbf44a87814987887e5d3f03c4b8bf0c294.tar.gz |
sem_ch3.adb (Analyze_Object_Declaration): Disable error message associated with dyamically tagged expressions if...
2009-04-29 Javier Miranda <miranda@adacore.com>
* sem_ch3.adb (Analyze_Object_Declaration): Disable error message
associated with dyamically tagged expressions if the expression
initializing a tagged type corresponds with a non default CPP
constructor.
(OK_For_Limited_Init): CPP constructor calls are OK for initialization
of limited type objects.
* sem_ch5.adb (Analyze_Assignment): Improve the error message reported
when a CPP constructor is called in an assignment. Disable also the
error message associated with dyamically tagged expressions if the
exporession initializing a tagged type corresponds with a non default
CPP constructor.
* sem_prag.adb (Analyze_Pragma): Remove code disabling the use of
non-default C++ constructors.
* sem_util.ads, sem_util.adb (Is_CPP_Constructor_Call): New subprogram.
* exp_tss.ads, exp_tss.adb (Base_Init_Proc): Add support for
non-default constructors.
(Init_Proc): Add support for non-default constructors.
* exp_disp.adb (Set_Default_Constructor): Removed.
(Set_CPP_Constructors): Code based in removed Set_Default_Constructor
but extending its functionality to handle non-default constructors.
* exp_aggr.adb (Build_Record_Aggr_Code): Add support for non-default
constructors. Minor code cleanup removing unrequired label and goto
statement.
* exp_ch3.adb (Build_Initialization_Call): Add support for non-default
constructors.
(Build_Init_Statements): Add support for non-default constructors.
(Expand_N_Object_Declaration): Add support for non-default constructors.
(Freeze_Record_Type): Replace call to Set_Default_Constructor by call
to Set_CPP_Constructors.
* exp_ch5.adb (Expand_N_Assignment_Statement): Add support for
non-default constructors.
Required to handle its use in build-in-place statements.
* gnat_rm.texi (CPP_Constructor): Document new extended use of this
pragma for non-default C++ constructors and the new compiler support
that allows the use of these constructors in record components, limited
aggregates, and extended return statements.
From-SVN: r146966
Diffstat (limited to 'gcc/ada/exp_aggr.adb')
-rw-r--r-- | gcc/ada/exp_aggr.adb | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 7c38cba8624..516905f8873 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -2775,10 +2775,24 @@ package body Exp_Aggr is while Present (Comp) loop Selector := Entity (First (Choices (Comp))); + -- C++ constructors + + if Is_CPP_Constructor_Call (Expression (Comp)) then + Append_List_To (L, + Build_Initialization_Call (Loc, + Id_Ref => Make_Selected_Component (Loc, + Prefix => New_Copy_Tree (Target), + Selector_Name => New_Occurrence_Of (Selector, + Loc)), + Typ => Etype (Selector), + Enclos_Type => Typ, + With_Default_Init => True, + Constructor_Ref => Expression (Comp))); + -- Ada 2005 (AI-287): For each default-initialized component generate -- a call to the corresponding IP subprogram if available. - if Box_Present (Comp) + elsif Box_Present (Comp) and then Has_Non_Null_Base_Init_Proc (Etype (Selector)) then if Ekind (Selector) /= E_Discriminant then @@ -2822,12 +2836,9 @@ package body Exp_Aggr is Enclos_Type => Typ, With_Default_Init => True)); - goto Next_Comp; - end if; - -- Prepare for component assignment - if Ekind (Selector) /= E_Discriminant + elsif Ekind (Selector) /= E_Discriminant or else Nkind (N) = N_Extension_Aggregate then -- All the discriminants have now been assigned @@ -3107,8 +3118,6 @@ package body Exp_Aggr is end; end if; - <<Next_Comp>> - Next (Comp); end loop; |