From 26a29f015c8fcd83cd199443745c9dfd462913bd Mon Sep 17 00:00:00 2001 From: Gary Dismukes Date: Wed, 20 Aug 2008 17:29:44 +0200 Subject: [PATCH] exp_ch3.adb (Build_Array_Init_Proc): Clarify comment related to creating dummy init proc. 2008-08-20 Gary Dismukes * exp_ch3.adb (Build_Array_Init_Proc): Clarify comment related to creating dummy init proc. (Requires_Init_Proc): Return False in the case No_Default_Initialization is in force and the type does not have associated default initialization. Move test of Is_Public (with tests of restrictions No_Initialize_Scalars and No_Default_Initialization) to end, past tests for default initialization. From-SVN: r139313 --- gcc/ada/exp_ch3.adb | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb index b5fac5c..57cb43e 100644 --- a/gcc/ada/exp_ch3.adb +++ b/gcc/ada/exp_ch3.adb @@ -692,9 +692,9 @@ package body Exp_Ch3 is -- would be needed if this restriction was not active (so that we can -- detect attempts to call it), so set a dummy init_proc in place. -- This is only done though when actual default initialization is - -- needed, so we exclude the setting in the Is_Public case, such - -- as for arrays of scalars, since otherwise such objects would be - -- wrongly flagged as violating the restriction. + -- needed (and not done when only Is_Public is True), since otherwise + -- objects such as arrays of scalars could be wrongly flagged as + -- violating the restriction. if Restriction_Active (No_Default_Initialization) then if Has_Default_Init then @@ -3013,11 +3013,6 @@ package body Exp_Ch3 is elsif Is_Interface (Rec_Id) then return False; - elsif not Restriction_Active (No_Initialize_Scalars) - and then Is_Public (Rec_Id) - then - return True; - elsif (Has_Discriminants (Rec_Id) and then not Is_Unchecked_Union (Rec_Id)) or else Is_Tagged_Type (Rec_Id) @@ -3042,6 +3037,22 @@ package body Exp_Ch3 is Next_Component (Id); end loop; + -- As explained above, a record initialization procedure is needed + -- for public types in case Initialize_Scalars applies to a client. + -- However, such a procedure is not needed in the case where either + -- of restrictions No_Initialize_Scalars or No_Default_Initialization + -- apply. No_Initialize_Scalars excludes the possibility of using + -- Initialize_Scalars in any partition, and No_Default_Initialization + -- implies that no initialization should ever be done for objects of + -- the type, so is incompatible with Initialize_Scalars. + + if not Restriction_Active (No_Initialize_Scalars) + and then not Restriction_Active (No_Default_Initialization) + and then Is_Public (Rec_Id) + then + return True; + end if; + return False; end Requires_Init_Proc; -- 2.7.4