1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1997-2017, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 -- This package contains routines which handle access-before-elaboration
27 -- run-time checks and compile-time diagnostics. See the body for details.
29 with Types
; use Types
;
33 procedure Build_Call_Marker
(N
: Node_Id
);
34 -- Create a call marker for call or requeue statement N and record it for
35 -- later processing by the ABE mechanism.
37 procedure Build_Variable_Reference_Marker
41 -- Create a variable reference marker for arbitrary node N if it mentions a
42 -- variable, and record it for later processing by the ABE mechanism. Flag
43 -- Read should be set when the reference denotes a read. Flag Write should
44 -- be set when the reference denotes a write.
46 procedure Check_Elaboration_Scenarios
;
47 -- Examine each scenario recorded during analysis/resolution and apply the
48 -- Ada or SPARK elaboration rules taking into account the model in effect.
49 -- This processing detects and diagnoses ABE issues, installs conditional
50 -- ABE checks or guaranteed ABE failures, and ensures the elaboration of
53 -- The following type classifies the various enclosing levels used in ABE
56 type Enclosing_Level_Kind
is
58 -- A construct is at the "declaration level" when it appears within the
59 -- declarations of a block statement, an entry body, a subprogram body,
60 -- or a task body, ignoring enclosing packages. Example:
63 -- procedure Proc is -- subprogram body
64 -- package Nested is -- enclosing package ignored
65 -- X ... -- at declaration level
69 -- A construct is at the "generic library level" when it appears in a
70 -- generic package library unit, ignoring enclosing packages. Example:
73 -- package Pack is -- generic package spec
74 -- package Nested is -- enclosing package ignored
75 -- X ... -- at generic library level
78 -- A construct is at the "instantiation library level" when it appears
79 -- in a library unit which is also an instantiation. Example:
81 -- package Inst is new Gen; -- at instantiation level
85 -- A construct is at the "library level" when it appears in a package
86 -- library unit, ignoring enclosing packages. Example:
88 -- package body Pack is -- package body
89 -- package Nested is -- enclosing package ignored
90 -- X ... -- at library level
93 -- This value is used to indicate that none of the levels above are in
96 subtype Any_Library_Level
is Enclosing_Level_Kind
range
97 Generic_Package_Spec
..
100 subtype Generic_Library_Level
is Enclosing_Level_Kind
range
101 Generic_Package_Spec
..
102 Generic_Package_Body
;
104 subtype Library_Level
is Enclosing_Level_Kind
range
108 subtype Library_Or_Instantiation_Level
is Enclosing_Level_Kind
range
112 function Find_Enclosing_Level
(N
: Node_Id
) return Enclosing_Level_Kind
;
113 -- Determine the enclosing level of arbitrary node N
115 procedure Initialize
;
116 -- Initialize the internal structures of this unit
118 procedure Kill_Elaboration_Scenario
(N
: Node_Id
);
119 -- Determine whether arbitrary node N denotes a scenario which requires
120 -- ABE diagnostics or runtime checks and eliminate it from a region with
123 procedure Record_Elaboration_Scenario
(N
: Node_Id
);
124 -- Determine whether atribtray node N denotes a scenario which requires
125 -- ABE diagnostics or runtime checks. If this is the case, store N into
126 -- a table for later processing.