Commit c37e6613 by Hristian Kirtchev Committed by Arnaud Charlet

sem_util.adb, [...]: Minor reformatting.

2016-04-20  Hristian Kirtchev  <kirtchev@adacore.com>

	* sem_util.adb, contracts.adb, ghost.adb, exp_ch6.adb: Minor
	reformatting.

From-SVN: r235246
parent 7f5e1dee
2016-04-20 Hristian Kirtchev <kirtchev@adacore.com>
* sem_util.adb, contracts.adb, ghost.adb, exp_ch6.adb: Minor
reformatting.
2016-04-20 Javier Miranda <miranda@adacore.com>
* contracts.adb (Build_Postconditions_Procedure): Code cleanup.
......
......@@ -1734,10 +1734,12 @@ package body Contracts is
-- 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
......@@ -1749,7 +1751,19 @@ package body Contracts is
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.
......@@ -1762,6 +1776,13 @@ package body Contracts is
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:
......@@ -1780,52 +1801,25 @@ package body Contracts is
-- 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;
----------------------------
......
......@@ -5522,6 +5522,7 @@ package body Exp_Ch6 is
procedure Expand_N_Subprogram_Body_Stub (N : Node_Id) is
Bod : Node_Id;
begin
if Present (Corresponding_Body (N)) then
Bod := Unit_Declaration_Node (Corresponding_Body (N));
......
......@@ -256,9 +256,9 @@ package body Ghost is
if Present (Subp_Id) then
-- The context is the internally built _postconditions
-- subprogram, which it is OK because the real check was
-- done before expansion activities.
-- The context is the internally built _Postconditions
-- procedure, which is OK because the real check was done
-- before expansion activities.
if Chars (Subp_Id) = Name_uPostconditions then
return True;
......
......@@ -14282,28 +14282,25 @@ package body Sem_Util is
--------------------------------------
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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment