if Is_Entity_Name (P) then
Pref_Id := Entity (P);
- if Ekind_In (Pref_Id, E_Function, E_Generic_Function)
- and then Ekind (Spec_Id) = Ekind (Pref_Id)
+ -- Either both the prefix and the annotated spec must be
+ -- generic functions, or they both must be non-generic
+ -- functions, or the prefix must be generic and the spec
+ -- must be non-generic (i.e. it must denote an instance).
+
+ if (Ekind_In (Pref_Id, E_Function, E_Generic_Function)
+ and then Ekind (Pref_Id) = Ekind (Spec_Id))
+ or else
+ (Ekind (Pref_Id) = E_Generic_Function
+ and then Ekind (Spec_Id) = E_Function)
then
if Denote_Same_Function (Pref_Id, Spec_Id) then
Set_Ekind (Id, E_Generic_Procedure);
end if;
- -- Analyze the aspects of the generic copy to ensure that all generated
- -- pragmas (if any) perform their semantic effects.
-
- if Has_Aspects (N) then
- Analyze_Aspect_Specifications (N, Id);
- end if;
-
-- Set SPARK_Mode from context
Set_SPARK_Pragma (Id, SPARK_Mode_Pragma);
Set_Etype (Id, Standard_Void_Type);
end if;
+ -- Analyze the aspects of the generic copy to ensure that all generated
+ -- pragmas (if any) perform their semantic effects.
+
+ if Has_Aspects (N) then
+ Analyze_Aspect_Specifications (N, Id);
+ end if;
+
-- For a library unit, we have reconstructed the entity for the unit,
-- and must reset it in the library tables. We also make sure that
-- Body_Required is set properly in the original compilation unit node.
-- Annotation of a subprogram; aspect expression is required
- elsif Is_Subprogram_Or_Entry (E) then
+ elsif Is_Subprogram_Or_Entry (E)
+ or else Is_Generic_Subprogram (E)
+ then
if Present (Expr) then
-- If we analyze subprogram body that acts as its own
Restore_Scope := True;
Push_Scope (E);
- if Is_Generic_Subprogram (E) then
- Install_Generic_Formals (E);
- else
- Install_Formals (E);
- end if;
+ -- Only formals of the subprogram itself can appear
+ -- in Relaxed_Initialization aspect expression, not
+ -- formals of the enclosing generic unit. (This is
+ -- different that in Precondition or Depends aspects,
+ -- where both kinds of formals are allowed.)
+
+ Install_Formals (E);
end if;
-- Aspect expression is either an aggregate with list of
-- Insert new name in symbol table of current scope with check for
-- duplications (error message is issued if a conflict is found).
-- Note: Enter_Name is not used for overloadable entities, instead these
- -- are entered using Sem_Ch6.Enter_Overloadable_Entity.
+ -- are entered using Sem_Ch6.Enter_Overloaded_Entity.
function Entity_Of (N : Node_Id) return Entity_Id;
-- Obtain the entity of arbitrary node N. If N is a renaming, return the