------------------------------------------
procedure Build_Access_Subprogram_Wrapper_Body
- (Decl : Node_Id;
+ (Decl : Node_Id;
New_Decl : Node_Id)
is
Loc : constant Source_Ptr := Sloc (Decl);
- Actuals : constant List_Id := New_List;
- Type_Def : constant Node_Id := Type_Definition (Decl);
- Type_Id : constant Entity_Id := Defining_Identifier (Decl);
- Spec_Node : constant Node_Id :=
- New_Copy_Tree (Specification (New_Decl));
+ Actuals : constant List_Id := New_List;
+ Type_Def : constant Node_Id := Type_Definition (Decl);
+ Type_Id : constant Entity_Id := Defining_Identifier (Decl);
+ Spec_Node : constant Node_Id :=
+ New_Copy_Tree (Specification (New_Decl));
Act : Node_Id;
Body_Node : Node_Id;
Call_Stmt : Node_Id;
Ptr : Entity_Id;
+
begin
if not Expander_Active then
return;
Make_Defining_Identifier
(Loc, Chars (Defining_Unit_Name (Spec_Node))));
- -- Create List of actuals for indirect call. The last
- -- parameter of the subprogram is the access value itself.
+ -- Create List of actuals for indirect call. The last parameter of the
+ -- subprogram is the access value itself.
Act := First (Parameter_Specifications (Spec_Node));
-- Add a field _parent in the extension part of the record
procedure Build_Access_Subprogram_Wrapper_Body
- (Decl : Node_Id;
+ (Decl : Node_Id;
New_Decl : Node_Id);
- -- Build the wrapper body, which holds the indirect call through
- -- an access_to_subprogram, and whose expansion incorporates the
- -- contracts of the access type declaration. Called from Build_
- -- Access_Subprogram_Wrapper.
- -- Building the wrapper is done during analysis to perform proper
- -- semantic checks on the relevant aspects. The wrapper body could
- -- be simplified to a null body when expansion is disabled ???
+ -- Build the wrapper body, which holds the indirect call through an access-
+ -- to-subprogram, and whose expansion incorporates the contracts of the
+ -- access type declaration. Called from Build_Access_Subprogram_Wrapper.
+ -- Building the wrapper is done during analysis to perform proper semantic
+ -- checks on the relevant aspects. The wrapper body could be simplified to
+ -- a null body when expansion is disabled ???
procedure Build_Discr_Checking_Funcs (N : Node_Id);
-- Builds function which checks whether the component name is consistent
-- record type.
procedure Build_Access_Subprogram_Wrapper (Decl : Node_Id);
- -- When an access_to_subprogram type has pre/postconditions, we
- -- build a subprogram that includes these contracts and is invoked
- -- by any indirect call through the corresponding access type.
+ -- When an access-to-subprogram type has pre/postconditions, we build a
+ -- subprogram that includes these contracts and is invoked by an indirect
+ -- call through the corresponding access type.
procedure Build_Derived_Type
(N : Node_Id;
Validate_Access_Type_Declaration (T, N);
-- If the type has contracts, we create the corresponding
- -- wrapper at once, before analyzing the aspect
- -- specifications, so that pre/postconditions can be
- -- handled directly on the generated wrapper.
+ -- wrapper at once, before analyzing the aspect specifications,
+ -- so that pre/postconditions can be handled directly on the
+ -- generated wrapper.
if Ada_Version >= Ada_2020
and then Present (Aspect_Specifications (N))
Spec : Node_Id;
procedure Replace_Type_Name (Expr : Node_Id);
- -- In the expressions for contract aspects, replace
- -- occurrences of the access type with the name of the
- -- subprogram entity, as needed, e.g. for 'Result.
- -- Apects that are not contracts 9e.g. Size or Aligment)
- -- remain on the originsl access type declaration.
- -- What about expanded names denoting formals, whose prefix
- -- in the source is the type name ???
+ -- In the expressions for contract aspects, replace occurrences of the
+ -- access type with the name of the subprogram entity, as needed, e.g.
+ -- for 'Result. Aspects that are not contracts, e.g. Size or Alignment)
+ -- remain on the original access type declaration. What about expanded
+ -- names denoting formals, whose prefix in source is the type name ???
-----------------------
-- Replace_Type_Name --
Next (Form_P);
end loop;
- -- Add to parameter specifications the access parameter that
- -- is passed in from an indirect call.
+ -- Add to parameter specifications the access parameter that is passed
+ -- in from an indirect call.
Append (
Make_Parameter_Specification (Loc,
then
null;
- -- Access_To_Subprogram type can have pre/postconditions, but
- -- these are trasnfered to the generated subprogram wrapper and
+ -- An access-to-subprogram type can have pre/postconditions, but
+ -- these are transferred to the generated subprogram wrapper and
-- analyzed there.
-- Otherwise the placement of the pragma is illegal
-- out to C that is known to denote the same object (RM 6.4.1(6.15/3))
-- This has been clarified in AI12-0216 to indicate that the illegality
-- only occurs if both formals are of an elementary type, because of the
- -- non-determinism on the write-back of the corresponding actuals.
+ -- nondeterminism on the write-back of the corresponding actuals.
-- Earlier versions of the language made it illegal if only one of the
-- actuals was an elementary parameter that overlapped a composite
-- actual, and both were writable.
-- If appropriate warning switch is set, we also report warnings on
-- overlapping parameters that are composite types. Users find these
- -- warnings useful, and they used in style guides.
+ -- warnings useful, and they are used in style guides.
-- It is also worthwhile to warn on overlaps of composite objects when
-- only one of the formals is (in)-out. Note that the RM rule above is