if Must_Rewrite_Indirect_Call
and then (not Is_Overloadable (Current_Scope)
- or else not (Is_Access_Subprogram_Wrapper (Current_Scope)
+ or else not (Is_Access_To_Subprogram_Wrapper (Current_Scope)
or else
(Chars (Current_Scope) = Name_uWrapped_Statements
- and then Is_Access_Subprogram_Wrapper
+ and then Is_Access_To_Subprogram_Wrapper
(Scope (Current_Scope)))))
then
declare
-- Otherwise the prefix denotes some unrelated function
else
- Error_Msg_Name_2 := Chars (Spec_Id);
+ if Is_Access_To_Subprogram_Wrapper (Spec_Id) then
+ Error_Msg_Name_2 :=
+ Chars (Etype (Last_Formal (Spec_Id)));
+ else
+ Error_Msg_Name_2 := Chars (Spec_Id);
+ end if;
+
Error_Attr
("incorrect prefix for attribute %, expected %", P);
end if;
elsif Is_Access_Subprogram_Type (Pref_Id) then
if Pref_Id = Spec_Id then
Set_Etype (N, Etype (Designated_Type (Spec_Id)));
+
+ -- Otherwise the prefix denotes some unrelated function
+
else
- Error_Msg_Name_2 := Chars (Spec_Id);
+ if Is_Access_To_Subprogram_Wrapper (Spec_Id) then
+ Error_Msg_Name_2 :=
+ Chars (Etype (Last_Formal (Spec_Id)));
+ else
+ Error_Msg_Name_2 := Chars (Spec_Id);
+ end if;
+
Error_Attr
("incorrect prefix for attribute %, expected %", P);
end if;
---------------------------------
procedure Check_Dispatching_Operation (Subp, Old_Subp : Entity_Id) is
- function Is_Access_To_Subprogram_Wrapper (E : Entity_Id) return Boolean;
- -- Return True if E is an access to subprogram wrapper
procedure Warn_On_Late_Primitive_After_Private_Extension
(Typ : Entity_Id;
-- if it is a public primitive defined after some private extension of
-- the tagged type.
- -------------------------------------
- -- Is_Access_To_Subprogram_Wrapper --
- -------------------------------------
-
- function Is_Access_To_Subprogram_Wrapper (E : Entity_Id) return Boolean
- is
- Decl_N : constant Node_Id := Unit_Declaration_Node (E);
- Par_N : constant Node_Id := Parent (List_Containing (Decl_N));
-
- begin
- -- Access to subprogram wrappers are declared in the freezing actions
-
- return Nkind (Par_N) = N_Freeze_Entity
- and then Ekind (Entity (Par_N)) = E_Access_Subprogram_Type;
- end Is_Access_To_Subprogram_Wrapper;
-
----------------------------------------------------
-- Warn_On_Late_Primitive_After_Private_Extension --
----------------------------------------------------
-- Wrappers of access to subprograms are not primitive subprograms.
- elsif Is_Wrapper (Subp)
- and then Is_Access_To_Subprogram_Wrapper (Subp)
- then
+ elsif Is_Access_To_Subprogram_Wrapper (Subp) then
return;
end if;
then
return Stmt;
- elsif Is_Access_Subprogram_Wrapper (Defining_Entity (Stmt))
+ elsif Is_Access_To_Subprogram_Wrapper (Defining_Entity (Stmt))
and then Ada_Version >= Ada_2022
then
return Stmt;
return False;
end Has_Non_Null_Statements;
- ----------------------------------
- -- Is_Access_Subprogram_Wrapper --
- ----------------------------------
+ -------------------------------------
+ -- Is_Access_To_Subprogram_Wrapper --
+ -------------------------------------
+
+ function Is_Access_To_Subprogram_Wrapper (E : Entity_Id) return Boolean is
+ Formal : Entity_Id;
- function Is_Access_Subprogram_Wrapper (E : Entity_Id) return Boolean is
- Formal : constant Entity_Id := Last_Formal (E);
begin
- return Present (Formal)
- and then Ekind (Etype (Formal)) in Access_Subprogram_Kind
- and then Access_Subprogram_Wrapper
- (Directly_Designated_Type (Etype (Formal))) = E;
- end Is_Access_Subprogram_Wrapper;
+ if not Is_Wrapper (E)
+ or else not Can_Have_Formals (E)
+ or else No (Last_Formal (E))
+ then
+ return False;
+
+ else
+ Formal := Last_Formal (E);
+
+ return Ekind (Etype (Formal)) in Access_Subprogram_Kind
+ and then Access_Subprogram_Wrapper
+ (Directly_Designated_Type (Etype (Formal))) = E;
+ end if;
+ end Is_Access_To_Subprogram_Wrapper;
---------------------------
-- Is_Explicitly_Aliased --
-- pragma Initialize_Scalars or by the binder. Return an expression created
-- at source location Loc, which denotes the invalid value.
- function Is_Access_Subprogram_Wrapper (E : Entity_Id) return Boolean;
+ function Is_Access_To_Subprogram_Wrapper (E : Entity_Id) return Boolean;
-- True if E is the constructed wrapper for an access_to_subprogram
-- type with Pre/Postconditions.