-- Local variables
- Loc : constant Source_Ptr := Sloc (Body_Decl);
- Params : List_Id := No_List;
- Proc_Bod : Node_Id;
- Proc_Id : Entity_Id;
+ Loc : constant Source_Ptr := Sloc (Body_Decl);
+ Params : List_Id := No_List;
+ Proc_Bod : Node_Id;
+ Proc_Decl : Node_Id;
+ Proc_Id : Entity_Id;
+ Proc_Spec : Node_Id;
-- Start of processing for Build_Postconditions_Procedure
end if;
Proc_Id := Make_Defining_Identifier (Loc, Name_uPostconditions);
- Set_Debug_Info_Needed (Proc_Id);
+ Set_Debug_Info_Needed (Proc_Id);
+ Set_Postconditions_Proc (Subp_Id, Proc_Id);
+
+ -- Force the front-end inlining of _Postconditions when generating C
+ -- code, since its body may have references to itypes defined in the
+ -- enclosing subprogram, which would cause problems for unnesting
+ -- routines in the absence of inlining.
+
+ if Generate_C_Code then
+ Set_Has_Pragma_Inline (Proc_Id);
+ Set_Has_Pragma_Inline_Always (Proc_Id);
+ Set_Is_Inlined (Proc_Id);
+ end if;
-- The related subprogram is a function: create the specification of
-- parameter _Result.
New_Occurrence_Of (Etype (Result), Loc)));
end if;
+ Proc_Spec :=
+ Make_Procedure_Specification (Loc,
+ Defining_Unit_Name => Proc_Id,
+ Parameter_Specifications => Params);
+
+ Proc_Decl := Make_Subprogram_Declaration (Loc, Proc_Spec);
+
-- Insert _Postconditions before the first source declaration of the
-- body. This ensures that the body will not cause any premature
-- freezing, as it may mention types:
-- order reference. The body of _Postconditions must be placed after
-- the declaration of Temp to preserve correct visibility.
+ Insert_Before_First_Source_Declaration (Proc_Decl);
+ Analyze (Proc_Decl);
+
-- Set an explicit End_Label to override the sloc of the implicit
-- RETURN statement, and prevent it from inheriting the sloc of one
-- the postconditions: this would cause confusing debug info to be
-- produced, interfering with coverage-analysis tools.
- declare
- Proc_Decl : Node_Id;
- Proc_Decl_Id : Entity_Id;
- Proc_Spec : Node_Id;
- begin
- Proc_Spec :=
- Make_Procedure_Specification (Loc,
- Defining_Unit_Name => Proc_Id,
- Parameter_Specifications => Params);
-
- Proc_Decl := Make_Subprogram_Declaration (Loc, Proc_Spec);
- Proc_Decl_Id := Defining_Entity (Specification (Proc_Decl));
- Set_Postconditions_Proc (Subp_Id, Proc_Decl_Id);
-
- -- Force the front end inlining of _PostConditions when generating
- -- C code since its body may have references to itypes defined in
- -- the enclosing subprogram, thus causing problems to unnesting
- -- routines.
-
- if Generate_C_Code then
- Set_Has_Pragma_Inline (Proc_Decl_Id);
- Set_Has_Pragma_Inline_Always (Proc_Decl_Id);
- Set_Is_Inlined (Proc_Decl_Id);
- end if;
-
- Insert_Before_First_Source_Declaration (Proc_Decl);
- Analyze (Proc_Decl);
-
- Proc_Bod :=
- Make_Subprogram_Body (Loc,
- Specification =>
- Copy_Subprogram_Spec (Proc_Spec),
- Declarations => Empty_List,
- Handled_Statement_Sequence =>
- Make_Handled_Sequence_Of_Statements (Loc,
- Statements => Stmts,
- End_Label => Make_Identifier (Loc, Chars (Proc_Id))));
-
- Insert_Before_First_Source_Declaration (Proc_Bod);
- Analyze (Proc_Bod);
- end;
+ Proc_Bod :=
+ Make_Subprogram_Body (Loc,
+ Specification =>
+ Copy_Subprogram_Spec (Proc_Spec),
+ Declarations => Empty_List,
+ Handled_Statement_Sequence =>
+ Make_Handled_Sequence_Of_Statements (Loc,
+ Statements => Stmts,
+ End_Label => Make_Identifier (Loc, Chars (Proc_Id))));
+
+ Insert_After_And_Analyze (Proc_Decl, Proc_Bod);
end Build_Postconditions_Procedure;
----------------------------
--------------------------------------
function Is_Unchecked_Conversion_Instance (Id : Entity_Id) return Boolean is
- Par : Node_Id;
- Gen_Par : Entity_Id;
+ Par : Node_Id;
begin
-- Look for a function whose generic parent is the predefined intrinsic
-- function Unchecked_Conversion.
if Ekind (Id) = E_Function then
- Par := Parent (Id);
+ Par := Parent (Id);
- if Nkind (Par) /= N_Function_Specification then
- return False;
- end if;
+ if Nkind (Par) = N_Function_Specification then
+ Par := Generic_Parent (Par);
- Gen_Par := Generic_Parent (Par);
-
- return
- Present (Gen_Par)
- and then Chars (Gen_Par) = Name_Unchecked_Conversion
- and then Is_Intrinsic_Subprogram (Gen_Par)
- and then Is_Predefined_File_Name
- (Unit_File_Name (Get_Source_Unit (Gen_Par)));
+ return
+ Present (Par)
+ and then Chars (Par) = Name_Unchecked_Conversion
+ and then Is_Intrinsic_Subprogram (Par)
+ and then Is_Predefined_File_Name
+ (Unit_File_Name (Get_Source_Unit (Par)));
+ end if;
end if;
return False;