diff options
Diffstat (limited to 'gcc/ada/exp_ch3.adb')
| -rw-r--r-- | gcc/ada/exp_ch3.adb | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb index 60224c1..57d2ec3 100644 --- a/gcc/ada/exp_ch3.adb +++ b/gcc/ada/exp_ch3.adb @@ -3185,8 +3185,8 @@ package body Exp_Ch3 is if Parent_Subtype_Renaming_Discrims then Append_List_To (Body_Stmts, Build_Init_Call_Thru (Parameters)); - elsif Present (Constructor_Name (Rec_Type)) then - if Present (Default_Constructor (Rec_Type)) then + elsif Needs_Construction (Rec_Type) then + if Has_Default_Constructor (Rec_Type) then -- The 'Make attribute reference (with no arguments) will -- generate a call to the one-parameter constructor procedure. @@ -3810,8 +3810,8 @@ package body Exp_Ch3 is -- Expand components with constructors to have the 'Make -- attribute. - elsif Present (Constructor_Name (Typ)) - and then Present (Default_Constructor (Typ)) + elsif Needs_Construction (Typ) + and then Has_Default_Constructor (Typ) then Set_Expression (Decl, Make_Attribute_Reference (Loc, @@ -4560,7 +4560,7 @@ package body Exp_Ch3 is -- since the call is generated, there had better be a routine -- at the other end of the call, even if it does nothing). - -- 10. The type has a specified Constructor aspect. + -- 10. The type needs construction with constructors. -- Note: the reason we exclude the CPP_Class case is because in this -- case the initialization is performed by the C++ constructors, and @@ -4577,7 +4577,7 @@ package body Exp_Ch3 is or else Is_Tagged_Type (Rec_Id) or else Is_Concurrent_Record_Type (Rec_Id) or else Has_Task (Rec_Id) - or else Present (Constructor_Name (Rec_Id)) + or else Needs_Construction (Rec_Id) then return True; end if; @@ -6684,7 +6684,8 @@ package body Exp_Ch3 is elsif not Is_Param_Block_Component_Type (Ptr_Typ) and then Is_Limited_Class_Wide_Type (Desig_Typ) then - Build_Class_Wide_Master (Ptr_Typ); + Build_Master_Entity (Ptr_Typ); + Build_Master_Renaming (Ptr_Typ); end if; end Build_Master; @@ -7587,8 +7588,8 @@ package body Exp_Ch3 is if No (Expr) and then Constant_Present (N) - and then (No (Constructor_Name (Typ)) - or else No (Default_Constructor (Typ))) + and then (not Needs_Construction (Typ) + or else not Has_Default_Constructor (Typ)) then return; end if; @@ -7619,8 +7620,8 @@ package body Exp_Ch3 is if Comes_From_Source (N) and then No (Expr) - and then Present (Constructor_Name (Typ)) - and then Present (Default_Constructor (Typ)) + and then Needs_Construction (Typ) + and then Has_Default_Constructor (Typ) then Expr := Make_Attribute_Reference (Loc, Attribute_Name => Name_Make, @@ -7651,7 +7652,9 @@ package body Exp_Ch3 is -- If tasks are being declared, make sure we have an activation chain -- defined for the tasks (has no effect if we already have one), and -- also that a Master variable is established (and that the appropriate - -- enclosing construct is established as a task master). + -- enclosing construct is established as a task master). And also deal + -- with objects initialized with a call to a BIP function that has task + -- formal parameters. if Has_Task (Typ) or else Might_Have_Tasks (Typ) @@ -7660,12 +7663,7 @@ package body Exp_Ch3 is then Build_Activation_Chain_Entity (N); - if Has_Task (Typ) then - Build_Master_Entity (Def_Id); - - -- Handle objects initialized with BIP function calls - - elsif Has_BIP_Init_Expr then + if Has_Task (Typ) or else Has_BIP_Init_Expr then Build_Master_Entity (Def_Id); end if; end if; @@ -7858,10 +7856,7 @@ package body Exp_Ch3 is -- Ada 2005 (AI-318-02): If the initialization expression is a call -- to a build-in-place function, then access to the declared object - -- must be passed to the function. Currently we limit such functions - -- to those with constrained limited result subtypes, but eventually - -- plan to expand the allowed forms of functions that are treated as - -- build-in-place. + -- must be passed to the function. elsif Is_Build_In_Place_Function_Call (Expr_Q) then Make_Build_In_Place_Call_In_Object_Declaration (N, Expr_Q); @@ -8286,6 +8281,16 @@ package body Exp_Ch3 is Set_Must_Not_Freeze (Id_Ref); Set_Assignment_OK (Id_Ref); + -- Avoid separating an object declaration from + -- its representation clauses. + + while Present (Next (Init_After)) + and then Nkind (Next (Init_After)) in + N_Attribute_Definition_Clause + loop + Init_After := Next (Init_After); + end loop; + Insert_Actions_After (Init_After, Build_Initialization_Call (N, Id_Ref, Typ, Constructor_Ref => Expr)); |
