annotate gcc/ada/sem_prag.ads @ 120:f93fa5091070

fix conv1.c
author mir3636
date Thu, 08 Mar 2018 14:53:42 +0900
parents 04ced10e8804
children 84e7813d76e9
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 -- --
kono
parents:
diff changeset
9 -- Copyright (C) 1992-2017, Free Software Foundation, Inc. --
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,
kono
parents:
diff changeset
194 Pragma_Warnings => False,
kono
parents:
diff changeset
195 others => True);
kono
parents:
diff changeset
196
kono
parents:
diff changeset
197 -----------------
kono
parents:
diff changeset
198 -- Subprograms --
kono
parents:
diff changeset
199 -----------------
kono
parents:
diff changeset
200
kono
parents:
diff changeset
201 procedure Analyze_Pragma (N : Node_Id);
kono
parents:
diff changeset
202 -- Analyze procedure for pragma reference node N
kono
parents:
diff changeset
203
kono
parents:
diff changeset
204 procedure Analyze_Contract_Cases_In_Decl_Part
kono
parents:
diff changeset
205 (N : Node_Id;
kono
parents:
diff changeset
206 Freeze_Id : Entity_Id := Empty);
kono
parents:
diff changeset
207 -- Perform full analysis of delayed pragma Contract_Cases. Freeze_Id is the
kono
parents:
diff changeset
208 -- entity of [generic] package body or [generic] subprogram body which
kono
parents:
diff changeset
209 -- caused "freezing" of the related contract where the pragma resides.
kono
parents:
diff changeset
210
kono
parents:
diff changeset
211 procedure Analyze_Depends_In_Decl_Part (N : Node_Id);
kono
parents:
diff changeset
212 -- Perform full analysis of delayed pragma Depends. This routine is also
kono
parents:
diff changeset
213 -- capable of performing basic analysis of pragma Refined_Depends.
kono
parents:
diff changeset
214
kono
parents:
diff changeset
215 procedure Analyze_External_Property_In_Decl_Part
kono
parents:
diff changeset
216 (N : Node_Id;
kono
parents:
diff changeset
217 Expr_Val : out Boolean);
kono
parents:
diff changeset
218 -- Perform full analysis of delayed pragmas Async_Readers, Async_Writers,
kono
parents:
diff changeset
219 -- Effective_Reads and Effective_Writes. Flag Expr_Val contains the Boolean
kono
parents:
diff changeset
220 -- argument of the pragma or a default True if no argument is present.
kono
parents:
diff changeset
221
kono
parents:
diff changeset
222 procedure Analyze_Global_In_Decl_Part (N : Node_Id);
kono
parents:
diff changeset
223 -- Perform full analysis of delayed pragma Global. This routine is also
kono
parents:
diff changeset
224 -- capable of performing basic analysis of pragma Refined_Global.
kono
parents:
diff changeset
225
kono
parents:
diff changeset
226 procedure Analyze_Initial_Condition_In_Decl_Part (N : Node_Id);
kono
parents:
diff changeset
227 -- Perform full analysis of delayed pragma Initial_Condition
kono
parents:
diff changeset
228
kono
parents:
diff changeset
229 procedure Analyze_Initializes_In_Decl_Part (N : Node_Id);
kono
parents:
diff changeset
230 -- Perform full analysis of delayed pragma Initializes
kono
parents:
diff changeset
231
kono
parents:
diff changeset
232 procedure Analyze_Part_Of_In_Decl_Part
kono
parents:
diff changeset
233 (N : Node_Id;
kono
parents:
diff changeset
234 Freeze_Id : Entity_Id := Empty);
kono
parents:
diff changeset
235 -- Perform full analysis of delayed pragma Part_Of. Freeze_Id is the entity
kono
parents:
diff changeset
236 -- of [generic] package body or [generic] subprogram body which caused the
kono
parents:
diff changeset
237 -- "freezing" of the related contract where the pragma resides.
kono
parents:
diff changeset
238
kono
parents:
diff changeset
239 procedure Analyze_Pre_Post_Condition_In_Decl_Part
kono
parents:
diff changeset
240 (N : Node_Id;
kono
parents:
diff changeset
241 Freeze_Id : Entity_Id := Empty);
kono
parents:
diff changeset
242 -- Perform full analysis of pragmas Precondition and Postcondition.
kono
parents:
diff changeset
243 -- Freeze_Id denotes the entity of [generic] package body or [generic]
kono
parents:
diff changeset
244 -- subprogram body which caused "freezing" of the related contract where
kono
parents:
diff changeset
245 -- the pragma resides.
kono
parents:
diff changeset
246
kono
parents:
diff changeset
247 procedure Analyze_Refined_Depends_In_Decl_Part (N : Node_Id);
kono
parents:
diff changeset
248 -- Preform full analysis of delayed pragma Refined_Depends. This routine
kono
parents:
diff changeset
249 -- uses Analyze_Depends_In_Decl_Part as a starting point, then performs
kono
parents:
diff changeset
250 -- various consistency checks between Depends and Refined_Depends.
kono
parents:
diff changeset
251
kono
parents:
diff changeset
252 procedure Analyze_Refined_Global_In_Decl_Part (N : Node_Id);
kono
parents:
diff changeset
253 -- Perform full analysis of delayed pragma Refined_Global. This routine
kono
parents:
diff changeset
254 -- uses Analyze_Global_In_Decl_Part as a starting point, then performs
kono
parents:
diff changeset
255 -- various consistency checks between Global and Refined_Global.
kono
parents:
diff changeset
256
kono
parents:
diff changeset
257 procedure Analyze_Refined_State_In_Decl_Part
kono
parents:
diff changeset
258 (N : Node_Id;
kono
parents:
diff changeset
259 Freeze_Id : Entity_Id := Empty);
kono
parents:
diff changeset
260 -- Perform full analysis of delayed pragma Refined_State. Freeze_Id denotes
kono
parents:
diff changeset
261 -- the entity of [generic] package body or [generic] subprogram body which
kono
parents:
diff changeset
262 -- caused "freezing" of the related contract where the pragma resides.
kono
parents:
diff changeset
263
kono
parents:
diff changeset
264 procedure Analyze_Test_Case_In_Decl_Part (N : Node_Id);
kono
parents:
diff changeset
265 -- Perform preanalysis of pragma Test_Case
kono
parents:
diff changeset
266
kono
parents:
diff changeset
267 function Build_Pragma_Check_Equivalent
kono
parents:
diff changeset
268 (Prag : Node_Id;
kono
parents:
diff changeset
269 Subp_Id : Entity_Id := Empty;
kono
parents:
diff changeset
270 Inher_Id : Entity_Id := Empty;
kono
parents:
diff changeset
271 Keep_Pragma_Id : Boolean := False) return Node_Id;
kono
parents:
diff changeset
272 -- Transform a pre- or [refined] postcondition denoted by Prag into an
kono
parents:
diff changeset
273 -- equivalent pragma Check. When the pre- or postcondition is inherited,
kono
parents:
diff changeset
274 -- the routine replaces the references of all formals of Inher_Id
kono
parents:
diff changeset
275 -- and primitive operations of its controlling type by references
kono
parents:
diff changeset
276 -- to the corresponding entities of Subp_Id and the descendant type.
kono
parents:
diff changeset
277 -- Keep_Pragma_Id is True when the newly created pragma should be
kono
parents:
diff changeset
278 -- in fact of the same kind as the source pragma Prag. This is used
kono
parents:
diff changeset
279 -- in GNATprove_Mode to generate the inherited pre- and postconditions.
kono
parents:
diff changeset
280
kono
parents:
diff changeset
281 procedure Check_Applicable_Policy (N : Node_Id);
kono
parents:
diff changeset
282 -- N is either an N_Aspect or an N_Pragma node. There are two cases. If
kono
parents:
diff changeset
283 -- the name of the aspect or pragma is not one of those recognized as
kono
parents:
diff changeset
284 -- an assertion kind by an Assertion_Policy pragma, then the call has
kono
parents:
diff changeset
285 -- no effect. Note that in the case of a pragma derived from an aspect,
kono
parents:
diff changeset
286 -- the name we use for the purpose of this procedure is the aspect name,
kono
parents:
diff changeset
287 -- which may be different from the pragma name (e.g. Precondition for
kono
parents:
diff changeset
288 -- Pre aspect). In addition, 'Class aspects are recognized (and the
kono
parents:
diff changeset
289 -- corresponding special names used in the processing).
kono
parents:
diff changeset
290 --
kono
parents:
diff changeset
291 -- If the name is a valid assertion kind name, then the Check_Policy pragma
kono
parents:
diff changeset
292 -- chain is checked for a matching entry (or for an Assertion entry which
kono
parents:
diff changeset
293 -- matches all possibilities). If a matching entry is found then the policy
kono
parents:
diff changeset
294 -- is checked. If it is On or Check, then the Is_Checked flag is set in
kono
parents:
diff changeset
295 -- the aspect or pragma node. If it is Off, Ignore, or Disable, then the
kono
parents:
diff changeset
296 -- Is_Ignored flag is set in the aspect or pragma node. Additionally for
kono
parents:
diff changeset
297 -- policy Disable, the Is_Disabled flag is set.
kono
parents:
diff changeset
298 --
kono
parents:
diff changeset
299 -- If no matching Check_Policy pragma is found then the effect depends on
kono
parents:
diff changeset
300 -- whether -gnata was used, if so, then the call has no effect, otherwise
kono
parents:
diff changeset
301 -- Is_Ignored (but not Is_Disabled) is set True.
kono
parents:
diff changeset
302
kono
parents:
diff changeset
303 procedure Check_External_Properties
kono
parents:
diff changeset
304 (Item : Node_Id;
kono
parents:
diff changeset
305 AR : Boolean;
kono
parents:
diff changeset
306 AW : Boolean;
kono
parents:
diff changeset
307 ER : Boolean;
kono
parents:
diff changeset
308 EW : Boolean);
kono
parents:
diff changeset
309 -- Flags AR, AW, ER and EW denote the static values of external properties
kono
parents:
diff changeset
310 -- Async_Readers, Async_Writers, Effective_Reads and Effective_Writes. Item
kono
parents:
diff changeset
311 -- is the related variable or state. Ensure legality of the combination and
kono
parents:
diff changeset
312 -- issue an error for an illegal combination.
kono
parents:
diff changeset
313
kono
parents:
diff changeset
314 function Check_Kind (Nam : Name_Id) return Name_Id;
kono
parents:
diff changeset
315 -- This function is used in connection with pragmas Assert, Check,
kono
parents:
diff changeset
316 -- and assertion aspects and pragmas, to determine if Check pragmas
kono
parents:
diff changeset
317 -- (or corresponding assertion aspects or pragmas) are currently active
kono
parents:
diff changeset
318 -- as determined by the presence of -gnata on the command line (which
kono
parents:
diff changeset
319 -- sets the default), and the appearance of pragmas Check_Policy and
kono
parents:
diff changeset
320 -- Assertion_Policy as configuration pragmas either in a configuration
kono
parents:
diff changeset
321 -- pragma file, or at the start of the current unit, or locally given
kono
parents:
diff changeset
322 -- Check_Policy and Assertion_Policy pragmas that are currently active.
kono
parents:
diff changeset
323 --
kono
parents:
diff changeset
324 -- The value returned is one of the names Check, Ignore, Disable (On
kono
parents:
diff changeset
325 -- returns Check, and Off returns Ignore).
kono
parents:
diff changeset
326 --
kono
parents:
diff changeset
327 -- Note: for assertion kinds Pre'Class, Post'Class, Invariant'Class,
kono
parents:
diff changeset
328 -- and Type_Invariant'Class, the name passed is Name_uPre, Name_uPost,
kono
parents:
diff changeset
329 -- Name_uInvariant, or Name_uType_Invariant, which corresponds to _Pre,
kono
parents:
diff changeset
330 -- _Post, _Invariant, or _Type_Invariant, which are special names used
kono
parents:
diff changeset
331 -- in identifiers to represent these attribute references.
kono
parents:
diff changeset
332
kono
parents:
diff changeset
333 procedure Check_Missing_Part_Of (Item_Id : Entity_Id);
kono
parents:
diff changeset
334 -- Determine whether the placement within the state space of an abstract
kono
parents:
diff changeset
335 -- state, variable or package instantiation denoted by Item_Id requires the
kono
parents:
diff changeset
336 -- use of indicator/option Part_Of. If this is the case, emit an error.
kono
parents:
diff changeset
337
kono
parents:
diff changeset
338 procedure Collect_Inherited_Class_Wide_Conditions (Subp : Entity_Id);
kono
parents:
diff changeset
339 -- In GNATprove mode, when analyzing an overriding subprogram, check
kono
parents:
diff changeset
340 -- whether the overridden operations have class-wide pre/postconditions,
kono
parents:
diff changeset
341 -- and generate the corresponding pragmas. The pragmas are inserted after
kono
parents:
diff changeset
342 -- the subprogram declaration, together with those generated for other
kono
parents:
diff changeset
343 -- aspects of the subprogram.
kono
parents:
diff changeset
344
kono
parents:
diff changeset
345 procedure Collect_Subprogram_Inputs_Outputs
kono
parents:
diff changeset
346 (Subp_Id : Entity_Id;
kono
parents:
diff changeset
347 Synthesize : Boolean := False;
kono
parents:
diff changeset
348 Subp_Inputs : in out Elist_Id;
kono
parents:
diff changeset
349 Subp_Outputs : in out Elist_Id;
kono
parents:
diff changeset
350 Global_Seen : out Boolean);
kono
parents:
diff changeset
351 -- Subsidiary to the analysis of pragmas Depends, Global, Refined_Depends
kono
parents:
diff changeset
352 -- and Refined_Global. The routine is also used by GNATprove. Collect all
kono
parents:
diff changeset
353 -- inputs and outputs of subprogram Subp_Id in lists Subp_Inputs (inputs)
kono
parents:
diff changeset
354 -- and Subp_Outputs (outputs). The inputs and outputs are gathered from:
kono
parents:
diff changeset
355 -- 1) The formal parameters of the subprogram
kono
parents:
diff changeset
356 -- 2) The generic formal parameters of the generic subprogram
kono
parents:
diff changeset
357 -- 3) The current instance of a concurrent type
kono
parents:
diff changeset
358 -- 4) The items of pragma [Refined_]Global
kono
parents:
diff changeset
359 -- or
kono
parents:
diff changeset
360 -- 5) The items of pragma [Refined_]Depends if there is no pragma
kono
parents:
diff changeset
361 -- [Refined_]Global present and flag Synthesize is set to True.
kono
parents:
diff changeset
362 -- If the subprogram has no inputs and/or outputs, then the returned list
kono
parents:
diff changeset
363 -- is No_Elist. Flag Global_Seen is set when the related subprogram has
kono
parents:
diff changeset
364 -- pragma [Refined_]Global.
kono
parents:
diff changeset
365
kono
parents:
diff changeset
366 function Delay_Config_Pragma_Analyze (N : Node_Id) return Boolean;
kono
parents:
diff changeset
367 -- N is a pragma appearing in a configuration pragma file. Most such
kono
parents:
diff changeset
368 -- pragmas are analyzed when the file is read, before parsing and analyzing
kono
parents:
diff changeset
369 -- the main unit. However, the analysis of certain pragmas results in
kono
parents:
diff changeset
370 -- adding information to the compiled main unit, and this cannot be done
kono
parents:
diff changeset
371 -- till the main unit is processed. Such pragmas return True from this
kono
parents:
diff changeset
372 -- function and in Frontend pragmas where Delay_Config_Pragma_Analyze is
kono
parents:
diff changeset
373 -- True have their analysis delayed until after the main program is parsed
kono
parents:
diff changeset
374 -- and analyzed.
kono
parents:
diff changeset
375
kono
parents:
diff changeset
376 function Find_Related_Package_Or_Body
kono
parents:
diff changeset
377 (Prag : Node_Id;
kono
parents:
diff changeset
378 Do_Checks : Boolean := False) return Node_Id;
kono
parents:
diff changeset
379 -- Subsidiary to the analysis of pragmas
kono
parents:
diff changeset
380 -- Abstract_State
kono
parents:
diff changeset
381 -- Initial_Condition
kono
parents:
diff changeset
382 -- Initializes
kono
parents:
diff changeset
383 -- Refined_State
kono
parents:
diff changeset
384 -- Find the declaration of the related package [body] subject to pragma
kono
parents:
diff changeset
385 -- Prag. The return value is either N_Package_Declaration, N_Package_Body,
kono
parents:
diff changeset
386 -- or Empty if the placement of the pragma is illegal. If flag Do_Checks is
kono
parents:
diff changeset
387 -- set, the routine reports duplicate pragmas.
kono
parents:
diff changeset
388
kono
parents:
diff changeset
389 function Find_Related_Declaration_Or_Body
kono
parents:
diff changeset
390 (Prag : Node_Id;
kono
parents:
diff changeset
391 Do_Checks : Boolean := False) return Node_Id;
kono
parents:
diff changeset
392 -- Subsidiary to the analysis of pragmas
kono
parents:
diff changeset
393 -- Contract_Cases
kono
parents:
diff changeset
394 -- Depends
kono
parents:
diff changeset
395 -- Extensions_Visible
kono
parents:
diff changeset
396 -- Global
kono
parents:
diff changeset
397 -- Initializes
kono
parents:
diff changeset
398 -- Max_Queue_Length
kono
parents:
diff changeset
399 -- Post
kono
parents:
diff changeset
400 -- Post_Class
kono
parents:
diff changeset
401 -- Postcondition
kono
parents:
diff changeset
402 -- Pre
kono
parents:
diff changeset
403 -- Pre_Class
kono
parents:
diff changeset
404 -- Precondition
kono
parents:
diff changeset
405 -- Refined_Depends
kono
parents:
diff changeset
406 -- Refined_Global
kono
parents:
diff changeset
407 -- Refined_Post
kono
parents:
diff changeset
408 -- Refined_State
kono
parents:
diff changeset
409 -- Test_Case
kono
parents:
diff changeset
410 -- Volatile_Function
kono
parents:
diff changeset
411 -- as well as attributes 'Old and 'Result. Find the declaration of the
kono
parents:
diff changeset
412 -- related entry, subprogram or task type [body] subject to pragma Prag.
kono
parents:
diff changeset
413 -- If flag Do_Checks is set, the routine reports duplicate pragmas and
kono
parents:
diff changeset
414 -- detects improper use of refinement pragmas in stand alone expression
kono
parents:
diff changeset
415 -- functions.
kono
parents:
diff changeset
416
kono
parents:
diff changeset
417 function Get_Argument
kono
parents:
diff changeset
418 (Prag : Node_Id;
kono
parents:
diff changeset
419 Context_Id : Node_Id := Empty) return Node_Id;
kono
parents:
diff changeset
420 -- Obtain the argument of pragma Prag depending on context and the nature
kono
parents:
diff changeset
421 -- of the pragma. The argument is extracted in the following manner:
kono
parents:
diff changeset
422 --
kono
parents:
diff changeset
423 -- When the pragma is generated from an aspect, return the corresponding
kono
parents:
diff changeset
424 -- aspect for ASIS or when Context_Id denotes a generic unit.
kono
parents:
diff changeset
425 --
kono
parents:
diff changeset
426 -- Otherwise return the first argument of Prag
kono
parents:
diff changeset
427 --
kono
parents:
diff changeset
428 -- Context denotes the entity of the function, package or procedure where
kono
parents:
diff changeset
429 -- Prag resides.
kono
parents:
diff changeset
430
kono
parents:
diff changeset
431 function Get_SPARK_Mode_From_Annotation
kono
parents:
diff changeset
432 (N : Node_Id) return SPARK_Mode_Type;
kono
parents:
diff changeset
433 -- Given an aspect or pragma SPARK_Mode node, return corresponding mode id
kono
parents:
diff changeset
434
kono
parents:
diff changeset
435 procedure Initialize;
kono
parents:
diff changeset
436 -- Initializes data structures used for pragma processing. Must be called
kono
parents:
diff changeset
437 -- before analyzing each new main source program.
kono
parents:
diff changeset
438
kono
parents:
diff changeset
439 function Is_Config_Static_String (Arg : Node_Id) return Boolean;
kono
parents:
diff changeset
440 -- This is called for a configuration pragma that requires either string
kono
parents:
diff changeset
441 -- literal or a concatenation of string literals. We cannot use normal
kono
parents:
diff changeset
442 -- static string processing because it is too early in the case of the
kono
parents:
diff changeset
443 -- pragma appearing in a configuration pragmas file. If Arg is of an
kono
parents:
diff changeset
444 -- appropriate form, then this call obtains the string (doing any necessary
kono
parents:
diff changeset
445 -- concatenations) and places it in Name_Buffer, setting Name_Len to its
kono
parents:
diff changeset
446 -- length, and then returns True. If it is not of the correct form, then an
kono
parents:
diff changeset
447 -- appropriate error message is posted, and False is returned.
kono
parents:
diff changeset
448
kono
parents:
diff changeset
449 function Is_Elaboration_SPARK_Mode (N : Node_Id) return Boolean;
kono
parents:
diff changeset
450 -- Determine whether pragma SPARK_Mode appears in the statement part of a
kono
parents:
diff changeset
451 -- package body.
kono
parents:
diff changeset
452
kono
parents:
diff changeset
453 function Is_Enabled_Pragma (Prag : Node_Id) return Boolean;
kono
parents:
diff changeset
454 -- Determine whether a Boolean-like SPARK pragma Prag is enabled. To be
kono
parents:
diff changeset
455 -- considered enabled, the pragma must either:
kono
parents:
diff changeset
456 -- * Appear without its Boolean expression
kono
parents:
diff changeset
457 -- * The Boolean expression evaluates to "True"
kono
parents:
diff changeset
458 --
kono
parents:
diff changeset
459 -- Boolean-like SPARK pragmas differ from pure Boolean Ada pragmas in that
kono
parents:
diff changeset
460 -- their optional Boolean expression must be static and cannot benefit from
kono
parents:
diff changeset
461 -- forward references. The following are Boolean-like SPARK pragmas:
kono
parents:
diff changeset
462 -- Async_Readers
kono
parents:
diff changeset
463 -- Async_Writers
kono
parents:
diff changeset
464 -- Constant_After_Elaboration
kono
parents:
diff changeset
465 -- Effective_Reads
kono
parents:
diff changeset
466 -- Effective_Writes
kono
parents:
diff changeset
467 -- Extensions_Visible
kono
parents:
diff changeset
468 -- Volatile_Function
kono
parents:
diff changeset
469
kono
parents:
diff changeset
470 function Is_Non_Significant_Pragma_Reference (N : Node_Id) return Boolean;
kono
parents:
diff changeset
471 -- The node N is a node for an entity and the issue is whether the
kono
parents:
diff changeset
472 -- occurrence is a reference for the purposes of giving warnings about
kono
parents:
diff changeset
473 -- unreferenced variables. This function returns True if the reference is
kono
parents:
diff changeset
474 -- not a reference from this point of view (e.g. the occurrence in a pragma
kono
parents:
diff changeset
475 -- Pack) and False if it is a real reference (e.g. the occurrence in a
kono
parents:
diff changeset
476 -- pragma Export);
kono
parents:
diff changeset
477
kono
parents:
diff changeset
478 function Is_Pragma_String_Literal (Par : Node_Id) return Boolean;
kono
parents:
diff changeset
479 -- Given an N_Pragma_Argument_Association node, Par, which has the form of
kono
parents:
diff changeset
480 -- an operator symbol, determines whether or not it should be treated as an
kono
parents:
diff changeset
481 -- string literal. This is called by Sem_Ch6.Analyze_Operator_Symbol. If
kono
parents:
diff changeset
482 -- True is returned, the argument is converted to a string literal. If
kono
parents:
diff changeset
483 -- False is returned, then the argument is treated as an entity reference
kono
parents:
diff changeset
484 -- to the operator.
kono
parents:
diff changeset
485
kono
parents:
diff changeset
486 function Is_Private_SPARK_Mode (N : Node_Id) return Boolean;
kono
parents:
diff changeset
487 -- Determine whether pragma SPARK_Mode appears in the private part of a
kono
parents:
diff changeset
488 -- package.
kono
parents:
diff changeset
489
kono
parents:
diff changeset
490 function Is_Valid_Assertion_Kind (Nam : Name_Id) return Boolean;
kono
parents:
diff changeset
491 -- Returns True if Nam is one of the names recognized as a valid assertion
kono
parents:
diff changeset
492 -- kind by the Assertion_Policy pragma. Note that the 'Class cases are
kono
parents:
diff changeset
493 -- represented by the corresponding special names Name_uPre, Name_uPost,
kono
parents:
diff changeset
494 -- Name_uInvariant, and Name_uType_Invariant (_Pre, _Post, _Invariant,
kono
parents:
diff changeset
495 -- and _Type_Invariant).
kono
parents:
diff changeset
496
kono
parents:
diff changeset
497 procedure Process_Compile_Time_Warning_Or_Error
kono
parents:
diff changeset
498 (N : Node_Id;
kono
parents:
diff changeset
499 Eloc : Source_Ptr);
kono
parents:
diff changeset
500 -- Common processing for Compile_Time_Error and Compile_Time_Warning of
kono
parents:
diff changeset
501 -- pragma N. Called when the pragma is processed as part of its regular
kono
parents:
diff changeset
502 -- analysis but also called after calling the back end to validate these
kono
parents:
diff changeset
503 -- pragmas for size and alignment appropriateness.
kono
parents:
diff changeset
504
kono
parents:
diff changeset
505 procedure Process_Compilation_Unit_Pragmas (N : Node_Id);
kono
parents:
diff changeset
506 -- Called at the start of processing compilation unit N to deal with any
kono
parents:
diff changeset
507 -- special issues regarding pragmas. In particular, we have to deal with
kono
parents:
diff changeset
508 -- Suppress_All at this stage, since it can appear after the unit instead
kono
parents:
diff changeset
509 -- of before (actually we allow it to appear anywhere).
kono
parents:
diff changeset
510
kono
parents:
diff changeset
511 procedure Relocate_Pragmas_To_Anonymous_Object
kono
parents:
diff changeset
512 (Typ_Decl : Node_Id;
kono
parents:
diff changeset
513 Obj_Decl : Node_Id);
kono
parents:
diff changeset
514 -- Relocate all pragmas that appear in the visible declarations of task or
kono
parents:
diff changeset
515 -- protected type declaration Typ_Decl after the declaration of anonymous
kono
parents:
diff changeset
516 -- object Obj_Decl. Table Pragmas_On_Anonymous_Object_OK contains the list
kono
parents:
diff changeset
517 -- of candidate pragmas.
kono
parents:
diff changeset
518
kono
parents:
diff changeset
519 procedure Relocate_Pragmas_To_Body
kono
parents:
diff changeset
520 (Subp_Body : Node_Id;
kono
parents:
diff changeset
521 Target_Body : Node_Id := Empty);
kono
parents:
diff changeset
522 -- Resocate all pragmas that follow and apply to subprogram body Subp_Body
kono
parents:
diff changeset
523 -- to its own declaration list. Candidate pragmas are classified in table
kono
parents:
diff changeset
524 -- Pragma_On_Body_Or_Stub_OK. If Target_Body is set, the pragma are moved
kono
parents:
diff changeset
525 -- to the declarations of Target_Body. This formal should be set when
kono
parents:
diff changeset
526 -- dealing with subprogram body stubs or expression functions.
kono
parents:
diff changeset
527
kono
parents:
diff changeset
528 procedure Set_Encoded_Interface_Name (E : Entity_Id; S : Node_Id);
kono
parents:
diff changeset
529 -- This routine is used to set an encoded interface name. The node S is
kono
parents:
diff changeset
530 -- an N_String_Literal node for the external name to be set, and E is an
kono
parents:
diff changeset
531 -- entity whose Interface_Name field is to be set. In the normal case where
kono
parents:
diff changeset
532 -- S contains a name that is a valid C identifier, then S is simply set as
kono
parents:
diff changeset
533 -- the value of the Interface_Name. Otherwise it is encoded as needed by
kono
parents:
diff changeset
534 -- particular operating systems. See the body for details of the encoding.
kono
parents:
diff changeset
535
kono
parents:
diff changeset
536 function Test_Case_Arg
kono
parents:
diff changeset
537 (Prag : Node_Id;
kono
parents:
diff changeset
538 Arg_Nam : Name_Id;
kono
parents:
diff changeset
539 From_Aspect : Boolean := False) return Node_Id;
kono
parents:
diff changeset
540 -- Obtain argument "Name", "Mode", "Ensures" or "Requires" from Test_Case
kono
parents:
diff changeset
541 -- pragma Prag as denoted by Arg_Nam. When From_Aspect is set, an attempt
kono
parents:
diff changeset
542 -- is made to retrieve the argument from the corresponding aspect if there
kono
parents:
diff changeset
543 -- is one. The returned argument has several formats:
kono
parents:
diff changeset
544 --
kono
parents:
diff changeset
545 -- N_Pragma_Argument_Association if retrieved directly from the pragma
kono
parents:
diff changeset
546 --
kono
parents:
diff changeset
547 -- N_Component_Association if retrieved from the corresponding aspect and
kono
parents:
diff changeset
548 -- the argument appears in a named association form.
kono
parents:
diff changeset
549 --
kono
parents:
diff changeset
550 -- An arbitrary expression if retrieved from the corresponding aspect and
kono
parents:
diff changeset
551 -- the argument appears in positional form.
kono
parents:
diff changeset
552 --
kono
parents:
diff changeset
553 -- Empty if there is no such argument
kono
parents:
diff changeset
554
kono
parents:
diff changeset
555 end Sem_Prag;