annotate gcc/ada/sem.adb @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
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 --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- B o d y --
kono
parents:
diff changeset
8 -- --
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
9 -- Copyright (C) 1992-2019, 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 Atree; use Atree;
kono
parents:
diff changeset
27 with Debug; use Debug;
kono
parents:
diff changeset
28 with Debug_A; use Debug_A;
kono
parents:
diff changeset
29 with Elists; use Elists;
kono
parents:
diff changeset
30 with Exp_SPARK; use Exp_SPARK;
kono
parents:
diff changeset
31 with Expander; use Expander;
kono
parents:
diff changeset
32 with Ghost; use Ghost;
kono
parents:
diff changeset
33 with Lib; use Lib;
kono
parents:
diff changeset
34 with Lib.Load; use Lib.Load;
kono
parents:
diff changeset
35 with Nlists; use Nlists;
kono
parents:
diff changeset
36 with Output; use Output;
kono
parents:
diff changeset
37 with Restrict; use Restrict;
kono
parents:
diff changeset
38 with Sem_Attr; use Sem_Attr;
kono
parents:
diff changeset
39 with Sem_Ch2; use Sem_Ch2;
kono
parents:
diff changeset
40 with Sem_Ch3; use Sem_Ch3;
kono
parents:
diff changeset
41 with Sem_Ch4; use Sem_Ch4;
kono
parents:
diff changeset
42 with Sem_Ch5; use Sem_Ch5;
kono
parents:
diff changeset
43 with Sem_Ch6; use Sem_Ch6;
kono
parents:
diff changeset
44 with Sem_Ch7; use Sem_Ch7;
kono
parents:
diff changeset
45 with Sem_Ch8; use Sem_Ch8;
kono
parents:
diff changeset
46 with Sem_Ch9; use Sem_Ch9;
kono
parents:
diff changeset
47 with Sem_Ch10; use Sem_Ch10;
kono
parents:
diff changeset
48 with Sem_Ch11; use Sem_Ch11;
kono
parents:
diff changeset
49 with Sem_Ch12; use Sem_Ch12;
kono
parents:
diff changeset
50 with Sem_Ch13; use Sem_Ch13;
kono
parents:
diff changeset
51 with Sem_Prag; use Sem_Prag;
kono
parents:
diff changeset
52 with Sem_Util; use Sem_Util;
kono
parents:
diff changeset
53 with Sinfo; use Sinfo;
kono
parents:
diff changeset
54 with Stand; use Stand;
kono
parents:
diff changeset
55 with Stylesw; use Stylesw;
kono
parents:
diff changeset
56 with Uintp; use Uintp;
kono
parents:
diff changeset
57 with Uname; use Uname;
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 with Unchecked_Deallocation;
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 pragma Warnings (Off, Sem_Util);
kono
parents:
diff changeset
62 -- Suppress warnings of unused with for Sem_Util (used only in asserts)
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 package body Sem is
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 Debug_Unit_Walk : Boolean renames Debug_Flag_Dot_WW;
kono
parents:
diff changeset
67 -- Controls debugging printouts for Walk_Library_Items
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 Outer_Generic_Scope : Entity_Id := Empty;
kono
parents:
diff changeset
70 -- Global reference to the outer scope that is generic. In a non-generic
kono
parents:
diff changeset
71 -- context, it is empty. At the moment, it is only used for avoiding
kono
parents:
diff changeset
72 -- freezing of external references in generics.
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 Comp_Unit_List : Elist_Id := No_Elist;
kono
parents:
diff changeset
75 -- Used by Walk_Library_Items. This is a list of N_Compilation_Unit nodes
kono
parents:
diff changeset
76 -- processed by Semantics, in an appropriate order. Initialized to
kono
parents:
diff changeset
77 -- No_Elist, because it's too early to call New_Elmt_List; we will set it
kono
parents:
diff changeset
78 -- to New_Elmt_List on first use.
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 generic
kono
parents:
diff changeset
81 with procedure Action (Withed_Unit : Node_Id);
kono
parents:
diff changeset
82 procedure Walk_Withs_Immediate (CU : Node_Id; Include_Limited : Boolean);
kono
parents:
diff changeset
83 -- Walk all the with clauses of CU, and call Action for the with'ed unit.
kono
parents:
diff changeset
84 -- Ignore limited withs, unless Include_Limited is True. CU must be an
kono
parents:
diff changeset
85 -- N_Compilation_Unit.
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 generic
kono
parents:
diff changeset
88 with procedure Action (Withed_Unit : Node_Id);
kono
parents:
diff changeset
89 procedure Walk_Withs (CU : Node_Id; Include_Limited : Boolean);
kono
parents:
diff changeset
90 -- Same as Walk_Withs_Immediate, but also include with clauses on subunits
kono
parents:
diff changeset
91 -- of this unit, since they count as dependences on their parent library
kono
parents:
diff changeset
92 -- item. CU must be an N_Compilation_Unit whose Unit is not an N_Subunit.
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 -------------
kono
parents:
diff changeset
95 -- Analyze --
kono
parents:
diff changeset
96 -------------
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 -- WARNING: This routine manages Ghost regions. Return statements must be
kono
parents:
diff changeset
99 -- replaced by gotos which jump to the end of the routine and restore the
kono
parents:
diff changeset
100 -- Ghost mode.
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 procedure Analyze (N : Node_Id) is
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
103 Saved_GM : constant Ghost_Mode_Type := Ghost_Mode;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
104 Saved_IGR : constant Node_Id := Ignored_Ghost_Region;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
105 -- Save the Ghost-related attributes to restore on exit
111
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 begin
kono
parents:
diff changeset
108 Debug_A_Entry ("analyzing ", N);
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 -- Immediate return if already analyzed
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112 if Analyzed (N) then
kono
parents:
diff changeset
113 Debug_A_Exit ("analyzing ", N, " (done, analyzed already)");
kono
parents:
diff changeset
114 return;
kono
parents:
diff changeset
115 end if;
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 -- A declaration may be subject to pragma Ghost. Set the mode now to
kono
parents:
diff changeset
118 -- ensure that any nodes generated during analysis and expansion are
kono
parents:
diff changeset
119 -- marked as Ghost.
kono
parents:
diff changeset
120
kono
parents:
diff changeset
121 if Is_Declaration (N) then
kono
parents:
diff changeset
122 Mark_And_Set_Ghost_Declaration (N);
kono
parents:
diff changeset
123 end if;
kono
parents:
diff changeset
124
kono
parents:
diff changeset
125 -- Otherwise processing depends on the node kind
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127 case Nkind (N) is
kono
parents:
diff changeset
128 when N_Abort_Statement =>
kono
parents:
diff changeset
129 Analyze_Abort_Statement (N);
kono
parents:
diff changeset
130
kono
parents:
diff changeset
131 when N_Abstract_Subprogram_Declaration =>
kono
parents:
diff changeset
132 Analyze_Abstract_Subprogram_Declaration (N);
kono
parents:
diff changeset
133
kono
parents:
diff changeset
134 when N_Accept_Alternative =>
kono
parents:
diff changeset
135 Analyze_Accept_Alternative (N);
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137 when N_Accept_Statement =>
kono
parents:
diff changeset
138 Analyze_Accept_Statement (N);
kono
parents:
diff changeset
139
kono
parents:
diff changeset
140 when N_Aggregate =>
kono
parents:
diff changeset
141 Analyze_Aggregate (N);
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143 when N_Allocator =>
kono
parents:
diff changeset
144 Analyze_Allocator (N);
kono
parents:
diff changeset
145
kono
parents:
diff changeset
146 when N_And_Then =>
kono
parents:
diff changeset
147 Analyze_Short_Circuit (N);
kono
parents:
diff changeset
148
kono
parents:
diff changeset
149 when N_Assignment_Statement =>
kono
parents:
diff changeset
150 Analyze_Assignment (N);
kono
parents:
diff changeset
151
kono
parents:
diff changeset
152 when N_Asynchronous_Select =>
kono
parents:
diff changeset
153 Analyze_Asynchronous_Select (N);
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 when N_At_Clause =>
kono
parents:
diff changeset
156 Analyze_At_Clause (N);
kono
parents:
diff changeset
157
kono
parents:
diff changeset
158 when N_Attribute_Reference =>
kono
parents:
diff changeset
159 Analyze_Attribute (N);
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161 when N_Attribute_Definition_Clause =>
kono
parents:
diff changeset
162 Analyze_Attribute_Definition_Clause (N);
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164 when N_Block_Statement =>
kono
parents:
diff changeset
165 Analyze_Block_Statement (N);
kono
parents:
diff changeset
166
kono
parents:
diff changeset
167 when N_Case_Expression =>
kono
parents:
diff changeset
168 Analyze_Case_Expression (N);
kono
parents:
diff changeset
169
kono
parents:
diff changeset
170 when N_Case_Statement =>
kono
parents:
diff changeset
171 Analyze_Case_Statement (N);
kono
parents:
diff changeset
172
kono
parents:
diff changeset
173 when N_Character_Literal =>
kono
parents:
diff changeset
174 Analyze_Character_Literal (N);
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 when N_Code_Statement =>
kono
parents:
diff changeset
177 Analyze_Code_Statement (N);
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179 when N_Compilation_Unit =>
kono
parents:
diff changeset
180 Analyze_Compilation_Unit (N);
kono
parents:
diff changeset
181
kono
parents:
diff changeset
182 when N_Component_Declaration =>
kono
parents:
diff changeset
183 Analyze_Component_Declaration (N);
kono
parents:
diff changeset
184
kono
parents:
diff changeset
185 when N_Compound_Statement =>
kono
parents:
diff changeset
186 Analyze_Compound_Statement (N);
kono
parents:
diff changeset
187
kono
parents:
diff changeset
188 when N_Conditional_Entry_Call =>
kono
parents:
diff changeset
189 Analyze_Conditional_Entry_Call (N);
kono
parents:
diff changeset
190
kono
parents:
diff changeset
191 when N_Delay_Alternative =>
kono
parents:
diff changeset
192 Analyze_Delay_Alternative (N);
kono
parents:
diff changeset
193
kono
parents:
diff changeset
194 when N_Delay_Relative_Statement =>
kono
parents:
diff changeset
195 Analyze_Delay_Relative (N);
kono
parents:
diff changeset
196
kono
parents:
diff changeset
197 when N_Delay_Until_Statement =>
kono
parents:
diff changeset
198 Analyze_Delay_Until (N);
kono
parents:
diff changeset
199
kono
parents:
diff changeset
200 when N_Delta_Aggregate =>
kono
parents:
diff changeset
201 Analyze_Aggregate (N);
kono
parents:
diff changeset
202
kono
parents:
diff changeset
203 when N_Entry_Body =>
kono
parents:
diff changeset
204 Analyze_Entry_Body (N);
kono
parents:
diff changeset
205
kono
parents:
diff changeset
206 when N_Entry_Body_Formal_Part =>
kono
parents:
diff changeset
207 Analyze_Entry_Body_Formal_Part (N);
kono
parents:
diff changeset
208
kono
parents:
diff changeset
209 when N_Entry_Call_Alternative =>
kono
parents:
diff changeset
210 Analyze_Entry_Call_Alternative (N);
kono
parents:
diff changeset
211
kono
parents:
diff changeset
212 when N_Entry_Declaration =>
kono
parents:
diff changeset
213 Analyze_Entry_Declaration (N);
kono
parents:
diff changeset
214
kono
parents:
diff changeset
215 when N_Entry_Index_Specification =>
kono
parents:
diff changeset
216 Analyze_Entry_Index_Specification (N);
kono
parents:
diff changeset
217
kono
parents:
diff changeset
218 when N_Enumeration_Representation_Clause =>
kono
parents:
diff changeset
219 Analyze_Enumeration_Representation_Clause (N);
kono
parents:
diff changeset
220
kono
parents:
diff changeset
221 when N_Exception_Declaration =>
kono
parents:
diff changeset
222 Analyze_Exception_Declaration (N);
kono
parents:
diff changeset
223
kono
parents:
diff changeset
224 when N_Exception_Renaming_Declaration =>
kono
parents:
diff changeset
225 Analyze_Exception_Renaming (N);
kono
parents:
diff changeset
226
kono
parents:
diff changeset
227 when N_Exit_Statement =>
kono
parents:
diff changeset
228 Analyze_Exit_Statement (N);
kono
parents:
diff changeset
229
kono
parents:
diff changeset
230 when N_Expanded_Name =>
kono
parents:
diff changeset
231 Analyze_Expanded_Name (N);
kono
parents:
diff changeset
232
kono
parents:
diff changeset
233 when N_Explicit_Dereference =>
kono
parents:
diff changeset
234 Analyze_Explicit_Dereference (N);
kono
parents:
diff changeset
235
kono
parents:
diff changeset
236 when N_Expression_Function =>
kono
parents:
diff changeset
237 Analyze_Expression_Function (N);
kono
parents:
diff changeset
238
kono
parents:
diff changeset
239 when N_Expression_With_Actions =>
kono
parents:
diff changeset
240 Analyze_Expression_With_Actions (N);
kono
parents:
diff changeset
241
kono
parents:
diff changeset
242 when N_Extended_Return_Statement =>
kono
parents:
diff changeset
243 Analyze_Extended_Return_Statement (N);
kono
parents:
diff changeset
244
kono
parents:
diff changeset
245 when N_Extension_Aggregate =>
kono
parents:
diff changeset
246 Analyze_Aggregate (N);
kono
parents:
diff changeset
247
kono
parents:
diff changeset
248 when N_Formal_Object_Declaration =>
kono
parents:
diff changeset
249 Analyze_Formal_Object_Declaration (N);
kono
parents:
diff changeset
250
kono
parents:
diff changeset
251 when N_Formal_Package_Declaration =>
kono
parents:
diff changeset
252 Analyze_Formal_Package_Declaration (N);
kono
parents:
diff changeset
253
kono
parents:
diff changeset
254 when N_Formal_Subprogram_Declaration =>
kono
parents:
diff changeset
255 Analyze_Formal_Subprogram_Declaration (N);
kono
parents:
diff changeset
256
kono
parents:
diff changeset
257 when N_Formal_Type_Declaration =>
kono
parents:
diff changeset
258 Analyze_Formal_Type_Declaration (N);
kono
parents:
diff changeset
259
kono
parents:
diff changeset
260 when N_Free_Statement =>
kono
parents:
diff changeset
261 Analyze_Free_Statement (N);
kono
parents:
diff changeset
262
kono
parents:
diff changeset
263 when N_Freeze_Entity =>
kono
parents:
diff changeset
264 Analyze_Freeze_Entity (N);
kono
parents:
diff changeset
265
kono
parents:
diff changeset
266 when N_Freeze_Generic_Entity =>
kono
parents:
diff changeset
267 Analyze_Freeze_Generic_Entity (N);
kono
parents:
diff changeset
268
kono
parents:
diff changeset
269 when N_Full_Type_Declaration =>
kono
parents:
diff changeset
270 Analyze_Full_Type_Declaration (N);
kono
parents:
diff changeset
271
kono
parents:
diff changeset
272 when N_Function_Call =>
kono
parents:
diff changeset
273 Analyze_Function_Call (N);
kono
parents:
diff changeset
274
kono
parents:
diff changeset
275 when N_Function_Instantiation =>
kono
parents:
diff changeset
276 Analyze_Function_Instantiation (N);
kono
parents:
diff changeset
277
kono
parents:
diff changeset
278 when N_Generic_Function_Renaming_Declaration =>
kono
parents:
diff changeset
279 Analyze_Generic_Function_Renaming (N);
kono
parents:
diff changeset
280
kono
parents:
diff changeset
281 when N_Generic_Package_Declaration =>
kono
parents:
diff changeset
282 Analyze_Generic_Package_Declaration (N);
kono
parents:
diff changeset
283
kono
parents:
diff changeset
284 when N_Generic_Package_Renaming_Declaration =>
kono
parents:
diff changeset
285 Analyze_Generic_Package_Renaming (N);
kono
parents:
diff changeset
286
kono
parents:
diff changeset
287 when N_Generic_Procedure_Renaming_Declaration =>
kono
parents:
diff changeset
288 Analyze_Generic_Procedure_Renaming (N);
kono
parents:
diff changeset
289
kono
parents:
diff changeset
290 when N_Generic_Subprogram_Declaration =>
kono
parents:
diff changeset
291 Analyze_Generic_Subprogram_Declaration (N);
kono
parents:
diff changeset
292
kono
parents:
diff changeset
293 when N_Goto_Statement =>
kono
parents:
diff changeset
294 Analyze_Goto_Statement (N);
kono
parents:
diff changeset
295
kono
parents:
diff changeset
296 when N_Handled_Sequence_Of_Statements =>
kono
parents:
diff changeset
297 Analyze_Handled_Statements (N);
kono
parents:
diff changeset
298
kono
parents:
diff changeset
299 when N_Identifier =>
kono
parents:
diff changeset
300 Analyze_Identifier (N);
kono
parents:
diff changeset
301
kono
parents:
diff changeset
302 when N_If_Expression =>
kono
parents:
diff changeset
303 Analyze_If_Expression (N);
kono
parents:
diff changeset
304
kono
parents:
diff changeset
305 when N_If_Statement =>
kono
parents:
diff changeset
306 Analyze_If_Statement (N);
kono
parents:
diff changeset
307
kono
parents:
diff changeset
308 when N_Implicit_Label_Declaration =>
kono
parents:
diff changeset
309 Analyze_Implicit_Label_Declaration (N);
kono
parents:
diff changeset
310
kono
parents:
diff changeset
311 when N_In =>
kono
parents:
diff changeset
312 Analyze_Membership_Op (N);
kono
parents:
diff changeset
313
kono
parents:
diff changeset
314 when N_Incomplete_Type_Declaration =>
kono
parents:
diff changeset
315 Analyze_Incomplete_Type_Decl (N);
kono
parents:
diff changeset
316
kono
parents:
diff changeset
317 when N_Indexed_Component =>
kono
parents:
diff changeset
318 Analyze_Indexed_Component_Form (N);
kono
parents:
diff changeset
319
kono
parents:
diff changeset
320 when N_Integer_Literal =>
kono
parents:
diff changeset
321 Analyze_Integer_Literal (N);
kono
parents:
diff changeset
322
kono
parents:
diff changeset
323 when N_Iterator_Specification =>
kono
parents:
diff changeset
324 Analyze_Iterator_Specification (N);
kono
parents:
diff changeset
325
kono
parents:
diff changeset
326 when N_Itype_Reference =>
kono
parents:
diff changeset
327 Analyze_Itype_Reference (N);
kono
parents:
diff changeset
328
kono
parents:
diff changeset
329 when N_Label =>
kono
parents:
diff changeset
330 Analyze_Label (N);
kono
parents:
diff changeset
331
kono
parents:
diff changeset
332 when N_Loop_Parameter_Specification =>
kono
parents:
diff changeset
333 Analyze_Loop_Parameter_Specification (N);
kono
parents:
diff changeset
334
kono
parents:
diff changeset
335 when N_Loop_Statement =>
kono
parents:
diff changeset
336 Analyze_Loop_Statement (N);
kono
parents:
diff changeset
337
kono
parents:
diff changeset
338 when N_Not_In =>
kono
parents:
diff changeset
339 Analyze_Membership_Op (N);
kono
parents:
diff changeset
340
kono
parents:
diff changeset
341 when N_Null =>
kono
parents:
diff changeset
342 Analyze_Null (N);
kono
parents:
diff changeset
343
kono
parents:
diff changeset
344 when N_Null_Statement =>
kono
parents:
diff changeset
345 Analyze_Null_Statement (N);
kono
parents:
diff changeset
346
kono
parents:
diff changeset
347 when N_Number_Declaration =>
kono
parents:
diff changeset
348 Analyze_Number_Declaration (N);
kono
parents:
diff changeset
349
kono
parents:
diff changeset
350 when N_Object_Declaration =>
kono
parents:
diff changeset
351 Analyze_Object_Declaration (N);
kono
parents:
diff changeset
352
kono
parents:
diff changeset
353 when N_Object_Renaming_Declaration =>
kono
parents:
diff changeset
354 Analyze_Object_Renaming (N);
kono
parents:
diff changeset
355
kono
parents:
diff changeset
356 when N_Operator_Symbol =>
kono
parents:
diff changeset
357 Analyze_Operator_Symbol (N);
kono
parents:
diff changeset
358
kono
parents:
diff changeset
359 when N_Op_Abs =>
kono
parents:
diff changeset
360 Analyze_Unary_Op (N);
kono
parents:
diff changeset
361
kono
parents:
diff changeset
362 when N_Op_Add =>
kono
parents:
diff changeset
363 Analyze_Arithmetic_Op (N);
kono
parents:
diff changeset
364
kono
parents:
diff changeset
365 when N_Op_And =>
kono
parents:
diff changeset
366 Analyze_Logical_Op (N);
kono
parents:
diff changeset
367
kono
parents:
diff changeset
368 when N_Op_Concat =>
kono
parents:
diff changeset
369 Analyze_Concatenation (N);
kono
parents:
diff changeset
370
kono
parents:
diff changeset
371 when N_Op_Divide =>
kono
parents:
diff changeset
372 Analyze_Arithmetic_Op (N);
kono
parents:
diff changeset
373
kono
parents:
diff changeset
374 when N_Op_Eq =>
kono
parents:
diff changeset
375 Analyze_Equality_Op (N);
kono
parents:
diff changeset
376
kono
parents:
diff changeset
377 when N_Op_Expon =>
kono
parents:
diff changeset
378 Analyze_Arithmetic_Op (N);
kono
parents:
diff changeset
379
kono
parents:
diff changeset
380 when N_Op_Ge =>
kono
parents:
diff changeset
381 Analyze_Comparison_Op (N);
kono
parents:
diff changeset
382
kono
parents:
diff changeset
383 when N_Op_Gt =>
kono
parents:
diff changeset
384 Analyze_Comparison_Op (N);
kono
parents:
diff changeset
385
kono
parents:
diff changeset
386 when N_Op_Le =>
kono
parents:
diff changeset
387 Analyze_Comparison_Op (N);
kono
parents:
diff changeset
388
kono
parents:
diff changeset
389 when N_Op_Lt =>
kono
parents:
diff changeset
390 Analyze_Comparison_Op (N);
kono
parents:
diff changeset
391
kono
parents:
diff changeset
392 when N_Op_Minus =>
kono
parents:
diff changeset
393 Analyze_Unary_Op (N);
kono
parents:
diff changeset
394
kono
parents:
diff changeset
395 when N_Op_Mod =>
kono
parents:
diff changeset
396 Analyze_Mod (N);
kono
parents:
diff changeset
397
kono
parents:
diff changeset
398 when N_Op_Multiply =>
kono
parents:
diff changeset
399 Analyze_Arithmetic_Op (N);
kono
parents:
diff changeset
400
kono
parents:
diff changeset
401 when N_Op_Ne =>
kono
parents:
diff changeset
402 Analyze_Equality_Op (N);
kono
parents:
diff changeset
403
kono
parents:
diff changeset
404 when N_Op_Not =>
kono
parents:
diff changeset
405 Analyze_Negation (N);
kono
parents:
diff changeset
406
kono
parents:
diff changeset
407 when N_Op_Or =>
kono
parents:
diff changeset
408 Analyze_Logical_Op (N);
kono
parents:
diff changeset
409
kono
parents:
diff changeset
410 when N_Op_Plus =>
kono
parents:
diff changeset
411 Analyze_Unary_Op (N);
kono
parents:
diff changeset
412
kono
parents:
diff changeset
413 when N_Op_Rem =>
kono
parents:
diff changeset
414 Analyze_Arithmetic_Op (N);
kono
parents:
diff changeset
415
kono
parents:
diff changeset
416 when N_Op_Rotate_Left =>
kono
parents:
diff changeset
417 Analyze_Arithmetic_Op (N);
kono
parents:
diff changeset
418
kono
parents:
diff changeset
419 when N_Op_Rotate_Right =>
kono
parents:
diff changeset
420 Analyze_Arithmetic_Op (N);
kono
parents:
diff changeset
421
kono
parents:
diff changeset
422 when N_Op_Shift_Left =>
kono
parents:
diff changeset
423 Analyze_Arithmetic_Op (N);
kono
parents:
diff changeset
424
kono
parents:
diff changeset
425 when N_Op_Shift_Right =>
kono
parents:
diff changeset
426 Analyze_Arithmetic_Op (N);
kono
parents:
diff changeset
427
kono
parents:
diff changeset
428 when N_Op_Shift_Right_Arithmetic =>
kono
parents:
diff changeset
429 Analyze_Arithmetic_Op (N);
kono
parents:
diff changeset
430
kono
parents:
diff changeset
431 when N_Op_Subtract =>
kono
parents:
diff changeset
432 Analyze_Arithmetic_Op (N);
kono
parents:
diff changeset
433
kono
parents:
diff changeset
434 when N_Op_Xor =>
kono
parents:
diff changeset
435 Analyze_Logical_Op (N);
kono
parents:
diff changeset
436
kono
parents:
diff changeset
437 when N_Or_Else =>
kono
parents:
diff changeset
438 Analyze_Short_Circuit (N);
kono
parents:
diff changeset
439
kono
parents:
diff changeset
440 when N_Others_Choice =>
kono
parents:
diff changeset
441 Analyze_Others_Choice (N);
kono
parents:
diff changeset
442
kono
parents:
diff changeset
443 when N_Package_Body =>
kono
parents:
diff changeset
444 Analyze_Package_Body (N);
kono
parents:
diff changeset
445
kono
parents:
diff changeset
446 when N_Package_Body_Stub =>
kono
parents:
diff changeset
447 Analyze_Package_Body_Stub (N);
kono
parents:
diff changeset
448
kono
parents:
diff changeset
449 when N_Package_Declaration =>
kono
parents:
diff changeset
450 Analyze_Package_Declaration (N);
kono
parents:
diff changeset
451
kono
parents:
diff changeset
452 when N_Package_Instantiation =>
kono
parents:
diff changeset
453 Analyze_Package_Instantiation (N);
kono
parents:
diff changeset
454
kono
parents:
diff changeset
455 when N_Package_Renaming_Declaration =>
kono
parents:
diff changeset
456 Analyze_Package_Renaming (N);
kono
parents:
diff changeset
457
kono
parents:
diff changeset
458 when N_Package_Specification =>
kono
parents:
diff changeset
459 Analyze_Package_Specification (N);
kono
parents:
diff changeset
460
kono
parents:
diff changeset
461 when N_Parameter_Association =>
kono
parents:
diff changeset
462 Analyze_Parameter_Association (N);
kono
parents:
diff changeset
463
kono
parents:
diff changeset
464 when N_Pragma =>
kono
parents:
diff changeset
465 Analyze_Pragma (N);
kono
parents:
diff changeset
466
kono
parents:
diff changeset
467 when N_Private_Extension_Declaration =>
kono
parents:
diff changeset
468 Analyze_Private_Extension_Declaration (N);
kono
parents:
diff changeset
469
kono
parents:
diff changeset
470 when N_Private_Type_Declaration =>
kono
parents:
diff changeset
471 Analyze_Private_Type_Declaration (N);
kono
parents:
diff changeset
472
kono
parents:
diff changeset
473 when N_Procedure_Call_Statement =>
kono
parents:
diff changeset
474 Analyze_Procedure_Call (N);
kono
parents:
diff changeset
475
kono
parents:
diff changeset
476 when N_Procedure_Instantiation =>
kono
parents:
diff changeset
477 Analyze_Procedure_Instantiation (N);
kono
parents:
diff changeset
478
kono
parents:
diff changeset
479 when N_Protected_Body =>
kono
parents:
diff changeset
480 Analyze_Protected_Body (N);
kono
parents:
diff changeset
481
kono
parents:
diff changeset
482 when N_Protected_Body_Stub =>
kono
parents:
diff changeset
483 Analyze_Protected_Body_Stub (N);
kono
parents:
diff changeset
484
kono
parents:
diff changeset
485 when N_Protected_Definition =>
kono
parents:
diff changeset
486 Analyze_Protected_Definition (N);
kono
parents:
diff changeset
487
kono
parents:
diff changeset
488 when N_Protected_Type_Declaration =>
kono
parents:
diff changeset
489 Analyze_Protected_Type_Declaration (N);
kono
parents:
diff changeset
490
kono
parents:
diff changeset
491 when N_Qualified_Expression =>
kono
parents:
diff changeset
492 Analyze_Qualified_Expression (N);
kono
parents:
diff changeset
493
kono
parents:
diff changeset
494 when N_Quantified_Expression =>
kono
parents:
diff changeset
495 Analyze_Quantified_Expression (N);
kono
parents:
diff changeset
496
kono
parents:
diff changeset
497 when N_Raise_Expression =>
kono
parents:
diff changeset
498 Analyze_Raise_Expression (N);
kono
parents:
diff changeset
499
kono
parents:
diff changeset
500 when N_Raise_Statement =>
kono
parents:
diff changeset
501 Analyze_Raise_Statement (N);
kono
parents:
diff changeset
502
kono
parents:
diff changeset
503 when N_Raise_xxx_Error =>
kono
parents:
diff changeset
504 Analyze_Raise_xxx_Error (N);
kono
parents:
diff changeset
505
kono
parents:
diff changeset
506 when N_Range =>
kono
parents:
diff changeset
507 Analyze_Range (N);
kono
parents:
diff changeset
508
kono
parents:
diff changeset
509 when N_Range_Constraint =>
kono
parents:
diff changeset
510 Analyze_Range (Range_Expression (N));
kono
parents:
diff changeset
511
kono
parents:
diff changeset
512 when N_Real_Literal =>
kono
parents:
diff changeset
513 Analyze_Real_Literal (N);
kono
parents:
diff changeset
514
kono
parents:
diff changeset
515 when N_Record_Representation_Clause =>
kono
parents:
diff changeset
516 Analyze_Record_Representation_Clause (N);
kono
parents:
diff changeset
517
kono
parents:
diff changeset
518 when N_Reference =>
kono
parents:
diff changeset
519 Analyze_Reference (N);
kono
parents:
diff changeset
520
kono
parents:
diff changeset
521 when N_Requeue_Statement =>
kono
parents:
diff changeset
522 Analyze_Requeue (N);
kono
parents:
diff changeset
523
kono
parents:
diff changeset
524 when N_Simple_Return_Statement =>
kono
parents:
diff changeset
525 Analyze_Simple_Return_Statement (N);
kono
parents:
diff changeset
526
kono
parents:
diff changeset
527 when N_Selected_Component =>
kono
parents:
diff changeset
528 Find_Selected_Component (N);
kono
parents:
diff changeset
529 -- ??? why not Analyze_Selected_Component, needs comments
kono
parents:
diff changeset
530
kono
parents:
diff changeset
531 when N_Selective_Accept =>
kono
parents:
diff changeset
532 Analyze_Selective_Accept (N);
kono
parents:
diff changeset
533
kono
parents:
diff changeset
534 when N_Single_Protected_Declaration =>
kono
parents:
diff changeset
535 Analyze_Single_Protected_Declaration (N);
kono
parents:
diff changeset
536
kono
parents:
diff changeset
537 when N_Single_Task_Declaration =>
kono
parents:
diff changeset
538 Analyze_Single_Task_Declaration (N);
kono
parents:
diff changeset
539
kono
parents:
diff changeset
540 when N_Slice =>
kono
parents:
diff changeset
541 Analyze_Slice (N);
kono
parents:
diff changeset
542
kono
parents:
diff changeset
543 when N_String_Literal =>
kono
parents:
diff changeset
544 Analyze_String_Literal (N);
kono
parents:
diff changeset
545
kono
parents:
diff changeset
546 when N_Subprogram_Body =>
kono
parents:
diff changeset
547 Analyze_Subprogram_Body (N);
kono
parents:
diff changeset
548
kono
parents:
diff changeset
549 when N_Subprogram_Body_Stub =>
kono
parents:
diff changeset
550 Analyze_Subprogram_Body_Stub (N);
kono
parents:
diff changeset
551
kono
parents:
diff changeset
552 when N_Subprogram_Declaration =>
kono
parents:
diff changeset
553 Analyze_Subprogram_Declaration (N);
kono
parents:
diff changeset
554
kono
parents:
diff changeset
555 when N_Subprogram_Renaming_Declaration =>
kono
parents:
diff changeset
556 Analyze_Subprogram_Renaming (N);
kono
parents:
diff changeset
557
kono
parents:
diff changeset
558 when N_Subtype_Declaration =>
kono
parents:
diff changeset
559 Analyze_Subtype_Declaration (N);
kono
parents:
diff changeset
560
kono
parents:
diff changeset
561 when N_Subtype_Indication =>
kono
parents:
diff changeset
562 Analyze_Subtype_Indication (N);
kono
parents:
diff changeset
563
kono
parents:
diff changeset
564 when N_Subunit =>
kono
parents:
diff changeset
565 Analyze_Subunit (N);
kono
parents:
diff changeset
566
kono
parents:
diff changeset
567 when N_Target_Name =>
kono
parents:
diff changeset
568 Analyze_Target_Name (N);
kono
parents:
diff changeset
569
kono
parents:
diff changeset
570 when N_Task_Body =>
kono
parents:
diff changeset
571 Analyze_Task_Body (N);
kono
parents:
diff changeset
572
kono
parents:
diff changeset
573 when N_Task_Body_Stub =>
kono
parents:
diff changeset
574 Analyze_Task_Body_Stub (N);
kono
parents:
diff changeset
575
kono
parents:
diff changeset
576 when N_Task_Definition =>
kono
parents:
diff changeset
577 Analyze_Task_Definition (N);
kono
parents:
diff changeset
578
kono
parents:
diff changeset
579 when N_Task_Type_Declaration =>
kono
parents:
diff changeset
580 Analyze_Task_Type_Declaration (N);
kono
parents:
diff changeset
581
kono
parents:
diff changeset
582 when N_Terminate_Alternative =>
kono
parents:
diff changeset
583 Analyze_Terminate_Alternative (N);
kono
parents:
diff changeset
584
kono
parents:
diff changeset
585 when N_Timed_Entry_Call =>
kono
parents:
diff changeset
586 Analyze_Timed_Entry_Call (N);
kono
parents:
diff changeset
587
kono
parents:
diff changeset
588 when N_Triggering_Alternative =>
kono
parents:
diff changeset
589 Analyze_Triggering_Alternative (N);
kono
parents:
diff changeset
590
kono
parents:
diff changeset
591 when N_Type_Conversion =>
kono
parents:
diff changeset
592 Analyze_Type_Conversion (N);
kono
parents:
diff changeset
593
kono
parents:
diff changeset
594 when N_Unchecked_Expression =>
kono
parents:
diff changeset
595 Analyze_Unchecked_Expression (N);
kono
parents:
diff changeset
596
kono
parents:
diff changeset
597 when N_Unchecked_Type_Conversion =>
kono
parents:
diff changeset
598 Analyze_Unchecked_Type_Conversion (N);
kono
parents:
diff changeset
599
kono
parents:
diff changeset
600 when N_Use_Package_Clause =>
kono
parents:
diff changeset
601 Analyze_Use_Package (N);
kono
parents:
diff changeset
602
kono
parents:
diff changeset
603 when N_Use_Type_Clause =>
kono
parents:
diff changeset
604 Analyze_Use_Type (N);
kono
parents:
diff changeset
605
kono
parents:
diff changeset
606 when N_Validate_Unchecked_Conversion =>
kono
parents:
diff changeset
607 null;
kono
parents:
diff changeset
608
kono
parents:
diff changeset
609 when N_Variant_Part =>
kono
parents:
diff changeset
610 Analyze_Variant_Part (N);
kono
parents:
diff changeset
611
kono
parents:
diff changeset
612 when N_With_Clause =>
kono
parents:
diff changeset
613 Analyze_With_Clause (N);
kono
parents:
diff changeset
614
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
615 -- A call to analyze a marker is ignored because the node does not
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
616 -- have any static and run-time semantics.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
617
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
618 when N_Call_Marker
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
619 | N_Variable_Reference_Marker
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
620 =>
111
kono
parents:
diff changeset
621 null;
kono
parents:
diff changeset
622
kono
parents:
diff changeset
623 -- A call to analyze the Empty node is an error, but most likely it
kono
parents:
diff changeset
624 -- is an error caused by an attempt to analyze a malformed piece of
kono
parents:
diff changeset
625 -- tree caused by some other error, so if there have been any other
kono
parents:
diff changeset
626 -- errors, we just ignore it, otherwise it is a real internal error
kono
parents:
diff changeset
627 -- which we complain about.
kono
parents:
diff changeset
628
kono
parents:
diff changeset
629 -- We must also consider the case of call to a runtime function that
kono
parents:
diff changeset
630 -- is not available in the configurable runtime.
kono
parents:
diff changeset
631
kono
parents:
diff changeset
632 when N_Empty =>
kono
parents:
diff changeset
633 pragma Assert (Serious_Errors_Detected /= 0
kono
parents:
diff changeset
634 or else Configurable_Run_Time_Violations /= 0);
kono
parents:
diff changeset
635 null;
kono
parents:
diff changeset
636
kono
parents:
diff changeset
637 -- A call to analyze the error node is simply ignored, to avoid
kono
parents:
diff changeset
638 -- causing cascaded errors (happens of course only in error cases)
kono
parents:
diff changeset
639 -- Disable expansion in case it is still enabled, to prevent other
kono
parents:
diff changeset
640 -- subsequent compiler glitches.
kono
parents:
diff changeset
641
kono
parents:
diff changeset
642 when N_Error =>
kono
parents:
diff changeset
643 Expander_Mode_Save_And_Set (False);
kono
parents:
diff changeset
644 null;
kono
parents:
diff changeset
645
kono
parents:
diff changeset
646 -- Push/Pop nodes normally don't come through an analyze call. An
kono
parents:
diff changeset
647 -- exception is the dummy ones bracketing a subprogram body. In any
kono
parents:
diff changeset
648 -- case there is nothing to be done to analyze such nodes.
kono
parents:
diff changeset
649
kono
parents:
diff changeset
650 when N_Push_Pop_xxx_Label =>
kono
parents:
diff changeset
651 null;
kono
parents:
diff changeset
652
kono
parents:
diff changeset
653 -- SCIL nodes don't need analysis because they are decorated when
kono
parents:
diff changeset
654 -- they are built. They are added to the tree by Insert_Actions and
kono
parents:
diff changeset
655 -- the call to analyze them is generated when the full list is
kono
parents:
diff changeset
656 -- analyzed.
kono
parents:
diff changeset
657
kono
parents:
diff changeset
658 when N_SCIL_Dispatch_Table_Tag_Init
kono
parents:
diff changeset
659 | N_SCIL_Dispatching_Call
kono
parents:
diff changeset
660 | N_SCIL_Membership_Test
kono
parents:
diff changeset
661 =>
kono
parents:
diff changeset
662 null;
kono
parents:
diff changeset
663
kono
parents:
diff changeset
664 -- A quantified expression with a missing "all" or "some" qualifier
kono
parents:
diff changeset
665 -- looks identical to an iterated component association. By language
kono
parents:
diff changeset
666 -- definition, the latter must be present within array aggregates. If
kono
parents:
diff changeset
667 -- this is not the case, then the iterated component association is
kono
parents:
diff changeset
668 -- really an illegal quantified expression. Diagnose this scenario.
kono
parents:
diff changeset
669
kono
parents:
diff changeset
670 when N_Iterated_Component_Association =>
kono
parents:
diff changeset
671 Diagnose_Iterated_Component_Association (N);
kono
parents:
diff changeset
672
kono
parents:
diff changeset
673 -- For the remaining node types, we generate compiler abort, because
kono
parents:
diff changeset
674 -- these nodes are always analyzed within the Sem_Chn routines and
kono
parents:
diff changeset
675 -- there should never be a case of making a call to the main Analyze
kono
parents:
diff changeset
676 -- routine for these node kinds. For example, an N_Access_Definition
kono
parents:
diff changeset
677 -- node appears only in the context of a type declaration, and is
kono
parents:
diff changeset
678 -- processed by the analyze routine for type declarations.
kono
parents:
diff changeset
679
kono
parents:
diff changeset
680 when N_Abortable_Part
kono
parents:
diff changeset
681 | N_Access_Definition
kono
parents:
diff changeset
682 | N_Access_Function_Definition
kono
parents:
diff changeset
683 | N_Access_Procedure_Definition
kono
parents:
diff changeset
684 | N_Access_To_Object_Definition
kono
parents:
diff changeset
685 | N_Aspect_Specification
kono
parents:
diff changeset
686 | N_Case_Expression_Alternative
kono
parents:
diff changeset
687 | N_Case_Statement_Alternative
kono
parents:
diff changeset
688 | N_Compilation_Unit_Aux
kono
parents:
diff changeset
689 | N_Component_Association
kono
parents:
diff changeset
690 | N_Component_Clause
kono
parents:
diff changeset
691 | N_Component_Definition
kono
parents:
diff changeset
692 | N_Component_List
kono
parents:
diff changeset
693 | N_Constrained_Array_Definition
kono
parents:
diff changeset
694 | N_Contract
kono
parents:
diff changeset
695 | N_Decimal_Fixed_Point_Definition
kono
parents:
diff changeset
696 | N_Defining_Character_Literal
kono
parents:
diff changeset
697 | N_Defining_Identifier
kono
parents:
diff changeset
698 | N_Defining_Operator_Symbol
kono
parents:
diff changeset
699 | N_Defining_Program_Unit_Name
kono
parents:
diff changeset
700 | N_Delta_Constraint
kono
parents:
diff changeset
701 | N_Derived_Type_Definition
kono
parents:
diff changeset
702 | N_Designator
kono
parents:
diff changeset
703 | N_Digits_Constraint
kono
parents:
diff changeset
704 | N_Discriminant_Association
kono
parents:
diff changeset
705 | N_Discriminant_Specification
kono
parents:
diff changeset
706 | N_Elsif_Part
kono
parents:
diff changeset
707 | N_Entry_Call_Statement
kono
parents:
diff changeset
708 | N_Enumeration_Type_Definition
kono
parents:
diff changeset
709 | N_Exception_Handler
kono
parents:
diff changeset
710 | N_Floating_Point_Definition
kono
parents:
diff changeset
711 | N_Formal_Decimal_Fixed_Point_Definition
kono
parents:
diff changeset
712 | N_Formal_Derived_Type_Definition
kono
parents:
diff changeset
713 | N_Formal_Discrete_Type_Definition
kono
parents:
diff changeset
714 | N_Formal_Floating_Point_Definition
kono
parents:
diff changeset
715 | N_Formal_Modular_Type_Definition
kono
parents:
diff changeset
716 | N_Formal_Ordinary_Fixed_Point_Definition
kono
parents:
diff changeset
717 | N_Formal_Private_Type_Definition
kono
parents:
diff changeset
718 | N_Formal_Incomplete_Type_Definition
kono
parents:
diff changeset
719 | N_Formal_Signed_Integer_Type_Definition
kono
parents:
diff changeset
720 | N_Function_Specification
kono
parents:
diff changeset
721 | N_Generic_Association
kono
parents:
diff changeset
722 | N_Index_Or_Discriminant_Constraint
kono
parents:
diff changeset
723 | N_Iteration_Scheme
kono
parents:
diff changeset
724 | N_Mod_Clause
kono
parents:
diff changeset
725 | N_Modular_Type_Definition
kono
parents:
diff changeset
726 | N_Ordinary_Fixed_Point_Definition
kono
parents:
diff changeset
727 | N_Parameter_Specification
kono
parents:
diff changeset
728 | N_Pragma_Argument_Association
kono
parents:
diff changeset
729 | N_Procedure_Specification
kono
parents:
diff changeset
730 | N_Real_Range_Specification
kono
parents:
diff changeset
731 | N_Record_Definition
kono
parents:
diff changeset
732 | N_Signed_Integer_Type_Definition
kono
parents:
diff changeset
733 | N_Unconstrained_Array_Definition
kono
parents:
diff changeset
734 | N_Unused_At_End
kono
parents:
diff changeset
735 | N_Unused_At_Start
kono
parents:
diff changeset
736 | N_Variant
kono
parents:
diff changeset
737 =>
kono
parents:
diff changeset
738 raise Program_Error;
kono
parents:
diff changeset
739 end case;
kono
parents:
diff changeset
740
kono
parents:
diff changeset
741 Debug_A_Exit ("analyzing ", N, " (done)");
kono
parents:
diff changeset
742
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
743 -- Mark relevant use-type and use-package clauses as effective
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
744 -- preferring the original node over the analyzed one in the case that
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
745 -- constant folding has occurred and removed references that need to be
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
746 -- examined. Also, if the node in question is overloaded then this is
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
747 -- deferred until resolution.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
748
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
749 declare
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
750 Operat : Node_Id := Empty;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
751 begin
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
752 -- Attempt to obtain a checkable operator node
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
753
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
754 if Nkind (Original_Node (N)) in N_Op then
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
755 Operat := Original_Node (N);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
756 elsif Nkind (N) in N_Op then
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
757 Operat := N;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
758 end if;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
759
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
760 -- Mark the operator
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
761
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
762 if Present (Operat)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
763 and then Present (Entity (Operat))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
764 and then not Is_Overloaded (Operat)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
765 then
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
766 Mark_Use_Clauses (Operat);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
767 end if;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
768 end;
111
kono
parents:
diff changeset
769
kono
parents:
diff changeset
770 -- Now that we have analyzed the node, we call the expander to perform
kono
parents:
diff changeset
771 -- possible expansion. We skip this for subexpressions, because we don't
kono
parents:
diff changeset
772 -- have the type yet, and the expander will need to know the type before
kono
parents:
diff changeset
773 -- it can do its job. For subexpression nodes, the call to the expander
kono
parents:
diff changeset
774 -- happens in Sem_Res.Resolve. A special exception is Raise_xxx_Error,
kono
parents:
diff changeset
775 -- which can appear in a statement context, and needs expanding now in
kono
parents:
diff changeset
776 -- the case (distinguished by Etype, as documented in Sinfo).
kono
parents:
diff changeset
777
kono
parents:
diff changeset
778 -- The Analyzed flag is also set at this point for non-subexpression
kono
parents:
diff changeset
779 -- nodes (in the case of subexpression nodes, we can't set the flag yet,
kono
parents:
diff changeset
780 -- since resolution and expansion have not yet been completed). Note
kono
parents:
diff changeset
781 -- that for N_Raise_xxx_Error we have to distinguish the expression
kono
parents:
diff changeset
782 -- case from the statement case.
kono
parents:
diff changeset
783
kono
parents:
diff changeset
784 if Nkind (N) not in N_Subexpr
kono
parents:
diff changeset
785 or else (Nkind (N) in N_Raise_xxx_Error
kono
parents:
diff changeset
786 and then Etype (N) = Standard_Void_Type)
kono
parents:
diff changeset
787 then
kono
parents:
diff changeset
788 Expand (N);
kono
parents:
diff changeset
789
kono
parents:
diff changeset
790 -- Replace a reference to a renaming with the renamed object for SPARK.
kono
parents:
diff changeset
791 -- In general this modification is performed by Expand_SPARK, however
kono
parents:
diff changeset
792 -- certain constructs may not reach the resolution or expansion phase
kono
parents:
diff changeset
793 -- and thus remain unchanged. The replacement is not performed when the
kono
parents:
diff changeset
794 -- construct is overloaded as resolution must first take place. This is
kono
parents:
diff changeset
795 -- also not done when analyzing a generic to preserve the original tree
kono
parents:
diff changeset
796 -- and because the reference may become overloaded in the instance.
kono
parents:
diff changeset
797
kono
parents:
diff changeset
798 elsif GNATprove_Mode
kono
parents:
diff changeset
799 and then Nkind_In (N, N_Expanded_Name, N_Identifier)
kono
parents:
diff changeset
800 and then not Is_Overloaded (N)
kono
parents:
diff changeset
801 and then not Inside_A_Generic
kono
parents:
diff changeset
802 then
kono
parents:
diff changeset
803 Expand_SPARK_Potential_Renaming (N);
kono
parents:
diff changeset
804 end if;
kono
parents:
diff changeset
805
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
806 Restore_Ghost_Region (Saved_GM, Saved_IGR);
111
kono
parents:
diff changeset
807 end Analyze;
kono
parents:
diff changeset
808
kono
parents:
diff changeset
809 -- Version with check(s) suppressed
kono
parents:
diff changeset
810
kono
parents:
diff changeset
811 procedure Analyze (N : Node_Id; Suppress : Check_Id) is
kono
parents:
diff changeset
812 begin
kono
parents:
diff changeset
813 if Suppress = All_Checks then
kono
parents:
diff changeset
814 declare
kono
parents:
diff changeset
815 Svs : constant Suppress_Array := Scope_Suppress.Suppress;
kono
parents:
diff changeset
816 begin
kono
parents:
diff changeset
817 Scope_Suppress.Suppress := (others => True);
kono
parents:
diff changeset
818 Analyze (N);
kono
parents:
diff changeset
819 Scope_Suppress.Suppress := Svs;
kono
parents:
diff changeset
820 end;
kono
parents:
diff changeset
821
kono
parents:
diff changeset
822 elsif Suppress = Overflow_Check then
kono
parents:
diff changeset
823 declare
kono
parents:
diff changeset
824 Svg : constant Boolean := Scope_Suppress.Suppress (Suppress);
kono
parents:
diff changeset
825 begin
kono
parents:
diff changeset
826 Scope_Suppress.Suppress (Suppress) := True;
kono
parents:
diff changeset
827 Analyze (N);
kono
parents:
diff changeset
828 Scope_Suppress.Suppress (Suppress) := Svg;
kono
parents:
diff changeset
829 end;
kono
parents:
diff changeset
830 end if;
kono
parents:
diff changeset
831 end Analyze;
kono
parents:
diff changeset
832
kono
parents:
diff changeset
833 ------------------
kono
parents:
diff changeset
834 -- Analyze_List --
kono
parents:
diff changeset
835 ------------------
kono
parents:
diff changeset
836
kono
parents:
diff changeset
837 procedure Analyze_List (L : List_Id) is
kono
parents:
diff changeset
838 Node : Node_Id;
kono
parents:
diff changeset
839
kono
parents:
diff changeset
840 begin
kono
parents:
diff changeset
841 Node := First (L);
kono
parents:
diff changeset
842 while Present (Node) loop
kono
parents:
diff changeset
843 Analyze (Node);
kono
parents:
diff changeset
844 Next (Node);
kono
parents:
diff changeset
845 end loop;
kono
parents:
diff changeset
846 end Analyze_List;
kono
parents:
diff changeset
847
kono
parents:
diff changeset
848 -- Version with check(s) suppressed
kono
parents:
diff changeset
849
kono
parents:
diff changeset
850 procedure Analyze_List (L : List_Id; Suppress : Check_Id) is
kono
parents:
diff changeset
851 begin
kono
parents:
diff changeset
852 if Suppress = All_Checks then
kono
parents:
diff changeset
853 declare
kono
parents:
diff changeset
854 Svs : constant Suppress_Array := Scope_Suppress.Suppress;
kono
parents:
diff changeset
855 begin
kono
parents:
diff changeset
856 Scope_Suppress.Suppress := (others => True);
kono
parents:
diff changeset
857 Analyze_List (L);
kono
parents:
diff changeset
858 Scope_Suppress.Suppress := Svs;
kono
parents:
diff changeset
859 end;
kono
parents:
diff changeset
860
kono
parents:
diff changeset
861 else
kono
parents:
diff changeset
862 declare
kono
parents:
diff changeset
863 Svg : constant Boolean := Scope_Suppress.Suppress (Suppress);
kono
parents:
diff changeset
864 begin
kono
parents:
diff changeset
865 Scope_Suppress.Suppress (Suppress) := True;
kono
parents:
diff changeset
866 Analyze_List (L);
kono
parents:
diff changeset
867 Scope_Suppress.Suppress (Suppress) := Svg;
kono
parents:
diff changeset
868 end;
kono
parents:
diff changeset
869 end if;
kono
parents:
diff changeset
870 end Analyze_List;
kono
parents:
diff changeset
871
kono
parents:
diff changeset
872 --------------------------
kono
parents:
diff changeset
873 -- Copy_Suppress_Status --
kono
parents:
diff changeset
874 --------------------------
kono
parents:
diff changeset
875
kono
parents:
diff changeset
876 procedure Copy_Suppress_Status
kono
parents:
diff changeset
877 (C : Check_Id;
kono
parents:
diff changeset
878 From : Entity_Id;
kono
parents:
diff changeset
879 To : Entity_Id)
kono
parents:
diff changeset
880 is
kono
parents:
diff changeset
881 Found : Boolean;
kono
parents:
diff changeset
882 pragma Warnings (Off, Found);
kono
parents:
diff changeset
883
kono
parents:
diff changeset
884 procedure Search_Stack
kono
parents:
diff changeset
885 (Top : Suppress_Stack_Entry_Ptr;
kono
parents:
diff changeset
886 Found : out Boolean);
kono
parents:
diff changeset
887 -- Search given suppress stack for matching entry for entity. If found
kono
parents:
diff changeset
888 -- then set Checks_May_Be_Suppressed on To, and push an appropriate
kono
parents:
diff changeset
889 -- entry for To onto the local suppress stack.
kono
parents:
diff changeset
890
kono
parents:
diff changeset
891 ------------------
kono
parents:
diff changeset
892 -- Search_Stack --
kono
parents:
diff changeset
893 ------------------
kono
parents:
diff changeset
894
kono
parents:
diff changeset
895 procedure Search_Stack
kono
parents:
diff changeset
896 (Top : Suppress_Stack_Entry_Ptr;
kono
parents:
diff changeset
897 Found : out Boolean)
kono
parents:
diff changeset
898 is
kono
parents:
diff changeset
899 Ptr : Suppress_Stack_Entry_Ptr;
kono
parents:
diff changeset
900
kono
parents:
diff changeset
901 begin
kono
parents:
diff changeset
902 Ptr := Top;
kono
parents:
diff changeset
903 while Ptr /= null loop
kono
parents:
diff changeset
904 if Ptr.Entity = From
kono
parents:
diff changeset
905 and then (Ptr.Check = All_Checks or else Ptr.Check = C)
kono
parents:
diff changeset
906 then
kono
parents:
diff changeset
907 if Ptr.Suppress then
kono
parents:
diff changeset
908 Set_Checks_May_Be_Suppressed (To, True);
kono
parents:
diff changeset
909 Push_Local_Suppress_Stack_Entry
kono
parents:
diff changeset
910 (Entity => To,
kono
parents:
diff changeset
911 Check => C,
kono
parents:
diff changeset
912 Suppress => True);
kono
parents:
diff changeset
913 Found := True;
kono
parents:
diff changeset
914 return;
kono
parents:
diff changeset
915 end if;
kono
parents:
diff changeset
916 end if;
kono
parents:
diff changeset
917
kono
parents:
diff changeset
918 Ptr := Ptr.Prev;
kono
parents:
diff changeset
919 end loop;
kono
parents:
diff changeset
920
kono
parents:
diff changeset
921 Found := False;
kono
parents:
diff changeset
922 return;
kono
parents:
diff changeset
923 end Search_Stack;
kono
parents:
diff changeset
924
kono
parents:
diff changeset
925 -- Start of processing for Copy_Suppress_Status
kono
parents:
diff changeset
926
kono
parents:
diff changeset
927 begin
kono
parents:
diff changeset
928 if not Checks_May_Be_Suppressed (From) then
kono
parents:
diff changeset
929 return;
kono
parents:
diff changeset
930 end if;
kono
parents:
diff changeset
931
kono
parents:
diff changeset
932 -- First search the global entity suppress table for a matching entry.
kono
parents:
diff changeset
933 -- We also search this in reverse order so that if there are multiple
kono
parents:
diff changeset
934 -- pragmas for the same entity, the last one applies.
kono
parents:
diff changeset
935
kono
parents:
diff changeset
936 Search_Stack (Global_Suppress_Stack_Top, Found);
kono
parents:
diff changeset
937
kono
parents:
diff changeset
938 if Found then
kono
parents:
diff changeset
939 return;
kono
parents:
diff changeset
940 end if;
kono
parents:
diff changeset
941
kono
parents:
diff changeset
942 -- Now search the local entity suppress stack, we search this in
kono
parents:
diff changeset
943 -- reverse order so that we get the innermost entry that applies to
kono
parents:
diff changeset
944 -- this case if there are nested entries. Note that for the purpose
kono
parents:
diff changeset
945 -- of this procedure we are ONLY looking for entries corresponding
kono
parents:
diff changeset
946 -- to a two-argument Suppress, where the second argument matches From.
kono
parents:
diff changeset
947
kono
parents:
diff changeset
948 Search_Stack (Local_Suppress_Stack_Top, Found);
kono
parents:
diff changeset
949 end Copy_Suppress_Status;
kono
parents:
diff changeset
950
kono
parents:
diff changeset
951 -------------------------
kono
parents:
diff changeset
952 -- Enter_Generic_Scope --
kono
parents:
diff changeset
953 -------------------------
kono
parents:
diff changeset
954
kono
parents:
diff changeset
955 procedure Enter_Generic_Scope (S : Entity_Id) is
kono
parents:
diff changeset
956 begin
kono
parents:
diff changeset
957 if No (Outer_Generic_Scope) then
kono
parents:
diff changeset
958 Outer_Generic_Scope := S;
kono
parents:
diff changeset
959 end if;
kono
parents:
diff changeset
960 end Enter_Generic_Scope;
kono
parents:
diff changeset
961
kono
parents:
diff changeset
962 ------------------------
kono
parents:
diff changeset
963 -- Exit_Generic_Scope --
kono
parents:
diff changeset
964 ------------------------
kono
parents:
diff changeset
965
kono
parents:
diff changeset
966 procedure Exit_Generic_Scope (S : Entity_Id) is
kono
parents:
diff changeset
967 begin
kono
parents:
diff changeset
968 if S = Outer_Generic_Scope then
kono
parents:
diff changeset
969 Outer_Generic_Scope := Empty;
kono
parents:
diff changeset
970 end if;
kono
parents:
diff changeset
971 end Exit_Generic_Scope;
kono
parents:
diff changeset
972
kono
parents:
diff changeset
973 -----------------------
kono
parents:
diff changeset
974 -- Explicit_Suppress --
kono
parents:
diff changeset
975 -----------------------
kono
parents:
diff changeset
976
kono
parents:
diff changeset
977 function Explicit_Suppress (E : Entity_Id; C : Check_Id) return Boolean is
kono
parents:
diff changeset
978 Ptr : Suppress_Stack_Entry_Ptr;
kono
parents:
diff changeset
979
kono
parents:
diff changeset
980 begin
kono
parents:
diff changeset
981 if not Checks_May_Be_Suppressed (E) then
kono
parents:
diff changeset
982 return False;
kono
parents:
diff changeset
983
kono
parents:
diff changeset
984 else
kono
parents:
diff changeset
985 Ptr := Global_Suppress_Stack_Top;
kono
parents:
diff changeset
986 while Ptr /= null loop
kono
parents:
diff changeset
987 if Ptr.Entity = E
kono
parents:
diff changeset
988 and then (Ptr.Check = All_Checks or else Ptr.Check = C)
kono
parents:
diff changeset
989 then
kono
parents:
diff changeset
990 return Ptr.Suppress;
kono
parents:
diff changeset
991 end if;
kono
parents:
diff changeset
992
kono
parents:
diff changeset
993 Ptr := Ptr.Prev;
kono
parents:
diff changeset
994 end loop;
kono
parents:
diff changeset
995 end if;
kono
parents:
diff changeset
996
kono
parents:
diff changeset
997 return False;
kono
parents:
diff changeset
998 end Explicit_Suppress;
kono
parents:
diff changeset
999
kono
parents:
diff changeset
1000 -----------------------------
kono
parents:
diff changeset
1001 -- External_Ref_In_Generic --
kono
parents:
diff changeset
1002 -----------------------------
kono
parents:
diff changeset
1003
kono
parents:
diff changeset
1004 function External_Ref_In_Generic (E : Entity_Id) return Boolean is
kono
parents:
diff changeset
1005 Scop : Entity_Id;
kono
parents:
diff changeset
1006
kono
parents:
diff changeset
1007 begin
kono
parents:
diff changeset
1008 -- Entity is global if defined outside of current outer_generic_scope:
kono
parents:
diff changeset
1009 -- Either the entity has a smaller depth that the outer generic, or it
kono
parents:
diff changeset
1010 -- is in a different compilation unit, or it is defined within a unit
kono
parents:
diff changeset
1011 -- in the same compilation, that is not within the outer_generic.
kono
parents:
diff changeset
1012
kono
parents:
diff changeset
1013 if No (Outer_Generic_Scope) then
kono
parents:
diff changeset
1014 return False;
kono
parents:
diff changeset
1015
kono
parents:
diff changeset
1016 elsif Scope_Depth (Scope (E)) < Scope_Depth (Outer_Generic_Scope)
kono
parents:
diff changeset
1017 or else not In_Same_Source_Unit (E, Outer_Generic_Scope)
kono
parents:
diff changeset
1018 then
kono
parents:
diff changeset
1019 return True;
kono
parents:
diff changeset
1020
kono
parents:
diff changeset
1021 else
kono
parents:
diff changeset
1022 Scop := Scope (E);
kono
parents:
diff changeset
1023 while Present (Scop) loop
kono
parents:
diff changeset
1024 if Scop = Outer_Generic_Scope then
kono
parents:
diff changeset
1025 return False;
kono
parents:
diff changeset
1026 elsif Scope_Depth (Scop) < Scope_Depth (Outer_Generic_Scope) then
kono
parents:
diff changeset
1027 return True;
kono
parents:
diff changeset
1028 else
kono
parents:
diff changeset
1029 Scop := Scope (Scop);
kono
parents:
diff changeset
1030 end if;
kono
parents:
diff changeset
1031 end loop;
kono
parents:
diff changeset
1032
kono
parents:
diff changeset
1033 return True;
kono
parents:
diff changeset
1034 end if;
kono
parents:
diff changeset
1035 end External_Ref_In_Generic;
kono
parents:
diff changeset
1036
kono
parents:
diff changeset
1037 ----------------
kono
parents:
diff changeset
1038 -- Initialize --
kono
parents:
diff changeset
1039 ----------------
kono
parents:
diff changeset
1040
kono
parents:
diff changeset
1041 procedure Initialize is
kono
parents:
diff changeset
1042 Next : Suppress_Stack_Entry_Ptr;
kono
parents:
diff changeset
1043
kono
parents:
diff changeset
1044 procedure Free is new Unchecked_Deallocation
kono
parents:
diff changeset
1045 (Suppress_Stack_Entry, Suppress_Stack_Entry_Ptr);
kono
parents:
diff changeset
1046
kono
parents:
diff changeset
1047 begin
kono
parents:
diff changeset
1048 -- Free any global suppress stack entries from a previous invocation
kono
parents:
diff changeset
1049 -- of the compiler (in the normal case this loop does nothing).
kono
parents:
diff changeset
1050
kono
parents:
diff changeset
1051 while Suppress_Stack_Entries /= null loop
kono
parents:
diff changeset
1052 Next := Suppress_Stack_Entries.Next;
kono
parents:
diff changeset
1053 Free (Suppress_Stack_Entries);
kono
parents:
diff changeset
1054 Suppress_Stack_Entries := Next;
kono
parents:
diff changeset
1055 end loop;
kono
parents:
diff changeset
1056
kono
parents:
diff changeset
1057 Local_Suppress_Stack_Top := null;
kono
parents:
diff changeset
1058 Global_Suppress_Stack_Top := null;
kono
parents:
diff changeset
1059
kono
parents:
diff changeset
1060 -- Clear scope stack, and reset global variables
kono
parents:
diff changeset
1061
kono
parents:
diff changeset
1062 Scope_Stack.Init;
kono
parents:
diff changeset
1063 Unloaded_Subunits := False;
kono
parents:
diff changeset
1064 end Initialize;
kono
parents:
diff changeset
1065
kono
parents:
diff changeset
1066 ------------------------------
kono
parents:
diff changeset
1067 -- Insert_After_And_Analyze --
kono
parents:
diff changeset
1068 ------------------------------
kono
parents:
diff changeset
1069
kono
parents:
diff changeset
1070 procedure Insert_After_And_Analyze (N : Node_Id; M : Node_Id) is
kono
parents:
diff changeset
1071 Node : Node_Id;
kono
parents:
diff changeset
1072
kono
parents:
diff changeset
1073 begin
kono
parents:
diff changeset
1074 if Present (M) then
kono
parents:
diff changeset
1075
kono
parents:
diff changeset
1076 -- If we are not at the end of the list, then the easiest
kono
parents:
diff changeset
1077 -- coding is simply to insert before our successor.
kono
parents:
diff changeset
1078
kono
parents:
diff changeset
1079 if Present (Next (N)) then
kono
parents:
diff changeset
1080 Insert_Before_And_Analyze (Next (N), M);
kono
parents:
diff changeset
1081
kono
parents:
diff changeset
1082 -- Case of inserting at the end of the list
kono
parents:
diff changeset
1083
kono
parents:
diff changeset
1084 else
kono
parents:
diff changeset
1085 -- Capture the Node_Id of the node to be inserted. This Node_Id
kono
parents:
diff changeset
1086 -- will still be the same after the insert operation.
kono
parents:
diff changeset
1087
kono
parents:
diff changeset
1088 Node := M;
kono
parents:
diff changeset
1089 Insert_After (N, M);
kono
parents:
diff changeset
1090
kono
parents:
diff changeset
1091 -- Now just analyze from the inserted node to the end of
kono
parents:
diff changeset
1092 -- the new list (note that this properly handles the case
kono
parents:
diff changeset
1093 -- where any of the analyze calls result in the insertion of
kono
parents:
diff changeset
1094 -- nodes after the analyzed node, expecting analysis).
kono
parents:
diff changeset
1095
kono
parents:
diff changeset
1096 while Present (Node) loop
kono
parents:
diff changeset
1097 Analyze (Node);
kono
parents:
diff changeset
1098 Mark_Rewrite_Insertion (Node);
kono
parents:
diff changeset
1099 Next (Node);
kono
parents:
diff changeset
1100 end loop;
kono
parents:
diff changeset
1101 end if;
kono
parents:
diff changeset
1102 end if;
kono
parents:
diff changeset
1103 end Insert_After_And_Analyze;
kono
parents:
diff changeset
1104
kono
parents:
diff changeset
1105 -- Version with check(s) suppressed
kono
parents:
diff changeset
1106
kono
parents:
diff changeset
1107 procedure Insert_After_And_Analyze
kono
parents:
diff changeset
1108 (N : Node_Id;
kono
parents:
diff changeset
1109 M : Node_Id;
kono
parents:
diff changeset
1110 Suppress : Check_Id)
kono
parents:
diff changeset
1111 is
kono
parents:
diff changeset
1112 begin
kono
parents:
diff changeset
1113 if Suppress = All_Checks then
kono
parents:
diff changeset
1114 declare
kono
parents:
diff changeset
1115 Svs : constant Suppress_Array := Scope_Suppress.Suppress;
kono
parents:
diff changeset
1116 begin
kono
parents:
diff changeset
1117 Scope_Suppress.Suppress := (others => True);
kono
parents:
diff changeset
1118 Insert_After_And_Analyze (N, M);
kono
parents:
diff changeset
1119 Scope_Suppress.Suppress := Svs;
kono
parents:
diff changeset
1120 end;
kono
parents:
diff changeset
1121
kono
parents:
diff changeset
1122 else
kono
parents:
diff changeset
1123 declare
kono
parents:
diff changeset
1124 Svg : constant Boolean := Scope_Suppress.Suppress (Suppress);
kono
parents:
diff changeset
1125 begin
kono
parents:
diff changeset
1126 Scope_Suppress.Suppress (Suppress) := True;
kono
parents:
diff changeset
1127 Insert_After_And_Analyze (N, M);
kono
parents:
diff changeset
1128 Scope_Suppress.Suppress (Suppress) := Svg;
kono
parents:
diff changeset
1129 end;
kono
parents:
diff changeset
1130 end if;
kono
parents:
diff changeset
1131 end Insert_After_And_Analyze;
kono
parents:
diff changeset
1132
kono
parents:
diff changeset
1133 -------------------------------
kono
parents:
diff changeset
1134 -- Insert_Before_And_Analyze --
kono
parents:
diff changeset
1135 -------------------------------
kono
parents:
diff changeset
1136
kono
parents:
diff changeset
1137 procedure Insert_Before_And_Analyze (N : Node_Id; M : Node_Id) is
kono
parents:
diff changeset
1138 Node : Node_Id;
kono
parents:
diff changeset
1139
kono
parents:
diff changeset
1140 begin
kono
parents:
diff changeset
1141 if Present (M) then
kono
parents:
diff changeset
1142
kono
parents:
diff changeset
1143 -- Capture the Node_Id of the first list node to be inserted.
kono
parents:
diff changeset
1144 -- This will still be the first node after the insert operation,
kono
parents:
diff changeset
1145 -- since Insert_List_After does not modify the Node_Id values.
kono
parents:
diff changeset
1146
kono
parents:
diff changeset
1147 Node := M;
kono
parents:
diff changeset
1148 Insert_Before (N, M);
kono
parents:
diff changeset
1149
kono
parents:
diff changeset
1150 -- The insertion does not change the Id's of any of the nodes in
kono
parents:
diff changeset
1151 -- the list, and they are still linked, so we can simply loop from
kono
parents:
diff changeset
1152 -- the original first node until we meet the node before which the
kono
parents:
diff changeset
1153 -- insertion is occurring. Note that this properly handles the case
kono
parents:
diff changeset
1154 -- where any of the analyzed nodes insert nodes after themselves,
kono
parents:
diff changeset
1155 -- expecting them to get analyzed.
kono
parents:
diff changeset
1156
kono
parents:
diff changeset
1157 while Node /= N loop
kono
parents:
diff changeset
1158 Analyze (Node);
kono
parents:
diff changeset
1159 Mark_Rewrite_Insertion (Node);
kono
parents:
diff changeset
1160 Next (Node);
kono
parents:
diff changeset
1161 end loop;
kono
parents:
diff changeset
1162 end if;
kono
parents:
diff changeset
1163 end Insert_Before_And_Analyze;
kono
parents:
diff changeset
1164
kono
parents:
diff changeset
1165 -- Version with check(s) suppressed
kono
parents:
diff changeset
1166
kono
parents:
diff changeset
1167 procedure Insert_Before_And_Analyze
kono
parents:
diff changeset
1168 (N : Node_Id;
kono
parents:
diff changeset
1169 M : Node_Id;
kono
parents:
diff changeset
1170 Suppress : Check_Id)
kono
parents:
diff changeset
1171 is
kono
parents:
diff changeset
1172 begin
kono
parents:
diff changeset
1173 if Suppress = All_Checks then
kono
parents:
diff changeset
1174 declare
kono
parents:
diff changeset
1175 Svs : constant Suppress_Array := Scope_Suppress.Suppress;
kono
parents:
diff changeset
1176 begin
kono
parents:
diff changeset
1177 Scope_Suppress.Suppress := (others => True);
kono
parents:
diff changeset
1178 Insert_Before_And_Analyze (N, M);
kono
parents:
diff changeset
1179 Scope_Suppress.Suppress := Svs;
kono
parents:
diff changeset
1180 end;
kono
parents:
diff changeset
1181
kono
parents:
diff changeset
1182 else
kono
parents:
diff changeset
1183 declare
kono
parents:
diff changeset
1184 Svg : constant Boolean := Scope_Suppress.Suppress (Suppress);
kono
parents:
diff changeset
1185 begin
kono
parents:
diff changeset
1186 Scope_Suppress.Suppress (Suppress) := True;
kono
parents:
diff changeset
1187 Insert_Before_And_Analyze (N, M);
kono
parents:
diff changeset
1188 Scope_Suppress.Suppress (Suppress) := Svg;
kono
parents:
diff changeset
1189 end;
kono
parents:
diff changeset
1190 end if;
kono
parents:
diff changeset
1191 end Insert_Before_And_Analyze;
kono
parents:
diff changeset
1192
kono
parents:
diff changeset
1193 -----------------------------------
kono
parents:
diff changeset
1194 -- Insert_List_After_And_Analyze --
kono
parents:
diff changeset
1195 -----------------------------------
kono
parents:
diff changeset
1196
kono
parents:
diff changeset
1197 procedure Insert_List_After_And_Analyze (N : Node_Id; L : List_Id) is
kono
parents:
diff changeset
1198 After : constant Node_Id := Next (N);
kono
parents:
diff changeset
1199 Node : Node_Id;
kono
parents:
diff changeset
1200
kono
parents:
diff changeset
1201 begin
kono
parents:
diff changeset
1202 if Is_Non_Empty_List (L) then
kono
parents:
diff changeset
1203
kono
parents:
diff changeset
1204 -- Capture the Node_Id of the first list node to be inserted.
kono
parents:
diff changeset
1205 -- This will still be the first node after the insert operation,
kono
parents:
diff changeset
1206 -- since Insert_List_After does not modify the Node_Id values.
kono
parents:
diff changeset
1207
kono
parents:
diff changeset
1208 Node := First (L);
kono
parents:
diff changeset
1209 Insert_List_After (N, L);
kono
parents:
diff changeset
1210
kono
parents:
diff changeset
1211 -- Now just analyze from the original first node until we get to the
kono
parents:
diff changeset
1212 -- successor of the original insertion point (which may be Empty if
kono
parents:
diff changeset
1213 -- the insertion point was at the end of the list). Note that this
kono
parents:
diff changeset
1214 -- properly handles the case where any of the analyze calls result in
kono
parents:
diff changeset
1215 -- the insertion of nodes after the analyzed node (possibly calling
kono
parents:
diff changeset
1216 -- this routine recursively).
kono
parents:
diff changeset
1217
kono
parents:
diff changeset
1218 while Node /= After loop
kono
parents:
diff changeset
1219 Analyze (Node);
kono
parents:
diff changeset
1220 Mark_Rewrite_Insertion (Node);
kono
parents:
diff changeset
1221 Next (Node);
kono
parents:
diff changeset
1222 end loop;
kono
parents:
diff changeset
1223 end if;
kono
parents:
diff changeset
1224 end Insert_List_After_And_Analyze;
kono
parents:
diff changeset
1225
kono
parents:
diff changeset
1226 ------------------------------------
kono
parents:
diff changeset
1227 -- Insert_List_Before_And_Analyze --
kono
parents:
diff changeset
1228 ------------------------------------
kono
parents:
diff changeset
1229
kono
parents:
diff changeset
1230 procedure Insert_List_Before_And_Analyze (N : Node_Id; L : List_Id) is
kono
parents:
diff changeset
1231 Node : Node_Id;
kono
parents:
diff changeset
1232
kono
parents:
diff changeset
1233 begin
kono
parents:
diff changeset
1234 if Is_Non_Empty_List (L) then
kono
parents:
diff changeset
1235
kono
parents:
diff changeset
1236 -- Capture the Node_Id of the first list node to be inserted. This
kono
parents:
diff changeset
1237 -- will still be the first node after the insert operation, since
kono
parents:
diff changeset
1238 -- Insert_List_After does not modify the Node_Id values.
kono
parents:
diff changeset
1239
kono
parents:
diff changeset
1240 Node := First (L);
kono
parents:
diff changeset
1241 Insert_List_Before (N, L);
kono
parents:
diff changeset
1242
kono
parents:
diff changeset
1243 -- The insertion does not change the Id's of any of the nodes in
kono
parents:
diff changeset
1244 -- the list, and they are still linked, so we can simply loop from
kono
parents:
diff changeset
1245 -- the original first node until we meet the node before which the
kono
parents:
diff changeset
1246 -- insertion is occurring. Note that this properly handles the case
kono
parents:
diff changeset
1247 -- where any of the analyzed nodes insert nodes after themselves,
kono
parents:
diff changeset
1248 -- expecting them to get analyzed.
kono
parents:
diff changeset
1249
kono
parents:
diff changeset
1250 while Node /= N loop
kono
parents:
diff changeset
1251 Analyze (Node);
kono
parents:
diff changeset
1252 Mark_Rewrite_Insertion (Node);
kono
parents:
diff changeset
1253 Next (Node);
kono
parents:
diff changeset
1254 end loop;
kono
parents:
diff changeset
1255 end if;
kono
parents:
diff changeset
1256 end Insert_List_Before_And_Analyze;
kono
parents:
diff changeset
1257
kono
parents:
diff changeset
1258 ----------
kono
parents:
diff changeset
1259 -- Lock --
kono
parents:
diff changeset
1260 ----------
kono
parents:
diff changeset
1261
kono
parents:
diff changeset
1262 procedure Lock is
kono
parents:
diff changeset
1263 begin
kono
parents:
diff changeset
1264 Scope_Stack.Release;
kono
parents:
diff changeset
1265 Scope_Stack.Locked := True;
kono
parents:
diff changeset
1266 end Lock;
kono
parents:
diff changeset
1267
kono
parents:
diff changeset
1268 ------------------------
kono
parents:
diff changeset
1269 -- Preanalysis_Active --
kono
parents:
diff changeset
1270 ------------------------
kono
parents:
diff changeset
1271
kono
parents:
diff changeset
1272 function Preanalysis_Active return Boolean is
kono
parents:
diff changeset
1273 begin
kono
parents:
diff changeset
1274 return not Full_Analysis and not Expander_Active;
kono
parents:
diff changeset
1275 end Preanalysis_Active;
kono
parents:
diff changeset
1276
kono
parents:
diff changeset
1277 ----------------
kono
parents:
diff changeset
1278 -- Preanalyze --
kono
parents:
diff changeset
1279 ----------------
kono
parents:
diff changeset
1280
kono
parents:
diff changeset
1281 procedure Preanalyze (N : Node_Id) is
kono
parents:
diff changeset
1282 Save_Full_Analysis : constant Boolean := Full_Analysis;
kono
parents:
diff changeset
1283
kono
parents:
diff changeset
1284 begin
kono
parents:
diff changeset
1285 Full_Analysis := False;
kono
parents:
diff changeset
1286 Expander_Mode_Save_And_Set (False);
kono
parents:
diff changeset
1287
kono
parents:
diff changeset
1288 Analyze (N);
kono
parents:
diff changeset
1289
kono
parents:
diff changeset
1290 Expander_Mode_Restore;
kono
parents:
diff changeset
1291 Full_Analysis := Save_Full_Analysis;
kono
parents:
diff changeset
1292 end Preanalyze;
kono
parents:
diff changeset
1293
kono
parents:
diff changeset
1294 --------------------------------------
kono
parents:
diff changeset
1295 -- Push_Global_Suppress_Stack_Entry --
kono
parents:
diff changeset
1296 --------------------------------------
kono
parents:
diff changeset
1297
kono
parents:
diff changeset
1298 procedure Push_Global_Suppress_Stack_Entry
kono
parents:
diff changeset
1299 (Entity : Entity_Id;
kono
parents:
diff changeset
1300 Check : Check_Id;
kono
parents:
diff changeset
1301 Suppress : Boolean)
kono
parents:
diff changeset
1302 is
kono
parents:
diff changeset
1303 begin
kono
parents:
diff changeset
1304 Global_Suppress_Stack_Top :=
kono
parents:
diff changeset
1305 new Suppress_Stack_Entry'
kono
parents:
diff changeset
1306 (Entity => Entity,
kono
parents:
diff changeset
1307 Check => Check,
kono
parents:
diff changeset
1308 Suppress => Suppress,
kono
parents:
diff changeset
1309 Prev => Global_Suppress_Stack_Top,
kono
parents:
diff changeset
1310 Next => Suppress_Stack_Entries);
kono
parents:
diff changeset
1311 Suppress_Stack_Entries := Global_Suppress_Stack_Top;
kono
parents:
diff changeset
1312 return;
kono
parents:
diff changeset
1313 end Push_Global_Suppress_Stack_Entry;
kono
parents:
diff changeset
1314
kono
parents:
diff changeset
1315 -------------------------------------
kono
parents:
diff changeset
1316 -- Push_Local_Suppress_Stack_Entry --
kono
parents:
diff changeset
1317 -------------------------------------
kono
parents:
diff changeset
1318
kono
parents:
diff changeset
1319 procedure Push_Local_Suppress_Stack_Entry
kono
parents:
diff changeset
1320 (Entity : Entity_Id;
kono
parents:
diff changeset
1321 Check : Check_Id;
kono
parents:
diff changeset
1322 Suppress : Boolean)
kono
parents:
diff changeset
1323 is
kono
parents:
diff changeset
1324 begin
kono
parents:
diff changeset
1325 Local_Suppress_Stack_Top :=
kono
parents:
diff changeset
1326 new Suppress_Stack_Entry'
kono
parents:
diff changeset
1327 (Entity => Entity,
kono
parents:
diff changeset
1328 Check => Check,
kono
parents:
diff changeset
1329 Suppress => Suppress,
kono
parents:
diff changeset
1330 Prev => Local_Suppress_Stack_Top,
kono
parents:
diff changeset
1331 Next => Suppress_Stack_Entries);
kono
parents:
diff changeset
1332 Suppress_Stack_Entries := Local_Suppress_Stack_Top;
kono
parents:
diff changeset
1333
kono
parents:
diff changeset
1334 return;
kono
parents:
diff changeset
1335 end Push_Local_Suppress_Stack_Entry;
kono
parents:
diff changeset
1336
kono
parents:
diff changeset
1337 ---------------
kono
parents:
diff changeset
1338 -- Semantics --
kono
parents:
diff changeset
1339 ---------------
kono
parents:
diff changeset
1340
kono
parents:
diff changeset
1341 procedure Semantics (Comp_Unit : Node_Id) is
kono
parents:
diff changeset
1342 procedure Do_Analyze;
kono
parents:
diff changeset
1343 -- Perform the analysis of the compilation unit
kono
parents:
diff changeset
1344
kono
parents:
diff changeset
1345 ----------------
kono
parents:
diff changeset
1346 -- Do_Analyze --
kono
parents:
diff changeset
1347 ----------------
kono
parents:
diff changeset
1348
kono
parents:
diff changeset
1349 -- WARNING: This routine manages Ghost regions. Return statements must
kono
parents:
diff changeset
1350 -- be replaced by gotos which jump to the end of the routine and restore
kono
parents:
diff changeset
1351 -- the Ghost mode.
kono
parents:
diff changeset
1352
kono
parents:
diff changeset
1353 procedure Do_Analyze is
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1354 Saved_GM : constant Ghost_Mode_Type := Ghost_Mode;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1355 Saved_IGR : constant Node_Id := Ignored_Ghost_Region;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1356 -- Save the Ghost-related attributes to restore on exit
111
kono
parents:
diff changeset
1357
kono
parents:
diff changeset
1358 -- Generally style checks are preserved across compilations, with
kono
parents:
diff changeset
1359 -- one exception: s-oscons.ads, which allows arbitrary long lines
kono
parents:
diff changeset
1360 -- unconditionally, and has no restore mechanism, because it is
kono
parents:
diff changeset
1361 -- intended as a lowest-level Pure package.
kono
parents:
diff changeset
1362
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1363 Saved_ML : constant Int := Style_Max_Line_Length;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1364 Saved_CML : constant Boolean := Style_Check_Max_Line_Length;
111
kono
parents:
diff changeset
1365
kono
parents:
diff changeset
1366 List : Elist_Id;
kono
parents:
diff changeset
1367
kono
parents:
diff changeset
1368 begin
kono
parents:
diff changeset
1369 List := Save_Scope_Stack;
kono
parents:
diff changeset
1370 Push_Scope (Standard_Standard);
kono
parents:
diff changeset
1371
kono
parents:
diff changeset
1372 -- Set up a clean environment before analyzing
kono
parents:
diff changeset
1373
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1374 Install_Ghost_Region (None, Empty);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1375
111
kono
parents:
diff changeset
1376 Outer_Generic_Scope := Empty;
kono
parents:
diff changeset
1377 Scope_Suppress := Suppress_Options;
kono
parents:
diff changeset
1378 Scope_Stack.Table
kono
parents:
diff changeset
1379 (Scope_Stack.Last).Component_Alignment_Default :=
kono
parents:
diff changeset
1380 Configuration_Component_Alignment;
kono
parents:
diff changeset
1381 Scope_Stack.Table
kono
parents:
diff changeset
1382 (Scope_Stack.Last).Is_Active_Stack_Base := True;
kono
parents:
diff changeset
1383
kono
parents:
diff changeset
1384 -- Now analyze the top level compilation unit node
kono
parents:
diff changeset
1385
kono
parents:
diff changeset
1386 Analyze (Comp_Unit);
kono
parents:
diff changeset
1387
kono
parents:
diff changeset
1388 -- Check for scope mismatch on exit from compilation
kono
parents:
diff changeset
1389
kono
parents:
diff changeset
1390 pragma Assert (Current_Scope = Standard_Standard
kono
parents:
diff changeset
1391 or else Comp_Unit = Cunit (Main_Unit));
kono
parents:
diff changeset
1392
kono
parents:
diff changeset
1393 -- Then pop entry for Standard, and pop implicit types
kono
parents:
diff changeset
1394
kono
parents:
diff changeset
1395 Pop_Scope;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1396 Restore_Scope_Stack (List);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1397 Restore_Ghost_Region (Saved_GM, Saved_IGR);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1398 Style_Max_Line_Length := Saved_ML;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1399 Style_Check_Max_Line_Length := Saved_CML;
111
kono
parents:
diff changeset
1400 end Do_Analyze;
kono
parents:
diff changeset
1401
kono
parents:
diff changeset
1402 -- Local variables
kono
parents:
diff changeset
1403
kono
parents:
diff changeset
1404 -- The following locations save the corresponding global flags and
kono
parents:
diff changeset
1405 -- variables so that they can be restored on completion. This is needed
kono
parents:
diff changeset
1406 -- so that calls to Rtsfind start with the proper default values for
kono
parents:
diff changeset
1407 -- these variables, and also that such calls do not disturb the settings
kono
parents:
diff changeset
1408 -- for units being analyzed at a higher level.
kono
parents:
diff changeset
1409
kono
parents:
diff changeset
1410 S_Current_Sem_Unit : constant Unit_Number_Type := Current_Sem_Unit;
kono
parents:
diff changeset
1411 S_Full_Analysis : constant Boolean := Full_Analysis;
kono
parents:
diff changeset
1412 S_GNAT_Mode : constant Boolean := GNAT_Mode;
kono
parents:
diff changeset
1413 S_Global_Dis_Names : constant Boolean := Global_Discard_Names;
kono
parents:
diff changeset
1414 S_In_Assertion_Expr : constant Nat := In_Assertion_Expr;
kono
parents:
diff changeset
1415 S_In_Default_Expr : constant Boolean := In_Default_Expr;
kono
parents:
diff changeset
1416 S_In_Spec_Expr : constant Boolean := In_Spec_Expression;
kono
parents:
diff changeset
1417 S_Inside_A_Generic : constant Boolean := Inside_A_Generic;
kono
parents:
diff changeset
1418 S_Outer_Gen_Scope : constant Entity_Id := Outer_Generic_Scope;
kono
parents:
diff changeset
1419 S_Style_Check : constant Boolean := Style_Check;
kono
parents:
diff changeset
1420
kono
parents:
diff changeset
1421 Already_Analyzed : constant Boolean := Analyzed (Comp_Unit);
kono
parents:
diff changeset
1422
kono
parents:
diff changeset
1423 Curunit : constant Unit_Number_Type := Get_Cunit_Unit_Number (Comp_Unit);
kono
parents:
diff changeset
1424 -- New value of Current_Sem_Unit
kono
parents:
diff changeset
1425
kono
parents:
diff changeset
1426 Generic_Main : constant Boolean :=
kono
parents:
diff changeset
1427 Nkind (Unit (Cunit (Main_Unit))) in N_Generic_Declaration;
kono
parents:
diff changeset
1428 -- If the main unit is generic, every compiled unit, including its
kono
parents:
diff changeset
1429 -- context, is compiled with expansion disabled.
kono
parents:
diff changeset
1430
kono
parents:
diff changeset
1431 Is_Main_Unit_Or_Main_Unit_Spec : constant Boolean :=
kono
parents:
diff changeset
1432 Curunit = Main_Unit
kono
parents:
diff changeset
1433 or else
kono
parents:
diff changeset
1434 (Nkind (Unit (Cunit (Main_Unit))) = N_Package_Body
kono
parents:
diff changeset
1435 and then Library_Unit (Cunit (Main_Unit)) = Cunit (Curunit));
kono
parents:
diff changeset
1436 -- Configuration flags have special settings when compiling a predefined
kono
parents:
diff changeset
1437 -- file as a main unit. This applies to its spec as well.
kono
parents:
diff changeset
1438
kono
parents:
diff changeset
1439 Ext_Main_Source_Unit : constant Boolean :=
kono
parents:
diff changeset
1440 In_Extended_Main_Source_Unit (Comp_Unit);
kono
parents:
diff changeset
1441 -- Determine if unit is in extended main source unit
kono
parents:
diff changeset
1442
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1443 Save_Config_Attrs : Config_Switches_Type;
111
kono
parents:
diff changeset
1444 -- Variable used to save values of config switches while we analyze the
kono
parents:
diff changeset
1445 -- new unit, to be restored on exit for proper recursive behavior.
kono
parents:
diff changeset
1446
kono
parents:
diff changeset
1447 Save_Cunit_Restrictions : Save_Cunit_Boolean_Restrictions;
kono
parents:
diff changeset
1448 -- Used to save non-partition wide restrictions before processing new
kono
parents:
diff changeset
1449 -- unit. All with'ed units are analyzed with config restrictions reset
kono
parents:
diff changeset
1450 -- and we need to restore these saved values at the end.
kono
parents:
diff changeset
1451
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1452 Save_Preanalysis_Counter : constant Nat :=
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1453 Inside_Preanalysis_Without_Freezing;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1454 -- Saves the preanalysis nesting-level counter; required since we may
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1455 -- need to analyze a unit as a consequence of the preanalysis of an
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1456 -- expression without freezing (and the loaded unit must be fully
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1457 -- analyzed).
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1458
111
kono
parents:
diff changeset
1459 -- Start of processing for Semantics
kono
parents:
diff changeset
1460
kono
parents:
diff changeset
1461 begin
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1462 Inside_Preanalysis_Without_Freezing := 0;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1463
111
kono
parents:
diff changeset
1464 if Debug_Unit_Walk then
kono
parents:
diff changeset
1465 if Already_Analyzed then
kono
parents:
diff changeset
1466 Write_Str ("(done)");
kono
parents:
diff changeset
1467 end if;
kono
parents:
diff changeset
1468
kono
parents:
diff changeset
1469 Write_Unit_Info
kono
parents:
diff changeset
1470 (Get_Cunit_Unit_Number (Comp_Unit),
kono
parents:
diff changeset
1471 Unit (Comp_Unit),
kono
parents:
diff changeset
1472 Prefix => "--> ");
kono
parents:
diff changeset
1473 Indent;
kono
parents:
diff changeset
1474 end if;
kono
parents:
diff changeset
1475
kono
parents:
diff changeset
1476 Compiler_State := Analyzing;
kono
parents:
diff changeset
1477 Current_Sem_Unit := Curunit;
kono
parents:
diff changeset
1478
kono
parents:
diff changeset
1479 -- Compile predefined units with GNAT_Mode set to True, to properly
kono
parents:
diff changeset
1480 -- process the categorization stuff. However, do not set GNAT_Mode
kono
parents:
diff changeset
1481 -- to True for the renamings units (Text_IO, IO_Exceptions, Direct_IO,
kono
parents:
diff changeset
1482 -- Sequential_IO) as this would prevent pragma Extend_System from being
kono
parents:
diff changeset
1483 -- taken into account, for example when Text_IO is renaming DEC.Text_IO.
kono
parents:
diff changeset
1484
kono
parents:
diff changeset
1485 if Is_Predefined_Unit (Current_Sem_Unit)
kono
parents:
diff changeset
1486 and then not Is_Predefined_Renaming (Current_Sem_Unit)
kono
parents:
diff changeset
1487 then
kono
parents:
diff changeset
1488 GNAT_Mode := True;
kono
parents:
diff changeset
1489 end if;
kono
parents:
diff changeset
1490
kono
parents:
diff changeset
1491 -- For generic main, never do expansion
kono
parents:
diff changeset
1492
kono
parents:
diff changeset
1493 if Generic_Main then
kono
parents:
diff changeset
1494 Expander_Mode_Save_And_Set (False);
kono
parents:
diff changeset
1495
kono
parents:
diff changeset
1496 -- Non generic case
kono
parents:
diff changeset
1497
kono
parents:
diff changeset
1498 else
kono
parents:
diff changeset
1499 Expander_Mode_Save_And_Set
kono
parents:
diff changeset
1500
kono
parents:
diff changeset
1501 -- Turn on expansion if generating code
kono
parents:
diff changeset
1502
kono
parents:
diff changeset
1503 (Operating_Mode = Generate_Code
kono
parents:
diff changeset
1504
kono
parents:
diff changeset
1505 -- Or if special debug flag -gnatdx is set
kono
parents:
diff changeset
1506
kono
parents:
diff changeset
1507 or else Debug_Flag_X
kono
parents:
diff changeset
1508
kono
parents:
diff changeset
1509 -- Or if in configuration run-time mode. We do this so we get
kono
parents:
diff changeset
1510 -- error messages about missing entities in the run-time even
kono
parents:
diff changeset
1511 -- if we are compiling in -gnatc (no code generation) mode.
kono
parents:
diff changeset
1512 -- Similar processing applies to No_Run_Time_Mode. However,
kono
parents:
diff changeset
1513 -- don't do this if debug flag -gnatd.Z is set or when we are
kono
parents:
diff changeset
1514 -- compiling a separate unit (this is to handle a situation
kono
parents:
diff changeset
1515 -- where this new processing causes trouble).
kono
parents:
diff changeset
1516
kono
parents:
diff changeset
1517 or else
kono
parents:
diff changeset
1518 ((Configurable_Run_Time_Mode or No_Run_Time_Mode)
kono
parents:
diff changeset
1519 and then not Debug_Flag_Dot_ZZ
kono
parents:
diff changeset
1520 and then Nkind (Unit (Cunit (Main_Unit))) /= N_Subunit));
kono
parents:
diff changeset
1521 end if;
kono
parents:
diff changeset
1522
kono
parents:
diff changeset
1523 Full_Analysis := True;
kono
parents:
diff changeset
1524 Inside_A_Generic := False;
kono
parents:
diff changeset
1525 In_Assertion_Expr := 0;
kono
parents:
diff changeset
1526 In_Default_Expr := False;
kono
parents:
diff changeset
1527 In_Spec_Expression := False;
kono
parents:
diff changeset
1528 Set_Comes_From_Source_Default (False);
kono
parents:
diff changeset
1529
kono
parents:
diff changeset
1530 -- Save current config switches and reset then appropriately
kono
parents:
diff changeset
1531
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1532 Save_Config_Attrs := Save_Config_Switches;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1533 Set_Config_Switches
111
kono
parents:
diff changeset
1534 (Is_Internal_Unit (Current_Sem_Unit),
kono
parents:
diff changeset
1535 Is_Main_Unit_Or_Main_Unit_Spec);
kono
parents:
diff changeset
1536
kono
parents:
diff changeset
1537 -- Save current non-partition-wide restrictions
kono
parents:
diff changeset
1538
kono
parents:
diff changeset
1539 Save_Cunit_Restrictions := Cunit_Boolean_Restrictions_Save;
kono
parents:
diff changeset
1540
kono
parents:
diff changeset
1541 -- For unit in main extended unit, we reset the configuration values
kono
parents:
diff changeset
1542 -- for the non-partition-wide restrictions. For other units reset them.
kono
parents:
diff changeset
1543
kono
parents:
diff changeset
1544 if Ext_Main_Source_Unit then
kono
parents:
diff changeset
1545 Restore_Config_Cunit_Boolean_Restrictions;
kono
parents:
diff changeset
1546 else
kono
parents:
diff changeset
1547 Reset_Cunit_Boolean_Restrictions;
kono
parents:
diff changeset
1548 end if;
kono
parents:
diff changeset
1549
kono
parents:
diff changeset
1550 -- Turn off style checks for unit that is not in the extended main
kono
parents:
diff changeset
1551 -- source unit. This improves processing efficiency for such units
kono
parents:
diff changeset
1552 -- (for which we don't want style checks anyway, and where they will
kono
parents:
diff changeset
1553 -- get suppressed), and is definitely needed to stop some style checks
kono
parents:
diff changeset
1554 -- from invading the run-time units (e.g. overriding checks).
kono
parents:
diff changeset
1555
kono
parents:
diff changeset
1556 if not Ext_Main_Source_Unit then
kono
parents:
diff changeset
1557 Style_Check := False;
kono
parents:
diff changeset
1558
kono
parents:
diff changeset
1559 -- If this is part of the extended main source unit, set style check
kono
parents:
diff changeset
1560 -- mode to match the style check mode of the main source unit itself.
kono
parents:
diff changeset
1561
kono
parents:
diff changeset
1562 else
kono
parents:
diff changeset
1563 Style_Check := Style_Check_Main;
kono
parents:
diff changeset
1564 end if;
kono
parents:
diff changeset
1565
kono
parents:
diff changeset
1566 -- Only do analysis of unit that has not already been analyzed
kono
parents:
diff changeset
1567
kono
parents:
diff changeset
1568 if not Analyzed (Comp_Unit) then
kono
parents:
diff changeset
1569 Initialize_Version (Current_Sem_Unit);
kono
parents:
diff changeset
1570
kono
parents:
diff changeset
1571 -- Do analysis, and then append the compilation unit onto the
kono
parents:
diff changeset
1572 -- Comp_Unit_List, if appropriate. This is done after analysis,
kono
parents:
diff changeset
1573 -- so if this unit depends on some others, they have already been
kono
parents:
diff changeset
1574 -- appended. We ignore bodies, except for the main unit itself, and
kono
parents:
diff changeset
1575 -- for subprogram bodies that act as specs. We have also to guard
kono
parents:
diff changeset
1576 -- against ill-formed subunits that have an improper context.
kono
parents:
diff changeset
1577
kono
parents:
diff changeset
1578 Do_Analyze;
kono
parents:
diff changeset
1579
kono
parents:
diff changeset
1580 if Present (Comp_Unit)
kono
parents:
diff changeset
1581 and then Nkind (Unit (Comp_Unit)) in N_Proper_Body
kono
parents:
diff changeset
1582 and then (Nkind (Unit (Comp_Unit)) /= N_Subprogram_Body
kono
parents:
diff changeset
1583 or else not Acts_As_Spec (Comp_Unit))
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1584 and then not Ext_Main_Source_Unit
111
kono
parents:
diff changeset
1585 then
kono
parents:
diff changeset
1586 null;
kono
parents:
diff changeset
1587
kono
parents:
diff changeset
1588 else
kono
parents:
diff changeset
1589 Append_New_Elmt (Comp_Unit, To => Comp_Unit_List);
kono
parents:
diff changeset
1590
kono
parents:
diff changeset
1591 if Debug_Unit_Walk then
kono
parents:
diff changeset
1592 Write_Str ("Appending ");
kono
parents:
diff changeset
1593 Write_Unit_Info
kono
parents:
diff changeset
1594 (Get_Cunit_Unit_Number (Comp_Unit), Unit (Comp_Unit));
kono
parents:
diff changeset
1595 end if;
kono
parents:
diff changeset
1596 end if;
kono
parents:
diff changeset
1597 end if;
kono
parents:
diff changeset
1598
kono
parents:
diff changeset
1599 -- Save indication of dynamic elaboration checks for ALI file
kono
parents:
diff changeset
1600
kono
parents:
diff changeset
1601 Set_Dynamic_Elab (Current_Sem_Unit, Dynamic_Elaboration_Checks);
kono
parents:
diff changeset
1602
kono
parents:
diff changeset
1603 -- Restore settings of saved switches to entry values
kono
parents:
diff changeset
1604
kono
parents:
diff changeset
1605 Current_Sem_Unit := S_Current_Sem_Unit;
kono
parents:
diff changeset
1606 Full_Analysis := S_Full_Analysis;
kono
parents:
diff changeset
1607 Global_Discard_Names := S_Global_Dis_Names;
kono
parents:
diff changeset
1608 GNAT_Mode := S_GNAT_Mode;
kono
parents:
diff changeset
1609 In_Assertion_Expr := S_In_Assertion_Expr;
kono
parents:
diff changeset
1610 In_Default_Expr := S_In_Default_Expr;
kono
parents:
diff changeset
1611 In_Spec_Expression := S_In_Spec_Expr;
kono
parents:
diff changeset
1612 Inside_A_Generic := S_Inside_A_Generic;
kono
parents:
diff changeset
1613 Outer_Generic_Scope := S_Outer_Gen_Scope;
kono
parents:
diff changeset
1614 Style_Check := S_Style_Check;
kono
parents:
diff changeset
1615
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1616 Restore_Config_Switches (Save_Config_Attrs);
111
kono
parents:
diff changeset
1617
kono
parents:
diff changeset
1618 -- Deal with restore of restrictions
kono
parents:
diff changeset
1619
kono
parents:
diff changeset
1620 Cunit_Boolean_Restrictions_Restore (Save_Cunit_Restrictions);
kono
parents:
diff changeset
1621
kono
parents:
diff changeset
1622 Expander_Mode_Restore;
kono
parents:
diff changeset
1623
kono
parents:
diff changeset
1624 if Debug_Unit_Walk then
kono
parents:
diff changeset
1625 Outdent;
kono
parents:
diff changeset
1626
kono
parents:
diff changeset
1627 if Already_Analyzed then
kono
parents:
diff changeset
1628 Write_Str ("(done)");
kono
parents:
diff changeset
1629 end if;
kono
parents:
diff changeset
1630
kono
parents:
diff changeset
1631 Write_Unit_Info
kono
parents:
diff changeset
1632 (Get_Cunit_Unit_Number (Comp_Unit),
kono
parents:
diff changeset
1633 Unit (Comp_Unit),
kono
parents:
diff changeset
1634 Prefix => "<-- ");
kono
parents:
diff changeset
1635 end if;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1636
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1637 Inside_Preanalysis_Without_Freezing := Save_Preanalysis_Counter;
111
kono
parents:
diff changeset
1638 end Semantics;
kono
parents:
diff changeset
1639
kono
parents:
diff changeset
1640 --------
kono
parents:
diff changeset
1641 -- ss --
kono
parents:
diff changeset
1642 --------
kono
parents:
diff changeset
1643
kono
parents:
diff changeset
1644 function ss (Index : Int) return Scope_Stack_Entry is
kono
parents:
diff changeset
1645 begin
kono
parents:
diff changeset
1646 return Scope_Stack.Table (Index);
kono
parents:
diff changeset
1647 end ss;
kono
parents:
diff changeset
1648
kono
parents:
diff changeset
1649 ---------
kono
parents:
diff changeset
1650 -- sst --
kono
parents:
diff changeset
1651 ---------
kono
parents:
diff changeset
1652
kono
parents:
diff changeset
1653 function sst return Scope_Stack_Entry is
kono
parents:
diff changeset
1654 begin
kono
parents:
diff changeset
1655 return ss (Scope_Stack.Last);
kono
parents:
diff changeset
1656 end sst;
kono
parents:
diff changeset
1657
kono
parents:
diff changeset
1658 ------------
kono
parents:
diff changeset
1659 -- Unlock --
kono
parents:
diff changeset
1660 ------------
kono
parents:
diff changeset
1661
kono
parents:
diff changeset
1662 procedure Unlock is
kono
parents:
diff changeset
1663 begin
kono
parents:
diff changeset
1664 Scope_Stack.Locked := False;
kono
parents:
diff changeset
1665 end Unlock;
kono
parents:
diff changeset
1666
kono
parents:
diff changeset
1667 ------------------------
kono
parents:
diff changeset
1668 -- Walk_Library_Items --
kono
parents:
diff changeset
1669 ------------------------
kono
parents:
diff changeset
1670
kono
parents:
diff changeset
1671 procedure Walk_Library_Items is
kono
parents:
diff changeset
1672 type Unit_Number_Set is array (Main_Unit .. Last_Unit) of Boolean;
kono
parents:
diff changeset
1673 pragma Pack (Unit_Number_Set);
kono
parents:
diff changeset
1674
kono
parents:
diff changeset
1675 Main_CU : constant Node_Id := Cunit (Main_Unit);
kono
parents:
diff changeset
1676
kono
parents:
diff changeset
1677 Seen, Done : Unit_Number_Set := (others => False);
kono
parents:
diff changeset
1678 -- Seen (X) is True after we have seen unit X in the walk. This is used
kono
parents:
diff changeset
1679 -- to prevent processing the same unit more than once. Done (X) is True
kono
parents:
diff changeset
1680 -- after we have fully processed X, and is used only for debugging
kono
parents:
diff changeset
1681 -- printouts and assertions.
kono
parents:
diff changeset
1682
kono
parents:
diff changeset
1683 Do_Main : Boolean := False;
kono
parents:
diff changeset
1684 -- Flag to delay processing the main body until after all other units.
kono
parents:
diff changeset
1685 -- This is needed because the spec of the main unit may appear in the
kono
parents:
diff changeset
1686 -- context of some other unit. We do not want this to force processing
kono
parents:
diff changeset
1687 -- of the main body before all other units have been processed.
kono
parents:
diff changeset
1688 --
kono
parents:
diff changeset
1689 -- Another circularity pattern occurs when the main unit is a child unit
kono
parents:
diff changeset
1690 -- and the body of an ancestor has a with-clause of the main unit or on
kono
parents:
diff changeset
1691 -- one of its children. In both cases the body in question has a with-
kono
parents:
diff changeset
1692 -- clause on the main unit, and must be excluded from the traversal. In
kono
parents:
diff changeset
1693 -- some convoluted cases this may lead to a CodePeer error because the
kono
parents:
diff changeset
1694 -- spec of a subprogram declared in an instance within the parent will
kono
parents:
diff changeset
1695 -- not be seen in the main unit.
kono
parents:
diff changeset
1696
kono
parents:
diff changeset
1697 function Depends_On_Main (CU : Node_Id) return Boolean;
kono
parents:
diff changeset
1698 -- The body of a unit that is withed by the spec of the main unit may in
kono
parents:
diff changeset
1699 -- turn have a with_clause on that spec. In that case do not traverse
kono
parents:
diff changeset
1700 -- the body, to prevent loops. It can also happen that the main body has
kono
parents:
diff changeset
1701 -- a with_clause on a child, which of course has an implicit with on its
kono
parents:
diff changeset
1702 -- parent. It's OK to traverse the child body if the main spec has been
kono
parents:
diff changeset
1703 -- processed, otherwise we also have a circularity to avoid.
kono
parents:
diff changeset
1704
kono
parents:
diff changeset
1705 procedure Do_Action (CU : Node_Id; Item : Node_Id);
kono
parents:
diff changeset
1706 -- Calls Action, with some validity checks
kono
parents:
diff changeset
1707
kono
parents:
diff changeset
1708 procedure Do_Unit_And_Dependents (CU : Node_Id; Item : Node_Id);
kono
parents:
diff changeset
1709 -- Calls Do_Action, first on the units with'ed by this one, then on
kono
parents:
diff changeset
1710 -- this unit. If it's an instance body, do the spec first. If it is
kono
parents:
diff changeset
1711 -- an instance spec, do the body last.
kono
parents:
diff changeset
1712
kono
parents:
diff changeset
1713 procedure Do_Withed_Unit (Withed_Unit : Node_Id);
kono
parents:
diff changeset
1714 -- Apply Do_Unit_And_Dependents to a unit in a context clause
kono
parents:
diff changeset
1715
kono
parents:
diff changeset
1716 procedure Process_Bodies_In_Context (Comp : Node_Id);
kono
parents:
diff changeset
1717 -- The main unit and its spec may depend on bodies that contain generics
kono
parents:
diff changeset
1718 -- that are instantiated in them. Iterate through the corresponding
kono
parents:
diff changeset
1719 -- contexts before processing main (spec/body) itself, to process bodies
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1720 -- that may be present, together with their context. The spec of main
111
kono
parents:
diff changeset
1721 -- is processed wherever it appears in the list of units, while the body
kono
parents:
diff changeset
1722 -- is processed as the last unit in the list.
kono
parents:
diff changeset
1723
kono
parents:
diff changeset
1724 ---------------------
kono
parents:
diff changeset
1725 -- Depends_On_Main --
kono
parents:
diff changeset
1726 ---------------------
kono
parents:
diff changeset
1727
kono
parents:
diff changeset
1728 function Depends_On_Main (CU : Node_Id) return Boolean is
kono
parents:
diff changeset
1729 CL : Node_Id;
kono
parents:
diff changeset
1730 MCU : constant Node_Id := Unit (Main_CU);
kono
parents:
diff changeset
1731
kono
parents:
diff changeset
1732 begin
kono
parents:
diff changeset
1733 -- Problem does not arise with main subprograms
kono
parents:
diff changeset
1734
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1735 if not Nkind_In (MCU, N_Package_Body, N_Package_Declaration) then
111
kono
parents:
diff changeset
1736 return False;
kono
parents:
diff changeset
1737 end if;
kono
parents:
diff changeset
1738
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1739 CL := First (Context_Items (CU));
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1740
111
kono
parents:
diff changeset
1741 while Present (CL) loop
kono
parents:
diff changeset
1742 if Nkind (CL) = N_With_Clause
kono
parents:
diff changeset
1743 and then Library_Unit (CL) = Main_CU
kono
parents:
diff changeset
1744 and then not Done (Get_Cunit_Unit_Number (Library_Unit (CL)))
kono
parents:
diff changeset
1745 then
kono
parents:
diff changeset
1746 return True;
kono
parents:
diff changeset
1747 end if;
kono
parents:
diff changeset
1748
kono
parents:
diff changeset
1749 Next (CL);
kono
parents:
diff changeset
1750 end loop;
kono
parents:
diff changeset
1751
kono
parents:
diff changeset
1752 return False;
kono
parents:
diff changeset
1753 end Depends_On_Main;
kono
parents:
diff changeset
1754
kono
parents:
diff changeset
1755 ---------------
kono
parents:
diff changeset
1756 -- Do_Action --
kono
parents:
diff changeset
1757 ---------------
kono
parents:
diff changeset
1758
kono
parents:
diff changeset
1759 procedure Do_Action (CU : Node_Id; Item : Node_Id) is
kono
parents:
diff changeset
1760 begin
kono
parents:
diff changeset
1761 -- This calls Action at the end. All the preceding code is just
kono
parents:
diff changeset
1762 -- assertions and debugging output.
kono
parents:
diff changeset
1763
kono
parents:
diff changeset
1764 pragma Assert (No (CU) or else Nkind (CU) = N_Compilation_Unit);
kono
parents:
diff changeset
1765
kono
parents:
diff changeset
1766 case Nkind (Item) is
kono
parents:
diff changeset
1767 when N_Generic_Function_Renaming_Declaration
kono
parents:
diff changeset
1768 | N_Generic_Package_Declaration
kono
parents:
diff changeset
1769 | N_Generic_Package_Renaming_Declaration
kono
parents:
diff changeset
1770 | N_Generic_Procedure_Renaming_Declaration
kono
parents:
diff changeset
1771 | N_Generic_Subprogram_Declaration
kono
parents:
diff changeset
1772 | N_Package_Declaration
kono
parents:
diff changeset
1773 | N_Package_Renaming_Declaration
kono
parents:
diff changeset
1774 | N_Subprogram_Declaration
kono
parents:
diff changeset
1775 | N_Subprogram_Renaming_Declaration
kono
parents:
diff changeset
1776 =>
kono
parents:
diff changeset
1777 -- Specs are OK
kono
parents:
diff changeset
1778
kono
parents:
diff changeset
1779 null;
kono
parents:
diff changeset
1780
kono
parents:
diff changeset
1781 when N_Package_Body =>
kono
parents:
diff changeset
1782
kono
parents:
diff changeset
1783 -- Package bodies are processed separately if the main unit
kono
parents:
diff changeset
1784 -- depends on them.
kono
parents:
diff changeset
1785
kono
parents:
diff changeset
1786 null;
kono
parents:
diff changeset
1787
kono
parents:
diff changeset
1788 when N_Subprogram_Body =>
kono
parents:
diff changeset
1789
kono
parents:
diff changeset
1790 -- A subprogram body must be the main unit
kono
parents:
diff changeset
1791
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1792 pragma Assert (Acts_As_Spec (CU) or else CU = Main_CU);
111
kono
parents:
diff changeset
1793 null;
kono
parents:
diff changeset
1794
kono
parents:
diff changeset
1795 when N_Function_Instantiation
kono
parents:
diff changeset
1796 | N_Package_Instantiation
kono
parents:
diff changeset
1797 | N_Procedure_Instantiation
kono
parents:
diff changeset
1798 =>
kono
parents:
diff changeset
1799 -- Can only happen if some generic body (needed for gnat2scil
kono
parents:
diff changeset
1800 -- traversal, but not by GNAT) is not available, ignore.
kono
parents:
diff changeset
1801
kono
parents:
diff changeset
1802 null;
kono
parents:
diff changeset
1803
kono
parents:
diff changeset
1804 -- All other cases cannot happen
kono
parents:
diff changeset
1805
kono
parents:
diff changeset
1806 when N_Subunit =>
kono
parents:
diff changeset
1807 pragma Assert (False, "subunit");
kono
parents:
diff changeset
1808 null;
kono
parents:
diff changeset
1809
kono
parents:
diff changeset
1810 when N_Null_Statement =>
kono
parents:
diff changeset
1811
kono
parents:
diff changeset
1812 -- Do not call Action for an ignored ghost unit
kono
parents:
diff changeset
1813
kono
parents:
diff changeset
1814 pragma Assert (Is_Ignored_Ghost_Node (Original_Node (Item)));
kono
parents:
diff changeset
1815 return;
kono
parents:
diff changeset
1816
kono
parents:
diff changeset
1817 when others =>
kono
parents:
diff changeset
1818 pragma Assert (False);
kono
parents:
diff changeset
1819 null;
kono
parents:
diff changeset
1820 end case;
kono
parents:
diff changeset
1821
kono
parents:
diff changeset
1822 if Present (CU) then
kono
parents:
diff changeset
1823 pragma Assert (Item /= Stand.Standard_Package_Node);
kono
parents:
diff changeset
1824 pragma Assert (Item = Unit (CU));
kono
parents:
diff changeset
1825
kono
parents:
diff changeset
1826 declare
kono
parents:
diff changeset
1827 Unit_Num : constant Unit_Number_Type :=
kono
parents:
diff changeset
1828 Get_Cunit_Unit_Number (CU);
kono
parents:
diff changeset
1829
kono
parents:
diff changeset
1830 procedure Assert_Done (Withed_Unit : Node_Id);
kono
parents:
diff changeset
1831 -- Assert Withed_Unit is already Done, unless it's a body. It
kono
parents:
diff changeset
1832 -- might seem strange for a with_clause to refer to a body, but
kono
parents:
diff changeset
1833 -- this happens in the case of a generic instantiation, which
kono
parents:
diff changeset
1834 -- gets transformed into the instance body (and the instance
kono
parents:
diff changeset
1835 -- spec is also created). With clauses pointing to the
kono
parents:
diff changeset
1836 -- instantiation end up pointing to the instance body.
kono
parents:
diff changeset
1837
kono
parents:
diff changeset
1838 -----------------
kono
parents:
diff changeset
1839 -- Assert_Done --
kono
parents:
diff changeset
1840 -----------------
kono
parents:
diff changeset
1841
kono
parents:
diff changeset
1842 procedure Assert_Done (Withed_Unit : Node_Id) is
kono
parents:
diff changeset
1843 begin
kono
parents:
diff changeset
1844 if not Done (Get_Cunit_Unit_Number (Withed_Unit)) then
kono
parents:
diff changeset
1845 if not Nkind_In
kono
parents:
diff changeset
1846 (Unit (Withed_Unit),
kono
parents:
diff changeset
1847 N_Generic_Package_Declaration,
kono
parents:
diff changeset
1848 N_Package_Body,
kono
parents:
diff changeset
1849 N_Package_Renaming_Declaration,
kono
parents:
diff changeset
1850 N_Subprogram_Body)
kono
parents:
diff changeset
1851 then
kono
parents:
diff changeset
1852 Write_Unit_Name
kono
parents:
diff changeset
1853 (Unit_Name (Get_Cunit_Unit_Number (Withed_Unit)));
kono
parents:
diff changeset
1854 Write_Str (" not yet walked!");
kono
parents:
diff changeset
1855
kono
parents:
diff changeset
1856 if Get_Cunit_Unit_Number (Withed_Unit) = Unit_Num then
kono
parents:
diff changeset
1857 Write_Str (" (self-ref)");
kono
parents:
diff changeset
1858 end if;
kono
parents:
diff changeset
1859
kono
parents:
diff changeset
1860 Write_Eol;
kono
parents:
diff changeset
1861
kono
parents:
diff changeset
1862 pragma Assert (False);
kono
parents:
diff changeset
1863 end if;
kono
parents:
diff changeset
1864 end if;
kono
parents:
diff changeset
1865 end Assert_Done;
kono
parents:
diff changeset
1866
kono
parents:
diff changeset
1867 procedure Assert_Withed_Units_Done is
kono
parents:
diff changeset
1868 new Walk_Withs (Assert_Done);
kono
parents:
diff changeset
1869
kono
parents:
diff changeset
1870 begin
kono
parents:
diff changeset
1871 if Debug_Unit_Walk then
kono
parents:
diff changeset
1872 Write_Unit_Info (Unit_Num, Item, Withs => True);
kono
parents:
diff changeset
1873 end if;
kono
parents:
diff changeset
1874
kono
parents:
diff changeset
1875 -- Main unit should come last, except in the case where we
kono
parents:
diff changeset
1876 -- skipped System_Aux_Id, in which case we missed the things it
kono
parents:
diff changeset
1877 -- depends on, and in the case of parent bodies if present.
kono
parents:
diff changeset
1878
kono
parents:
diff changeset
1879 pragma Assert
kono
parents:
diff changeset
1880 (not Done (Main_Unit)
kono
parents:
diff changeset
1881 or else Present (System_Aux_Id)
kono
parents:
diff changeset
1882 or else Nkind (Item) = N_Package_Body);
kono
parents:
diff changeset
1883
kono
parents:
diff changeset
1884 -- We shouldn't do the same thing twice
kono
parents:
diff changeset
1885
kono
parents:
diff changeset
1886 pragma Assert (not Done (Unit_Num));
kono
parents:
diff changeset
1887
kono
parents:
diff changeset
1888 -- Everything we depend upon should already be done
kono
parents:
diff changeset
1889
kono
parents:
diff changeset
1890 pragma Debug
kono
parents:
diff changeset
1891 (Assert_Withed_Units_Done (CU, Include_Limited => False));
kono
parents:
diff changeset
1892 end;
kono
parents:
diff changeset
1893
kono
parents:
diff changeset
1894 else
kono
parents:
diff changeset
1895 -- Must be Standard, which has no entry in the units table
kono
parents:
diff changeset
1896
kono
parents:
diff changeset
1897 pragma Assert (Item = Stand.Standard_Package_Node);
kono
parents:
diff changeset
1898
kono
parents:
diff changeset
1899 if Debug_Unit_Walk then
kono
parents:
diff changeset
1900 Write_Line ("Standard");
kono
parents:
diff changeset
1901 end if;
kono
parents:
diff changeset
1902 end if;
kono
parents:
diff changeset
1903
kono
parents:
diff changeset
1904 Action (Item);
kono
parents:
diff changeset
1905 end Do_Action;
kono
parents:
diff changeset
1906
kono
parents:
diff changeset
1907 --------------------
kono
parents:
diff changeset
1908 -- Do_Withed_Unit --
kono
parents:
diff changeset
1909 --------------------
kono
parents:
diff changeset
1910
kono
parents:
diff changeset
1911 procedure Do_Withed_Unit (Withed_Unit : Node_Id) is
kono
parents:
diff changeset
1912 begin
kono
parents:
diff changeset
1913 Do_Unit_And_Dependents (Withed_Unit, Unit (Withed_Unit));
kono
parents:
diff changeset
1914
kono
parents:
diff changeset
1915 -- If the unit in the with_clause is a generic instance, the clause
kono
parents:
diff changeset
1916 -- now denotes the instance body. Traverse the corresponding spec
kono
parents:
diff changeset
1917 -- because there may be no other dependence that will force the
kono
parents:
diff changeset
1918 -- traversal of its own context.
kono
parents:
diff changeset
1919
kono
parents:
diff changeset
1920 if Nkind (Unit (Withed_Unit)) = N_Package_Body
kono
parents:
diff changeset
1921 and then Is_Generic_Instance
kono
parents:
diff changeset
1922 (Defining_Entity (Unit (Library_Unit (Withed_Unit))))
kono
parents:
diff changeset
1923 then
kono
parents:
diff changeset
1924 Do_Withed_Unit (Library_Unit (Withed_Unit));
kono
parents:
diff changeset
1925 end if;
kono
parents:
diff changeset
1926 end Do_Withed_Unit;
kono
parents:
diff changeset
1927
kono
parents:
diff changeset
1928 ----------------------------
kono
parents:
diff changeset
1929 -- Do_Unit_And_Dependents --
kono
parents:
diff changeset
1930 ----------------------------
kono
parents:
diff changeset
1931
kono
parents:
diff changeset
1932 procedure Do_Unit_And_Dependents (CU : Node_Id; Item : Node_Id) is
kono
parents:
diff changeset
1933 Unit_Num : constant Unit_Number_Type := Get_Cunit_Unit_Number (CU);
kono
parents:
diff changeset
1934 Child : Node_Id;
kono
parents:
diff changeset
1935 Body_U : Unit_Number_Type;
kono
parents:
diff changeset
1936 Parent_CU : Node_Id;
kono
parents:
diff changeset
1937
kono
parents:
diff changeset
1938 procedure Do_Withed_Units is new Walk_Withs (Do_Withed_Unit);
kono
parents:
diff changeset
1939
kono
parents:
diff changeset
1940 begin
kono
parents:
diff changeset
1941 if not Seen (Unit_Num) then
kono
parents:
diff changeset
1942
kono
parents:
diff changeset
1943 -- Process the with clauses
kono
parents:
diff changeset
1944
kono
parents:
diff changeset
1945 Do_Withed_Units (CU, Include_Limited => False);
kono
parents:
diff changeset
1946
kono
parents:
diff changeset
1947 -- Process the unit if it is a spec or the main unit, if it
kono
parents:
diff changeset
1948 -- has no previous spec or we have done all other units.
kono
parents:
diff changeset
1949
kono
parents:
diff changeset
1950 if not Nkind_In (Item, N_Package_Body, N_Subprogram_Body)
kono
parents:
diff changeset
1951 or else Acts_As_Spec (CU)
kono
parents:
diff changeset
1952 then
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1953 if CU = Main_CU and then not Do_Main then
111
kono
parents:
diff changeset
1954 Seen (Unit_Num) := False;
kono
parents:
diff changeset
1955
kono
parents:
diff changeset
1956 else
kono
parents:
diff changeset
1957 Seen (Unit_Num) := True;
kono
parents:
diff changeset
1958
kono
parents:
diff changeset
1959 if CU = Library_Unit (Main_CU) then
kono
parents:
diff changeset
1960 Process_Bodies_In_Context (CU);
kono
parents:
diff changeset
1961
kono
parents:
diff changeset
1962 -- If main is a child unit, examine parent unit contexts
kono
parents:
diff changeset
1963 -- to see if they include instantiated units. Also, if
kono
parents:
diff changeset
1964 -- the parent itself is an instance, process its body
kono
parents:
diff changeset
1965 -- because it may contain subprograms that are called
kono
parents:
diff changeset
1966 -- in the main unit.
kono
parents:
diff changeset
1967
kono
parents:
diff changeset
1968 if Is_Child_Unit (Cunit_Entity (Main_Unit)) then
kono
parents:
diff changeset
1969 Child := Cunit_Entity (Main_Unit);
kono
parents:
diff changeset
1970 while Is_Child_Unit (Child) loop
kono
parents:
diff changeset
1971 Parent_CU :=
kono
parents:
diff changeset
1972 Cunit
kono
parents:
diff changeset
1973 (Get_Cunit_Entity_Unit_Number (Scope (Child)));
kono
parents:
diff changeset
1974 Process_Bodies_In_Context (Parent_CU);
kono
parents:
diff changeset
1975
kono
parents:
diff changeset
1976 if Nkind (Unit (Parent_CU)) = N_Package_Body
kono
parents:
diff changeset
1977 and then
kono
parents:
diff changeset
1978 Nkind (Original_Node (Unit (Parent_CU)))
kono
parents:
diff changeset
1979 = N_Package_Instantiation
kono
parents:
diff changeset
1980 and then
kono
parents:
diff changeset
1981 not Seen (Get_Cunit_Unit_Number (Parent_CU))
kono
parents:
diff changeset
1982 then
kono
parents:
diff changeset
1983 Body_U := Get_Cunit_Unit_Number (Parent_CU);
kono
parents:
diff changeset
1984 Seen (Body_U) := True;
kono
parents:
diff changeset
1985 Do_Action (Parent_CU, Unit (Parent_CU));
kono
parents:
diff changeset
1986 Done (Body_U) := True;
kono
parents:
diff changeset
1987 end if;
kono
parents:
diff changeset
1988
kono
parents:
diff changeset
1989 Child := Scope (Child);
kono
parents:
diff changeset
1990 end loop;
kono
parents:
diff changeset
1991 end if;
kono
parents:
diff changeset
1992 end if;
kono
parents:
diff changeset
1993
kono
parents:
diff changeset
1994 Do_Action (CU, Item);
kono
parents:
diff changeset
1995 Done (Unit_Num) := True;
kono
parents:
diff changeset
1996 end if;
kono
parents:
diff changeset
1997 end if;
kono
parents:
diff changeset
1998 end if;
kono
parents:
diff changeset
1999 end Do_Unit_And_Dependents;
kono
parents:
diff changeset
2000
kono
parents:
diff changeset
2001 -------------------------------
kono
parents:
diff changeset
2002 -- Process_Bodies_In_Context --
kono
parents:
diff changeset
2003 -------------------------------
kono
parents:
diff changeset
2004
kono
parents:
diff changeset
2005 procedure Process_Bodies_In_Context (Comp : Node_Id) is
kono
parents:
diff changeset
2006 Body_CU : Node_Id;
kono
parents:
diff changeset
2007 Body_U : Unit_Number_Type;
kono
parents:
diff changeset
2008 Clause : Node_Id;
kono
parents:
diff changeset
2009 Spec : Node_Id;
kono
parents:
diff changeset
2010
kono
parents:
diff changeset
2011 procedure Do_Withed_Units is new Walk_Withs (Do_Withed_Unit);
kono
parents:
diff changeset
2012
kono
parents:
diff changeset
2013 -- Start of processing for Process_Bodies_In_Context
kono
parents:
diff changeset
2014
kono
parents:
diff changeset
2015 begin
kono
parents:
diff changeset
2016 Clause := First (Context_Items (Comp));
kono
parents:
diff changeset
2017 while Present (Clause) loop
kono
parents:
diff changeset
2018 if Nkind (Clause) = N_With_Clause then
kono
parents:
diff changeset
2019 Spec := Library_Unit (Clause);
kono
parents:
diff changeset
2020 Body_CU := Library_Unit (Spec);
kono
parents:
diff changeset
2021
kono
parents:
diff changeset
2022 -- If we are processing the spec of the main unit, load bodies
kono
parents:
diff changeset
2023 -- only if the with_clause indicates that it forced the loading
kono
parents:
diff changeset
2024 -- of the body for a generic instantiation. Note that bodies of
kono
parents:
diff changeset
2025 -- parents that are instances have been loaded already.
kono
parents:
diff changeset
2026
kono
parents:
diff changeset
2027 if Present (Body_CU)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2028 and then Body_CU /= Main_CU
111
kono
parents:
diff changeset
2029 and then Nkind (Unit (Body_CU)) /= N_Subprogram_Body
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2030 and then Nkind (Unit (Comp)) /= N_Package_Declaration
111
kono
parents:
diff changeset
2031 then
kono
parents:
diff changeset
2032 Body_U := Get_Cunit_Unit_Number (Body_CU);
kono
parents:
diff changeset
2033
kono
parents:
diff changeset
2034 if not Seen (Body_U)
kono
parents:
diff changeset
2035 and then not Depends_On_Main (Body_CU)
kono
parents:
diff changeset
2036 then
kono
parents:
diff changeset
2037 Seen (Body_U) := True;
kono
parents:
diff changeset
2038 Do_Withed_Units (Body_CU, Include_Limited => False);
kono
parents:
diff changeset
2039 Do_Action (Body_CU, Unit (Body_CU));
kono
parents:
diff changeset
2040 Done (Body_U) := True;
kono
parents:
diff changeset
2041 end if;
kono
parents:
diff changeset
2042 end if;
kono
parents:
diff changeset
2043 end if;
kono
parents:
diff changeset
2044
kono
parents:
diff changeset
2045 Next (Clause);
kono
parents:
diff changeset
2046 end loop;
kono
parents:
diff changeset
2047 end Process_Bodies_In_Context;
kono
parents:
diff changeset
2048
kono
parents:
diff changeset
2049 -- Local Declarations
kono
parents:
diff changeset
2050
kono
parents:
diff changeset
2051 Cur : Elmt_Id;
kono
parents:
diff changeset
2052
kono
parents:
diff changeset
2053 -- Start of processing for Walk_Library_Items
kono
parents:
diff changeset
2054
kono
parents:
diff changeset
2055 begin
kono
parents:
diff changeset
2056 if Debug_Unit_Walk then
kono
parents:
diff changeset
2057 Write_Line ("Walk_Library_Items:");
kono
parents:
diff changeset
2058 Indent;
kono
parents:
diff changeset
2059 end if;
kono
parents:
diff changeset
2060
kono
parents:
diff changeset
2061 -- Do Standard first, then walk the Comp_Unit_List
kono
parents:
diff changeset
2062
kono
parents:
diff changeset
2063 Do_Action (Empty, Standard_Package_Node);
kono
parents:
diff changeset
2064
kono
parents:
diff changeset
2065 -- First place the context of all instance bodies on the corresponding
kono
parents:
diff changeset
2066 -- spec, because it may be needed to analyze the code at the place of
kono
parents:
diff changeset
2067 -- the instantiation.
kono
parents:
diff changeset
2068
kono
parents:
diff changeset
2069 Cur := First_Elmt (Comp_Unit_List);
kono
parents:
diff changeset
2070 while Present (Cur) loop
kono
parents:
diff changeset
2071 declare
kono
parents:
diff changeset
2072 CU : constant Node_Id := Node (Cur);
kono
parents:
diff changeset
2073 N : constant Node_Id := Unit (CU);
kono
parents:
diff changeset
2074
kono
parents:
diff changeset
2075 begin
kono
parents:
diff changeset
2076 if Nkind (N) = N_Package_Body
kono
parents:
diff changeset
2077 and then Is_Generic_Instance (Defining_Entity (N))
kono
parents:
diff changeset
2078 then
kono
parents:
diff changeset
2079 Append_List
kono
parents:
diff changeset
2080 (Context_Items (CU), Context_Items (Library_Unit (CU)));
kono
parents:
diff changeset
2081 end if;
kono
parents:
diff changeset
2082
kono
parents:
diff changeset
2083 Next_Elmt (Cur);
kono
parents:
diff changeset
2084 end;
kono
parents:
diff changeset
2085 end loop;
kono
parents:
diff changeset
2086
kono
parents:
diff changeset
2087 -- Now traverse compilation units (specs) in order
kono
parents:
diff changeset
2088
kono
parents:
diff changeset
2089 Cur := First_Elmt (Comp_Unit_List);
kono
parents:
diff changeset
2090 while Present (Cur) loop
kono
parents:
diff changeset
2091 declare
kono
parents:
diff changeset
2092 CU : constant Node_Id := Node (Cur);
kono
parents:
diff changeset
2093 N : constant Node_Id := Unit (CU);
kono
parents:
diff changeset
2094 Par : Entity_Id;
kono
parents:
diff changeset
2095
kono
parents:
diff changeset
2096 begin
kono
parents:
diff changeset
2097 pragma Assert (Nkind (CU) = N_Compilation_Unit);
kono
parents:
diff changeset
2098
kono
parents:
diff changeset
2099 case Nkind (N) is
kono
parents:
diff changeset
2100
kono
parents:
diff changeset
2101 -- If it is a subprogram body, process it if it has no
kono
parents:
diff changeset
2102 -- separate spec.
kono
parents:
diff changeset
2103
kono
parents:
diff changeset
2104 -- If it's a package body, ignore it, unless it is a body
kono
parents:
diff changeset
2105 -- created for an instance that is the main unit. In the case
kono
parents:
diff changeset
2106 -- of subprograms, the body is the wrapper package. In case of
kono
parents:
diff changeset
2107 -- a package, the original file carries the body, and the spec
kono
parents:
diff changeset
2108 -- appears as a later entry in the units list.
kono
parents:
diff changeset
2109
kono
parents:
diff changeset
2110 -- Otherwise bodies appear in the list only because of inlining
kono
parents:
diff changeset
2111 -- or instantiations, and they are processed only if relevant.
kono
parents:
diff changeset
2112 -- The flag Withed_Body on a context clause indicates that a
kono
parents:
diff changeset
2113 -- unit contains an instantiation that may be needed later,
kono
parents:
diff changeset
2114 -- and therefore the body that contains the generic body (and
kono
parents:
diff changeset
2115 -- its context) must be traversed immediately after the
kono
parents:
diff changeset
2116 -- corresponding spec (see Do_Unit_And_Dependents).
kono
parents:
diff changeset
2117
kono
parents:
diff changeset
2118 -- The main unit itself is processed separately after all other
kono
parents:
diff changeset
2119 -- specs, and relevant bodies are examined in Process_Main.
kono
parents:
diff changeset
2120
kono
parents:
diff changeset
2121 when N_Subprogram_Body =>
kono
parents:
diff changeset
2122 if Acts_As_Spec (N) then
kono
parents:
diff changeset
2123 Do_Unit_And_Dependents (CU, N);
kono
parents:
diff changeset
2124 end if;
kono
parents:
diff changeset
2125
kono
parents:
diff changeset
2126 when N_Package_Body =>
kono
parents:
diff changeset
2127 if CU = Main_CU
kono
parents:
diff changeset
2128 and then Nkind (Original_Node (Unit (Main_CU))) in
kono
parents:
diff changeset
2129 N_Generic_Instantiation
kono
parents:
diff changeset
2130 and then Present (Library_Unit (Main_CU))
kono
parents:
diff changeset
2131 then
kono
parents:
diff changeset
2132 Do_Unit_And_Dependents
kono
parents:
diff changeset
2133 (Library_Unit (Main_CU),
kono
parents:
diff changeset
2134 Unit (Library_Unit (Main_CU)));
kono
parents:
diff changeset
2135 end if;
kono
parents:
diff changeset
2136
kono
parents:
diff changeset
2137 -- It is a spec, process it, and the units it depends on,
kono
parents:
diff changeset
2138 -- unless it is a descendant of the main unit. This can happen
kono
parents:
diff changeset
2139 -- when the body of a parent depends on some other descendant.
kono
parents:
diff changeset
2140
kono
parents:
diff changeset
2141 when N_Null_Statement =>
kono
parents:
diff changeset
2142
kono
parents:
diff changeset
2143 -- Ignore an ignored ghost unit
kono
parents:
diff changeset
2144
kono
parents:
diff changeset
2145 pragma Assert (Is_Ignored_Ghost_Node (Original_Node (N)));
kono
parents:
diff changeset
2146 null;
kono
parents:
diff changeset
2147
kono
parents:
diff changeset
2148 when others =>
kono
parents:
diff changeset
2149 Par := Scope (Defining_Entity (Unit (CU)));
kono
parents:
diff changeset
2150
kono
parents:
diff changeset
2151 if Is_Child_Unit (Defining_Entity (Unit (CU))) then
kono
parents:
diff changeset
2152 while Present (Par)
kono
parents:
diff changeset
2153 and then Par /= Standard_Standard
kono
parents:
diff changeset
2154 and then Par /= Cunit_Entity (Main_Unit)
kono
parents:
diff changeset
2155 loop
kono
parents:
diff changeset
2156 Par := Scope (Par);
kono
parents:
diff changeset
2157 end loop;
kono
parents:
diff changeset
2158 end if;
kono
parents:
diff changeset
2159
kono
parents:
diff changeset
2160 if Par /= Cunit_Entity (Main_Unit) then
kono
parents:
diff changeset
2161 Do_Unit_And_Dependents (CU, N);
kono
parents:
diff changeset
2162 end if;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2163
111
kono
parents:
diff changeset
2164 end case;
kono
parents:
diff changeset
2165 end;
kono
parents:
diff changeset
2166
kono
parents:
diff changeset
2167 Next_Elmt (Cur);
kono
parents:
diff changeset
2168 end loop;
kono
parents:
diff changeset
2169
kono
parents:
diff changeset
2170 -- Now process package bodies on which main depends, followed by bodies
kono
parents:
diff changeset
2171 -- of parents, if present, and finally main itself.
kono
parents:
diff changeset
2172
kono
parents:
diff changeset
2173 if not Done (Main_Unit) then
kono
parents:
diff changeset
2174 Do_Main := True;
kono
parents:
diff changeset
2175
kono
parents:
diff changeset
2176 Process_Main : declare
kono
parents:
diff changeset
2177 Parent_CU : Node_Id;
kono
parents:
diff changeset
2178 Body_CU : Node_Id;
kono
parents:
diff changeset
2179 Body_U : Unit_Number_Type;
kono
parents:
diff changeset
2180 Child : Entity_Id;
kono
parents:
diff changeset
2181
kono
parents:
diff changeset
2182 function Is_Subunit_Of_Main (U : Node_Id) return Boolean;
kono
parents:
diff changeset
2183 -- If the main unit has subunits, their context may include
kono
parents:
diff changeset
2184 -- bodies that are needed in the body of main. We must examine
kono
parents:
diff changeset
2185 -- the context of the subunits, which are otherwise not made
kono
parents:
diff changeset
2186 -- explicit in the main unit.
kono
parents:
diff changeset
2187
kono
parents:
diff changeset
2188 ------------------------
kono
parents:
diff changeset
2189 -- Is_Subunit_Of_Main --
kono
parents:
diff changeset
2190 ------------------------
kono
parents:
diff changeset
2191
kono
parents:
diff changeset
2192 function Is_Subunit_Of_Main (U : Node_Id) return Boolean is
kono
parents:
diff changeset
2193 Lib : Node_Id;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2194
111
kono
parents:
diff changeset
2195 begin
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2196 if Present (U) and then Nkind (Unit (U)) = N_Subunit then
111
kono
parents:
diff changeset
2197 Lib := Library_Unit (U);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2198 return Lib = Main_CU or else Is_Subunit_Of_Main (Lib);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2199 else
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2200 return False;
111
kono
parents:
diff changeset
2201 end if;
kono
parents:
diff changeset
2202 end Is_Subunit_Of_Main;
kono
parents:
diff changeset
2203
kono
parents:
diff changeset
2204 -- Start of processing for Process_Main
kono
parents:
diff changeset
2205
kono
parents:
diff changeset
2206 begin
kono
parents:
diff changeset
2207 Process_Bodies_In_Context (Main_CU);
kono
parents:
diff changeset
2208
kono
parents:
diff changeset
2209 for Unit_Num in Done'Range loop
kono
parents:
diff changeset
2210 if Is_Subunit_Of_Main (Cunit (Unit_Num)) then
kono
parents:
diff changeset
2211 Process_Bodies_In_Context (Cunit (Unit_Num));
kono
parents:
diff changeset
2212 end if;
kono
parents:
diff changeset
2213 end loop;
kono
parents:
diff changeset
2214
kono
parents:
diff changeset
2215 -- If the main unit is a child unit, parent bodies may be present
kono
parents:
diff changeset
2216 -- because they export instances or inlined subprograms. Check for
kono
parents:
diff changeset
2217 -- presence of these, which are not present in context clauses.
kono
parents:
diff changeset
2218 -- Note that if the parents are instances, their bodies have been
kono
parents:
diff changeset
2219 -- processed before the main spec, because they may be needed
kono
parents:
diff changeset
2220 -- therein, so the following loop only affects non-instances.
kono
parents:
diff changeset
2221
kono
parents:
diff changeset
2222 if Is_Child_Unit (Cunit_Entity (Main_Unit)) then
kono
parents:
diff changeset
2223 Child := Cunit_Entity (Main_Unit);
kono
parents:
diff changeset
2224 while Is_Child_Unit (Child) loop
kono
parents:
diff changeset
2225 Parent_CU :=
kono
parents:
diff changeset
2226 Cunit (Get_Cunit_Entity_Unit_Number (Scope (Child)));
kono
parents:
diff changeset
2227 Body_CU := Library_Unit (Parent_CU);
kono
parents:
diff changeset
2228
kono
parents:
diff changeset
2229 if Present (Body_CU)
kono
parents:
diff changeset
2230 and then not Seen (Get_Cunit_Unit_Number (Body_CU))
kono
parents:
diff changeset
2231 and then not Depends_On_Main (Body_CU)
kono
parents:
diff changeset
2232 then
kono
parents:
diff changeset
2233 Body_U := Get_Cunit_Unit_Number (Body_CU);
kono
parents:
diff changeset
2234 Seen (Body_U) := True;
kono
parents:
diff changeset
2235 Do_Action (Body_CU, Unit (Body_CU));
kono
parents:
diff changeset
2236 Done (Body_U) := True;
kono
parents:
diff changeset
2237 end if;
kono
parents:
diff changeset
2238
kono
parents:
diff changeset
2239 Child := Scope (Child);
kono
parents:
diff changeset
2240 end loop;
kono
parents:
diff changeset
2241 end if;
kono
parents:
diff changeset
2242
kono
parents:
diff changeset
2243 Do_Action (Main_CU, Unit (Main_CU));
kono
parents:
diff changeset
2244 Done (Main_Unit) := True;
kono
parents:
diff changeset
2245 end Process_Main;
kono
parents:
diff changeset
2246 end if;
kono
parents:
diff changeset
2247
kono
parents:
diff changeset
2248 if Debug_Unit_Walk then
kono
parents:
diff changeset
2249 if Done /= (Done'Range => True) then
kono
parents:
diff changeset
2250 Write_Eol;
kono
parents:
diff changeset
2251 Write_Line ("Ignored units:");
kono
parents:
diff changeset
2252
kono
parents:
diff changeset
2253 Indent;
kono
parents:
diff changeset
2254
kono
parents:
diff changeset
2255 for Unit_Num in Done'Range loop
kono
parents:
diff changeset
2256 if not Done (Unit_Num) then
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2257
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2258 -- Units with configuration pragmas (.ads files) have empty
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2259 -- compilation-unit nodes; skip printing info about them.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2260
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2261 if Present (Cunit (Unit_Num)) then
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2262 Write_Unit_Info
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2263 (Unit_Num, Unit (Cunit (Unit_Num)), Withs => True);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2264 end if;
111
kono
parents:
diff changeset
2265 end if;
kono
parents:
diff changeset
2266 end loop;
kono
parents:
diff changeset
2267
kono
parents:
diff changeset
2268 Outdent;
kono
parents:
diff changeset
2269 end if;
kono
parents:
diff changeset
2270 end if;
kono
parents:
diff changeset
2271
kono
parents:
diff changeset
2272 pragma Assert (Done (Main_Unit));
kono
parents:
diff changeset
2273
kono
parents:
diff changeset
2274 if Debug_Unit_Walk then
kono
parents:
diff changeset
2275 Outdent;
kono
parents:
diff changeset
2276 Write_Line ("end Walk_Library_Items.");
kono
parents:
diff changeset
2277 end if;
kono
parents:
diff changeset
2278 end Walk_Library_Items;
kono
parents:
diff changeset
2279
kono
parents:
diff changeset
2280 ----------------
kono
parents:
diff changeset
2281 -- Walk_Withs --
kono
parents:
diff changeset
2282 ----------------
kono
parents:
diff changeset
2283
kono
parents:
diff changeset
2284 procedure Walk_Withs (CU : Node_Id; Include_Limited : Boolean) is
kono
parents:
diff changeset
2285 pragma Assert (Nkind (CU) = N_Compilation_Unit);
kono
parents:
diff changeset
2286 pragma Assert (Nkind (Unit (CU)) /= N_Subunit);
kono
parents:
diff changeset
2287
kono
parents:
diff changeset
2288 procedure Walk_Immediate is new Walk_Withs_Immediate (Action);
kono
parents:
diff changeset
2289
kono
parents:
diff changeset
2290 begin
kono
parents:
diff changeset
2291 -- First walk the withs immediately on the library item
kono
parents:
diff changeset
2292
kono
parents:
diff changeset
2293 Walk_Immediate (CU, Include_Limited);
kono
parents:
diff changeset
2294
kono
parents:
diff changeset
2295 -- For a body, we must also check for any subunits which belong to it
kono
parents:
diff changeset
2296 -- and which have context clauses of their own, since these with'ed
kono
parents:
diff changeset
2297 -- units are part of its own dependencies.
kono
parents:
diff changeset
2298
kono
parents:
diff changeset
2299 if Nkind (Unit (CU)) in N_Unit_Body then
kono
parents:
diff changeset
2300 for S in Main_Unit .. Last_Unit loop
kono
parents:
diff changeset
2301
kono
parents:
diff changeset
2302 -- We are only interested in subunits. For preproc. data and def.
kono
parents:
diff changeset
2303 -- files, Cunit is Empty, so we need to test that first.
kono
parents:
diff changeset
2304
kono
parents:
diff changeset
2305 if Cunit (S) /= Empty
kono
parents:
diff changeset
2306 and then Nkind (Unit (Cunit (S))) = N_Subunit
kono
parents:
diff changeset
2307 then
kono
parents:
diff changeset
2308 declare
kono
parents:
diff changeset
2309 Pnode : Node_Id;
kono
parents:
diff changeset
2310
kono
parents:
diff changeset
2311 begin
kono
parents:
diff changeset
2312 Pnode := Library_Unit (Cunit (S));
kono
parents:
diff changeset
2313
kono
parents:
diff changeset
2314 -- In -gnatc mode, the errors in the subunits will not have
kono
parents:
diff changeset
2315 -- been recorded, but the analysis of the subunit may have
kono
parents:
diff changeset
2316 -- failed, so just quit.
kono
parents:
diff changeset
2317
kono
parents:
diff changeset
2318 if No (Pnode) then
kono
parents:
diff changeset
2319 exit;
kono
parents:
diff changeset
2320 end if;
kono
parents:
diff changeset
2321
kono
parents:
diff changeset
2322 -- Find ultimate parent of the subunit
kono
parents:
diff changeset
2323
kono
parents:
diff changeset
2324 while Nkind (Unit (Pnode)) = N_Subunit loop
kono
parents:
diff changeset
2325 Pnode := Library_Unit (Pnode);
kono
parents:
diff changeset
2326 end loop;
kono
parents:
diff changeset
2327
kono
parents:
diff changeset
2328 -- See if it belongs to current unit, and if so, include its
kono
parents:
diff changeset
2329 -- with_clauses. Do not process main unit prematurely.
kono
parents:
diff changeset
2330
kono
parents:
diff changeset
2331 if Pnode = CU and then CU /= Cunit (Main_Unit) then
kono
parents:
diff changeset
2332 Walk_Immediate (Cunit (S), Include_Limited);
kono
parents:
diff changeset
2333 end if;
kono
parents:
diff changeset
2334 end;
kono
parents:
diff changeset
2335 end if;
kono
parents:
diff changeset
2336 end loop;
kono
parents:
diff changeset
2337 end if;
kono
parents:
diff changeset
2338 end Walk_Withs;
kono
parents:
diff changeset
2339
kono
parents:
diff changeset
2340 --------------------------
kono
parents:
diff changeset
2341 -- Walk_Withs_Immediate --
kono
parents:
diff changeset
2342 --------------------------
kono
parents:
diff changeset
2343
kono
parents:
diff changeset
2344 procedure Walk_Withs_Immediate (CU : Node_Id; Include_Limited : Boolean) is
kono
parents:
diff changeset
2345 pragma Assert (Nkind (CU) = N_Compilation_Unit);
kono
parents:
diff changeset
2346
kono
parents:
diff changeset
2347 Context_Item : Node_Id;
kono
parents:
diff changeset
2348 Lib_Unit : Node_Id;
kono
parents:
diff changeset
2349
kono
parents:
diff changeset
2350 begin
kono
parents:
diff changeset
2351 Context_Item := First (Context_Items (CU));
kono
parents:
diff changeset
2352 while Present (Context_Item) loop
kono
parents:
diff changeset
2353 if Nkind (Context_Item) = N_With_Clause
kono
parents:
diff changeset
2354 and then (Include_Limited
kono
parents:
diff changeset
2355 or else not Limited_Present (Context_Item))
kono
parents:
diff changeset
2356 then
kono
parents:
diff changeset
2357 Lib_Unit := Library_Unit (Context_Item);
kono
parents:
diff changeset
2358 Action (Lib_Unit);
kono
parents:
diff changeset
2359 end if;
kono
parents:
diff changeset
2360
kono
parents:
diff changeset
2361 Context_Item := Next (Context_Item);
kono
parents:
diff changeset
2362 end loop;
kono
parents:
diff changeset
2363 end Walk_Withs_Immediate;
kono
parents:
diff changeset
2364
kono
parents:
diff changeset
2365 end Sem;