diff options
Diffstat (limited to 'gcc/ada/sem_ch3.adb')
-rw-r--r-- | gcc/ada/sem_ch3.adb | 64 |
1 files changed, 42 insertions, 22 deletions
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 76dc632..dbe4d72 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -1318,7 +1318,8 @@ package body Sem_Ch3 is Check_Restriction (No_Access_Subprograms, T_Def); - Create_Extra_Formals (Desig_Type); + -- Addition of extra formals must be delayed till the freeze point so + -- that we know the convention. end Access_Subprogram_Declaration; ---------------------------- @@ -4721,6 +4722,26 @@ package body Sem_Ch3 is Expand_Sliding_Conversion (E, T); end if; + if In_Spec_Expression and then In_Declare_Expr > 0 then + -- It is too early to be doing expansion-ish things, + -- so exit early. But we have to set Ekind (Id) now so + -- that subsequent uses of this entity are not rejected + -- via the same mechanism that (correctly) rejects + -- "X : Integer := X;". + + if Constant_Present (N) then + Mutate_Ekind (Id, E_Constant); + Set_Is_True_Constant (Id); + else + Mutate_Ekind (Id, E_Variable); + if Present (E) then + Set_Has_Initial_Value (Id); + end if; + end if; + + goto Leave; + end if; + Expand_Subtype_From_Expr (N => N, Unc_Type => T, @@ -11768,11 +11789,9 @@ package body Sem_Ch3 is Insert_Before (Typ_Decl, Decl); Analyze (Decl); - -- If an access to subprogram, create the extra formals - - if Present (Acc_Def) then - Create_Extra_Formals (Designated_Type (Anon_Access)); - end if; + -- At first sight we could add here the extra formals of an access to + -- subprogram; however, it must delayed till the freeze point so that + -- we know the convention. if Nkind (Comp_Def) = N_Component_Definition then Rewrite (Comp_Def, @@ -16033,12 +16052,12 @@ package body Sem_Ch3 is Next_Formal (Formal); end loop; - -- Extra formals are shared between the parent subprogram and the - -- derived subprogram (implicit in the above copy of formals), unless - -- the parent type is a limited interface type; hence we must inherit - -- also the reference to the first extra formal. When the parent type is - -- an interface the extra formals will be added when the subprogram is - -- frozen (see Freeze.Freeze_Subprogram). + -- Extra formals are shared between the parent subprogram and this + -- internal entity built by Derive_Subprogram (implicit in the above + -- copy of formals), unless the parent type is a limited interface type; + -- hence we must inherit also the reference to the first extra formal. + -- When the parent type is an interface, the extra formals will be added + -- when the tagged type is frozen (see Expand_Freeze_Record_Type). if not Is_Limited_Interface (Parent_Type) then Set_Extra_Formals (New_Subp, Extra_Formals (Parent_Subp)); @@ -16079,7 +16098,7 @@ package body Sem_Ch3 is Copy_Strub_Mode (New_Subp, Alias (New_Subp)); -- Derived subprograms of a tagged type must inherit the convention - -- of the parent subprogram (a requirement of AI-117). Derived + -- of the parent subprogram (a requirement of AI95-117). Derived -- subprograms of untagged types simply get convention Ada by default. -- If the derived type is a tagged generic formal type with unknown @@ -16497,15 +16516,15 @@ package body Sem_Ch3 is -- Local variables - Alias_Subp : Entity_Id; - Act_List : Elist_Id; - Act_Elmt : Elmt_Id; - Act_Subp : Entity_Id := Empty; - Elmt : Elmt_Id; - Need_Search : Boolean := False; - New_Subp : Entity_Id := Empty; - Parent_Base : Entity_Id; - Subp : Entity_Id; + Alias_Subp : Entity_Id; + Act_List : Elist_Id; + Act_Elmt : Elmt_Id; + Act_Subp : Entity_Id := Empty; + Elmt : Elmt_Id; + Need_Search : Boolean := False; + New_Subp : Entity_Id; + Parent_Base : Entity_Id; + Subp : Entity_Id; -- Start of processing for Derive_Subprograms @@ -20145,6 +20164,7 @@ package body Sem_Ch3 is case Nkind (Original_Node (Exp)) is when N_Aggregate + | N_Delta_Aggregate | N_Extension_Aggregate | N_Function_Call | N_Op |