annotate gcc/ada/restrict.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 -- R E S T R I C T --
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 -- This package deals with the implementation of the Restrictions pragma
kono
parents:
diff changeset
27
kono
parents:
diff changeset
28 with Aspects; use Aspects;
kono
parents:
diff changeset
29 with Namet; use Namet;
kono
parents:
diff changeset
30 with Rident; use Rident;
kono
parents:
diff changeset
31 with Snames; use Snames;
kono
parents:
diff changeset
32 with Table;
kono
parents:
diff changeset
33 with Types; use Types;
kono
parents:
diff changeset
34 with Uintp; use Uintp;
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 package Restrict is
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 Restrictions : Restrictions_Info := No_Restrictions;
kono
parents:
diff changeset
39 -- This variable records restrictions found in any units in the main
kono
parents:
diff changeset
40 -- extended unit, and in the case of restrictions checked for partition
kono
parents:
diff changeset
41 -- consistency, restrictions found in any with'ed units, parent specs
kono
parents:
diff changeset
42 -- etc., since we may as well check as much as we can at compile time.
kono
parents:
diff changeset
43 -- These variables should not be referenced directly by clients. Instead
kono
parents:
diff changeset
44 -- use Check_Restriction to record a violation of a restriction, and
kono
parents:
diff changeset
45 -- Restriction_Active to test if a given restriction is active.
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 Restrictions_Loc : array (All_Restrictions) of Source_Ptr :=
kono
parents:
diff changeset
48 (others => No_Location);
kono
parents:
diff changeset
49 -- Locations of Restrictions pragmas for error message purposes.
kono
parents:
diff changeset
50 -- Valid only if corresponding entry in Restrictions is set. A value
kono
parents:
diff changeset
51 -- of No_Location is used for implicit restrictions set by another
kono
parents:
diff changeset
52 -- pragma, and a value of System_Location is used for restrictions
kono
parents:
diff changeset
53 -- set from package Standard by the processing in Targparm.
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 Restriction_Profile_Name : array (All_Restrictions) of Profile_Name;
kono
parents:
diff changeset
56 -- Entries in this array are valid only if the corresponding restriction in
kono
parents:
diff changeset
57 -- Restrictions is set. The value is the corresponding profile name if the
kono
parents:
diff changeset
58 -- restriction was set by a Profile or Profile_Warnings pragma. The value
kono
parents:
diff changeset
59 -- is No_Profile in all other cases.
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 Main_Restrictions : Restrictions_Info := No_Restrictions;
kono
parents:
diff changeset
62 -- This variable records only restrictions found in any units of the
kono
parents:
diff changeset
63 -- main extended unit. These are the variables used for ali file output,
kono
parents:
diff changeset
64 -- since we want the binder to be able to accurately diagnose inter-unit
kono
parents:
diff changeset
65 -- restriction violations.
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 Restriction_Warnings : Rident.Restriction_Flags := (others => False);
kono
parents:
diff changeset
68 -- If one of these flags is set, then it means that violation of the
kono
parents:
diff changeset
69 -- corresponding restriction results only in a warning message, not
kono
parents:
diff changeset
70 -- in an error message, and the restriction is not otherwise enforced.
kono
parents:
diff changeset
71 -- Note that the flags in Restrictions are set to indicate that the
kono
parents:
diff changeset
72 -- restriction is set in this case, but Main_Restrictions is never
kono
parents:
diff changeset
73 -- set if Restriction_Warnings is set, so this does not look like a
kono
parents:
diff changeset
74 -- restriction to the binder.
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 -- The following declarations establish a mapping between restriction
kono
parents:
diff changeset
77 -- identifiers, and the names of corresponding restricted library units.
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 type Unit_Entry is record
kono
parents:
diff changeset
80 Res_Id : Restriction_Id;
kono
parents:
diff changeset
81 Filenm : String (1 .. 8);
kono
parents:
diff changeset
82 end record;
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 Unit_Array : constant array (Positive range <>) of Unit_Entry := (
kono
parents:
diff changeset
85 (No_Asynchronous_Control, "a-astaco"),
kono
parents:
diff changeset
86 (No_Calendar, "a-calend"),
kono
parents:
diff changeset
87 (No_Calendar, "calendar"),
kono
parents:
diff changeset
88 (No_Delay, "a-calend"),
kono
parents:
diff changeset
89 (No_Delay, "calendar"),
kono
parents:
diff changeset
90 (No_Dynamic_Priorities, "a-dynpri"),
kono
parents:
diff changeset
91 (No_Finalization, "a-finali"),
kono
parents:
diff changeset
92 (No_IO, "a-direio"),
kono
parents:
diff changeset
93 (No_IO, "directio"),
kono
parents:
diff changeset
94 (No_IO, "a-sequio"),
kono
parents:
diff changeset
95 (No_IO, "sequenio"),
kono
parents:
diff changeset
96 (No_IO, "a-ststio"),
kono
parents:
diff changeset
97 (No_IO, "a-textio"),
kono
parents:
diff changeset
98 (No_IO, "text_io "),
kono
parents:
diff changeset
99 (No_IO, "a-witeio"),
kono
parents:
diff changeset
100 (No_Task_Attributes_Package, "a-tasatt"),
kono
parents:
diff changeset
101 (No_Unchecked_Conversion, "a-unccon"),
kono
parents:
diff changeset
102 (No_Unchecked_Conversion, "unchconv"),
kono
parents:
diff changeset
103 (No_Unchecked_Deallocation, "a-uncdea"),
kono
parents:
diff changeset
104 (No_Unchecked_Deallocation, "unchdeal"));
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 -- The following map has True for all GNAT-defined Restrictions. It is used
kono
parents:
diff changeset
107 -- to implement pragma Restrictions (No_Implementation_Restrictions) (which
kono
parents:
diff changeset
108 -- is why this restriction itself is excluded from the list).
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 Implementation_Restriction : constant array (All_Restrictions) of Boolean :=
kono
parents:
diff changeset
111 (Simple_Barriers => True,
kono
parents:
diff changeset
112 No_Calendar => True,
kono
parents:
diff changeset
113 No_Default_Initialization => True,
kono
parents:
diff changeset
114 No_Direct_Boolean_Operators => True,
kono
parents:
diff changeset
115 No_Dispatching_Calls => True,
kono
parents:
diff changeset
116 No_Dynamic_Attachment => True,
kono
parents:
diff changeset
117 No_Elaboration_Code => True,
kono
parents:
diff changeset
118 No_Enumeration_Maps => True,
kono
parents:
diff changeset
119 No_Entry_Calls_In_Elaboration_Code => True,
kono
parents:
diff changeset
120 No_Entry_Queue => True,
kono
parents:
diff changeset
121 No_Exception_Handlers => True,
kono
parents:
diff changeset
122 No_Exception_Propagation => True,
kono
parents:
diff changeset
123 No_Exception_Registration => True,
kono
parents:
diff changeset
124 No_Finalization => True,
kono
parents:
diff changeset
125 No_Fixed_IO => True,
kono
parents:
diff changeset
126 No_Implementation_Attributes => True,
kono
parents:
diff changeset
127 No_Implementation_Pragmas => True,
kono
parents:
diff changeset
128 No_Implicit_Conditionals => True,
kono
parents:
diff changeset
129 No_Implicit_Aliasing => True,
kono
parents:
diff changeset
130 No_Implicit_Dynamic_Code => True,
kono
parents:
diff changeset
131 No_Implicit_Loops => True,
kono
parents:
diff changeset
132 No_Initialize_Scalars => True,
kono
parents:
diff changeset
133 No_Local_Protected_Objects => True,
kono
parents:
diff changeset
134 No_Long_Long_Integers => True,
kono
parents:
diff changeset
135 No_Multiple_Elaboration => True,
kono
parents:
diff changeset
136 No_Protected_Type_Allocators => True,
kono
parents:
diff changeset
137 No_Relative_Delay => True,
kono
parents:
diff changeset
138 No_Requeue_Statements => True,
kono
parents:
diff changeset
139 No_Secondary_Stack => True,
kono
parents:
diff changeset
140 No_Select_Statements => True,
kono
parents:
diff changeset
141 No_Standard_Storage_Pools => True,
kono
parents:
diff changeset
142 No_Stream_Optimizations => True,
kono
parents:
diff changeset
143 No_Streams => True,
kono
parents:
diff changeset
144 No_Task_Attributes_Package => True,
kono
parents:
diff changeset
145 No_Task_Termination => True,
kono
parents:
diff changeset
146 No_Tasking => True,
kono
parents:
diff changeset
147 No_Wide_Characters => True,
kono
parents:
diff changeset
148 Static_Priorities => True,
kono
parents:
diff changeset
149 Static_Storage_Size => True,
kono
parents:
diff changeset
150 Pure_Barriers => True,
kono
parents:
diff changeset
151 SPARK_05 => True,
kono
parents:
diff changeset
152 others => False);
kono
parents:
diff changeset
153
kono
parents:
diff changeset
154 --------------------------
kono
parents:
diff changeset
155 -- No_Dependences Table --
kono
parents:
diff changeset
156 --------------------------
kono
parents:
diff changeset
157
kono
parents:
diff changeset
158 -- The following table records entries made by Restrictions pragmas
kono
parents:
diff changeset
159 -- that specify a parameter for No_Dependence. Each such pragma makes
kono
parents:
diff changeset
160 -- an entry in this table.
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 -- Note: we have chosen to implement this restriction in the "syntactic"
kono
parents:
diff changeset
163 -- form, where we do not check that the named package is a language defined
kono
parents:
diff changeset
164 -- package, but instead we allow arbitrary package names. The discussion of
kono
parents:
diff changeset
165 -- this issue is not complete in the ARG, but the sense seems to be leaning
kono
parents:
diff changeset
166 -- in this direction, which makes more sense to us, since it is much more
kono
parents:
diff changeset
167 -- useful, and much easier to implement.
kono
parents:
diff changeset
168
kono
parents:
diff changeset
169 type ND_Entry is record
kono
parents:
diff changeset
170 Unit : Node_Id;
kono
parents:
diff changeset
171 -- The unit parameter from the No_Dependence pragma
kono
parents:
diff changeset
172
kono
parents:
diff changeset
173 Warn : Boolean;
kono
parents:
diff changeset
174 -- True if from Restriction_Warnings, False if from Restrictions
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 Profile : Profile_Name;
kono
parents:
diff changeset
177 -- Set to name of profile from which No_Dependence entry came, or to
kono
parents:
diff changeset
178 -- No_Profile if a pragma Restriction set the No_Dependence entry.
kono
parents:
diff changeset
179 end record;
kono
parents:
diff changeset
180
kono
parents:
diff changeset
181 package No_Dependences is new Table.Table (
kono
parents:
diff changeset
182 Table_Component_Type => ND_Entry,
kono
parents:
diff changeset
183 Table_Index_Type => Int,
kono
parents:
diff changeset
184 Table_Low_Bound => 0,
kono
parents:
diff changeset
185 Table_Initial => 200,
kono
parents:
diff changeset
186 Table_Increment => 200,
kono
parents:
diff changeset
187 Table_Name => "Name_No_Dependences");
kono
parents:
diff changeset
188
kono
parents:
diff changeset
189 ----------------------------
kono
parents:
diff changeset
190 -- No_Use_Of_Entity Table --
kono
parents:
diff changeset
191 ----------------------------
kono
parents:
diff changeset
192
kono
parents:
diff changeset
193 -- The following table records entries made by Restrictions pragmas
kono
parents:
diff changeset
194 -- that specify a parameter for No_Use_Of_Entity. Each such pragma makes
kono
parents:
diff changeset
195 -- an entry in this table.
kono
parents:
diff changeset
196
kono
parents:
diff changeset
197 -- Note: we have chosen to implement this restriction in the "syntactic"
kono
parents:
diff changeset
198 -- form, where we allow arbitrary fully qualified names to be specified.
kono
parents:
diff changeset
199
kono
parents:
diff changeset
200 type NE_Entry is record
kono
parents:
diff changeset
201 Entity : Node_Id;
kono
parents:
diff changeset
202 -- The entity parameter from the No_Use_Of_Entity pragma. This is in
kono
parents:
diff changeset
203 -- the form of a selected component, since that is the way the parser
kono
parents:
diff changeset
204 -- processes it, and we don't further analyze it.
kono
parents:
diff changeset
205
kono
parents:
diff changeset
206 Warn : Boolean;
kono
parents:
diff changeset
207 -- True if from Restriction_Warnings, False if from Restrictions
kono
parents:
diff changeset
208
kono
parents:
diff changeset
209 Profile : Profile_Name;
kono
parents:
diff changeset
210 -- Set to name of profile from which No_Use_Of_Entity entry came, or to
kono
parents:
diff changeset
211 -- No_Profile if a pragma Restriction set the No_Use_Of_Entity entry.
kono
parents:
diff changeset
212 end record;
kono
parents:
diff changeset
213
kono
parents:
diff changeset
214 package No_Use_Of_Entity is new Table.Table (
kono
parents:
diff changeset
215 Table_Component_Type => NE_Entry,
kono
parents:
diff changeset
216 Table_Index_Type => Int,
kono
parents:
diff changeset
217 Table_Low_Bound => 0,
kono
parents:
diff changeset
218 Table_Initial => 200,
kono
parents:
diff changeset
219 Table_Increment => 200,
kono
parents:
diff changeset
220 Table_Name => "Name_No_Use_Of_Entity");
kono
parents:
diff changeset
221
kono
parents:
diff changeset
222 -- Note that in addition to making an entry in this table, we also set the
kono
parents:
diff changeset
223 -- Boolean2 flag of the Name_Table entry for the simple name of the entity.
kono
parents:
diff changeset
224 -- This is used to avoid most useless searches of this table.
kono
parents:
diff changeset
225
kono
parents:
diff changeset
226 -----------------
kono
parents:
diff changeset
227 -- Subprograms --
kono
parents:
diff changeset
228 -----------------
kono
parents:
diff changeset
229
kono
parents:
diff changeset
230 -- Note: several of these subprograms can generate error messages (e.g.
kono
parents:
diff changeset
231 -- Check_Restriction). These routines should be called in the analyzer
kono
parents:
diff changeset
232 -- rather than the expander, so that the associated error messages are
kono
parents:
diff changeset
233 -- correctly generated in semantics only (-gnatc) mode.
kono
parents:
diff changeset
234
kono
parents:
diff changeset
235 function Abort_Allowed return Boolean;
kono
parents:
diff changeset
236 pragma Inline (Abort_Allowed);
kono
parents:
diff changeset
237 -- Tests to see if abort is allowed by the current restrictions settings.
kono
parents:
diff changeset
238 -- For abort to be allowed, either No_Abort_Statements must be False,
kono
parents:
diff changeset
239 -- or Max_Asynchronous_Select_Nesting must be non-zero.
kono
parents:
diff changeset
240
kono
parents:
diff changeset
241 procedure Check_Compiler_Unit (Feature : String; N : Node_Id);
kono
parents:
diff changeset
242 -- If unit N is in a unit that has a pragma Compiler_Unit_Warning, then
kono
parents:
diff changeset
243 -- a message is posted on node N noting use of the given feature is not
kono
parents:
diff changeset
244 -- permitted in the compiler (bootstrap considerations).
kono
parents:
diff changeset
245
kono
parents:
diff changeset
246 procedure Check_Compiler_Unit (Feature : String; Loc : Source_Ptr);
kono
parents:
diff changeset
247 -- If unit N is in a unit that has a pragma Compiler_Unit_Warning, then a
kono
parents:
diff changeset
248 -- message is posted at location Loc noting use of the given feature is not
kono
parents:
diff changeset
249 -- permitted in the compiler (bootstrap considerations).
kono
parents:
diff changeset
250
kono
parents:
diff changeset
251 procedure Check_Restricted_Unit (U : Unit_Name_Type; N : Node_Id);
kono
parents:
diff changeset
252 -- Checks if loading of unit U is prohibited by the setting of some
kono
parents:
diff changeset
253 -- restriction (e.g. No_IO restricts the loading of unit Ada.Text_IO).
kono
parents:
diff changeset
254 -- If a restriction exists post error message at the given node.
kono
parents:
diff changeset
255
kono
parents:
diff changeset
256 procedure Check_Restriction
kono
parents:
diff changeset
257 (Msg_Issued : out Boolean;
kono
parents:
diff changeset
258 R : Restriction_Id;
kono
parents:
diff changeset
259 N : Node_Id;
kono
parents:
diff changeset
260 V : Uint := Uint_Minus_1);
kono
parents:
diff changeset
261 -- Checks that the given restriction is not set, and if it is set, an
kono
parents:
diff changeset
262 -- appropriate message is posted on the given node, in which case
kono
parents:
diff changeset
263 -- Msg_Issued is set to True (and False otherwise). Also records the
kono
parents:
diff changeset
264 -- violation in the appropriate internal arrays. Note that it is mandatory
kono
parents:
diff changeset
265 -- to always use this routine to check if a restriction is violated. Such
kono
parents:
diff changeset
266 -- checks must never be done directly by the caller, since otherwise
kono
parents:
diff changeset
267 -- violations in the absence of restrictions are not properly recorded. The
kono
parents:
diff changeset
268 -- value of V is relevant only for parameter restrictions, and in this case
kono
parents:
diff changeset
269 -- indicates the exact count for the violation. If the exact count is not
kono
parents:
diff changeset
270 -- known, V is left at its default of -1 which indicates an unknown count.
kono
parents:
diff changeset
271
kono
parents:
diff changeset
272 procedure Check_Restriction
kono
parents:
diff changeset
273 (R : Restriction_Id;
kono
parents:
diff changeset
274 N : Node_Id;
kono
parents:
diff changeset
275 V : Uint := Uint_Minus_1);
kono
parents:
diff changeset
276 -- Wrapper on Check_Restriction with Msg_Issued, with the out-parameter
kono
parents:
diff changeset
277 -- being ignored here.
kono
parents:
diff changeset
278
kono
parents:
diff changeset
279 procedure Check_Restriction_No_Dependence (U : Node_Id; Err : Node_Id);
kono
parents:
diff changeset
280 -- Called when a dependence on a unit is created (either implicitly, or by
kono
parents:
diff changeset
281 -- an explicit WITH clause). U is a node for the unit involved, and Err is
kono
parents:
diff changeset
282 -- the node to which an error will be attached if necessary.
kono
parents:
diff changeset
283
kono
parents:
diff changeset
284 procedure Check_Restriction_No_Specification_Of_Aspect (N : Node_Id);
kono
parents:
diff changeset
285 -- N is the node id for an N_Aspect_Specification. An error message
kono
parents:
diff changeset
286 -- (warning) will be issued if a restriction (warning) was previously set
kono
parents:
diff changeset
287 -- for this aspect using Set_No_Specification_Of_Aspect.
kono
parents:
diff changeset
288
kono
parents:
diff changeset
289 procedure Check_Restriction_No_Use_Of_Attribute (N : Node_Id);
kono
parents:
diff changeset
290 -- N denotes an attribute definition clause or an attribute reference. An
kono
parents:
diff changeset
291 -- error message (warning) will be issued if a restriction (warning) was
kono
parents:
diff changeset
292 -- previously set for this attribute using Set_No_Use_Of_Attribute.
kono
parents:
diff changeset
293
kono
parents:
diff changeset
294 procedure Check_Restriction_No_Use_Of_Entity (N : Node_Id);
kono
parents:
diff changeset
295 -- N is the node id for an entity reference. An error message (warning)
kono
parents:
diff changeset
296 -- will be issued if a restriction (warning) was previously set for this
kono
parents:
diff changeset
297 -- entity name using Set_No_Use_Of_Entity.
kono
parents:
diff changeset
298
kono
parents:
diff changeset
299 procedure Check_Restriction_No_Use_Of_Pragma (N : Node_Id);
kono
parents:
diff changeset
300 -- N is the node of a pragma. An error message (warning) will be issued
kono
parents:
diff changeset
301 -- if a restriction (warning) was previously set for this pragma using
kono
parents:
diff changeset
302 -- Set_No_Use_Of_Pragma.
kono
parents:
diff changeset
303
kono
parents:
diff changeset
304 procedure Check_Elaboration_Code_Allowed (N : Node_Id);
kono
parents:
diff changeset
305 -- Tests to see if elaboration code is allowed by the current restrictions
kono
parents:
diff changeset
306 -- settings. This function is called by Gigi when it needs to define an
kono
parents:
diff changeset
307 -- elaboration routine. If elaboration code is not allowed, an error
kono
parents:
diff changeset
308 -- message is posted on the node given as argument.
kono
parents:
diff changeset
309
kono
parents:
diff changeset
310 procedure Check_SPARK_05_Restriction
kono
parents:
diff changeset
311 (Msg : String;
kono
parents:
diff changeset
312 N : Node_Id;
kono
parents:
diff changeset
313 Force : Boolean := False);
kono
parents:
diff changeset
314 -- Node N represents a construct not allowed in SPARK_05 mode. If this is
kono
parents:
diff changeset
315 -- a source node, or if the restriction is forced (Force = True), and
kono
parents:
diff changeset
316 -- the SPARK_05 restriction is set, then an error is issued on N. Msg
kono
parents:
diff changeset
317 -- is appended to the restriction failure message.
kono
parents:
diff changeset
318
kono
parents:
diff changeset
319 procedure Check_SPARK_05_Restriction
kono
parents:
diff changeset
320 (Msg1 : String;
kono
parents:
diff changeset
321 Msg2 : String;
kono
parents:
diff changeset
322 N : Node_Id);
kono
parents:
diff changeset
323 -- Same as Check_SPARK_05_Restriction except there is a continuation
kono
parents:
diff changeset
324 -- message Msg2 following the initial message Msg1.
kono
parents:
diff changeset
325
kono
parents:
diff changeset
326 procedure Check_No_Implicit_Aliasing (Obj : Node_Id);
kono
parents:
diff changeset
327 -- Obj is a node for which Is_Aliased_View is True, which is being used in
kono
parents:
diff changeset
328 -- a context (e.g. 'Access) where no implicit aliasing is allowed if the
kono
parents:
diff changeset
329 -- restriction No_Implicit_Aliasing is set. This procedure checks for the
kono
parents:
diff changeset
330 -- case where the restriction is active and Obj does not meet the required
kono
parents:
diff changeset
331 -- rules for avoiding implicit aliases, and issues a restriction message.
kono
parents:
diff changeset
332
kono
parents:
diff changeset
333 procedure Check_Implicit_Dynamic_Code_Allowed (N : Node_Id);
kono
parents:
diff changeset
334 -- Tests to see if dynamic code generation (dynamically generated
kono
parents:
diff changeset
335 -- trampolines, in particular) is allowed by the current restrictions
kono
parents:
diff changeset
336 -- settings. This function is called by Gigi when it needs to generate code
kono
parents:
diff changeset
337 -- that generates a trampoline. If not allowed, an error message is posted
kono
parents:
diff changeset
338 -- on the node given as argument.
kono
parents:
diff changeset
339
kono
parents:
diff changeset
340 procedure Check_No_Implicit_Heap_Alloc (N : Node_Id);
kono
parents:
diff changeset
341 -- Equivalent to Check_Restriction (No_Implicit_Heap_Allocations, N).
kono
parents:
diff changeset
342 -- Provided for easy use by back end, which has to check this restriction.
kono
parents:
diff changeset
343
kono
parents:
diff changeset
344 procedure Check_No_Implicit_Task_Alloc (N : Node_Id);
kono
parents:
diff changeset
345 -- Equivalent to Check_Restriction (No_Implicit_Task_Allocations, N).
kono
parents:
diff changeset
346 -- Provided for easy use by back end, which has to check this restriction.
kono
parents:
diff changeset
347
kono
parents:
diff changeset
348 procedure Check_No_Implicit_Protected_Alloc (N : Node_Id);
kono
parents:
diff changeset
349 -- Equivalent to:
kono
parents:
diff changeset
350 -- Check_Restriction (No_Implicit_Protected_Object_Allocations, N)
kono
parents:
diff changeset
351 -- Provided for easy use by back end, which has to check this restriction.
kono
parents:
diff changeset
352
kono
parents:
diff changeset
353 procedure Check_Obsolescent_2005_Entity (E : Entity_Id; N : Node_Id);
kono
parents:
diff changeset
354 -- This routine checks if the entity E is one of the obsolescent entries
kono
parents:
diff changeset
355 -- in Ada.Characters.Handling in Ada 2005 and No_Obsolescent_Features
kono
parents:
diff changeset
356 -- restriction is active. If so an appropriate message is given. N is
kono
parents:
diff changeset
357 -- the node on which the message is to be placed. It's a bit kludgy to
kono
parents:
diff changeset
358 -- have this highly specialized routine rather than some wonderful general
kono
parents:
diff changeset
359 -- mechanism (e.g. a special pragma) to handle this case, but there are
kono
parents:
diff changeset
360 -- only six cases, and it is not worth the effort to do something general.
kono
parents:
diff changeset
361
kono
parents:
diff changeset
362 procedure Check_Wide_Character_Restriction (E : Entity_Id; N : Node_Id);
kono
parents:
diff changeset
363 -- This procedure checks if the No_Wide_Character restriction is active,
kono
parents:
diff changeset
364 -- and if so, if N Comes_From_Source, and the root type of E is one of
kono
parents:
diff changeset
365 -- [Wide_]Wide_Character or [Wide_]Wide_String, then the restriction
kono
parents:
diff changeset
366 -- violation is recorded, and an appropriate message given.
kono
parents:
diff changeset
367
kono
parents:
diff changeset
368 function Get_Restriction_Id
kono
parents:
diff changeset
369 (N : Name_Id) return Restriction_Id;
kono
parents:
diff changeset
370 -- Given an identifier name, determines if it is a valid restriction
kono
parents:
diff changeset
371 -- identifier, and if so returns the corresponding Restriction_Id value,
kono
parents:
diff changeset
372 -- otherwise returns Not_A_Restriction_Id.
kono
parents:
diff changeset
373
kono
parents:
diff changeset
374 function OK_No_Dependence_Unit_Name (N : Node_Id) return Boolean;
kono
parents:
diff changeset
375 -- Used in checking No_Dependence argument of pragma Restrictions or
kono
parents:
diff changeset
376 -- pragma Restrictions_Warning, or attribute Restriction_Set. Returns
kono
parents:
diff changeset
377 -- True if N has the proper form for a unit name, False otherwise.
kono
parents:
diff changeset
378
kono
parents:
diff changeset
379 function OK_No_Use_Of_Entity_Name (N : Node_Id) return Boolean;
kono
parents:
diff changeset
380 -- Used in checking No_Use_Of_Entity argument of pragma Restrictions or
kono
parents:
diff changeset
381 -- pragma Restrictions_Warning, or attribute Restriction_Set. Returns
kono
parents:
diff changeset
382 -- True if N has the proper form for an entity name, False otherwise.
kono
parents:
diff changeset
383
kono
parents:
diff changeset
384 function Is_In_Hidden_Part_In_SPARK (Loc : Source_Ptr) return Boolean;
kono
parents:
diff changeset
385 -- Determine if given location is covered by a hidden region range in the
kono
parents:
diff changeset
386 -- SPARK hides table.
kono
parents:
diff changeset
387
kono
parents:
diff changeset
388 function No_Exception_Handlers_Set return Boolean;
kono
parents:
diff changeset
389 -- Test to see if current restrictions settings specify that no exception
kono
parents:
diff changeset
390 -- handlers are present. This function is called by Gigi when it needs to
kono
parents:
diff changeset
391 -- expand an AT END clean up identifier with no exception handler. True
kono
parents:
diff changeset
392 -- will be returned if the configurable run-time is activated, and either
kono
parents:
diff changeset
393 -- of the restrictions No_Exception_Handlers or No_Exception_Propagation is
kono
parents:
diff changeset
394 -- set. In the latter case, the source may contain handlers but they either
kono
parents:
diff changeset
395 -- get converted using the local goto transformation or deleted.
kono
parents:
diff changeset
396
kono
parents:
diff changeset
397 function No_Exception_Propagation_Active return Boolean;
kono
parents:
diff changeset
398 -- Test to see if current restrictions settings specify that no
kono
parents:
diff changeset
399 -- exception propagation is activated.
kono
parents:
diff changeset
400
kono
parents:
diff changeset
401 function Process_Restriction_Synonyms (N : Node_Id) return Name_Id;
kono
parents:
diff changeset
402 -- Id is a node whose Chars field contains the name of a restriction.
kono
parents:
diff changeset
403 -- If it is one of synonyms that we allow for historical purposes (for
kono
parents:
diff changeset
404 -- list see System.Rident), then the proper official name is returned.
kono
parents:
diff changeset
405
kono
parents:
diff changeset
406 function Restriction_Active (R : All_Restrictions) return Boolean;
kono
parents:
diff changeset
407 pragma Inline (Restriction_Active);
kono
parents:
diff changeset
408 -- Determines if a given restriction is active. This call should only be
kono
parents:
diff changeset
409 -- used where the compiled code depends on whether the restriction is
kono
parents:
diff changeset
410 -- active. Always use Check_Restriction to record a violation. Note that
kono
parents:
diff changeset
411 -- this returns False if we only have a Restriction_Warnings set, since
kono
parents:
diff changeset
412 -- restriction warnings should never affect generated code. If you want
kono
parents:
diff changeset
413 -- to know if a call to Check_Restriction is needed then use the function
kono
parents:
diff changeset
414 -- Restriction_Check_Required instead.
kono
parents:
diff changeset
415
kono
parents:
diff changeset
416 function Restriction_Check_Required (R : All_Restrictions) return Boolean;
kono
parents:
diff changeset
417 pragma Inline (Restriction_Check_Required);
kono
parents:
diff changeset
418 -- Determines if either a Restriction_Warnings or Restrictions pragma has
kono
parents:
diff changeset
419 -- been given for the specified restriction. If true, then a subsequent
kono
parents:
diff changeset
420 -- call to Check_Restriction is required if the restriction is violated.
kono
parents:
diff changeset
421 -- This must not be used to guard code generation that depends on whether
kono
parents:
diff changeset
422 -- a restriction is active (see Restriction_Active above). Typically it
kono
parents:
diff changeset
423 -- is used to avoid complex code to determine if a restriction is violated,
kono
parents:
diff changeset
424 -- executing this code only if needed.
kono
parents:
diff changeset
425
kono
parents:
diff changeset
426 function Restricted_Profile return Boolean;
kono
parents:
diff changeset
427 -- Tests if set of restrictions corresponding to Restricted_Tasking profile
kono
parents:
diff changeset
428 -- is currently in effect (set by pragma Profile, or by an appropriate set
kono
parents:
diff changeset
429 -- of individual Restrictions pragmas). Returns True only if all the
kono
parents:
diff changeset
430 -- required restrictions are set.
kono
parents:
diff changeset
431
kono
parents:
diff changeset
432 procedure Set_Hidden_Part_In_SPARK (Loc1, Loc2 : Source_Ptr);
kono
parents:
diff changeset
433 -- Insert a new hidden region range in the SPARK hides table. The effect
kono
parents:
diff changeset
434 -- is to hide any SPARK violation messages which are in the range Loc1 to
kono
parents:
diff changeset
435 -- Loc2-1 (i.e. Loc2 is the first location for reenabling checks).
kono
parents:
diff changeset
436
kono
parents:
diff changeset
437 procedure Set_Profile_Restrictions
kono
parents:
diff changeset
438 (P : Profile_Name;
kono
parents:
diff changeset
439 N : Node_Id;
kono
parents:
diff changeset
440 Warn : Boolean);
kono
parents:
diff changeset
441 -- Sets the set of restrictions associated with the given profile name. N
kono
parents:
diff changeset
442 -- is the node of the construct to which error messages are to be attached
kono
parents:
diff changeset
443 -- as required. Warn is set True for the case of Profile_Warnings where the
kono
parents:
diff changeset
444 -- restrictions are set as warnings rather than legality requirements, and
kono
parents:
diff changeset
445 -- is also True for Profile if the Treat_Restrictions_As_Warnings flag is
kono
parents:
diff changeset
446 -- set. It is false for Profile if this flag is not set.
kono
parents:
diff changeset
447
kono
parents:
diff changeset
448 procedure Set_Restriction
kono
parents:
diff changeset
449 (R : All_Boolean_Restrictions;
kono
parents:
diff changeset
450 N : Node_Id);
kono
parents:
diff changeset
451 -- N is a node (typically a pragma node) that has the effect of setting
kono
parents:
diff changeset
452 -- Boolean restriction R. The restriction is set in Restrictions, and
kono
parents:
diff changeset
453 -- also in Main_Restrictions if this is the main unit.
kono
parents:
diff changeset
454
kono
parents:
diff changeset
455 procedure Set_Restriction
kono
parents:
diff changeset
456 (R : All_Parameter_Restrictions;
kono
parents:
diff changeset
457 N : Node_Id;
kono
parents:
diff changeset
458 V : Integer);
kono
parents:
diff changeset
459 -- Similar to the above, except that this is used for the case of a
kono
parents:
diff changeset
460 -- parameter restriction, and the corresponding value V is given.
kono
parents:
diff changeset
461
kono
parents:
diff changeset
462 procedure Set_Restriction_No_Dependence
kono
parents:
diff changeset
463 (Unit : Node_Id;
kono
parents:
diff changeset
464 Warn : Boolean;
kono
parents:
diff changeset
465 Profile : Profile_Name := No_Profile);
kono
parents:
diff changeset
466 -- Sets given No_Dependence restriction in table if not there already. Warn
kono
parents:
diff changeset
467 -- is True if from Restriction_Warnings, or for Restrictions if the flag
kono
parents:
diff changeset
468 -- Treat_Restrictions_As_Warnings is set. False if from Restrictions and
kono
parents:
diff changeset
469 -- this flag is not set. Profile is set to a non-default value if the
kono
parents:
diff changeset
470 -- No_Dependence restriction comes from a Profile pragma.
kono
parents:
diff changeset
471
kono
parents:
diff changeset
472 procedure Set_Restriction_No_Specification_Of_Aspect
kono
parents:
diff changeset
473 (N : Node_Id;
kono
parents:
diff changeset
474 Warning : Boolean);
kono
parents:
diff changeset
475 -- N is the node id for an identifier from a pragma Restrictions for the
kono
parents:
diff changeset
476 -- No_Specification_Of_Aspect pragma. An error message will be issued if
kono
parents:
diff changeset
477 -- the identifier is not a valid aspect name. Warning is set True for the
kono
parents:
diff changeset
478 -- case of a Restriction_Warnings pragma specifying this restriction and
kono
parents:
diff changeset
479 -- False for a Restrictions pragma specifying this restriction.
kono
parents:
diff changeset
480
kono
parents:
diff changeset
481 procedure Set_Restriction_No_Specification_Of_Aspect (A_Id : Aspect_Id);
kono
parents:
diff changeset
482 -- Version used by Get_Target_Parameters (via Tbuild)
kono
parents:
diff changeset
483
kono
parents:
diff changeset
484 procedure Set_Restriction_No_Use_Of_Attribute
kono
parents:
diff changeset
485 (N : Node_Id;
kono
parents:
diff changeset
486 Warning : Boolean);
kono
parents:
diff changeset
487 -- N is the node id for the identifier in a pragma Restrictions for
kono
parents:
diff changeset
488 -- No_Use_Of_Attribute. Caller has verified that this is a valid attribute
kono
parents:
diff changeset
489 -- designator.
kono
parents:
diff changeset
490
kono
parents:
diff changeset
491 procedure Set_Restriction_No_Use_Of_Attribute (A_Id : Attribute_Id);
kono
parents:
diff changeset
492 -- Version used by Get_Target_Parameters (via Tbuild)
kono
parents:
diff changeset
493
kono
parents:
diff changeset
494 procedure Set_Restriction_No_Use_Of_Entity
kono
parents:
diff changeset
495 (Entity : Node_Id;
kono
parents:
diff changeset
496 Warning : Boolean;
kono
parents:
diff changeset
497 Profile : Profile_Name := No_Profile);
kono
parents:
diff changeset
498 -- Sets given No_Use_Of_Entity restriction in table if not there already.
kono
parents:
diff changeset
499 -- Warn is True if from Restriction_Warnings, or for Restrictions if the
kono
parents:
diff changeset
500 -- flag Treat_Restrictions_As_Warnings is set. False if from Restrictions
kono
parents:
diff changeset
501 -- and this flag is not set. Profile is set to a non-default value if the
kono
parents:
diff changeset
502 -- No_Dependence restriction comes from a Profile pragma. This procedure
kono
parents:
diff changeset
503 -- also takes care of setting the Boolean2 flag of the simple name for
kono
parents:
diff changeset
504 -- the entity (to optimize table searches).
kono
parents:
diff changeset
505
kono
parents:
diff changeset
506 procedure Set_Restriction_No_Use_Of_Pragma
kono
parents:
diff changeset
507 (N : Node_Id;
kono
parents:
diff changeset
508 Warning : Boolean);
kono
parents:
diff changeset
509 -- N is the node id for the identifier in a pragma Restrictions for
kono
parents:
diff changeset
510 -- No_Use_Of_Pragma. Caller has verified that this is a valid pragma id.
kono
parents:
diff changeset
511
kono
parents:
diff changeset
512 procedure Set_Restriction_No_Use_Of_Pragma (A_Id : Pragma_Id);
kono
parents:
diff changeset
513 -- Version used in call from Get_Target_Parameters (via Tbuild).
kono
parents:
diff changeset
514
kono
parents:
diff changeset
515 function Tasking_Allowed return Boolean;
kono
parents:
diff changeset
516 pragma Inline (Tasking_Allowed);
kono
parents:
diff changeset
517 -- Tests if tasking operations are allowed by the current restrictions
kono
parents:
diff changeset
518 -- settings. For tasking to be allowed Max_Tasks must be non-zero.
kono
parents:
diff changeset
519
kono
parents:
diff changeset
520 ----------------------------------------------
kono
parents:
diff changeset
521 -- Handling of Boolean Compilation Switches --
kono
parents:
diff changeset
522 ----------------------------------------------
kono
parents:
diff changeset
523
kono
parents:
diff changeset
524 -- The following declarations are used for proper saving and restoring of
kono
parents:
diff changeset
525 -- restrictions for separate compilation units. There are two cases:
kono
parents:
diff changeset
526
kono
parents:
diff changeset
527 -- For partition-wide restrictions, we just let the restrictions pragmas
kono
parents:
diff changeset
528 -- pile up, and we never reset them. We might as well detect what we can
kono
parents:
diff changeset
529 -- at compile time. If e.g. a with'ed unit has a restriction for one of
kono
parents:
diff changeset
530 -- the partition-wide restrictions, then the binder will enforce it on
kono
parents:
diff changeset
531 -- all units in the partition, including the unit with the WITH. Although
kono
parents:
diff changeset
532 -- it would not be wrong to leave this till bind time, we might as well
kono
parents:
diff changeset
533 -- flag it earlier at compile time.
kono
parents:
diff changeset
534
kono
parents:
diff changeset
535 -- For non-partition-wide restrictions, we have quite a different state
kono
parents:
diff changeset
536 -- of affairs. Here it would be quite wrong to carry a restriction from
kono
parents:
diff changeset
537 -- a with'ed unit to another with'ed unit, or from a package spec to the
kono
parents:
diff changeset
538 -- package body. This means that we have to reset these non-partition
kono
parents:
diff changeset
539 -- wide restrictions at the start of each separate compilation unit. For
kono
parents:
diff changeset
540 -- units in the extended main program, we need to reset them all to the
kono
parents:
diff changeset
541 -- values set by the configuration pragma file(s). For units not in the
kono
parents:
diff changeset
542 -- extended main program, e.g. with'ed units, we might as well reset all
kono
parents:
diff changeset
543 -- of these restrictions to off (False). The actual initial values will
kono
parents:
diff changeset
544 -- be taken from the config files active when those units are compiled
kono
parents:
diff changeset
545 -- as main units.
kono
parents:
diff changeset
546
kono
parents:
diff changeset
547 type Save_Cunit_Boolean_Restrictions is private;
kono
parents:
diff changeset
548 -- Type used for saving and restoring compilation unit restrictions.
kono
parents:
diff changeset
549
kono
parents:
diff changeset
550 function Cunit_Boolean_Restrictions_Save
kono
parents:
diff changeset
551 return Save_Cunit_Boolean_Restrictions;
kono
parents:
diff changeset
552 -- This function saves the compilation unit restriction settings, leaving
kono
parents:
diff changeset
553 -- them unchanged. This is used e.g. at the start of processing a context
kono
parents:
diff changeset
554 -- clause, so that the main unit restrictions can be restored after all
kono
parents:
diff changeset
555 -- the with'ed units have been processed.
kono
parents:
diff changeset
556
kono
parents:
diff changeset
557 procedure Cunit_Boolean_Restrictions_Restore
kono
parents:
diff changeset
558 (R : Save_Cunit_Boolean_Restrictions);
kono
parents:
diff changeset
559 -- This is the corresponding restore procedure to restore restrictions
kono
parents:
diff changeset
560 -- previously saved by Cunit_Boolean_Restrictions_Save. However it does
kono
parents:
diff changeset
561 -- not reset No_Elaboration_Code, this stays set if it was set before
kono
parents:
diff changeset
562 -- the call, and also if it is set before the call, then the Config
kono
parents:
diff changeset
563 -- setting is also updated to include this restriction. This is what
kono
parents:
diff changeset
564 -- implements the special handling of No_Elaboration_Code.
kono
parents:
diff changeset
565
kono
parents:
diff changeset
566 procedure Save_Config_Cunit_Boolean_Restrictions;
kono
parents:
diff changeset
567 -- This saves the current compilation unit restrictions in an internal
kono
parents:
diff changeset
568 -- variable, and leaves them unchanged. This is called immediately after
kono
parents:
diff changeset
569 -- processing the configuration file pragmas, to record the restrictions
kono
parents:
diff changeset
570 -- set by these configuration file pragmas.
kono
parents:
diff changeset
571
kono
parents:
diff changeset
572 procedure Restore_Config_Cunit_Boolean_Restrictions;
kono
parents:
diff changeset
573 -- This restores the value saved by the previous call to save config values
kono
parents:
diff changeset
574 -- saved by Save_Config_Cunit_Boolean_Restrictions. It is called at the
kono
parents:
diff changeset
575 -- start of processing a new unit that is part of the main sources (e.g.
kono
parents:
diff changeset
576 -- a package spec when the main unit is a package body).
kono
parents:
diff changeset
577
kono
parents:
diff changeset
578 procedure Reset_Cunit_Boolean_Restrictions;
kono
parents:
diff changeset
579 -- Turns off all non-partition-wide boolean restrictions
kono
parents:
diff changeset
580
kono
parents:
diff changeset
581 procedure Add_To_Config_Boolean_Restrictions (R : Restriction_Id);
kono
parents:
diff changeset
582 -- Add specified restriction to stored configuration boolean restrictions.
kono
parents:
diff changeset
583 -- This is used for handling the special case of No_Elaboration_Code.
kono
parents:
diff changeset
584
kono
parents:
diff changeset
585 private
kono
parents:
diff changeset
586 type Save_Cunit_Boolean_Restrictions is
kono
parents:
diff changeset
587 array (Cunit_Boolean_Restrictions) of Boolean;
kono
parents:
diff changeset
588 -- Type used for saving and restoring compilation unit restrictions.
kono
parents:
diff changeset
589 -- See Compilation_Unit_Restrictions_[Save|Restore] subprograms.
kono
parents:
diff changeset
590
kono
parents:
diff changeset
591 end Restrict;