summaryrefslogtreecommitdiff
path: root/gcc/ada/exp_ch6.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2005-07-04 13:26:45 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2005-07-04 13:26:45 +0000
commit586402e19ea0dcf17005106b7e5d14a8f39a1eb1 (patch)
tree633c05c9e717cfac8109be0508f2149ee422efed /gcc/ada/exp_ch6.adb
parent5330273bf54bb7563d94e1468c98c2d9421ea4bd (diff)
downloadgcc-586402e19ea0dcf17005106b7e5d14a8f39a1eb1.tar.gz
2005-07-04 Gary Dismukes <dismukes@adacore.com>
Ed Schonberg <schonberg@adacore.com> Javier Miranda <miranda@adacore.com> * checks.adb (Null_Exclusion_Static_Checks): In the case of N_Object_Declaration, only perform the checks if the Object_Definition is not an Access_Definition. * sem_ch3.adb (Access_Subprogram_Declaration): Add test for the case where the parent of an the access definition is an N_Object_Declaration when determining the Associated_Node_For_Itype and scope of an anonymous access-to-subprogram type. * exp_ch6.adb (Expand_N_Subprogram_Declaration): Set the Corresponding_Spec on the body created for a null procedure. Add ??? comment. Remove New_Copy_Tree call on body argument to Set_Body_To_Inline. * exp_ch6.adb (Add_Simple_Call_By_Copy_Code): For an out parameter with discriminants, use the type of the actual as well, because the discriminants may be read by the called subprogram. * sem_ch3.adb (Access_Type_Declaration): If the designated type is an access type we do not need to handle non-limited views. (Build_Derived_Record_Type): Additional check to check that in case of private types, interfaces are only allowed in private extensions. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@101575 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/exp_ch6.adb')
-rw-r--r--gcc/ada/exp_ch6.adb34
1 files changed, 28 insertions, 6 deletions
diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb
index 2b188bb3e3d..ee7278cc426 100644
--- a/gcc/ada/exp_ch6.adb
+++ b/gcc/ada/exp_ch6.adb
@@ -760,13 +760,25 @@ package body Exp_Ch6 is
Outcod := New_Copy_Tree (Incod);
-- Generate declaration of temporary variable, initializing it
- -- with the input parameter unless we have an OUT variable or
+ -- with the input parameter unless we have an OUT formal or
-- this is an initialization call.
+ -- If the formal is an out parameter with discriminants, the
+ -- discriminants must be captured even if the rest of the object
+ -- is in principle uninitialized, because the discriminants may
+ -- be read by the called subprogram.
+
if Ekind (Formal) = E_Out_Parameter then
Incod := Empty;
+ if Has_Discriminants (Etype (Formal)) then
+ Indic := New_Occurrence_Of (Etype (Actual), Loc);
+ end if;
+
elsif Inside_Init_Proc then
+
+ -- Could use a comment here to match comment below ???
+
if Nkind (Actual) /= N_Selected_Component
or else
not Has_Discriminant_Dependent_Constraint
@@ -774,11 +786,10 @@ package body Exp_Ch6 is
then
Incod := Empty;
- else
- -- We need the component in order to generate the proper
- -- actual subtype, that depends on enclosing discriminants.
- -- What is the comment for, given code below is null ???
+ -- Otherwise, keep the component in order to generate the proper
+ -- actual subtype, that depends on enclosing discriminants.
+ else
null;
end if;
end if;
@@ -3859,9 +3870,20 @@ package body Exp_Ch6 is
Make_Handled_Sequence_Of_Statements (Loc,
Statements => New_List (Make_Null_Statement (Loc))));
begin
- Set_Body_To_Inline (N, New_Copy_Tree (Bod));
+ Set_Body_To_Inline (N, Bod);
Insert_After (N, Bod);
Analyze (Bod);
+
+ -- Corresponding_Spec isn't being set by Analyze_Subprogram_Body,
+ -- evidently because Set_Has_Completion is called earlier for null
+ -- procedures in Analyze_Subprogram_Declaration, so we force its
+ -- setting here. If the setting of Has_Completion is not set
+ -- earlier, then it can result in missing body errors if other
+ -- errors were already reported (since expansion is turned off).
+
+ -- Should creation of the empty body be moved to the analyzer???
+
+ Set_Corresponding_Spec (Bod, Defining_Entity (Specification (N)));
end;
end if;
end Expand_N_Subprogram_Declaration;