annotate gcc/ada/frontend.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 -- F R O N T E N D --
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 System.Strings; use System.Strings;
kono
parents:
diff changeset
27
kono
parents:
diff changeset
28 with Atree; use Atree;
kono
parents:
diff changeset
29 with Checks;
kono
parents:
diff changeset
30 with CStand;
kono
parents:
diff changeset
31 with Debug; use Debug;
kono
parents:
diff changeset
32 with Elists;
kono
parents:
diff changeset
33 with Exp_Dbug;
kono
parents:
diff changeset
34 with Exp_Unst;
kono
parents:
diff changeset
35 with Fmap;
kono
parents:
diff changeset
36 with Fname.UF;
kono
parents:
diff changeset
37 with Ghost; use Ghost;
kono
parents:
diff changeset
38 with Inline; use Inline;
kono
parents:
diff changeset
39 with Lib; use Lib;
kono
parents:
diff changeset
40 with Lib.Load; use Lib.Load;
kono
parents:
diff changeset
41 with Lib.Xref;
kono
parents:
diff changeset
42 with Live; use Live;
kono
parents:
diff changeset
43 with Namet; use Namet;
kono
parents:
diff changeset
44 with Nlists; use Nlists;
kono
parents:
diff changeset
45 with Opt; use Opt;
kono
parents:
diff changeset
46 with Osint;
kono
parents:
diff changeset
47 with Par;
kono
parents:
diff changeset
48 with Prep;
kono
parents:
diff changeset
49 with Prepcomp;
kono
parents:
diff changeset
50 with Restrict; use Restrict;
kono
parents:
diff changeset
51 with Rident; use Rident;
kono
parents:
diff changeset
52 with Rtsfind;
kono
parents:
diff changeset
53 with Snames; use Snames;
kono
parents:
diff changeset
54 with Sprint;
kono
parents:
diff changeset
55 with Scn; use Scn;
kono
parents:
diff changeset
56 with Sem; use Sem;
kono
parents:
diff changeset
57 with Sem_Aux;
kono
parents:
diff changeset
58 with Sem_Ch8;
kono
parents:
diff changeset
59 with Sem_SCIL;
kono
parents:
diff changeset
60 with Sem_Elab; use Sem_Elab;
kono
parents:
diff changeset
61 with Sem_Prag; use Sem_Prag;
kono
parents:
diff changeset
62 with Sem_Warn;
kono
parents:
diff changeset
63 with Sinfo; use Sinfo;
kono
parents:
diff changeset
64 with Sinput; use Sinput;
kono
parents:
diff changeset
65 with Sinput.L; use Sinput.L;
kono
parents:
diff changeset
66 with SCIL_LL;
kono
parents:
diff changeset
67 with Tbuild; use Tbuild;
kono
parents:
diff changeset
68 with Types; use Types;
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 procedure Frontend is
kono
parents:
diff changeset
71 begin
kono
parents:
diff changeset
72 -- Carry out package initializations. These are initializations which might
kono
parents:
diff changeset
73 -- logically be performed at elaboration time, were it not for the fact
kono
parents:
diff changeset
74 -- that we may be doing things more than once in the big loop over files.
kono
parents:
diff changeset
75 -- Like elaboration, the order in which these calls are made is in some
kono
parents:
diff changeset
76 -- cases important. For example, Lib cannot be initialized before Namet,
kono
parents:
diff changeset
77 -- since it uses names table entries.
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 Rtsfind.Initialize;
kono
parents:
diff changeset
80 Nlists.Initialize;
kono
parents:
diff changeset
81 Elists.Initialize;
kono
parents:
diff changeset
82 Lib.Load.Initialize;
kono
parents:
diff changeset
83 Sem_Aux.Initialize;
kono
parents:
diff changeset
84 Sem_Ch8.Initialize;
kono
parents:
diff changeset
85 Sem_Prag.Initialize;
kono
parents:
diff changeset
86 Fname.UF.Initialize;
kono
parents:
diff changeset
87 Checks.Initialize;
kono
parents:
diff changeset
88 Sem_Warn.Initialize;
kono
parents:
diff changeset
89 Prep.Initialize;
kono
parents:
diff changeset
90 Sem_Elab.Initialize;
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 if Generate_SCIL then
kono
parents:
diff changeset
93 SCIL_LL.Initialize;
kono
parents:
diff changeset
94 end if;
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 -- Create package Standard
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 CStand.Create_Standard;
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 -- Check possible symbol definitions specified by -gnateD switches
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 Prepcomp.Process_Command_Line_Symbol_Definitions;
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 -- If -gnatep= was specified, parse the preprocessing data file
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 if Preprocessing_Data_File /= null then
kono
parents:
diff changeset
107 Name_Len := Preprocessing_Data_File'Length;
kono
parents:
diff changeset
108 Name_Buffer (1 .. Name_Len) := Preprocessing_Data_File.all;
kono
parents:
diff changeset
109 Prepcomp.Parse_Preprocessing_Data_File (Name_Find);
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111 -- Otherwise, check if there were preprocessing symbols on the command
kono
parents:
diff changeset
112 -- line and set preprocessing if there are.
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 else
kono
parents:
diff changeset
115 Prepcomp.Check_Symbols;
kono
parents:
diff changeset
116 end if;
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 -- We set Parsing_Main_Extended_Source true here to cover processing of all
kono
parents:
diff changeset
119 -- the configuration pragma files, as well as the main source unit itself.
kono
parents:
diff changeset
120
kono
parents:
diff changeset
121 Parsing_Main_Extended_Source := True;
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 -- Now that the preprocessing situation is established, we are able to
kono
parents:
diff changeset
124 -- load the main source (this is no longer done by Lib.Load.Initialize).
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 Lib.Load.Load_Main_Source;
kono
parents:
diff changeset
127
kono
parents:
diff changeset
128 -- Return immediately if the main source could not be found
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 if Sinput.Main_Source_File <= No_Source_File then
kono
parents:
diff changeset
131 return;
kono
parents:
diff changeset
132 end if;
kono
parents:
diff changeset
133
kono
parents:
diff changeset
134 -- Read and process configuration pragma files if present
kono
parents:
diff changeset
135
kono
parents:
diff changeset
136 declare
kono
parents:
diff changeset
137 Dot_Gnat_Adc : constant File_Name_Type := Name_Find ("./gnat.adc");
kono
parents:
diff changeset
138 Gnat_Adc : constant File_Name_Type := Name_Find ("gnat.adc");
kono
parents:
diff changeset
139
kono
parents:
diff changeset
140 Save_Style_Check : constant Boolean := Opt.Style_Check;
kono
parents:
diff changeset
141 -- Save style check mode so it can be restored later
kono
parents:
diff changeset
142
kono
parents:
diff changeset
143 Config_Pragmas : List_Id := Empty_List;
kono
parents:
diff changeset
144 -- Gather configuration pragmas
kono
parents:
diff changeset
145
kono
parents:
diff changeset
146 Source_Config_File : Source_File_Index;
kono
parents:
diff changeset
147 -- Source reference for -gnatec configuration file
kono
parents:
diff changeset
148
kono
parents:
diff changeset
149 Prag : Node_Id;
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151 begin
kono
parents:
diff changeset
152 -- We always analyze config files with style checks off, since we
kono
parents:
diff changeset
153 -- don't want a miscellaneous gnat.adc that is around to discombobulate
kono
parents:
diff changeset
154 -- intended -gnatg or -gnaty compilations. We also disconnect checking
kono
parents:
diff changeset
155 -- for maximum line length.
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 Opt.Style_Check := False;
kono
parents:
diff changeset
158 Style_Check := False;
kono
parents:
diff changeset
159
kono
parents:
diff changeset
160 -- Capture current suppress options, which may get modified
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 Scope_Suppress := Opt.Suppress_Options;
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164 -- First deal with gnat.adc file
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166 if Opt.Config_File then
kono
parents:
diff changeset
167 Source_gnat_adc := Load_Config_File (Gnat_Adc);
kono
parents:
diff changeset
168
kono
parents:
diff changeset
169 -- Case of gnat.adc file present
kono
parents:
diff changeset
170
kono
parents:
diff changeset
171 if Source_gnat_adc > No_Source_File then
kono
parents:
diff changeset
172
kono
parents:
diff changeset
173 -- Parse the gnat.adc file for configuration pragmas
kono
parents:
diff changeset
174
kono
parents:
diff changeset
175 Initialize_Scanner (No_Unit, Source_gnat_adc);
kono
parents:
diff changeset
176 Config_Pragmas := Par (Configuration_Pragmas => True);
kono
parents:
diff changeset
177
kono
parents:
diff changeset
178 -- We add a compilation dependency for gnat.adc so that if it
kono
parents:
diff changeset
179 -- changes, we force a recompilation.
kono
parents:
diff changeset
180
kono
parents:
diff changeset
181 Prepcomp.Add_Dependency (Source_gnat_adc);
kono
parents:
diff changeset
182 end if;
kono
parents:
diff changeset
183 end if;
kono
parents:
diff changeset
184
kono
parents:
diff changeset
185 -- Now deal with specified config pragmas files if there are any
kono
parents:
diff changeset
186
kono
parents:
diff changeset
187 if Opt.Config_File_Names /= null then
kono
parents:
diff changeset
188
kono
parents:
diff changeset
189 -- Loop through config pragmas files
kono
parents:
diff changeset
190
kono
parents:
diff changeset
191 for Index in Opt.Config_File_Names'Range loop
kono
parents:
diff changeset
192 declare
kono
parents:
diff changeset
193 Len : constant Natural := Config_File_Names (Index)'Length;
kono
parents:
diff changeset
194 Str : constant String (1 .. Len) :=
kono
parents:
diff changeset
195 Config_File_Names (Index).all;
kono
parents:
diff changeset
196
kono
parents:
diff changeset
197 Config_Name : constant File_Name_Type := Name_Find (Str);
kono
parents:
diff changeset
198 Temp_File : constant Boolean :=
kono
parents:
diff changeset
199 Len > 4
kono
parents:
diff changeset
200 and then
kono
parents:
diff changeset
201 (Str (Len - 3 .. Len) = ".TMP"
kono
parents:
diff changeset
202 or else
kono
parents:
diff changeset
203 Str (Len - 3 .. Len) = ".tmp");
kono
parents:
diff changeset
204 -- Extension indicating a temporary config file?
kono
parents:
diff changeset
205
kono
parents:
diff changeset
206 begin
kono
parents:
diff changeset
207 -- Skip it if it's the default name, already loaded above.
kono
parents:
diff changeset
208 -- Otherwise, we get confusing warning messages about seeing
kono
parents:
diff changeset
209 -- the same thing twice.
kono
parents:
diff changeset
210
kono
parents:
diff changeset
211 if Config_Name /= Gnat_Adc
kono
parents:
diff changeset
212 and then Config_Name /= Dot_Gnat_Adc
kono
parents:
diff changeset
213 then
kono
parents:
diff changeset
214 -- Load the file, error if we did not find it
kono
parents:
diff changeset
215
kono
parents:
diff changeset
216 Source_Config_File := Load_Config_File (Config_Name);
kono
parents:
diff changeset
217
kono
parents:
diff changeset
218 if Source_Config_File <= No_Source_File then
kono
parents:
diff changeset
219 Osint.Fail
kono
parents:
diff changeset
220 ("cannot find configuration pragmas file "
kono
parents:
diff changeset
221 & Config_File_Names (Index).all);
kono
parents:
diff changeset
222
kono
parents:
diff changeset
223 -- If we did find the file, and it is not a temporary file,
kono
parents:
diff changeset
224 -- then we add a compilation dependency for it so that if it
kono
parents:
diff changeset
225 -- changes, we force a recompilation.
kono
parents:
diff changeset
226
kono
parents:
diff changeset
227 elsif not Temp_File then
kono
parents:
diff changeset
228 Prepcomp.Add_Dependency (Source_Config_File);
kono
parents:
diff changeset
229 end if;
kono
parents:
diff changeset
230
kono
parents:
diff changeset
231 -- Parse the config pragmas file, and accumulate results
kono
parents:
diff changeset
232
kono
parents:
diff changeset
233 Initialize_Scanner (No_Unit, Source_Config_File);
kono
parents:
diff changeset
234 Append_List_To
kono
parents:
diff changeset
235 (Config_Pragmas, Par (Configuration_Pragmas => True));
kono
parents:
diff changeset
236 end if;
kono
parents:
diff changeset
237 end;
kono
parents:
diff changeset
238 end loop;
kono
parents:
diff changeset
239 end if;
kono
parents:
diff changeset
240
kono
parents:
diff changeset
241 -- Now analyze all pragmas except those whose analysis must be
kono
parents:
diff changeset
242 -- deferred till after the main unit is analyzed.
kono
parents:
diff changeset
243
kono
parents:
diff changeset
244 if Config_Pragmas /= Error_List
kono
parents:
diff changeset
245 and then Operating_Mode /= Check_Syntax
kono
parents:
diff changeset
246 then
kono
parents:
diff changeset
247 Prag := First (Config_Pragmas);
kono
parents:
diff changeset
248 while Present (Prag) loop
kono
parents:
diff changeset
249 if not Delay_Config_Pragma_Analyze (Prag) then
kono
parents:
diff changeset
250 Analyze_Pragma (Prag);
kono
parents:
diff changeset
251 end if;
kono
parents:
diff changeset
252
kono
parents:
diff changeset
253 Next (Prag);
kono
parents:
diff changeset
254 end loop;
kono
parents:
diff changeset
255 end if;
kono
parents:
diff changeset
256
kono
parents:
diff changeset
257 -- Restore style check, but if config file turned on checks, leave on
kono
parents:
diff changeset
258
kono
parents:
diff changeset
259 Opt.Style_Check := Save_Style_Check or Style_Check;
kono
parents:
diff changeset
260
kono
parents:
diff changeset
261 -- Capture any modifications to suppress options from config pragmas
kono
parents:
diff changeset
262
kono
parents:
diff changeset
263 Opt.Suppress_Options := Scope_Suppress;
kono
parents:
diff changeset
264
kono
parents:
diff changeset
265 -- If a target dependency info file has been read through switch
kono
parents:
diff changeset
266 -- -gnateT=, add it to the dependencies.
kono
parents:
diff changeset
267
kono
parents:
diff changeset
268 if Target_Dependent_Info_Read_Name /= null then
kono
parents:
diff changeset
269 declare
kono
parents:
diff changeset
270 Index : Source_File_Index;
kono
parents:
diff changeset
271 begin
kono
parents:
diff changeset
272 Name_Len := 0;
kono
parents:
diff changeset
273 Add_Str_To_Name_Buffer (Target_Dependent_Info_Read_Name.all);
kono
parents:
diff changeset
274 Index := Load_Config_File (Name_Enter);
kono
parents:
diff changeset
275 Prepcomp.Add_Dependency (Index);
kono
parents:
diff changeset
276 end;
kono
parents:
diff changeset
277 end if;
kono
parents:
diff changeset
278
kono
parents:
diff changeset
279 -- This is where we can capture the value of the compilation unit
kono
parents:
diff changeset
280 -- specific restrictions that have been set by the config pragma
kono
parents:
diff changeset
281 -- files (or from Targparm), for later restoration when processing
kono
parents:
diff changeset
282 -- e.g. subunits.
kono
parents:
diff changeset
283
kono
parents:
diff changeset
284 Save_Config_Cunit_Boolean_Restrictions;
kono
parents:
diff changeset
285
kono
parents:
diff changeset
286 -- If there was a -gnatem switch, initialize the mappings of unit names
kono
parents:
diff changeset
287 -- to file names and of file names to path names from the mapping file.
kono
parents:
diff changeset
288
kono
parents:
diff changeset
289 if Mapping_File_Name /= null then
kono
parents:
diff changeset
290 Fmap.Initialize (Mapping_File_Name.all);
kono
parents:
diff changeset
291 end if;
kono
parents:
diff changeset
292
kono
parents:
diff changeset
293 -- Adjust Optimize_Alignment mode from debug switches if necessary
kono
parents:
diff changeset
294
kono
parents:
diff changeset
295 if Debug_Flag_Dot_SS then
kono
parents:
diff changeset
296 Optimize_Alignment := 'S';
kono
parents:
diff changeset
297 elsif Debug_Flag_Dot_TT then
kono
parents:
diff changeset
298 Optimize_Alignment := 'T';
kono
parents:
diff changeset
299 end if;
kono
parents:
diff changeset
300
kono
parents:
diff changeset
301 -- We have now processed the command line switches, and the
kono
parents:
diff changeset
302 -- configuration pragma files, so this is the point at which we want to
kono
parents:
diff changeset
303 -- capture the values of the configuration switches (see Opt for further
kono
parents:
diff changeset
304 -- details).
kono
parents:
diff changeset
305
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
306 Register_Config_Switches;
111
kono
parents:
diff changeset
307
kono
parents:
diff changeset
308 -- Check for file which contains No_Body pragma
kono
parents:
diff changeset
309
kono
parents:
diff changeset
310 if Source_File_Is_No_Body (Source_Index (Main_Unit)) then
kono
parents:
diff changeset
311 Change_Main_Unit_To_Spec;
kono
parents:
diff changeset
312 end if;
kono
parents:
diff changeset
313
kono
parents:
diff changeset
314 -- Initialize the scanner. Note that we do this after the call to
kono
parents:
diff changeset
315 -- Create_Standard, which uses the scanner in its processing of
kono
parents:
diff changeset
316 -- floating-point bounds.
kono
parents:
diff changeset
317
kono
parents:
diff changeset
318 Initialize_Scanner (Main_Unit, Source_Index (Main_Unit));
kono
parents:
diff changeset
319
kono
parents:
diff changeset
320 -- Here we call the parser to parse the compilation unit (or units in
kono
parents:
diff changeset
321 -- the check syntax mode, but in that case we won't go on to the
kono
parents:
diff changeset
322 -- semantics in any case).
kono
parents:
diff changeset
323
kono
parents:
diff changeset
324 Discard_List (Par (Configuration_Pragmas => False));
kono
parents:
diff changeset
325 Parsing_Main_Extended_Source := False;
kono
parents:
diff changeset
326
kono
parents:
diff changeset
327 -- The main unit is now loaded, and subunits of it can be loaded,
kono
parents:
diff changeset
328 -- without reporting spurious loading circularities.
kono
parents:
diff changeset
329
kono
parents:
diff changeset
330 Set_Loading (Main_Unit, False);
kono
parents:
diff changeset
331
kono
parents:
diff changeset
332 -- Now that the main unit is installed, we can complete the analysis
kono
parents:
diff changeset
333 -- of the pragmas in gnat.adc and the configuration file, that require
kono
parents:
diff changeset
334 -- a context for their semantic processing.
kono
parents:
diff changeset
335
kono
parents:
diff changeset
336 if Config_Pragmas /= Error_List
kono
parents:
diff changeset
337 and then Operating_Mode /= Check_Syntax
kono
parents:
diff changeset
338
kono
parents:
diff changeset
339 -- Do not attempt to process deferred configuration pragmas if the
kono
parents:
diff changeset
340 -- main unit failed to load, to avoid cascaded inconsistencies that
kono
parents:
diff changeset
341 -- can lead to a compiler crash.
kono
parents:
diff changeset
342
kono
parents:
diff changeset
343 and then Fatal_Error (Main_Unit) /= Error_Detected
kono
parents:
diff changeset
344 then
kono
parents:
diff changeset
345 -- Pragmas that require some semantic activity, such as
kono
parents:
diff changeset
346 -- Interrupt_State, cannot be processed until the main unit is
kono
parents:
diff changeset
347 -- installed, because they require a compilation unit on which to
kono
parents:
diff changeset
348 -- attach with_clauses, etc. So analyze them now.
kono
parents:
diff changeset
349
kono
parents:
diff changeset
350 declare
kono
parents:
diff changeset
351 Prag : Node_Id;
kono
parents:
diff changeset
352
kono
parents:
diff changeset
353 begin
kono
parents:
diff changeset
354 Prag := First (Config_Pragmas);
kono
parents:
diff changeset
355 while Present (Prag) loop
kono
parents:
diff changeset
356
kono
parents:
diff changeset
357 -- Guard against the case where a configuration pragma may be
kono
parents:
diff changeset
358 -- split into multiple pragmas and the original rewritten as a
kono
parents:
diff changeset
359 -- null statement.
kono
parents:
diff changeset
360
kono
parents:
diff changeset
361 if Nkind (Prag) = N_Pragma
kono
parents:
diff changeset
362 and then Delay_Config_Pragma_Analyze (Prag)
kono
parents:
diff changeset
363 then
kono
parents:
diff changeset
364 Analyze_Pragma (Prag);
kono
parents:
diff changeset
365 end if;
kono
parents:
diff changeset
366
kono
parents:
diff changeset
367 Next (Prag);
kono
parents:
diff changeset
368 end loop;
kono
parents:
diff changeset
369 end;
kono
parents:
diff changeset
370 end if;
kono
parents:
diff changeset
371
kono
parents:
diff changeset
372 -- If we have restriction No_Exception_Propagation, and we did not have
kono
parents:
diff changeset
373 -- an explicit switch turning off Warn_On_Non_Local_Exception, then turn
kono
parents:
diff changeset
374 -- on this warning by default if we have encountered an exception
kono
parents:
diff changeset
375 -- handler.
kono
parents:
diff changeset
376
kono
parents:
diff changeset
377 if Restriction_Check_Required (No_Exception_Propagation)
kono
parents:
diff changeset
378 and then not No_Warn_On_Non_Local_Exception
kono
parents:
diff changeset
379 and then Exception_Handler_Encountered
kono
parents:
diff changeset
380 then
kono
parents:
diff changeset
381 Warn_On_Non_Local_Exception := True;
kono
parents:
diff changeset
382 end if;
kono
parents:
diff changeset
383
kono
parents:
diff changeset
384 -- Now on to the semantics. Skip if in syntax only mode
kono
parents:
diff changeset
385
kono
parents:
diff changeset
386 if Operating_Mode /= Check_Syntax then
kono
parents:
diff changeset
387
kono
parents:
diff changeset
388 -- Install the configuration pragmas in the tree
kono
parents:
diff changeset
389
kono
parents:
diff changeset
390 Set_Config_Pragmas
kono
parents:
diff changeset
391 (Aux_Decls_Node (Cunit (Main_Unit)), Config_Pragmas);
kono
parents:
diff changeset
392
kono
parents:
diff changeset
393 -- Following steps are skipped if we had a fatal error during parsing
kono
parents:
diff changeset
394
kono
parents:
diff changeset
395 if Fatal_Error (Main_Unit) /= Error_Detected then
kono
parents:
diff changeset
396
kono
parents:
diff changeset
397 -- Reset Operating_Mode to Check_Semantics for subunits. We cannot
kono
parents:
diff changeset
398 -- actually generate code for subunits, so we suppress expansion.
kono
parents:
diff changeset
399 -- This also corrects certain problems that occur if we try to
kono
parents:
diff changeset
400 -- incorporate subunits at a lower level.
kono
parents:
diff changeset
401
kono
parents:
diff changeset
402 if Operating_Mode = Generate_Code
kono
parents:
diff changeset
403 and then Nkind (Unit (Cunit (Main_Unit))) = N_Subunit
kono
parents:
diff changeset
404 then
kono
parents:
diff changeset
405 Operating_Mode := Check_Semantics;
kono
parents:
diff changeset
406 end if;
kono
parents:
diff changeset
407
kono
parents:
diff changeset
408 -- Analyze (and possibly expand) main unit
kono
parents:
diff changeset
409
kono
parents:
diff changeset
410 Scope_Suppress := Suppress_Options;
kono
parents:
diff changeset
411 Semantics (Cunit (Main_Unit));
kono
parents:
diff changeset
412
kono
parents:
diff changeset
413 -- Cleanup processing after completing main analysis
kono
parents:
diff changeset
414
kono
parents:
diff changeset
415 -- Comment needed for ASIS mode test and GNATprove mode test???
kono
parents:
diff changeset
416
kono
parents:
diff changeset
417 pragma Assert
kono
parents:
diff changeset
418 (Operating_Mode = Generate_Code
kono
parents:
diff changeset
419 or else Operating_Mode = Check_Semantics);
kono
parents:
diff changeset
420
kono
parents:
diff changeset
421 if Operating_Mode = Generate_Code
kono
parents:
diff changeset
422 or else (ASIS_Mode or GNATprove_Mode)
kono
parents:
diff changeset
423 then
kono
parents:
diff changeset
424 Instantiate_Bodies;
kono
parents:
diff changeset
425 end if;
kono
parents:
diff changeset
426
kono
parents:
diff changeset
427 -- Analyze all inlined bodies, check access-before-elaboration
kono
parents:
diff changeset
428 -- rules, and remove ignored Ghost code when generating code or
kono
parents:
diff changeset
429 -- compiling for GNATprove.
kono
parents:
diff changeset
430
kono
parents:
diff changeset
431 if Operating_Mode = Generate_Code or else GNATprove_Mode then
kono
parents:
diff changeset
432 if Inline_Processing_Required then
kono
parents:
diff changeset
433 Analyze_Inlined_Bodies;
kono
parents:
diff changeset
434 end if;
kono
parents:
diff changeset
435
kono
parents:
diff changeset
436 -- Remove entities from program that do not have any execution
kono
parents:
diff changeset
437 -- time references.
kono
parents:
diff changeset
438
kono
parents:
diff changeset
439 if Debug_Flag_UU then
kono
parents:
diff changeset
440 Collect_Garbage_Entities;
kono
parents:
diff changeset
441 end if;
kono
parents:
diff changeset
442
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
443 if Legacy_Elaboration_Checks then
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
444 Check_Elab_Calls;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
445 end if;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
446
111
kono
parents:
diff changeset
447 -- Examine all top level scenarios collected during analysis
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
448 -- and resolution. Diagnose conditional ABEs, install run-time
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
449 -- checks to catch conditional ABEs, and guarantee the prior
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
450 -- elaboration of external units.
111
kono
parents:
diff changeset
451
kono
parents:
diff changeset
452 Check_Elaboration_Scenarios;
kono
parents:
diff changeset
453
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
454 -- Examine all top level scenarios collected during analysis and
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
455 -- resolution in order to diagnose conditional ABEs, even in the
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
456 -- presence of serious errors.
111
kono
parents:
diff changeset
457
kono
parents:
diff changeset
458 else
kono
parents:
diff changeset
459 Check_Elaboration_Scenarios;
kono
parents:
diff changeset
460 end if;
kono
parents:
diff changeset
461
kono
parents:
diff changeset
462 -- At this stage we can unnest subprogram bodies if required
kono
parents:
diff changeset
463
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
464 if Total_Errors_Detected = 0 then
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
465 Exp_Unst.Unnest_Subprograms (Cunit (Main_Unit));
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
466 end if;
111
kono
parents:
diff changeset
467
kono
parents:
diff changeset
468 -- List library units if requested
kono
parents:
diff changeset
469
kono
parents:
diff changeset
470 if List_Units then
kono
parents:
diff changeset
471 Lib.List;
kono
parents:
diff changeset
472 end if;
kono
parents:
diff changeset
473
kono
parents:
diff changeset
474 -- Output waiting warning messages
kono
parents:
diff changeset
475
kono
parents:
diff changeset
476 Lib.Xref.Process_Deferred_References;
kono
parents:
diff changeset
477 Sem_Warn.Output_Non_Modified_In_Out_Warnings;
kono
parents:
diff changeset
478 Sem_Warn.Output_Unreferenced_Messages;
kono
parents:
diff changeset
479 Sem_Warn.Check_Unused_Withs;
kono
parents:
diff changeset
480 Sem_Warn.Output_Unused_Warnings_Off_Warnings;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
481
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
482 -- Remove any ignored Ghost code as it must not appear in the
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
483 -- executable. This action must be performed last because it
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
484 -- heavily alters the tree.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
485
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
486 if Operating_Mode = Generate_Code or else GNATprove_Mode then
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
487 Remove_Ignored_Ghost_Code;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
488 end if;
111
kono
parents:
diff changeset
489 end if;
kono
parents:
diff changeset
490 end if;
kono
parents:
diff changeset
491 end;
kono
parents:
diff changeset
492
kono
parents:
diff changeset
493 -- Qualify all entity names in inner packages, package bodies, etc
kono
parents:
diff changeset
494
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
495 if not GNATprove_Mode then
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
496 Exp_Dbug.Qualify_All_Entity_Names;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
497 end if;
111
kono
parents:
diff changeset
498
kono
parents:
diff changeset
499 -- SCIL backend requirement. Check that SCIL nodes associated with
kono
parents:
diff changeset
500 -- dispatching calls reference subprogram calls.
kono
parents:
diff changeset
501
kono
parents:
diff changeset
502 if Generate_SCIL then
kono
parents:
diff changeset
503 pragma Debug (Sem_SCIL.Check_SCIL_Nodes (Cunit (Main_Unit)));
kono
parents:
diff changeset
504 null;
kono
parents:
diff changeset
505 end if;
kono
parents:
diff changeset
506
kono
parents:
diff changeset
507 -- Dump the source now. Note that we do this as soon as the analysis
kono
parents:
diff changeset
508 -- of the tree is complete, because it is not just a dump in the case
kono
parents:
diff changeset
509 -- of -gnatD, where it rewrites all source locations in the tree.
kono
parents:
diff changeset
510
kono
parents:
diff changeset
511 Sprint.Source_Dump;
kono
parents:
diff changeset
512
kono
parents:
diff changeset
513 -- Check again for configuration pragmas that appear in the context
kono
parents:
diff changeset
514 -- of the main unit. These pragmas only affect the main unit, and the
kono
parents:
diff changeset
515 -- corresponding flag is reset after each call to Semantics, but they
kono
parents:
diff changeset
516 -- may affect the generated ali for the unit, and therefore the flag
kono
parents:
diff changeset
517 -- must be set properly after compilation. Currently we only check for
kono
parents:
diff changeset
518 -- Initialize_Scalars, but others should be checked: as well???
kono
parents:
diff changeset
519
kono
parents:
diff changeset
520 declare
kono
parents:
diff changeset
521 Item : Node_Id;
kono
parents:
diff changeset
522
kono
parents:
diff changeset
523 begin
kono
parents:
diff changeset
524 Item := First (Context_Items (Cunit (Main_Unit)));
kono
parents:
diff changeset
525 while Present (Item) loop
kono
parents:
diff changeset
526 if Nkind (Item) = N_Pragma
kono
parents:
diff changeset
527 and then Pragma_Name (Item) = Name_Initialize_Scalars
kono
parents:
diff changeset
528 then
kono
parents:
diff changeset
529 Initialize_Scalars := True;
kono
parents:
diff changeset
530 end if;
kono
parents:
diff changeset
531
kono
parents:
diff changeset
532 Next (Item);
kono
parents:
diff changeset
533 end loop;
kono
parents:
diff changeset
534 end;
kono
parents:
diff changeset
535
kono
parents:
diff changeset
536 -- If a mapping file has been specified by a -gnatem switch, update
kono
parents:
diff changeset
537 -- it if there has been some sources that were not in the mappings.
kono
parents:
diff changeset
538
kono
parents:
diff changeset
539 if Mapping_File_Name /= null then
kono
parents:
diff changeset
540 Fmap.Update_Mapping_File (Mapping_File_Name.all);
kono
parents:
diff changeset
541 end if;
kono
parents:
diff changeset
542
kono
parents:
diff changeset
543 return;
kono
parents:
diff changeset
544 end Frontend;