ada: Update copyright notice
[official-gcc.git] / gcc / ada / ghost.ads
blob67ef194d9cc06b30d93af8f51b58f78dd5d13e39
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- G H O S T --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 2014-2023, Free Software Foundation, Inc. --
10 -- --
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. --
20 -- --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
23 -- --
24 ------------------------------------------------------------------------------
26 -- This package contains routines that deal with the static and runtime
27 -- semantics of Ghost entities.
29 with Opt; use Opt;
30 with Types; use Types;
32 package Ghost is
34 procedure Check_Ghost_Completion
35 (Prev_Id : Entity_Id;
36 Compl_Id : Entity_Id);
37 -- Verify that the Ghost policy of initial entity Prev_Id is compatible
38 -- with the Ghost policy of completing entity Compl_Id. Emit an error if
39 -- this is not the case.
41 procedure Check_Ghost_Context
42 (Ghost_Id : Entity_Id;
43 Ghost_Ref : Node_Id);
44 -- Determine whether node Ghost_Ref appears within a Ghost-friendly context
45 -- where Ghost entity Ghost_Id can safely reside.
47 procedure Check_Ghost_Context_In_Generic_Association
48 (Actual : Node_Id;
49 Formal : Entity_Id);
50 -- Check that if Actual contains references to ghost entities, generic
51 -- formal parameter Formal is ghost (SPARK RM 6.9(10)).
53 procedure Check_Ghost_Formal_Procedure_Or_Package
54 (N : Node_Id;
55 Actual : Entity_Id;
56 Formal : Entity_Id;
57 Is_Default : Boolean := False);
58 -- Verify that if generic formal procedure (resp. package) Formal is ghost,
59 -- then Actual is not Empty and also a ghost procedure (resp. package)
60 -- (SPARK RM 6.9(13-14)). The error if any is located on N. If
61 -- Is_Default is False, N and Actual represent the actual parameter in an
62 -- instantiation. Otherwise, they represent the default subprogram of a
63 -- formal subprogram declaration.
65 procedure Check_Ghost_Formal_Variable
66 (Actual : Node_Id;
67 Formal : Entity_Id;
68 Is_Default : Boolean := False);
69 -- Verify that if Formal (either an IN OUT generic formal parameter, or an
70 -- IN generic formal parameter of access-to-variable type) is ghost, then
71 -- Actual is a ghost object (SPARK RM 6.9(13-14)). Is_Default is True when
72 -- Actual is the default expression of the formal object declaration.
74 procedure Check_Ghost_Overriding
75 (Subp : Entity_Id;
76 Overridden_Subp : Entity_Id);
77 -- Verify that the Ghost policy of parent subprogram Overridden_Subp is
78 -- compatible with the Ghost policy of overriding subprogram Subp. Emit
79 -- an error if this is not the case.
81 procedure Check_Ghost_Primitive (Prim : Entity_Id; Typ : Entity_Id);
82 -- Verify that the Ghost policy of primitive operation Prim is the same as
83 -- the Ghost policy of tagged type Typ. Emit an error if this is not the
84 -- case.
86 procedure Check_Ghost_Refinement
87 (State : Node_Id;
88 State_Id : Entity_Id;
89 Constit : Node_Id;
90 Constit_Id : Entity_Id);
91 -- Verify that the Ghost policy of constituent Constit_Id is compatible
92 -- with the Ghost policy of abstract state State_I.
94 procedure Check_Ghost_Type (Typ : Entity_Id);
95 -- Verify that Ghost type Typ is neither concurrent, nor effectively
96 -- volatile.
98 function Implements_Ghost_Interface (Typ : Entity_Id) return Boolean;
99 -- Determine whether type Typ implements at least one Ghost interface
101 procedure Initialize;
102 -- Initialize internal tables
104 procedure Install_Ghost_Region (Mode : Ghost_Mode_Type; N : Node_Id);
105 pragma Inline (Install_Ghost_Region);
106 -- Install a Ghost region described by mode Mode and ignored region start
107 -- node N.
109 function Is_Ghost_Assignment (N : Node_Id) return Boolean;
110 -- Determine whether arbitrary node N denotes an assignment statement whose
111 -- target is a Ghost entity.
113 function Is_Ghost_Declaration (N : Node_Id) return Boolean;
114 -- Determine whether arbitrary node N denotes a declaration which defines
115 -- a Ghost entity.
117 function Is_Ghost_Pragma (N : Node_Id) return Boolean;
118 -- Determine whether arbitrary node N denotes a pragma which encloses a
119 -- Ghost entity or is associated with a Ghost entity.
121 function Is_Ghost_Procedure_Call (N : Node_Id) return Boolean;
122 -- Determine whether arbitrary node N denotes a procedure call invoking a
123 -- Ghost procedure.
125 function Is_Ignored_Ghost_Unit (N : Node_Id) return Boolean;
126 -- Determine whether compilation unit N is subject to pragma Ghost with
127 -- policy Ignore.
129 procedure Lock;
130 -- Lock internal tables before calling backend
132 procedure Mark_And_Set_Ghost_Assignment (N : Node_Id);
133 -- Mark assignment statement N as Ghost when:
135 -- * The left hand side denotes a Ghost entity
137 -- Install the Ghost mode of the assignment statement. This routine starts
138 -- a Ghost region and must be used with routine Restore_Ghost_Region.
140 procedure Mark_And_Set_Ghost_Body
141 (N : Node_Id;
142 Spec_Id : Entity_Id);
143 -- Mark package or subprogram body N as Ghost when:
145 -- * The body is subject to pragma Ghost
147 -- * The body completes a previous declaration whose spec denoted by
148 -- Spec_Id is a Ghost entity.
150 -- * The body appears within a Ghost region
152 -- Install the Ghost mode of the body. This routine starts a Ghost region
153 -- and must be used with routine Restore_Ghost_Region.
155 procedure Mark_And_Set_Ghost_Completion
156 (N : Node_Id;
157 Prev_Id : Entity_Id);
158 -- Mark completion N of a deferred constant or private type [extension]
159 -- Ghost when:
161 -- * The entity of the previous declaration denoted by Prev_Id is Ghost
163 -- * The completion appears within a Ghost region
165 -- Install the Ghost mode of the completion. This routine starts a Ghost
166 -- region and must be used with routine Restore_Ghost_Region.
168 procedure Mark_And_Set_Ghost_Declaration (N : Node_Id);
169 -- Mark declaration N as Ghost when:
171 -- * The declaration is subject to pragma Ghost
173 -- * The declaration denotes a child package or subprogram and the parent
174 -- is a Ghost unit.
176 -- * The declaration appears within a Ghost region
178 -- Install the Ghost mode of the declaration. This routine starts a Ghost
179 -- region and must be used with routine Restore_Ghost_Region.
181 procedure Mark_And_Set_Ghost_Instantiation
182 (N : Node_Id;
183 Gen_Id : Entity_Id);
184 -- Mark instantiation N as Ghost when:
186 -- * The instantiation is subject to pragma Ghost
188 -- * The generic template denoted by Gen_Id is Ghost
190 -- * The instantiation appears within a Ghost region
192 -- Install the Ghost mode of the instantiation. This routine starts a Ghost
193 -- region and must be used with routine Restore_Ghost_Region.
195 procedure Mark_And_Set_Ghost_Procedure_Call (N : Node_Id);
196 -- Mark procedure call N as Ghost when:
198 -- * The procedure being invoked is a Ghost entity
200 -- Install the Ghost mode of the procedure call. This routine starts a
201 -- Ghost region and must be used with routine Restore_Ghost_Region.
203 procedure Mark_Ghost_Clause (N : Node_Id);
204 -- Mark use package, use type, or with clause N as Ghost when:
206 -- * The clause mentions a Ghost entity
208 procedure Mark_Ghost_Pragma
209 (N : Node_Id;
210 Id : Entity_Id);
211 -- Mark pragma N as Ghost when:
213 -- * The pragma encloses Ghost entity Id
215 -- * The pragma is associated with Ghost entity Id
217 procedure Mark_Ghost_Renaming
218 (N : Node_Id;
219 Id : Entity_Id);
220 -- Mark renaming declaration N as Ghost when:
222 -- * Renamed entity Id denotes a Ghost entity
224 procedure Remove_Ignored_Ghost_Code;
225 -- Remove all code marked as ignored Ghost from the trees of all qualifying
226 -- units (SPARK RM 6.9(4)).
228 -- WARNING: this is a separate front end pass, care should be taken to keep
229 -- it optimized.
231 procedure Restore_Ghost_Region (Mode : Ghost_Mode_Type; N : Node_Id);
232 pragma Inline (Restore_Ghost_Region);
233 -- Restore a Ghost region to a previous state described by mode Mode and
234 -- ignored region start node N. This routine must be used in conjunction
235 -- with the following routines:
237 -- Install_Ghost_Region
238 -- Mark_And_Set_xxx
239 -- Set_Ghost_Mode
241 procedure Set_Ghost_Mode (N : Node_Or_Entity_Id);
242 -- Install the Ghost mode of arbitrary node N. This routine starts a Ghost
243 -- region and must be used with routine Restore_Ghost_Region.
245 procedure Set_Is_Ghost_Entity (Id : Entity_Id);
246 -- Set the relevant Ghost attributes of entity Id depending on the current
247 -- Ghost assertion policy in effect.
249 end Ghost;