diff options
author | Hristian Kirtchev <kirtchev@adacore.com> | 2017-01-13 09:34:48 +0000 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2017-01-13 10:34:48 +0100 |
commit | d65a80fd559aca749b54eb6affd71d2d84f410f8 (patch) | |
tree | 5dd4560e392930b55539c9078451e000762bf3ea /gcc/ada/exp_util.adb | |
parent | 3c3b9090f86bef51e5b023616d1cfdcfa39f82b7 (diff) | |
download | gcc-d65a80fd559aca749b54eb6affd71d2d84f410f8.zip gcc-d65a80fd559aca749b54eb6affd71d2d84f410f8.tar.gz gcc-d65a80fd559aca749b54eb6affd71d2d84f410f8.tar.bz2 |
atree.adb (Allocate_Initialize_Node): A newly created node is no longer marked as Ghost at this level.
2017-01-13 Hristian Kirtchev <kirtchev@adacore.com>
* atree.adb (Allocate_Initialize_Node): A newly created node is
no longer marked as Ghost at this level.
(Mark_New_Ghost_Node): New routine.
(New_Copy): Mark the copy as Ghost.
(New_Entity): Mark the entity as Ghost.
(New_Node): Mark the node as Ghost.
* einfo.adb (Is_Checked_Ghost_Entity): This attribute can now
apply to unanalyzed entities.
(Is_Ignored_Ghost_Entity): This attribute can now apply to unanalyzed
entities.
(Set_Is_Checked_Ghost_Entity): This attribute now
applies to all entities as well as unanalyzed entities.
(Set_Is_Ignored_Ghost_Entity): This attribute now applies to
all entities as well as unanalyzed entities.
* expander.adb Add with and use clauses for Ghost.
(Expand): Install and revert the Ghost region associated with the node
being expanded.
* exp_ch3.adb (Expand_Freeze_Array_Type): Remove all Ghost-related code.
(Expand_Freeze_Class_Wide_Type): Remoe all Ghost-related code.
(Expand_Freeze_Enumeration_Type): Remove all Ghost-related code.
(Expand_Freeze_Record_Type): Remove all Ghost-related code.
(Freeze_Type): Install and revert the Ghost region associated
with the type being frozen.
* exp_ch5.adb Remove with and use clauses for Ghost.
(Expand_N_Assignment_Statement): Remove all Ghost-related code.
* exp_ch6.adb Remove with and use clauses for Ghost.
(Expand_N_Procedure_Call_Statement): Remove all Ghost-relatd code.
(Expand_N_Subprogram_Body): Remove all Ghost-related code.
* exp_ch7.adb (Build_Invariant_Procedure_Body): Install and revert the
Ghost region of the working type.
(Build_Invariant_Procedure_Declaration): Install and revert
the Ghost region of the working type.
(Expand_N_Package_Body): Remove all Ghost-related code.
* exp_ch8.adb Remove with and use clauses for Ghost.
(Expand_N_Exception_Renaming_Declaration): Remove all Ghost-related
code.
(Expand_N_Object_Renaming_Declaration): Remove all Ghost-related code.
(Expand_N_Package_Renaming_Declaration): Remove all Ghost-related code.
(Expand_N_Subprogram_Renaming_Declaration): Remove all Ghost-related
code.
* exp_ch13.adb Remove with and use clauses for Ghost.
(Expand_N_Freeze_Entity): Remove all Ghost-related code.
* exp_disp.adb (Make_DT): Install and revert the Ghost region of
the tagged type. Move the generation of various entities within
the Ghost region of the type.
* exp_prag.adb Remove with and use clauses for Ghost.
(Expand_Pragma_Check): Remove all Ghost-related code.
(Expand_Pragma_Contract_Cases): Remove all Ghost-related code.
(Expand_Pragma_Initial_Condition): Remove all Ghost-related code.
(Expand_Pragma_Loop_Variant): Remove all Ghost-related code.
* exp_util.adb (Build_DIC_Procedure_Body): Install
and revert the Ghost region of the working types.
(Build_DIC_Procedure_Declaration): Install and revert the
Ghost region of the working type.
(Make_Invariant_Call): Install and revert the Ghost region of the
associated type.
(Make_Predicate_Call): Reimplemented. Install and revert the
Ghost region of the associated type.
* freeze.adb (Freeze_Entity): Install and revert the Ghost region
of the entity being frozen.
(New_Freeze_Node): Removed.
* ghost.adb Remove with and use clauses for Opt.
(Check_Ghost_Completion): Update the parameter profile
and all references to formal parameters.
(Ghost_Entity): Update the comment on usage.
(Install_Ghost_Mode): New routines.
(Is_Ghost_Assignment): New routine.
(Is_Ghost_Declaration): New routine.
(Is_Ghost_Pragma): New routine.
(Is_Ghost_Procedure_Call): New routine.
(Is_Ghost_Renaming): Removed.
(Is_OK_Declaration): Reimplemented.
(Is_OK_Pragma): Reimplemented.
(Is_OK_Statement): Reimplemented.
(Is_Subject_To_Ghost): Update the comment on usage.
(Mark_And_Set_Ghost_Assignment): New routine.
(Mark_And_Set_Ghost_Body): New routine.
(Mark_And_Set_Ghost_Completion): New routine.
(Mark_And_Set_Ghost_Declaration): New routine.
(Mark_And_Set_Ghost_Instantiation): New routine.
(Mark_And_Set_Ghost_Procedure_Call): New routine.
(Mark_Full_View_As_Ghost): Removed.
(Mark_Ghost_Declaration_Or_Body): New routine.
(Mark_Ghost_Pragma): New routine.
(Mark_Ghost_Renaming): New routine.
(Mark_Pragma_As_Ghost): Removed.
(Mark_Renaming_As_Ghost): Removed.
(Propagate_Ignored_Ghost_Code): Update the comment on usage.
(Prune_Node): Freeze nodes no longer need special pruning, they
are processed by the general ignored Ghost code mechanism.
(Restore_Ghost_Mode): New routine.
(Set_Ghost_Mode): Reimplemented.
(Set_Ghost_Mode_From_Entity): Removed.
* ghost.ads Add with and use clauses for Ghost.
(Check_Ghost_Completion): Update the parameter profile
along with the comment on usage.
(Install_Ghost_Mode): New routine.
(Is_Ghost_Assignment): New routine.
(Is_Ghost_Declaration): New routine.
(Is_Ghost_Pragma): New routine.
(Is_Ghost_Procedure_Call): New routine.
(Mark_And_Set_Ghost_Assignment): New routine.
(Mark_And_Set_Ghost_Body): New routine.
(Mark_And_Set_Ghost_Completion): New routine.
(Mark_And_Set_Ghost_Declaration): New routine.
(Mark_And_Set_Ghost_Instantiation): New routine.
(Mark_And_Set_Ghost_Procedure_Call): New routine.
(Mark_Full_View_As_Ghost): Removed.
(Mark_Ghost_Pragma): New routine.
(Mark_Ghost_Renaming): New routine.
(Mark_Pragma_As_Ghost): Removed.
(Mark_Renaming_As_Ghost): Removed.
(Restore_Ghost_Mode): New routine.
(Set_Ghost_Mode): Redefined.
(Set_Ghost_Mode_From_Entity): Removed.
* sem.adb (Analyze): Install and revert the Ghost region of the
node being analyzed.
(Do_Analyze): Change the way a clean Ghost
region is installed and reverted.
* sem_ch3.adb (Analyze_Full_Type_Declaration): Remove
all Ghost-related code.
(Analyze_Incomplete_Type_Decl): Remove all Ghost-related code.
(Analyze_Number_Declaration): Remove all Ghost-related code.
(Analyze_Object_Declaration): Install and revert the Ghost region of
a deferred object declaration's completion.
(Array_Type_Declaration): Remove all Ghost-related code.
(Build_Derived_Type): Update the comment on
the propagation of Ghost attributes from a parent to a derived type.
(Derive_Subprogram): Remove all Ghost-related code.
(Make_Class_Wide_Type): Remove all Ghost-related code.
(Make_Implicit_Base): Remove all Ghost-related code.
(Process_Full_View): Install and revert the Ghost region of
the partial view. There is no longer need to check the Ghost
completion here.
* sem_ch5.adb (Analyze_Assignment): Install and revert the Ghost
region of the left hand side.
* sem_ch6.adb (Analyze_Abstract_Subprogram_Declaration): Remove
all Ghost-related code.
(Analyze_Expression_Function): Remove all Ghost-related code.
(Analyze_Generic_Subprogram_Body): Remove all Ghost-related code.
(Analyze_Procedure_Call): Install and revert the Ghost region of
the procedure being called.
(Analyze_Subprogram_Body_Helper): Install and revert the Ghost
region of the spec or body.
(Analyze_Subprogram_Declaration): Remove all Ghost-related code.
(Build_Subprogram_Declaration): Remove all Ghost-related code.
(Find_Corresponding_Spec): Remove all Ghost-related code.
(Process_Formals): Remove all Ghost-related code.
* sem_ch7.adb (Analyze_Package_Body_Helper): Install and revert
the Ghost region of the spec.
(Analyze_Package_Declaration): Remove all Ghost-related code.
* sem_ch8.adb (Analyze_Exception_Renaming): Mark a renaming as
Ghost when it aliases a Ghost entity.
(Analyze_Generic_Renaming): Mark a renaming as Ghost when it aliases
a Ghost entity.
(Analyze_Object_Renaming): Mark a renaming as Ghost when
it aliases a Ghost entity.
(Analyze_Package_Renaming): Mark a renaming as Ghost when it aliases
a Ghost entity.
(Analyze_Subprogram_Renaming): Mark a renaming as Ghost when it
aliases a Ghost entity.
* sem_ch11.adb Remove with and use clauses for Ghost.
(Analyze_Exception_Declaration): Remove all Ghost-related code.
* sem_ch12.adb (Analyze_Generic_Package_Declaration): Remove all
Ghost-related code.
(Analyze_Generic_Subprogram_Declaration): Remove all Ghost-related
code.
(Analyze_Package_Instantiation): Install and revert the Ghost region
of the package instantiation.
(Analyze_Subprogram_Instantiation): Install
and revert the Ghost region of the subprogram instantiation.
(Instantiate_Package_Body): Code clean up. Install and revert the
Ghost region of the package body.
(Instantiate_Subprogram_Body): Code clean up. Install and revert the
Ghost region of the subprogram body.
* sem_ch13.adb (Build_Predicate_Functions): Install
and revert the Ghost region of the related type.
(Build_Predicate_Function_Declaration): Code clean up. Install
and rever the Ghost region of the related type.
* sem_prag.adb (Analyze_Contract_Cases_In_Decl_Part):
Install and revert the Ghost region of the pragma.
(Analyze_Initial_Condition_In_Decl_Part): Install and revert the
Ghost region of the pragma.
(Analyze_Pragma): Install and revert the Ghost region of various
pragmas. Mark a pragma as Ghost when it is related to a Ghost entity
or encloses a Ghost entity.
(Analyze_Pre_Post_Condition): Install and revert the Ghost
region of the pragma.
(Analyze_Pre_Post_Condition_In_Decl_Part): Install and revert the
Ghost region of the pragma.
* sem_res.adb (Resolve): Remove all Ghost-related code.
* sem_util.adb (Is_Declaration): Reimplemented.
(Is_Declaration_Other_Than_Renaming): New routine.
* sem_util.ads (Is_Declaration_Other_Than_Renaming): New routine.
* sinfo.adb (Is_Checked_Ghost_Pragma): New routine.
(Is_Ghost_Pragma): Removed.
(Is_Ignored_Ghost_Pragma): New routine.
(Set_Is_Checked_Ghost_Pragma): New routine.
(Set_Is_Ghost_Pragma): Removed.
(Set_Is_Ignored_Ghost_Pragma): New routine.
* sinfo.ads: Update the documentation on Ghost mode and
Ghost regions. New attributes Is_Checked_Ghost_Pragma
and Is_Ignored_Ghost_Pragma along with usages in nodes.
Remove attribute Is_Ghost_Pragma along with usages in nodes.
(Is_Checked_Ghost_Pragma): New routine along with pragma Inline.
(Is_Ghost_Pragma): Removed along with pragma Inline.
(Is_Ignored_Ghost_Pragma): New routine along with pragma Inline.
(Set_Is_Checked_Ghost_Pragma): New routine along with pragma Inline.
(Set_Is_Ghost_Pragma): Removed along with pragma Inline.
(Set_Is_Ignored_Ghost_Pragma): New routine along with pragma Inline.
From-SVN: r244395
Diffstat (limited to 'gcc/ada/exp_util.adb')
-rw-r--r-- | gcc/ada/exp_util.adb | 83 |
1 files changed, 34 insertions, 49 deletions
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index d400041..8297013 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -1712,12 +1712,11 @@ package body Exp_Util is Loc : constant Source_Ptr := Sloc (Typ); - Save_Ghost_Mode : constant Ghost_Mode_Type := Ghost_Mode; - DIC_Prag : Node_Id; DIC_Typ : Entity_Id; Dummy_1 : Entity_Id; Dummy_2 : Entity_Id; + Mode : Ghost_Mode_Type; Proc_Body : Node_Id; Proc_Body_Id : Entity_Id; Proc_Decl : Node_Id; @@ -1749,6 +1748,11 @@ package body Exp_Util is Work_Typ := Corresponding_Concurrent_Type (Work_Typ); end if; + -- The working type may be subject to pragma Ghost. Set the mode now to + -- ensure that the DIC procedure is properly marked as Ghost. + + Set_Ghost_Mode (Work_Typ, Mode); + -- The working type must be either define a DIC pragma of its own or -- inherit one from a parent type. @@ -1767,7 +1771,7 @@ package body Exp_Util is -- argument is "null". if not Is_Verifiable_DIC_Pragma (DIC_Prag) then - return; + goto Leave; end if; -- The working type may lack a DIC procedure declaration. This may be @@ -1799,14 +1803,9 @@ package body Exp_Util is -- Nothing to do if the DIC procedure already has a body if Present (Corresponding_Body (Proc_Decl)) then - return; + goto Leave; end if; - -- The working type may be subject to pragma Ghost. Set the mode now to - -- ensure that the DIC procedure is properly marked as Ghost. - - Set_Ghost_Mode_From_Entity (Work_Typ); - -- Emulate the environment of the DIC procedure by installing its scope -- and formal parameters. @@ -1917,7 +1916,8 @@ package body Exp_Util is Append_Freeze_Action (Work_Typ, Proc_Body); end if; - Ghost_Mode := Save_Ghost_Mode; + <<Leave>> + Restore_Ghost_Mode (Mode); end Build_DIC_Procedure_Body; ------------------------------------- @@ -1927,10 +1927,9 @@ package body Exp_Util is procedure Build_DIC_Procedure_Declaration (Typ : Entity_Id) is Loc : constant Source_Ptr := Sloc (Typ); - Save_Ghost_Mode : constant Ghost_Mode_Type := Ghost_Mode; - DIC_Prag : Node_Id; DIC_Typ : Entity_Id; + Mode : Ghost_Mode_Type; Proc_Decl : Node_Id; Proc_Id : Entity_Id; Typ_Decl : Node_Id; @@ -1973,6 +1972,11 @@ package body Exp_Util is Work_Typ := Corresponding_Concurrent_Type (Work_Typ); end if; + -- The working type may be subject to pragma Ghost. Set the mode now to + -- ensure that the DIC procedure is properly marked as Ghost. + + Set_Ghost_Mode (Work_Typ, Mode); + -- The type must be either subject to a DIC pragma or inherit one from a -- parent type. @@ -1991,19 +1995,14 @@ package body Exp_Util is -- argument is "null". if not Is_Verifiable_DIC_Pragma (DIC_Prag) then - return; + goto Leave; -- Nothing to do if the type already has a DIC procedure elsif Present (DIC_Procedure (Work_Typ)) then - return; + goto Leave; end if; - -- The working type may be subject to pragma Ghost. Set the mode now to - -- ensure that the DIC procedure is properly marked as Ghost. - - Set_Ghost_Mode_From_Entity (Work_Typ); - Proc_Id := Make_Defining_Identifier (Loc, Chars => @@ -2025,13 +2024,6 @@ package body Exp_Util is Set_Needs_Debug_Info (Proc_Id); end if; - -- Mark the DIC procedure explicitly as Ghost because it does not come - -- from source. - - if Ghost_Mode > None then - Set_Is_Ghost_Entity (Proc_Id); - end if; - -- Obtain all views of the input type Get_Views (Work_Typ, Priv_Typ, Full_Typ, Full_Base, CRec_Typ); @@ -2106,7 +2098,8 @@ package body Exp_Util is Insert_After_And_Analyze (Typ_Decl, Proc_Decl); end if; - Ghost_Mode := Save_Ghost_Mode; + <<Leave>> + Restore_Ghost_Mode (Mode); end Build_DIC_Procedure_Declaration; -------------------------- @@ -7816,8 +7809,9 @@ package body Exp_Util is ------------------------- function Make_Invariant_Call (Expr : Node_Id) return Node_Id is - Loc : constant Source_Ptr := Sloc (Expr); - Typ : constant Entity_Id := Base_Type (Etype (Expr)); + Loc : constant Source_Ptr := Sloc (Expr); + Typ : constant Entity_Id := Base_Type (Etype (Expr)); + Proc_Id : Entity_Id; begin @@ -7910,11 +7904,11 @@ package body Exp_Util is Expr : Node_Id; Mem : Boolean := False) return Node_Id is - Loc : constant Source_Ptr := Sloc (Expr); - Call : Node_Id; - PFM : Entity_Id; + Loc : constant Source_Ptr := Sloc (Expr); - Save_Ghost_Mode : constant Ghost_Mode_Type := Ghost_Mode; + Call : Node_Id; + Func_Id : Entity_Id; + Mode : Ghost_Mode_Type; begin pragma Assert (Present (Predicate_Function (Typ))); @@ -7922,33 +7916,24 @@ package body Exp_Util is -- The related type may be subject to pragma Ghost. Set the mode now to -- ensure that the call is properly marked as Ghost. - Set_Ghost_Mode_From_Entity (Typ); + Set_Ghost_Mode (Typ, Mode); -- Call special membership version if requested and available - if Mem then - PFM := Predicate_Function_M (Typ); - - if Present (PFM) then - Call := - Make_Function_Call (Loc, - Name => New_Occurrence_Of (PFM, Loc), - Parameter_Associations => New_List (Relocate_Node (Expr))); - - Ghost_Mode := Save_Ghost_Mode; - return Call; - end if; + if Mem and then Present (Predicate_Function_M (Typ)) then + Func_Id := Predicate_Function_M (Typ); + else + Func_Id := Predicate_Function (Typ); end if; -- Case of calling normal predicate function Call := Make_Function_Call (Loc, - Name => - New_Occurrence_Of (Predicate_Function (Typ), Loc), + Name => New_Occurrence_Of (Func_Id, Loc), Parameter_Associations => New_List (Relocate_Node (Expr))); - Ghost_Mode := Save_Ghost_Mode; + Restore_Ghost_Mode (Mode); return Call; end Make_Predicate_Call; |