annotate gcc/ada/sem_prag.ads @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- S E M _ P R A G --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 1992-2018, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
kono
parents:
diff changeset
17 -- for more details. You should have received a copy of the GNU General --
kono
parents:
diff changeset
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
kono
parents:
diff changeset
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
kono
parents:
diff changeset
20 -- --
kono
parents:
diff changeset
21 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
23 -- --
kono
parents:
diff changeset
24 ------------------------------------------------------------------------------
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 -- Pragma handling is isolated in a separate package
kono
parents:
diff changeset
27 -- (logically this processing belongs in chapter 4)
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 with Namet; use Namet;
kono
parents:
diff changeset
30 with Opt; use Opt;
kono
parents:
diff changeset
31 with Snames; use Snames;
kono
parents:
diff changeset
32 with Types; use Types;
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 package Sem_Prag is
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 -- The following table lists all pragmas that emulate an Ada 2012 aspect
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 Aspect_Specifying_Pragma : constant array (Pragma_Id) of Boolean :=
kono
parents:
diff changeset
39 (Pragma_Abstract_State => True,
kono
parents:
diff changeset
40 Pragma_All_Calls_Remote => True,
kono
parents:
diff changeset
41 Pragma_Annotate => True,
kono
parents:
diff changeset
42 Pragma_Async_Readers => True,
kono
parents:
diff changeset
43 Pragma_Async_Writers => True,
kono
parents:
diff changeset
44 Pragma_Asynchronous => True,
kono
parents:
diff changeset
45 Pragma_Atomic => True,
kono
parents:
diff changeset
46 Pragma_Atomic_Components => True,
kono
parents:
diff changeset
47 Pragma_Attach_Handler => True,
kono
parents:
diff changeset
48 Pragma_Constant_After_Elaboration => True,
kono
parents:
diff changeset
49 Pragma_Contract_Cases => True,
kono
parents:
diff changeset
50 Pragma_Convention => True,
kono
parents:
diff changeset
51 Pragma_CPU => True,
kono
parents:
diff changeset
52 Pragma_Default_Initial_Condition => True,
kono
parents:
diff changeset
53 Pragma_Default_Storage_Pool => True,
kono
parents:
diff changeset
54 Pragma_Depends => True,
kono
parents:
diff changeset
55 Pragma_Discard_Names => True,
kono
parents:
diff changeset
56 Pragma_Dispatching_Domain => True,
kono
parents:
diff changeset
57 Pragma_Effective_Reads => True,
kono
parents:
diff changeset
58 Pragma_Effective_Writes => True,
kono
parents:
diff changeset
59 Pragma_Elaborate_Body => True,
kono
parents:
diff changeset
60 Pragma_Export => True,
kono
parents:
diff changeset
61 Pragma_Extensions_Visible => True,
kono
parents:
diff changeset
62 Pragma_Favor_Top_Level => True,
kono
parents:
diff changeset
63 Pragma_Ghost => True,
kono
parents:
diff changeset
64 Pragma_Global => True,
kono
parents:
diff changeset
65 Pragma_Import => True,
kono
parents:
diff changeset
66 Pragma_Independent => True,
kono
parents:
diff changeset
67 Pragma_Independent_Components => True,
kono
parents:
diff changeset
68 Pragma_Initial_Condition => True,
kono
parents:
diff changeset
69 Pragma_Initializes => True,
kono
parents:
diff changeset
70 Pragma_Inline => True,
kono
parents:
diff changeset
71 Pragma_Inline_Always => True,
kono
parents:
diff changeset
72 Pragma_Interrupt_Handler => True,
kono
parents:
diff changeset
73 Pragma_Interrupt_Priority => True,
kono
parents:
diff changeset
74 Pragma_Invariant => True,
kono
parents:
diff changeset
75 Pragma_Linker_Section => True,
kono
parents:
diff changeset
76 Pragma_Lock_Free => True,
kono
parents:
diff changeset
77 Pragma_No_Elaboration_Code_All => True,
kono
parents:
diff changeset
78 Pragma_No_Return => True,
kono
parents:
diff changeset
79 Pragma_Obsolescent => True,
kono
parents:
diff changeset
80 Pragma_Pack => True,
kono
parents:
diff changeset
81 Pragma_Part_Of => True,
kono
parents:
diff changeset
82 Pragma_Persistent_BSS => True,
kono
parents:
diff changeset
83 Pragma_Post => True,
kono
parents:
diff changeset
84 Pragma_Post_Class => True,
kono
parents:
diff changeset
85 Pragma_Postcondition => True,
kono
parents:
diff changeset
86 Pragma_Pre => True,
kono
parents:
diff changeset
87 Pragma_Pre_Class => True,
kono
parents:
diff changeset
88 Pragma_Precondition => True,
kono
parents:
diff changeset
89 Pragma_Predicate => True,
kono
parents:
diff changeset
90 Pragma_Preelaborable_Initialization => True,
kono
parents:
diff changeset
91 Pragma_Preelaborate => True,
kono
parents:
diff changeset
92 Pragma_Priority => True,
kono
parents:
diff changeset
93 Pragma_Pure => True,
kono
parents:
diff changeset
94 Pragma_Pure_Function => True,
kono
parents:
diff changeset
95 Pragma_Refined_Depends => True,
kono
parents:
diff changeset
96 Pragma_Refined_Global => True,
kono
parents:
diff changeset
97 Pragma_Refined_Post => True,
kono
parents:
diff changeset
98 Pragma_Refined_State => True,
kono
parents:
diff changeset
99 Pragma_Relative_Deadline => True,
kono
parents:
diff changeset
100 Pragma_Remote_Access_Type => True,
kono
parents:
diff changeset
101 Pragma_Remote_Call_Interface => True,
kono
parents:
diff changeset
102 Pragma_Remote_Types => True,
kono
parents:
diff changeset
103 Pragma_Secondary_Stack_Size => True,
kono
parents:
diff changeset
104 Pragma_Shared => True,
kono
parents:
diff changeset
105 Pragma_Shared_Passive => True,
kono
parents:
diff changeset
106 Pragma_Simple_Storage_Pool_Type => True,
kono
parents:
diff changeset
107 Pragma_SPARK_Mode => True,
kono
parents:
diff changeset
108 Pragma_Storage_Size => True,
kono
parents:
diff changeset
109 Pragma_Suppress => True,
kono
parents:
diff changeset
110 Pragma_Suppress_Debug_Info => True,
kono
parents:
diff changeset
111 Pragma_Suppress_Initialization => True,
kono
parents:
diff changeset
112 Pragma_Test_Case => True,
kono
parents:
diff changeset
113 Pragma_Thread_Local_Storage => True,
kono
parents:
diff changeset
114 Pragma_Type_Invariant => True,
kono
parents:
diff changeset
115 Pragma_Unchecked_Union => True,
kono
parents:
diff changeset
116 Pragma_Universal_Aliasing => True,
kono
parents:
diff changeset
117 Pragma_Universal_Data => True,
kono
parents:
diff changeset
118 Pragma_Unmodified => True,
kono
parents:
diff changeset
119 Pragma_Unreferenced => True,
kono
parents:
diff changeset
120 Pragma_Unreferenced_Objects => True,
kono
parents:
diff changeset
121 Pragma_Unsuppress => True,
kono
parents:
diff changeset
122 Pragma_Volatile => True,
kono
parents:
diff changeset
123 Pragma_Volatile_Components => True,
kono
parents:
diff changeset
124 Pragma_Volatile_Full_Access => True,
kono
parents:
diff changeset
125 Pragma_Warnings => True,
kono
parents:
diff changeset
126 others => False);
kono
parents:
diff changeset
127
kono
parents:
diff changeset
128 -- The following table lists all pragmas that act as an assertion
kono
parents:
diff changeset
129 -- expression.
kono
parents:
diff changeset
130
kono
parents:
diff changeset
131 Assertion_Expression_Pragma : constant array (Pragma_Id) of Boolean :=
kono
parents:
diff changeset
132 (Pragma_Assert => True,
kono
parents:
diff changeset
133 Pragma_Assert_And_Cut => True,
kono
parents:
diff changeset
134 Pragma_Assume => True,
kono
parents:
diff changeset
135 Pragma_Check => True,
kono
parents:
diff changeset
136 Pragma_Contract_Cases => True,
kono
parents:
diff changeset
137 Pragma_Default_Initial_Condition => True,
kono
parents:
diff changeset
138 Pragma_Initial_Condition => True,
kono
parents:
diff changeset
139 Pragma_Invariant => True,
kono
parents:
diff changeset
140 Pragma_Loop_Invariant => True,
kono
parents:
diff changeset
141 Pragma_Loop_Variant => True,
kono
parents:
diff changeset
142 Pragma_Post => True,
kono
parents:
diff changeset
143 Pragma_Post_Class => True,
kono
parents:
diff changeset
144 Pragma_Postcondition => True,
kono
parents:
diff changeset
145 Pragma_Pre => True,
kono
parents:
diff changeset
146 Pragma_Pre_Class => True,
kono
parents:
diff changeset
147 Pragma_Precondition => True,
kono
parents:
diff changeset
148 Pragma_Predicate => True,
kono
parents:
diff changeset
149 Pragma_Refined_Post => True,
kono
parents:
diff changeset
150 Pragma_Test_Case => True,
kono
parents:
diff changeset
151 Pragma_Type_Invariant => True,
kono
parents:
diff changeset
152 Pragma_Type_Invariant_Class => True,
kono
parents:
diff changeset
153 others => False);
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 -- The following table lists all the implementation-defined pragmas that
kono
parents:
diff changeset
156 -- should apply to the anonymous object produced by the analysis of a
kono
parents:
diff changeset
157 -- single protected or task type. The table should be synchronized with
kono
parents:
diff changeset
158 -- Aspect_On_Anonymous_Object_OK in unit Aspects.
kono
parents:
diff changeset
159
kono
parents:
diff changeset
160 Pragma_On_Anonymous_Object_OK : constant array (Pragma_Id) of Boolean :=
kono
parents:
diff changeset
161 (Pragma_Depends => True,
kono
parents:
diff changeset
162 Pragma_Global => True,
kono
parents:
diff changeset
163 Pragma_Part_Of => True,
kono
parents:
diff changeset
164 others => False);
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166 -- The following table lists all the implementation-defined pragmas that
kono
parents:
diff changeset
167 -- may apply to a body stub (no language defined pragmas apply). The table
kono
parents:
diff changeset
168 -- should be synchronized with Aspect_On_Body_Or_Stub_OK in unit Aspects.
kono
parents:
diff changeset
169
kono
parents:
diff changeset
170 Pragma_On_Body_Or_Stub_OK : constant array (Pragma_Id) of Boolean :=
kono
parents:
diff changeset
171 (Pragma_Refined_Depends => True,
kono
parents:
diff changeset
172 Pragma_Refined_Global => True,
kono
parents:
diff changeset
173 Pragma_Refined_Post => True,
kono
parents:
diff changeset
174 Pragma_SPARK_Mode => True,
kono
parents:
diff changeset
175 Pragma_Warnings => True,
kono
parents:
diff changeset
176 others => False);
kono
parents:
diff changeset
177
kono
parents:
diff changeset
178 -- The following table lists all pragmas which are significant in SPARK and
kono
parents:
diff changeset
179 -- as a result get translated into verification conditions. The table is an
kono
parents:
diff changeset
180 -- amalgamation of the pragmas listed in SPARK RM 16.1 and internally added
kono
parents:
diff changeset
181 -- entries.
kono
parents:
diff changeset
182
kono
parents:
diff changeset
183 Pragma_Significant_In_SPARK : constant array (Pragma_Id) of Boolean :=
kono
parents:
diff changeset
184 (Pragma_All_Calls_Remote => False,
kono
parents:
diff changeset
185 Pragma_Asynchronous => False,
kono
parents:
diff changeset
186 Pragma_Default_Storage_Pool => False,
kono
parents:
diff changeset
187 Pragma_Discard_Names => False,
kono
parents:
diff changeset
188 Pragma_Dispatching_Domain => False,
kono
parents:
diff changeset
189 Pragma_Priority_Specific_Dispatching => False,
kono
parents:
diff changeset
190 Pragma_Remote_Call_Interface => False,
kono
parents:
diff changeset
191 Pragma_Remote_Types => False,
kono
parents:
diff changeset
192 Pragma_Shared_Passive => False,
kono
parents:
diff changeset
193 Pragma_Task_Dispatching_Policy => False,
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
194 Pragma_Unmodified => False,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
195 Pragma_Unreferenced => False,
111
kono
parents:
diff changeset
196 Pragma_Warnings => False,
kono
parents:
diff changeset
197 others => True);
kono
parents:
diff changeset
198
kono
parents:
diff changeset
199 -----------------
kono
parents:
diff changeset
200 -- Subprograms --
kono
parents:
diff changeset
201 -----------------
kono
parents:
diff changeset
202
kono
parents:
diff changeset
203 procedure Analyze_Pragma (N : Node_Id);
kono
parents:
diff changeset
204 -- Analyze procedure for pragma reference node N
kono
parents:
diff changeset
205
kono
parents:
diff changeset
206 procedure Analyze_Contract_Cases_In_Decl_Part
kono
parents:
diff changeset
207 (N : Node_Id;
kono
parents:
diff changeset
208 Freeze_Id : Entity_Id := Empty);
kono
parents:
diff changeset
209 -- Perform full analysis of delayed pragma Contract_Cases. Freeze_Id is the
kono
parents:
diff changeset
210 -- entity of [generic] package body or [generic] subprogram body which
kono
parents:
diff changeset
211 -- caused "freezing" of the related contract where the pragma resides.
kono
parents:
diff changeset
212
kono
parents:
diff changeset
213 procedure Analyze_Depends_In_Decl_Part (N : Node_Id);
kono
parents:
diff changeset
214 -- Perform full analysis of delayed pragma Depends. This routine is also
kono
parents:
diff changeset
215 -- capable of performing basic analysis of pragma Refined_Depends.
kono
parents:
diff changeset
216
kono
parents:
diff changeset
217 procedure Analyze_External_Property_In_Decl_Part
kono
parents:
diff changeset
218 (N : Node_Id;
kono
parents:
diff changeset
219 Expr_Val : out Boolean);
kono
parents:
diff changeset
220 -- Perform full analysis of delayed pragmas Async_Readers, Async_Writers,
kono
parents:
diff changeset
221 -- Effective_Reads and Effective_Writes. Flag Expr_Val contains the Boolean
kono
parents:
diff changeset
222 -- argument of the pragma or a default True if no argument is present.
kono
parents:
diff changeset
223
kono
parents:
diff changeset
224 procedure Analyze_Global_In_Decl_Part (N : Node_Id);
kono
parents:
diff changeset
225 -- Perform full analysis of delayed pragma Global. This routine is also
kono
parents:
diff changeset
226 -- capable of performing basic analysis of pragma Refined_Global.
kono
parents:
diff changeset
227
kono
parents:
diff changeset
228 procedure Analyze_Initial_Condition_In_Decl_Part (N : Node_Id);
kono
parents:
diff changeset
229 -- Perform full analysis of delayed pragma Initial_Condition
kono
parents:
diff changeset
230
kono
parents:
diff changeset
231 procedure Analyze_Initializes_In_Decl_Part (N : Node_Id);
kono
parents:
diff changeset
232 -- Perform full analysis of delayed pragma Initializes
kono
parents:
diff changeset
233
kono
parents:
diff changeset
234 procedure Analyze_Part_Of_In_Decl_Part
kono
parents:
diff changeset
235 (N : Node_Id;
kono
parents:
diff changeset
236 Freeze_Id : Entity_Id := Empty);
kono
parents:
diff changeset
237 -- Perform full analysis of delayed pragma Part_Of. Freeze_Id is the entity
kono
parents:
diff changeset
238 -- of [generic] package body or [generic] subprogram body which caused the
kono
parents:
diff changeset
239 -- "freezing" of the related contract where the pragma resides.
kono
parents:
diff changeset
240
kono
parents:
diff changeset
241 procedure Analyze_Pre_Post_Condition_In_Decl_Part
kono
parents:
diff changeset
242 (N : Node_Id;
kono
parents:
diff changeset
243 Freeze_Id : Entity_Id := Empty);
kono
parents:
diff changeset
244 -- Perform full analysis of pragmas Precondition and Postcondition.
kono
parents:
diff changeset
245 -- Freeze_Id denotes the entity of [generic] package body or [generic]
kono
parents:
diff changeset
246 -- subprogram body which caused "freezing" of the related contract where
kono
parents:
diff changeset
247 -- the pragma resides.
kono
parents:
diff changeset
248
kono
parents:
diff changeset
249 procedure Analyze_Refined_Depends_In_Decl_Part (N : Node_Id);
kono
parents:
diff changeset
250 -- Preform full analysis of delayed pragma Refined_Depends. This routine
kono
parents:
diff changeset
251 -- uses Analyze_Depends_In_Decl_Part as a starting point, then performs
kono
parents:
diff changeset
252 -- various consistency checks between Depends and Refined_Depends.
kono
parents:
diff changeset
253
kono
parents:
diff changeset
254 procedure Analyze_Refined_Global_In_Decl_Part (N : Node_Id);
kono
parents:
diff changeset
255 -- Perform full analysis of delayed pragma Refined_Global. This routine
kono
parents:
diff changeset
256 -- uses Analyze_Global_In_Decl_Part as a starting point, then performs
kono
parents:
diff changeset
257 -- various consistency checks between Global and Refined_Global.
kono
parents:
diff changeset
258
kono
parents:
diff changeset
259 procedure Analyze_Refined_State_In_Decl_Part
kono
parents:
diff changeset
260 (N : Node_Id;
kono
parents:
diff changeset
261 Freeze_Id : Entity_Id := Empty);
kono
parents:
diff changeset
262 -- Perform full analysis of delayed pragma Refined_State. Freeze_Id denotes
kono
parents:
diff changeset
263 -- the entity of [generic] package body or [generic] subprogram body which
kono
parents:
diff changeset
264 -- caused "freezing" of the related contract where the pragma resides.
kono
parents:
diff changeset
265
kono
parents:
diff changeset
266 procedure Analyze_Test_Case_In_Decl_Part (N : Node_Id);
kono
parents:
diff changeset
267 -- Perform preanalysis of pragma Test_Case
kono
parents:
diff changeset
268
kono
parents:
diff changeset
269 function Build_Pragma_Check_Equivalent
kono
parents:
diff changeset
270 (Prag : Node_Id;
kono
parents:
diff changeset
271 Subp_Id : Entity_Id := Empty;
kono
parents:
diff changeset
272 Inher_Id : Entity_Id := Empty;
kono
parents:
diff changeset
273 Keep_Pragma_Id : Boolean := False) return Node_Id;
kono
parents:
diff changeset
274 -- Transform a pre- or [refined] postcondition denoted by Prag into an
kono
parents:
diff changeset
275 -- equivalent pragma Check. When the pre- or postcondition is inherited,
kono
parents:
diff changeset
276 -- the routine replaces the references of all formals of Inher_Id
kono
parents:
diff changeset
277 -- and primitive operations of its controlling type by references
kono
parents:
diff changeset
278 -- to the corresponding entities of Subp_Id and the descendant type.
kono
parents:
diff changeset
279 -- Keep_Pragma_Id is True when the newly created pragma should be
kono
parents:
diff changeset
280 -- in fact of the same kind as the source pragma Prag. This is used
kono
parents:
diff changeset
281 -- in GNATprove_Mode to generate the inherited pre- and postconditions.
kono
parents:
diff changeset
282
kono
parents:
diff changeset
283 procedure Check_Applicable_Policy (N : Node_Id);
kono
parents:
diff changeset
284 -- N is either an N_Aspect or an N_Pragma node. There are two cases. If
kono
parents:
diff changeset
285 -- the name of the aspect or pragma is not one of those recognized as
kono
parents:
diff changeset
286 -- an assertion kind by an Assertion_Policy pragma, then the call has
kono
parents:
diff changeset
287 -- no effect. Note that in the case of a pragma derived from an aspect,
kono
parents:
diff changeset
288 -- the name we use for the purpose of this procedure is the aspect name,
kono
parents:
diff changeset
289 -- which may be different from the pragma name (e.g. Precondition for
kono
parents:
diff changeset
290 -- Pre aspect). In addition, 'Class aspects are recognized (and the
kono
parents:
diff changeset
291 -- corresponding special names used in the processing).
kono
parents:
diff changeset
292 --
kono
parents:
diff changeset
293 -- If the name is a valid assertion kind name, then the Check_Policy pragma
kono
parents:
diff changeset
294 -- chain is checked for a matching entry (or for an Assertion entry which
kono
parents:
diff changeset
295 -- matches all possibilities). If a matching entry is found then the policy
kono
parents:
diff changeset
296 -- is checked. If it is On or Check, then the Is_Checked flag is set in
kono
parents:
diff changeset
297 -- the aspect or pragma node. If it is Off, Ignore, or Disable, then the
kono
parents:
diff changeset
298 -- Is_Ignored flag is set in the aspect or pragma node. Additionally for
kono
parents:
diff changeset
299 -- policy Disable, the Is_Disabled flag is set.
kono
parents:
diff changeset
300 --
kono
parents:
diff changeset
301 -- If no matching Check_Policy pragma is found then the effect depends on
kono
parents:
diff changeset
302 -- whether -gnata was used, if so, then the call has no effect, otherwise
kono
parents:
diff changeset
303 -- Is_Ignored (but not Is_Disabled) is set True.
kono
parents:
diff changeset
304
kono
parents:
diff changeset
305 procedure Check_External_Properties
kono
parents:
diff changeset
306 (Item : Node_Id;
kono
parents:
diff changeset
307 AR : Boolean;
kono
parents:
diff changeset
308 AW : Boolean;
kono
parents:
diff changeset
309 ER : Boolean;
kono
parents:
diff changeset
310 EW : Boolean);
kono
parents:
diff changeset
311 -- Flags AR, AW, ER and EW denote the static values of external properties
kono
parents:
diff changeset
312 -- Async_Readers, Async_Writers, Effective_Reads and Effective_Writes. Item
kono
parents:
diff changeset
313 -- is the related variable or state. Ensure legality of the combination and
kono
parents:
diff changeset
314 -- issue an error for an illegal combination.
kono
parents:
diff changeset
315
kono
parents:
diff changeset
316 function Check_Kind (Nam : Name_Id) return Name_Id;
kono
parents:
diff changeset
317 -- This function is used in connection with pragmas Assert, Check,
kono
parents:
diff changeset
318 -- and assertion aspects and pragmas, to determine if Check pragmas
kono
parents:
diff changeset
319 -- (or corresponding assertion aspects or pragmas) are currently active
kono
parents:
diff changeset
320 -- as determined by the presence of -gnata on the command line (which
kono
parents:
diff changeset
321 -- sets the default), and the appearance of pragmas Check_Policy and
kono
parents:
diff changeset
322 -- Assertion_Policy as configuration pragmas either in a configuration
kono
parents:
diff changeset
323 -- pragma file, or at the start of the current unit, or locally given
kono
parents:
diff changeset
324 -- Check_Policy and Assertion_Policy pragmas that are currently active.
kono
parents:
diff changeset
325 --
kono
parents:
diff changeset
326 -- The value returned is one of the names Check, Ignore, Disable (On
kono
parents:
diff changeset
327 -- returns Check, and Off returns Ignore).
kono
parents:
diff changeset
328 --
kono
parents:
diff changeset
329 -- Note: for assertion kinds Pre'Class, Post'Class, Invariant'Class,
kono
parents:
diff changeset
330 -- and Type_Invariant'Class, the name passed is Name_uPre, Name_uPost,
kono
parents:
diff changeset
331 -- Name_uInvariant, or Name_uType_Invariant, which corresponds to _Pre,
kono
parents:
diff changeset
332 -- _Post, _Invariant, or _Type_Invariant, which are special names used
kono
parents:
diff changeset
333 -- in identifiers to represent these attribute references.
kono
parents:
diff changeset
334
kono
parents:
diff changeset
335 procedure Check_Missing_Part_Of (Item_Id : Entity_Id);
kono
parents:
diff changeset
336 -- Determine whether the placement within the state space of an abstract
kono
parents:
diff changeset
337 -- state, variable or package instantiation denoted by Item_Id requires the
kono
parents:
diff changeset
338 -- use of indicator/option Part_Of. If this is the case, emit an error.
kono
parents:
diff changeset
339
kono
parents:
diff changeset
340 procedure Collect_Inherited_Class_Wide_Conditions (Subp : Entity_Id);
kono
parents:
diff changeset
341 -- In GNATprove mode, when analyzing an overriding subprogram, check
kono
parents:
diff changeset
342 -- whether the overridden operations have class-wide pre/postconditions,
kono
parents:
diff changeset
343 -- and generate the corresponding pragmas. The pragmas are inserted after
kono
parents:
diff changeset
344 -- the subprogram declaration, together with those generated for other
kono
parents:
diff changeset
345 -- aspects of the subprogram.
kono
parents:
diff changeset
346
kono
parents:
diff changeset
347 procedure Collect_Subprogram_Inputs_Outputs
kono
parents:
diff changeset
348 (Subp_Id : Entity_Id;
kono
parents:
diff changeset
349 Synthesize : Boolean := False;
kono
parents:
diff changeset
350 Subp_Inputs : in out Elist_Id;
kono
parents:
diff changeset
351 Subp_Outputs : in out Elist_Id;
kono
parents:
diff changeset
352 Global_Seen : out Boolean);
kono
parents:
diff changeset
353 -- Subsidiary to the analysis of pragmas Depends, Global, Refined_Depends
kono
parents:
diff changeset
354 -- and Refined_Global. The routine is also used by GNATprove. Collect all
kono
parents:
diff changeset
355 -- inputs and outputs of subprogram Subp_Id in lists Subp_Inputs (inputs)
kono
parents:
diff changeset
356 -- and Subp_Outputs (outputs). The inputs and outputs are gathered from:
kono
parents:
diff changeset
357 -- 1) The formal parameters of the subprogram
kono
parents:
diff changeset
358 -- 2) The generic formal parameters of the generic subprogram
kono
parents:
diff changeset
359 -- 3) The current instance of a concurrent type
kono
parents:
diff changeset
360 -- 4) The items of pragma [Refined_]Global
kono
parents:
diff changeset
361 -- or
kono
parents:
diff changeset
362 -- 5) The items of pragma [Refined_]Depends if there is no pragma
kono
parents:
diff changeset
363 -- [Refined_]Global present and flag Synthesize is set to True.
kono
parents:
diff changeset
364 -- If the subprogram has no inputs and/or outputs, then the returned list
kono
parents:
diff changeset
365 -- is No_Elist. Flag Global_Seen is set when the related subprogram has
kono
parents:
diff changeset
366 -- pragma [Refined_]Global.
kono
parents:
diff changeset
367
kono
parents:
diff changeset
368 function Delay_Config_Pragma_Analyze (N : Node_Id) return Boolean;
kono
parents:
diff changeset
369 -- N is a pragma appearing in a configuration pragma file. Most such
kono
parents:
diff changeset
370 -- pragmas are analyzed when the file is read, before parsing and analyzing
kono
parents:
diff changeset
371 -- the main unit. However, the analysis of certain pragmas results in
kono
parents:
diff changeset
372 -- adding information to the compiled main unit, and this cannot be done
kono
parents:
diff changeset
373 -- till the main unit is processed. Such pragmas return True from this
kono
parents:
diff changeset
374 -- function and in Frontend pragmas where Delay_Config_Pragma_Analyze is
kono
parents:
diff changeset
375 -- True have their analysis delayed until after the main program is parsed
kono
parents:
diff changeset
376 -- and analyzed.
kono
parents:
diff changeset
377
kono
parents:
diff changeset
378 function Find_Related_Package_Or_Body
kono
parents:
diff changeset
379 (Prag : Node_Id;
kono
parents:
diff changeset
380 Do_Checks : Boolean := False) return Node_Id;
kono
parents:
diff changeset
381 -- Subsidiary to the analysis of pragmas
kono
parents:
diff changeset
382 -- Abstract_State
kono
parents:
diff changeset
383 -- Initial_Condition
kono
parents:
diff changeset
384 -- Initializes
kono
parents:
diff changeset
385 -- Refined_State
kono
parents:
diff changeset
386 -- Find the declaration of the related package [body] subject to pragma
kono
parents:
diff changeset
387 -- Prag. The return value is either N_Package_Declaration, N_Package_Body,
kono
parents:
diff changeset
388 -- or Empty if the placement of the pragma is illegal. If flag Do_Checks is
kono
parents:
diff changeset
389 -- set, the routine reports duplicate pragmas.
kono
parents:
diff changeset
390
kono
parents:
diff changeset
391 function Find_Related_Declaration_Or_Body
kono
parents:
diff changeset
392 (Prag : Node_Id;
kono
parents:
diff changeset
393 Do_Checks : Boolean := False) return Node_Id;
kono
parents:
diff changeset
394 -- Subsidiary to the analysis of pragmas
kono
parents:
diff changeset
395 -- Contract_Cases
kono
parents:
diff changeset
396 -- Depends
kono
parents:
diff changeset
397 -- Extensions_Visible
kono
parents:
diff changeset
398 -- Global
kono
parents:
diff changeset
399 -- Initializes
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
400 -- Max_Entry_Queue_Depth
111
kono
parents:
diff changeset
401 -- Max_Queue_Length
kono
parents:
diff changeset
402 -- Post
kono
parents:
diff changeset
403 -- Post_Class
kono
parents:
diff changeset
404 -- Postcondition
kono
parents:
diff changeset
405 -- Pre
kono
parents:
diff changeset
406 -- Pre_Class
kono
parents:
diff changeset
407 -- Precondition
kono
parents:
diff changeset
408 -- Refined_Depends
kono
parents:
diff changeset
409 -- Refined_Global
kono
parents:
diff changeset
410 -- Refined_Post
kono
parents:
diff changeset
411 -- Refined_State
kono
parents:
diff changeset
412 -- Test_Case
kono
parents:
diff changeset
413 -- Volatile_Function
kono
parents:
diff changeset
414 -- as well as attributes 'Old and 'Result. Find the declaration of the
kono
parents:
diff changeset
415 -- related entry, subprogram or task type [body] subject to pragma Prag.
kono
parents:
diff changeset
416 -- If flag Do_Checks is set, the routine reports duplicate pragmas and
kono
parents:
diff changeset
417 -- detects improper use of refinement pragmas in stand alone expression
kono
parents:
diff changeset
418 -- functions.
kono
parents:
diff changeset
419
kono
parents:
diff changeset
420 function Get_Argument
kono
parents:
diff changeset
421 (Prag : Node_Id;
kono
parents:
diff changeset
422 Context_Id : Node_Id := Empty) return Node_Id;
kono
parents:
diff changeset
423 -- Obtain the argument of pragma Prag depending on context and the nature
kono
parents:
diff changeset
424 -- of the pragma. The argument is extracted in the following manner:
kono
parents:
diff changeset
425 --
kono
parents:
diff changeset
426 -- When the pragma is generated from an aspect, return the corresponding
kono
parents:
diff changeset
427 -- aspect for ASIS or when Context_Id denotes a generic unit.
kono
parents:
diff changeset
428 --
kono
parents:
diff changeset
429 -- Otherwise return the first argument of Prag
kono
parents:
diff changeset
430 --
kono
parents:
diff changeset
431 -- Context denotes the entity of the function, package or procedure where
kono
parents:
diff changeset
432 -- Prag resides.
kono
parents:
diff changeset
433
kono
parents:
diff changeset
434 function Get_SPARK_Mode_From_Annotation
kono
parents:
diff changeset
435 (N : Node_Id) return SPARK_Mode_Type;
kono
parents:
diff changeset
436 -- Given an aspect or pragma SPARK_Mode node, return corresponding mode id
kono
parents:
diff changeset
437
kono
parents:
diff changeset
438 procedure Initialize;
kono
parents:
diff changeset
439 -- Initializes data structures used for pragma processing. Must be called
kono
parents:
diff changeset
440 -- before analyzing each new main source program.
kono
parents:
diff changeset
441
kono
parents:
diff changeset
442 function Is_Config_Static_String (Arg : Node_Id) return Boolean;
kono
parents:
diff changeset
443 -- This is called for a configuration pragma that requires either string
kono
parents:
diff changeset
444 -- literal or a concatenation of string literals. We cannot use normal
kono
parents:
diff changeset
445 -- static string processing because it is too early in the case of the
kono
parents:
diff changeset
446 -- pragma appearing in a configuration pragmas file. If Arg is of an
kono
parents:
diff changeset
447 -- appropriate form, then this call obtains the string (doing any necessary
kono
parents:
diff changeset
448 -- concatenations) and places it in Name_Buffer, setting Name_Len to its
kono
parents:
diff changeset
449 -- length, and then returns True. If it is not of the correct form, then an
kono
parents:
diff changeset
450 -- appropriate error message is posted, and False is returned.
kono
parents:
diff changeset
451
kono
parents:
diff changeset
452 function Is_Elaboration_SPARK_Mode (N : Node_Id) return Boolean;
kono
parents:
diff changeset
453 -- Determine whether pragma SPARK_Mode appears in the statement part of a
kono
parents:
diff changeset
454 -- package body.
kono
parents:
diff changeset
455
kono
parents:
diff changeset
456 function Is_Enabled_Pragma (Prag : Node_Id) return Boolean;
kono
parents:
diff changeset
457 -- Determine whether a Boolean-like SPARK pragma Prag is enabled. To be
kono
parents:
diff changeset
458 -- considered enabled, the pragma must either:
kono
parents:
diff changeset
459 -- * Appear without its Boolean expression
kono
parents:
diff changeset
460 -- * The Boolean expression evaluates to "True"
kono
parents:
diff changeset
461 --
kono
parents:
diff changeset
462 -- Boolean-like SPARK pragmas differ from pure Boolean Ada pragmas in that
kono
parents:
diff changeset
463 -- their optional Boolean expression must be static and cannot benefit from
kono
parents:
diff changeset
464 -- forward references. The following are Boolean-like SPARK pragmas:
kono
parents:
diff changeset
465 -- Async_Readers
kono
parents:
diff changeset
466 -- Async_Writers
kono
parents:
diff changeset
467 -- Constant_After_Elaboration
kono
parents:
diff changeset
468 -- Effective_Reads
kono
parents:
diff changeset
469 -- Effective_Writes
kono
parents:
diff changeset
470 -- Extensions_Visible
kono
parents:
diff changeset
471 -- Volatile_Function
kono
parents:
diff changeset
472
kono
parents:
diff changeset
473 function Is_Non_Significant_Pragma_Reference (N : Node_Id) return Boolean;
kono
parents:
diff changeset
474 -- The node N is a node for an entity and the issue is whether the
kono
parents:
diff changeset
475 -- occurrence is a reference for the purposes of giving warnings about
kono
parents:
diff changeset
476 -- unreferenced variables. This function returns True if the reference is
kono
parents:
diff changeset
477 -- not a reference from this point of view (e.g. the occurrence in a pragma
kono
parents:
diff changeset
478 -- Pack) and False if it is a real reference (e.g. the occurrence in a
kono
parents:
diff changeset
479 -- pragma Export);
kono
parents:
diff changeset
480
kono
parents:
diff changeset
481 function Is_Pragma_String_Literal (Par : Node_Id) return Boolean;
kono
parents:
diff changeset
482 -- Given an N_Pragma_Argument_Association node, Par, which has the form of
kono
parents:
diff changeset
483 -- an operator symbol, determines whether or not it should be treated as an
kono
parents:
diff changeset
484 -- string literal. This is called by Sem_Ch6.Analyze_Operator_Symbol. If
kono
parents:
diff changeset
485 -- True is returned, the argument is converted to a string literal. If
kono
parents:
diff changeset
486 -- False is returned, then the argument is treated as an entity reference
kono
parents:
diff changeset
487 -- to the operator.
kono
parents:
diff changeset
488
kono
parents:
diff changeset
489 function Is_Private_SPARK_Mode (N : Node_Id) return Boolean;
kono
parents:
diff changeset
490 -- Determine whether pragma SPARK_Mode appears in the private part of a
kono
parents:
diff changeset
491 -- package.
kono
parents:
diff changeset
492
kono
parents:
diff changeset
493 function Is_Valid_Assertion_Kind (Nam : Name_Id) return Boolean;
kono
parents:
diff changeset
494 -- Returns True if Nam is one of the names recognized as a valid assertion
kono
parents:
diff changeset
495 -- kind by the Assertion_Policy pragma. Note that the 'Class cases are
kono
parents:
diff changeset
496 -- represented by the corresponding special names Name_uPre, Name_uPost,
kono
parents:
diff changeset
497 -- Name_uInvariant, and Name_uType_Invariant (_Pre, _Post, _Invariant,
kono
parents:
diff changeset
498 -- and _Type_Invariant).
kono
parents:
diff changeset
499
kono
parents:
diff changeset
500 procedure Process_Compile_Time_Warning_Or_Error
kono
parents:
diff changeset
501 (N : Node_Id;
kono
parents:
diff changeset
502 Eloc : Source_Ptr);
kono
parents:
diff changeset
503 -- Common processing for Compile_Time_Error and Compile_Time_Warning of
kono
parents:
diff changeset
504 -- pragma N. Called when the pragma is processed as part of its regular
kono
parents:
diff changeset
505 -- analysis but also called after calling the back end to validate these
kono
parents:
diff changeset
506 -- pragmas for size and alignment appropriateness.
kono
parents:
diff changeset
507
kono
parents:
diff changeset
508 procedure Process_Compilation_Unit_Pragmas (N : Node_Id);
kono
parents:
diff changeset
509 -- Called at the start of processing compilation unit N to deal with any
kono
parents:
diff changeset
510 -- special issues regarding pragmas. In particular, we have to deal with
kono
parents:
diff changeset
511 -- Suppress_All at this stage, since it can appear after the unit instead
kono
parents:
diff changeset
512 -- of before (actually we allow it to appear anywhere).
kono
parents:
diff changeset
513
kono
parents:
diff changeset
514 procedure Relocate_Pragmas_To_Anonymous_Object
kono
parents:
diff changeset
515 (Typ_Decl : Node_Id;
kono
parents:
diff changeset
516 Obj_Decl : Node_Id);
kono
parents:
diff changeset
517 -- Relocate all pragmas that appear in the visible declarations of task or
kono
parents:
diff changeset
518 -- protected type declaration Typ_Decl after the declaration of anonymous
kono
parents:
diff changeset
519 -- object Obj_Decl. Table Pragmas_On_Anonymous_Object_OK contains the list
kono
parents:
diff changeset
520 -- of candidate pragmas.
kono
parents:
diff changeset
521
kono
parents:
diff changeset
522 procedure Relocate_Pragmas_To_Body
kono
parents:
diff changeset
523 (Subp_Body : Node_Id;
kono
parents:
diff changeset
524 Target_Body : Node_Id := Empty);
kono
parents:
diff changeset
525 -- Resocate all pragmas that follow and apply to subprogram body Subp_Body
kono
parents:
diff changeset
526 -- to its own declaration list. Candidate pragmas are classified in table
kono
parents:
diff changeset
527 -- Pragma_On_Body_Or_Stub_OK. If Target_Body is set, the pragma are moved
kono
parents:
diff changeset
528 -- to the declarations of Target_Body. This formal should be set when
kono
parents:
diff changeset
529 -- dealing with subprogram body stubs or expression functions.
kono
parents:
diff changeset
530
kono
parents:
diff changeset
531 procedure Set_Encoded_Interface_Name (E : Entity_Id; S : Node_Id);
kono
parents:
diff changeset
532 -- This routine is used to set an encoded interface name. The node S is
kono
parents:
diff changeset
533 -- an N_String_Literal node for the external name to be set, and E is an
kono
parents:
diff changeset
534 -- entity whose Interface_Name field is to be set. In the normal case where
kono
parents:
diff changeset
535 -- S contains a name that is a valid C identifier, then S is simply set as
kono
parents:
diff changeset
536 -- the value of the Interface_Name. Otherwise it is encoded as needed by
kono
parents:
diff changeset
537 -- particular operating systems. See the body for details of the encoding.
kono
parents:
diff changeset
538
kono
parents:
diff changeset
539 function Test_Case_Arg
kono
parents:
diff changeset
540 (Prag : Node_Id;
kono
parents:
diff changeset
541 Arg_Nam : Name_Id;
kono
parents:
diff changeset
542 From_Aspect : Boolean := False) return Node_Id;
kono
parents:
diff changeset
543 -- Obtain argument "Name", "Mode", "Ensures" or "Requires" from Test_Case
kono
parents:
diff changeset
544 -- pragma Prag as denoted by Arg_Nam. When From_Aspect is set, an attempt
kono
parents:
diff changeset
545 -- is made to retrieve the argument from the corresponding aspect if there
kono
parents:
diff changeset
546 -- is one. The returned argument has several formats:
kono
parents:
diff changeset
547 --
kono
parents:
diff changeset
548 -- N_Pragma_Argument_Association if retrieved directly from the pragma
kono
parents:
diff changeset
549 --
kono
parents:
diff changeset
550 -- N_Component_Association if retrieved from the corresponding aspect and
kono
parents:
diff changeset
551 -- the argument appears in a named association form.
kono
parents:
diff changeset
552 --
kono
parents:
diff changeset
553 -- An arbitrary expression if retrieved from the corresponding aspect and
kono
parents:
diff changeset
554 -- the argument appears in positional form.
kono
parents:
diff changeset
555 --
kono
parents:
diff changeset
556 -- Empty if there is no such argument
kono
parents:
diff changeset
557
kono
parents:
diff changeset
558 end Sem_Prag;