annotate gcc/ada/sem_ch13.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 _ C H 1 3 --
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 with Table;
kono
parents:
diff changeset
27 with Types; use Types;
kono
parents:
diff changeset
28 with Uintp; use Uintp;
kono
parents:
diff changeset
29
kono
parents:
diff changeset
30 package Sem_Ch13 is
kono
parents:
diff changeset
31 procedure Analyze_At_Clause (N : Node_Id);
kono
parents:
diff changeset
32 procedure Analyze_Attribute_Definition_Clause (N : Node_Id);
kono
parents:
diff changeset
33 procedure Analyze_Enumeration_Representation_Clause (N : Node_Id);
kono
parents:
diff changeset
34 procedure Analyze_Free_Statement (N : Node_Id);
kono
parents:
diff changeset
35 procedure Analyze_Freeze_Entity (N : Node_Id);
kono
parents:
diff changeset
36 procedure Analyze_Freeze_Generic_Entity (N : Node_Id);
kono
parents:
diff changeset
37 procedure Analyze_Record_Representation_Clause (N : Node_Id);
kono
parents:
diff changeset
38 procedure Analyze_Code_Statement (N : Node_Id);
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 procedure Analyze_Aspect_Specifications (N : Node_Id; E : Entity_Id);
kono
parents:
diff changeset
41 -- This procedure is called to analyze aspect specifications for node N. E
kono
parents:
diff changeset
42 -- is the corresponding entity declared by the declaration node N. Callers
kono
parents:
diff changeset
43 -- should check that Has_Aspects (N) is True before calling this routine.
kono
parents:
diff changeset
44
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
45 procedure Analyze_Aspects_On_Subprogram_Body_Or_Stub (N : Node_Id);
111
kono
parents:
diff changeset
46 -- Analyze the aspect specifications of [generic] subprogram body or stub
kono
parents:
diff changeset
47 -- N. Callers should check that Has_Aspects (N) is True before calling the
kono
parents:
diff changeset
48 -- routine. This routine diagnoses misplaced aspects that should appear on
kono
parents:
diff changeset
49 -- the initial declaration of N and offers suggestions for replacements.
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 procedure Adjust_Record_For_Reverse_Bit_Order (R : Entity_Id);
kono
parents:
diff changeset
52 -- Called from Freeze where R is a record entity for which reverse bit
kono
parents:
diff changeset
53 -- order is specified and there is at least one component clause. Note:
kono
parents:
diff changeset
54 -- component positions are normally adjusted as per AI95-0133, unless
kono
parents:
diff changeset
55 -- -gnatd.p is used to restore original Ada 95 mode.
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 procedure Check_Record_Representation_Clause (N : Node_Id);
kono
parents:
diff changeset
58 -- This procedure completes the analysis of a record representation clause
kono
parents:
diff changeset
59 -- N. It is called at freeze time after adjustment of component clause bit
kono
parents:
diff changeset
60 -- positions for possible non-standard bit order. In the case of Ada 2005
kono
parents:
diff changeset
61 -- (machine scalar) mode, this adjustment can make substantial changes, so
kono
parents:
diff changeset
62 -- some checks, in particular for component overlaps cannot be done at the
kono
parents:
diff changeset
63 -- time the record representation clause is first seen, but must be delayed
kono
parents:
diff changeset
64 -- till freeze time, and in particular is called after calling the above
kono
parents:
diff changeset
65 -- procedure for adjusting record bit positions for reverse bit order.
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 procedure Initialize;
kono
parents:
diff changeset
68 -- Initialize internal tables for new compilation
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 procedure Kill_Rep_Clause (N : Node_Id);
kono
parents:
diff changeset
71 -- This procedure is called for a rep clause N when we are in -gnatI mode
kono
parents:
diff changeset
72 -- (Ignore_Rep_Clauses). It replaces the node N with a null statement. This
kono
parents:
diff changeset
73 -- is only called if Ignore_Rep_Clauses is True.
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 procedure Set_Enum_Esize (T : Entity_Id);
kono
parents:
diff changeset
76 -- This routine sets the Esize field for an enumeration type T, based
kono
parents:
diff changeset
77 -- on the current representation information available for T. Note that
kono
parents:
diff changeset
78 -- the setting of the RM_Size field is not affected. This routine also
kono
parents:
diff changeset
79 -- initializes the alignment field to zero.
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 function Minimum_Size
kono
parents:
diff changeset
82 (T : Entity_Id;
kono
parents:
diff changeset
83 Biased : Boolean := False) return Nat;
kono
parents:
diff changeset
84 -- Given an elementary type, determines the minimum number of bits required
kono
parents:
diff changeset
85 -- to represent all values of the type. This function may not be called
kono
parents:
diff changeset
86 -- with any other types. If the flag Biased is set True, then the minimum
kono
parents:
diff changeset
87 -- size calculation that biased representation is used in the case of a
kono
parents:
diff changeset
88 -- discrete type, e.g. the range 7..8 gives a minimum size of 4 with
kono
parents:
diff changeset
89 -- Biased set to False, and 1 with Biased set to True. Note that the
kono
parents:
diff changeset
90 -- biased parameter only has an effect if the type is not biased, it
kono
parents:
diff changeset
91 -- causes Minimum_Size to indicate the minimum size of an object with
kono
parents:
diff changeset
92 -- the given type, of the size the type would have if it were biased. If
kono
parents:
diff changeset
93 -- the type is already biased, then Minimum_Size returns the biased size,
kono
parents:
diff changeset
94 -- regardless of the setting of Biased. Also, fixed-point types are never
kono
parents:
diff changeset
95 -- biased in the current implementation. If the size is not known at
kono
parents:
diff changeset
96 -- compile time, this function returns 0.
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 procedure Check_Constant_Address_Clause (Expr : Node_Id; U_Ent : Entity_Id);
kono
parents:
diff changeset
99 -- Expr is an expression for an address clause. This procedure checks
kono
parents:
diff changeset
100 -- that the expression is constant, in the limited sense that it is safe
kono
parents:
diff changeset
101 -- to evaluate it at the point the object U_Ent is declared, rather than
kono
parents:
diff changeset
102 -- at the point of the address clause. The condition for this to be true
kono
parents:
diff changeset
103 -- is that the expression has no variables, no constants declared after
kono
parents:
diff changeset
104 -- U_Ent, and no calls to non-pure functions. If this condition is not
kono
parents:
diff changeset
105 -- met, then an appropriate error message is posted. This check is applied
kono
parents:
diff changeset
106 -- at the point an object with an address clause is frozen, as well as for
kono
parents:
diff changeset
107 -- address clauses for tasks and entries.
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 procedure Check_Size
kono
parents:
diff changeset
110 (N : Node_Id;
kono
parents:
diff changeset
111 T : Entity_Id;
kono
parents:
diff changeset
112 Siz : Uint;
kono
parents:
diff changeset
113 Biased : out Boolean);
kono
parents:
diff changeset
114 -- Called when size Siz is specified for subtype T. This subprogram checks
kono
parents:
diff changeset
115 -- that the size is appropriate, posting errors on node N as required.
kono
parents:
diff changeset
116 -- This check is effective for elementary types and bit-packed arrays.
kono
parents:
diff changeset
117 -- For other non-elementary types, a check is only made if an explicit
kono
parents:
diff changeset
118 -- size has been given for the type (and the specified size must match).
kono
parents:
diff changeset
119 -- The parameter Biased is set False if the size specified did not require
kono
parents:
diff changeset
120 -- the use of biased representation, and True if biased representation
kono
parents:
diff changeset
121 -- was required to meet the size requirement. Note that Biased is only
kono
parents:
diff changeset
122 -- set if the type is not currently biased, but biasing it is the only
kono
parents:
diff changeset
123 -- way to meet the requirement. If the type is currently biased, then
kono
parents:
diff changeset
124 -- this biased size is used in the initial check, and Biased is False.
kono
parents:
diff changeset
125 -- If the size is too small, and an error message is given, then both
kono
parents:
diff changeset
126 -- Esize and RM_Size are reset to the allowed minimum value in T.
kono
parents:
diff changeset
127
kono
parents:
diff changeset
128 function Rep_Item_Too_Early (T : Entity_Id; N : Node_Id) return Boolean;
kono
parents:
diff changeset
129 -- Called at start of processing a representation clause/pragma. Used to
kono
parents:
diff changeset
130 -- check that the representation item is not being applied to an incomplete
kono
parents:
diff changeset
131 -- type or to a generic formal type or a type derived from a generic formal
kono
parents:
diff changeset
132 -- type. Returns False if no such error occurs. If this error does occur,
kono
parents:
diff changeset
133 -- appropriate error messages are posted on node N, and True is returned.
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 generic
kono
parents:
diff changeset
136 with procedure Replace_Type_Reference (N : Node_Id);
kono
parents:
diff changeset
137 procedure Replace_Type_References_Generic (N : Node_Id; T : Entity_Id);
kono
parents:
diff changeset
138 -- This is used to scan an expression for a predicate or invariant aspect
kono
parents:
diff changeset
139 -- replacing occurrences of the name of the subtype to which the aspect
kono
parents:
diff changeset
140 -- applies with appropriate references to the parameter of the predicate
kono
parents:
diff changeset
141 -- function or invariant procedure. The procedure passed as a generic
kono
parents:
diff changeset
142 -- parameter does the actual replacement of node N, which is either a
kono
parents:
diff changeset
143 -- simple direct reference to T, or a selected component that represents
kono
parents:
diff changeset
144 -- an appropriately qualified occurrence of T.
kono
parents:
diff changeset
145
kono
parents:
diff changeset
146 function Rep_Item_Too_Late
kono
parents:
diff changeset
147 (T : Entity_Id;
kono
parents:
diff changeset
148 N : Node_Id;
kono
parents:
diff changeset
149 FOnly : Boolean := False) return Boolean;
kono
parents:
diff changeset
150 -- Called at the start of processing a representation clause or a
kono
parents:
diff changeset
151 -- representation pragma. Used to check that a representation item for
kono
parents:
diff changeset
152 -- entity T does not appear too late (according to the rules in RM 13.1(9)
kono
parents:
diff changeset
153 -- and RM 13.1(10)). N is the associated node, which in the pragma case
kono
parents:
diff changeset
154 -- is the pragma or representation clause itself, used for placing error
kono
parents:
diff changeset
155 -- messages if the item is too late.
kono
parents:
diff changeset
156 --
kono
parents:
diff changeset
157 -- Fonly is a flag that causes only the freezing rule (para 9) to be
kono
parents:
diff changeset
158 -- applied, and the tests of para 10 are skipped. This is appropriate for
kono
parents:
diff changeset
159 -- both subtype related attributes (Alignment and Size) and for stream
kono
parents:
diff changeset
160 -- attributes, which, although certainly not subtype related attributes,
kono
parents:
diff changeset
161 -- clearly should not be subject to the para 10 restrictions (see
kono
parents:
diff changeset
162 -- AI95-00137). Similarly, we also skip the para 10 restrictions for
kono
parents:
diff changeset
163 -- the Storage_Size case where they also clearly do not apply, and for
kono
parents:
diff changeset
164 -- Stream_Convert which is in the same category as the stream attributes.
kono
parents:
diff changeset
165 --
kono
parents:
diff changeset
166 -- If the rep item is too late, an appropriate message is output and True
kono
parents:
diff changeset
167 -- is returned, which is a signal that the caller should abandon processing
kono
parents:
diff changeset
168 -- for the item. If the item is not too late, then False is returned, and
kono
parents:
diff changeset
169 -- the caller can continue processing the item.
kono
parents:
diff changeset
170 --
kono
parents:
diff changeset
171 -- If no error is detected, this call also as a side effect links the
kono
parents:
diff changeset
172 -- representation item onto the head of the representation item chain
kono
parents:
diff changeset
173 -- (referenced by the First_Rep_Item field of the entity).
kono
parents:
diff changeset
174 --
kono
parents:
diff changeset
175 -- Note: Rep_Item_Too_Late must be called with the underlying type in the
kono
parents:
diff changeset
176 -- case of a private or incomplete type. The protocol is to first check for
kono
parents:
diff changeset
177 -- Rep_Item_Too_Early using the initial entity, then take the underlying
kono
parents:
diff changeset
178 -- type, then call Rep_Item_Too_Late on the result.
kono
parents:
diff changeset
179 --
kono
parents:
diff changeset
180 -- Note: Calls to Rep_Item_Too_Late are ignored for the case of attribute
kono
parents:
diff changeset
181 -- definition clauses which have From_Aspect_Specification set. This is
kono
parents:
diff changeset
182 -- because such clauses are linked on to the Rep_Item chain in procedure
kono
parents:
diff changeset
183 -- Sem_Ch13.Analyze_Aspect_Specifications. See that procedure for details.
kono
parents:
diff changeset
184
kono
parents:
diff changeset
185 function Same_Representation (Typ1, Typ2 : Entity_Id) return Boolean;
kono
parents:
diff changeset
186 -- Given two types, where the two types are related by possible derivation,
kono
parents:
diff changeset
187 -- determines if the two types have the same representation, or different
kono
parents:
diff changeset
188 -- representations, requiring the special processing for representation
kono
parents:
diff changeset
189 -- change. A False result is possible only for array, enumeration or
kono
parents:
diff changeset
190 -- record types.
kono
parents:
diff changeset
191
kono
parents:
diff changeset
192 procedure Validate_Compile_Time_Warning_Error (N : Node_Id);
kono
parents:
diff changeset
193 -- N is a pragma Compile_Time_Error or Compile_Warning_Error whose boolean
kono
parents:
diff changeset
194 -- expression is not known at compile time. This procedure makes an entry
kono
parents:
diff changeset
195 -- in a table. The actual checking is performed by Validate_Compile_Time_
kono
parents:
diff changeset
196 -- Warning_Errors, which is invoked after calling the back end.
kono
parents:
diff changeset
197
kono
parents:
diff changeset
198 procedure Validate_Compile_Time_Warning_Errors;
kono
parents:
diff changeset
199 -- This routine is called after calling the back end to validate pragmas
kono
parents:
diff changeset
200 -- Compile_Time_Error and Compile_Time_Warning for size and alignment
kono
parents:
diff changeset
201 -- appropriateness. The reason it is called that late is to take advantage
kono
parents:
diff changeset
202 -- of any back-annotation of size and alignment performed by the back end.
kono
parents:
diff changeset
203
kono
parents:
diff changeset
204 procedure Validate_Unchecked_Conversion
kono
parents:
diff changeset
205 (N : Node_Id;
kono
parents:
diff changeset
206 Act_Unit : Entity_Id);
kono
parents:
diff changeset
207 -- Validate a call to unchecked conversion. N is the node for the actual
kono
parents:
diff changeset
208 -- instantiation, which is used only for error messages. Act_Unit is the
kono
parents:
diff changeset
209 -- entity for the instantiation, from which the actual types etc. for this
kono
parents:
diff changeset
210 -- instantiation can be determined. This procedure makes an entry in a
kono
parents:
diff changeset
211 -- table and/or generates an N_Validate_Unchecked_Conversion node. The
kono
parents:
diff changeset
212 -- actual checking is done in Validate_Unchecked_Conversions or in the
kono
parents:
diff changeset
213 -- back end as required.
kono
parents:
diff changeset
214
kono
parents:
diff changeset
215 procedure Validate_Unchecked_Conversions;
kono
parents:
diff changeset
216 -- This routine is called after calling the back end to validate unchecked
kono
parents:
diff changeset
217 -- conversions for size and alignment appropriateness. The reason it is
kono
parents:
diff changeset
218 -- called that late is to take advantage of any back-annotation of size
kono
parents:
diff changeset
219 -- and alignment performed by the back end.
kono
parents:
diff changeset
220
kono
parents:
diff changeset
221 procedure Validate_Address_Clauses;
kono
parents:
diff changeset
222 -- This is called after the back end has been called (and thus after the
kono
parents:
diff changeset
223 -- alignments of objects have been back annotated). It goes through the
kono
parents:
diff changeset
224 -- table of saved address clauses checking for suspicious alignments and
kono
parents:
diff changeset
225 -- if necessary issuing warnings.
kono
parents:
diff changeset
226
kono
parents:
diff changeset
227 procedure Validate_Independence;
kono
parents:
diff changeset
228 -- This is called after the back end has been called (and thus after the
kono
parents:
diff changeset
229 -- layout of components has been back annotated). It goes through the
kono
parents:
diff changeset
230 -- table of saved pragma Independent[_Component] entries, checking that
kono
parents:
diff changeset
231 -- independence can be achieved, and if necessary issuing error messages.
kono
parents:
diff changeset
232
kono
parents:
diff changeset
233 -------------------------------------
kono
parents:
diff changeset
234 -- Table for Validate_Independence --
kono
parents:
diff changeset
235 -------------------------------------
kono
parents:
diff changeset
236
kono
parents:
diff changeset
237 -- If a legal pragma Independent or Independent_Components is given for
kono
parents:
diff changeset
238 -- an entity, then an entry is made in this table, to be checked by a
kono
parents:
diff changeset
239 -- call to Validate_Independence after back annotation of layout is done.
kono
parents:
diff changeset
240
kono
parents:
diff changeset
241 type Independence_Check_Record is record
kono
parents:
diff changeset
242 N : Node_Id;
kono
parents:
diff changeset
243 -- The pragma Independent or Independent_Components
kono
parents:
diff changeset
244
kono
parents:
diff changeset
245 E : Entity_Id;
kono
parents:
diff changeset
246 -- The entity to which it applies
kono
parents:
diff changeset
247 end record;
kono
parents:
diff changeset
248
kono
parents:
diff changeset
249 package Independence_Checks is new Table.Table (
kono
parents:
diff changeset
250 Table_Component_Type => Independence_Check_Record,
kono
parents:
diff changeset
251 Table_Index_Type => Int,
kono
parents:
diff changeset
252 Table_Low_Bound => 1,
kono
parents:
diff changeset
253 Table_Initial => 20,
kono
parents:
diff changeset
254 Table_Increment => 200,
kono
parents:
diff changeset
255 Table_Name => "Independence_Checks");
kono
parents:
diff changeset
256
kono
parents:
diff changeset
257 -----------------------------------
kono
parents:
diff changeset
258 -- Handling of Aspect Visibility --
kono
parents:
diff changeset
259 -----------------------------------
kono
parents:
diff changeset
260
kono
parents:
diff changeset
261 -- The visibility of aspects is tricky. First, the visibility is delayed
kono
parents:
diff changeset
262 -- to the freeze point. This is not too complicated, what we do is simply
kono
parents:
diff changeset
263 -- to leave the aspect "laying in wait" for the freeze point, and at that
kono
parents:
diff changeset
264 -- point materialize and analyze the corresponding attribute definition
kono
parents:
diff changeset
265 -- clause or pragma. There is some special processing for preconditions
kono
parents:
diff changeset
266 -- and postonditions, where the pragmas themselves deal with the required
kono
parents:
diff changeset
267 -- delay, but basically the approach is the same, delay analysis of the
kono
parents:
diff changeset
268 -- expression to the freeze point.
kono
parents:
diff changeset
269
kono
parents:
diff changeset
270 -- Much harder is the requirement for diagnosing cases in which an early
kono
parents:
diff changeset
271 -- freeze causes a change in visibility. Consider:
kono
parents:
diff changeset
272
kono
parents:
diff changeset
273 -- package AspectVis is
kono
parents:
diff changeset
274 -- R_Size : constant Integer := 32;
kono
parents:
diff changeset
275 --
kono
parents:
diff changeset
276 -- package Inner is
kono
parents:
diff changeset
277 -- type R is new Integer with
kono
parents:
diff changeset
278 -- Size => R_Size;
kono
parents:
diff changeset
279 -- F : R; -- freezes
kono
parents:
diff changeset
280 -- R_Size : constant Integer := 64;
kono
parents:
diff changeset
281 -- S : constant Integer := R'Size; -- 32 not 64
kono
parents:
diff changeset
282 -- end Inner;
kono
parents:
diff changeset
283 -- end AspectVis;
kono
parents:
diff changeset
284
kono
parents:
diff changeset
285 -- Here the 32 not 64 shows what would be expected if this program were
kono
parents:
diff changeset
286 -- legal, since the evaluation of R_Size has to be done at the freeze
kono
parents:
diff changeset
287 -- point and gets the outer definition not the inner one.
kono
parents:
diff changeset
288
kono
parents:
diff changeset
289 -- But the language rule requires this program to be diagnosed as illegal
kono
parents:
diff changeset
290 -- because the visibility changes between the freeze point and the end of
kono
parents:
diff changeset
291 -- the declarative region.
kono
parents:
diff changeset
292
kono
parents:
diff changeset
293 -- To meet this requirement, we first note that the Expression field of the
kono
parents:
diff changeset
294 -- N_Aspect_Specification node holds the raw unanalyzed expression, which
kono
parents:
diff changeset
295 -- will get used in processing the aspect. At the time of analyzing the
kono
parents:
diff changeset
296 -- N_Aspect_Specification node, we create a complete copy of the expression
kono
parents:
diff changeset
297 -- and store it in the entity field of the Identifier (an odd usage, but
kono
parents:
diff changeset
298 -- the identifier is not used except to identify the aspect, so its Entity
kono
parents:
diff changeset
299 -- field is otherwise unused, and we are short of room in the node).
kono
parents:
diff changeset
300
kono
parents:
diff changeset
301 -- This copy stays unanalyzed up to the freeze point, where we analyze the
kono
parents:
diff changeset
302 -- resulting pragma or attribute definition clause, except that in the
kono
parents:
diff changeset
303 -- case of invariants and predicates, we mark occurrences of the subtype
kono
parents:
diff changeset
304 -- name as having the entity of the subprogram parameter, so that they
kono
parents:
diff changeset
305 -- will not cause trouble in the following steps.
kono
parents:
diff changeset
306
kono
parents:
diff changeset
307 -- Then at the freeze point, we create another copy of this unanalyzed
kono
parents:
diff changeset
308 -- expression. By this time we no longer need the Expression field for
kono
parents:
diff changeset
309 -- other purposes, so we can store it there. Now we have two copies of
kono
parents:
diff changeset
310 -- the original unanalyzed expression. One of them gets preanalyzed at
kono
parents:
diff changeset
311 -- the freeze point to capture the visibility at the freeze point.
kono
parents:
diff changeset
312
kono
parents:
diff changeset
313 -- Now when we hit the freeze all at the end of the declarative part, if
kono
parents:
diff changeset
314 -- we come across a frozen entity with delayed aspects, we still have one
kono
parents:
diff changeset
315 -- copy of the unanalyzed expression available in the node, and we again
kono
parents:
diff changeset
316 -- do a preanalysis using that copy and the visibility at the end of the
kono
parents:
diff changeset
317 -- declarative part. Now we have two preanalyzed expression (preanalysis
kono
parents:
diff changeset
318 -- is good enough, since we are only interested in referenced entities).
kono
parents:
diff changeset
319 -- One captures the visibility at the freeze point, the other captures the
kono
parents:
diff changeset
320 -- visibility at the end of the declarative part. We see if the entities
kono
parents:
diff changeset
321 -- in these two expressions are the same, by seeing if the two expressions
kono
parents:
diff changeset
322 -- are fully conformant, and if not, issue appropriate error messages.
kono
parents:
diff changeset
323
kono
parents:
diff changeset
324 -- Quite an awkward approach, but this is an awkard requirement
kono
parents:
diff changeset
325
kono
parents:
diff changeset
326 procedure Analyze_Aspects_At_Freeze_Point (E : Entity_Id);
kono
parents:
diff changeset
327 -- Analyze all the delayed aspects for entity E at freezing point. This
kono
parents:
diff changeset
328 -- includes dealing with inheriting delayed aspects from the parent type
kono
parents:
diff changeset
329 -- in the case where a derived type is frozen.
kono
parents:
diff changeset
330
kono
parents:
diff changeset
331 procedure Check_Aspect_At_Freeze_Point (ASN : Node_Id);
kono
parents:
diff changeset
332 -- Performs the processing described above at the freeze point, ASN is the
kono
parents:
diff changeset
333 -- N_Aspect_Specification node for the aspect.
kono
parents:
diff changeset
334
kono
parents:
diff changeset
335 procedure Check_Aspect_At_End_Of_Declarations (ASN : Node_Id);
kono
parents:
diff changeset
336 -- Performs the processing described above at the freeze all point, and
kono
parents:
diff changeset
337 -- issues appropriate error messages if the visibility has indeed changed.
kono
parents:
diff changeset
338 -- Again, ASN is the N_Aspect_Specification node for the aspect.
kono
parents:
diff changeset
339
kono
parents:
diff changeset
340 procedure Inherit_Aspects_At_Freeze_Point (Typ : Entity_Id);
kono
parents:
diff changeset
341 -- Given an entity Typ that denotes a derived type or a subtype, this
kono
parents:
diff changeset
342 -- routine performs the inheritance of aspects at the freeze point.
kono
parents:
diff changeset
343
kono
parents:
diff changeset
344 procedure Resolve_Aspect_Expressions (E : Entity_Id);
kono
parents:
diff changeset
345 -- Name resolution of an aspect expression happens at the end of the
kono
parents:
diff changeset
346 -- current declarative part or at the freeze point for the entity,
kono
parents:
diff changeset
347 -- whichever comes first. For declarations in the visible part of a
kono
parents:
diff changeset
348 -- package, name resolution takes place before analysis of the private
kono
parents:
diff changeset
349 -- part even though the freeze point of the entity may appear later.
kono
parents:
diff changeset
350
kono
parents:
diff changeset
351 procedure Validate_Iterable_Aspect (Typ : Entity_Id; ASN : Node_Id);
kono
parents:
diff changeset
352 -- For SPARK 2014 formal containers. The expression has the form of an
kono
parents:
diff changeset
353 -- aggregate, and each entry must denote a function with the proper syntax
kono
parents:
diff changeset
354 -- for First, Next, and Has_Element. Optionally an Element primitive may
kono
parents:
diff changeset
355 -- also be defined.
kono
parents:
diff changeset
356
kono
parents:
diff changeset
357 -----------------------------------------------------------
kono
parents:
diff changeset
358 -- Visibility of Discriminants in Aspect Specifications --
kono
parents:
diff changeset
359 -----------------------------------------------------------
kono
parents:
diff changeset
360
kono
parents:
diff changeset
361 -- The discriminants of a type are visible when analyzing the aspect
kono
parents:
diff changeset
362 -- specifications of a type declaration or protected type declaration,
kono
parents:
diff changeset
363 -- but not when analyzing those of a subtype declaration. The following
kono
parents:
diff changeset
364 -- routines enforce this distinction.
kono
parents:
diff changeset
365
kono
parents:
diff changeset
366 procedure Install_Discriminants (E : Entity_Id);
kono
parents:
diff changeset
367 -- Make visible the discriminants of type entity E
kono
parents:
diff changeset
368
kono
parents:
diff changeset
369 procedure Push_Scope_And_Install_Discriminants (E : Entity_Id);
kono
parents:
diff changeset
370 -- Push scope E and makes visible the discriminants of type entity E if E
kono
parents:
diff changeset
371 -- has discriminants and is not a subtype.
kono
parents:
diff changeset
372
kono
parents:
diff changeset
373 procedure Uninstall_Discriminants (E : Entity_Id);
kono
parents:
diff changeset
374 -- Remove visibility to the discriminants of type entity E
kono
parents:
diff changeset
375
kono
parents:
diff changeset
376 procedure Uninstall_Discriminants_And_Pop_Scope (E : Entity_Id);
kono
parents:
diff changeset
377 -- Remove visibility to the discriminants of type entity E and pop the
kono
parents:
diff changeset
378 -- scope stack if E has discriminants and is not a subtype.
kono
parents:
diff changeset
379
kono
parents:
diff changeset
380 end Sem_Ch13;