diff options
author | Ed Schonberg <schonberg@adacore.com> | 2005-03-29 18:21:32 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2005-03-29 18:21:32 +0200 |
commit | 2813bb6b356e37af272d5ce279d0fdddc794e34f (patch) | |
tree | d54b5ee5ac14be2f30051dc60ff8454a94566bcf /gcc/ada | |
parent | 981234802e8314987fc1e9c6b9594462bb5aa0f4 (diff) | |
download | gcc-2813bb6b356e37af272d5ce279d0fdddc794e34f.zip gcc-2813bb6b356e37af272d5ce279d0fdddc794e34f.tar.gz gcc-2813bb6b356e37af272d5ce279d0fdddc794e34f.tar.bz2 |
sem_ch6.adb (Set_Formal_Mode): If the subtype has a non_null indicator, indicate that the formal can never be null.
2005-03-29 Ed Schonberg <schonberg@adacore.com>
* sem_ch6.adb (Set_Formal_Mode): If the subtype has a non_null
indicator, indicate that the formal can never be null.
(Process_Formals): If a formal has a non_null indicator, insert the
resulting subtype immediately before the enclosing subprogram decl,
and not at the beginning of the corresponding declarative part, to
prevent access before elaboration (Ada2005).
From-SVN: r97185
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/sem_ch6.adb | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index 27da2a7..024a6cb 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -5089,8 +5089,8 @@ package body Sem_Ch6 is -- Ada 2005 (AI-231): Create and decorate an internal subtype -- declaration corresponding to the null-excluding type of the - -- formal in the enclosing scope. In addition, replace the - -- parameter type of the formal to this internal subtype. + -- formal in the enclosing scope. Finally, replace the + -- parameter type of the formal with the internal subtype. if Null_Exclusion_Present (Param_Spec) then declare @@ -5105,7 +5105,7 @@ package body Sem_Ch6 is Ptype : constant Node_Id := Parameter_Type (Param_Spec); Decl : Node_Id; - P : Node_Id := Parent (Parent (Related_Nod)); + P : Node_Id := Parent (Related_Nod); begin Set_Is_Internal (Anon); @@ -5127,12 +5127,13 @@ package body Sem_Ch6 is Mark_Rewrite_Insertion (Decl); -- Insert the new declaration in the nearest enclosing scope + -- in front of the subprogram or entry declaration. - while not Has_Declarations (P) loop + while not Is_List_Member (P) loop P := Parent (P); end loop; - Prepend (Decl, Declarations (P)); + Insert_Before (P, Decl); Rewrite (Ptype, New_Occurrence_Of (Anon, Loc)); Mark_Rewrite_Insertion (Ptype); @@ -5456,15 +5457,24 @@ package body Sem_Ch6 is if Nkind (Parameter_Type (Spec)) = N_Access_Definition then - -- Ada 2005 (AI-231): This behaviour has been modified in Ada 2005. - -- It is only forced if the null_exclusion appears. + -- Ada 2005 (AI-231): In Ada95, access parameters are always non- + -- null; In Ada 2005, only if then null_exclusion is explicit. if Ada_Version < Ada_05 or else Null_Exclusion_Present (Spec) + or else Can_Never_Be_Null (Etype (Formal_Id)) then Set_Is_Known_Non_Null (Formal_Id); Set_Can_Never_Be_Null (Formal_Id); end if; + + elsif Is_Access_Type (Etype (Formal_Id)) + and then Can_Never_Be_Null (Etype (Formal_Id)) + then + -- Ada 2005: The access subtype may be declared with null-exclusion + + Set_Is_Known_Non_Null (Formal_Id); + Set_Can_Never_Be_Null (Formal_Id); end if; Set_Mechanism (Formal_Id, Default_Mechanism); |