1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2014-2015, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 -- This package contains routines that deal with the static and runtime
27 -- semantics of Ghost entities.
29 with Types
; use Types
;
33 procedure Add_Ignored_Ghost_Unit
(Unit
: Node_Id
);
34 -- Add a single ignored Ghost compilation unit to the internal table for
37 procedure Check_Ghost_Completion
38 (Partial_View
: Entity_Id
;
39 Full_View
: Entity_Id
);
40 -- Verify that the Ghost policy of a full view or a completion is the same
41 -- as the Ghost policy of the partial view. Emit an error if this is not
44 procedure Check_Ghost_Context
(Ghost_Id
: Entity_Id
; Ghost_Ref
: Node_Id
);
45 -- Determine whether node Ghost_Ref appears within a Ghost-friendly context
46 -- where Ghost entity Ghost_Id can safely reside.
48 procedure Check_Ghost_Overriding
50 Overridden_Subp
: Entity_Id
);
51 -- Verify that the Ghost policy of parent subprogram Overridden_Subp is
52 -- compatible with the Ghost policy of overriding subprogram Subp. Emit
53 -- an error if this is not the case.
55 procedure Check_Ghost_Primitive
(Prim
: Entity_Id
; Typ
: Entity_Id
);
56 -- Verify that the Ghost policy of primitive operation Prim is the same as
57 -- the Ghost policy of tagged type Typ. Emit an error if this is not the
60 procedure Check_Ghost_Refinement
64 Constit_Id
: Entity_Id
);
65 -- Verify that the Ghost policy of constituent Constit_Id is compatible
66 -- with the Ghost policy of abstract state State_I.
68 function Implements_Ghost_Interface
(Typ
: Entity_Id
) return Boolean;
69 -- Determine whether type Typ implements at least one Ghost interface
72 -- Initialize internal tables
75 -- Lock internal tables before calling backend
77 procedure Mark_Full_View_As_Ghost
78 (Priv_Typ
: Entity_Id
;
79 Full_Typ
: Entity_Id
);
80 -- Set all Ghost-related attributes of type Full_Typ depending on the Ghost
81 -- mode of incomplete or private type Priv_Typ.
83 procedure Mark_Pragma_As_Ghost
85 Context_Id
: Entity_Id
);
86 -- Set all Ghost-related attributes of pragma Prag if its context denoted
87 -- by Id is a Ghost entity.
89 procedure Mark_Renaming_As_Ghost
92 -- Set all Ghost-related attributes of renaming declaration Ren_Decl if its
93 -- renamed name denoted by Nam_Id is a Ghost entity.
95 procedure Remove_Ignored_Ghost_Code
;
96 -- Remove all code marked as ignored Ghost from the trees of all qualifying
97 -- units (SPARK RM 6.9(4)).
99 -- WARNING: this is a separate front end pass, care should be taken to keep
102 procedure Set_Ghost_Mode
(N
: Node_Id
; Id
: Entity_Id
:= Empty
);
103 -- Set the value of global variable Ghost_Mode depending on the following
106 -- If N is a declaration, determine whether N is subject to pragma Ghost.
107 -- If this is the case, the Ghost_Mode is set based on the current Ghost
108 -- policy in effect. Special cases:
110 -- N is the completion of a deferred constant, the Ghost_Mode is set
111 -- based on the mode of partial declaration entity denoted by Id.
113 -- N is the full view of a private type, the Ghost_Mode is set based
114 -- on the mode of the partial declaration entity denoted by Id.
116 -- If N is an assignment statement or a procedure call, the Ghost_Mode is
117 -- set based on the mode of the name.
119 -- If N denotes a package or a subprogram body, the Ghost_Mode is set to
120 -- the current Ghost policy in effect if the body is subject to Ghost or
121 -- the corresponding spec denoted by Id is a Ghost entity.
123 -- If N is a pragma, the Ghost_Mode is set based on the mode of the
126 -- If N is a freeze node, the Global_Mode is set based on the mode of
129 -- WARNING: the caller must save and restore the value of Ghost_Mode in a
130 -- a stack-like fasion as this routine may override the existing value.
132 procedure Set_Ghost_Mode_From_Entity
(Id
: Entity_Id
);
133 -- Set the valye of global variable Ghost_Mode depending on the mode of
136 -- WARNING: the caller must save and restore the value of Ghost_Mode in a
137 -- a stack-like fasion as this routine may override the existing value.
139 procedure Set_Is_Ghost_Entity
(Id
: Entity_Id
);
140 -- Set the relevant Ghost attributes of entity Id depending on the current
141 -- Ghost assertion policy in effect.