annotate gcc/ada/gnat1drv.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 -- G N A T 1 D R V --
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 Back_End; use Back_End;
kono
parents:
diff changeset
28 with Checks;
kono
parents:
diff changeset
29 with Comperr;
kono
parents:
diff changeset
30 with Csets;
kono
parents:
diff changeset
31 with Debug; use Debug;
kono
parents:
diff changeset
32 with Elists;
kono
parents:
diff changeset
33 with Errout; use Errout;
kono
parents:
diff changeset
34 with Exp_CG;
kono
parents:
diff changeset
35 with Fmap;
kono
parents:
diff changeset
36 with Fname; use Fname;
kono
parents:
diff changeset
37 with Fname.UF; use Fname.UF;
kono
parents:
diff changeset
38 with Frontend;
kono
parents:
diff changeset
39 with Ghost; use Ghost;
kono
parents:
diff changeset
40 with Gnatvsn; use Gnatvsn;
kono
parents:
diff changeset
41 with Inline;
kono
parents:
diff changeset
42 with Lib; use Lib;
kono
parents:
diff changeset
43 with Lib.Writ; use Lib.Writ;
kono
parents:
diff changeset
44 with Lib.Xref;
kono
parents:
diff changeset
45 with Namet; use Namet;
kono
parents:
diff changeset
46 with Nlists;
kono
parents:
diff changeset
47 with Opt; use Opt;
kono
parents:
diff changeset
48 with Osint; use Osint;
kono
parents:
diff changeset
49 with Osint.C; use Osint.C;
kono
parents:
diff changeset
50 with Output; use Output;
kono
parents:
diff changeset
51 with Par_SCO;
kono
parents:
diff changeset
52 with Prepcomp;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
53 with Repinfo;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
54 with Repinfo.Input;
111
kono
parents:
diff changeset
55 with Restrict;
kono
parents:
diff changeset
56 with Rident; use Rident;
kono
parents:
diff changeset
57 with Rtsfind;
kono
parents:
diff changeset
58 with SCOs;
kono
parents:
diff changeset
59 with Sem;
kono
parents:
diff changeset
60 with Sem_Ch8;
kono
parents:
diff changeset
61 with Sem_Ch12;
kono
parents:
diff changeset
62 with Sem_Ch13;
kono
parents:
diff changeset
63 with Sem_Elim;
kono
parents:
diff changeset
64 with Sem_Eval;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
65 with Sem_Prag;
111
kono
parents:
diff changeset
66 with Sem_Type;
kono
parents:
diff changeset
67 with Set_Targ;
kono
parents:
diff changeset
68 with Sinfo; use Sinfo;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
69 with Sinput; use Sinput;
111
kono
parents:
diff changeset
70 with Sinput.L; use Sinput.L;
kono
parents:
diff changeset
71 with Snames; use Snames;
kono
parents:
diff changeset
72 with Sprint; use Sprint;
kono
parents:
diff changeset
73 with Stringt;
kono
parents:
diff changeset
74 with Stylesw; use Stylesw;
kono
parents:
diff changeset
75 with Targparm; use Targparm;
kono
parents:
diff changeset
76 with Tbuild;
kono
parents:
diff changeset
77 with Tree_Gen;
kono
parents:
diff changeset
78 with Treepr; use Treepr;
kono
parents:
diff changeset
79 with Ttypes;
kono
parents:
diff changeset
80 with Types; use Types;
kono
parents:
diff changeset
81 with Uintp;
kono
parents:
diff changeset
82 with Uname; use Uname;
kono
parents:
diff changeset
83 with Urealp;
kono
parents:
diff changeset
84 with Usage;
kono
parents:
diff changeset
85 with Validsw; use Validsw;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
86 with Warnsw; use Warnsw;
111
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 with System.Assertions;
kono
parents:
diff changeset
89 with System.OS_Lib;
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 --------------
kono
parents:
diff changeset
92 -- Gnat1drv --
kono
parents:
diff changeset
93 --------------
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 procedure Gnat1drv is
kono
parents:
diff changeset
96 procedure Adjust_Global_Switches;
kono
parents:
diff changeset
97 -- There are various interactions between front-end switch settings,
kono
parents:
diff changeset
98 -- including debug switch settings and target dependent parameters.
kono
parents:
diff changeset
99 -- This procedure takes care of properly handling these interactions.
kono
parents:
diff changeset
100 -- We do it after scanning out all the switches, so that we are not
kono
parents:
diff changeset
101 -- depending on the order in which switches appear.
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 procedure Check_Bad_Body (Unit_Node : Node_Id; Unit_Kind : Node_Kind);
kono
parents:
diff changeset
104 -- Called to check whether a unit described by its compilation unit node
kono
parents:
diff changeset
105 -- and kind has a bad body.
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 procedure Check_Rep_Info;
kono
parents:
diff changeset
108 -- Called when we are not generating code, to check if -gnatR was requested
kono
parents:
diff changeset
109 -- and if so, explain that we will not be honoring the request.
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111 procedure Post_Compilation_Validation_Checks;
kono
parents:
diff changeset
112 -- This procedure performs various validation checks that have to be left
kono
parents:
diff changeset
113 -- to the end of the compilation process, after generating code but before
kono
parents:
diff changeset
114 -- issuing error messages. In particular, these checks generally require
kono
parents:
diff changeset
115 -- the information provided by the back end in back annotation of declared
kono
parents:
diff changeset
116 -- entities (e.g. actual size and alignment values chosen by the back end).
kono
parents:
diff changeset
117
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
118 procedure Read_JSON_Files_For_Repinfo;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
119 -- This procedure exercises the JSON parser of Repinfo by reading back the
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
120 -- JSON files generated by -gnatRjs in a previous compilation session. It
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
121 -- is intended to make sure that the JSON generator and the JSON parser are
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
122 -- kept synchronized when the JSON format evolves.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
123
111
kono
parents:
diff changeset
124 ----------------------------
kono
parents:
diff changeset
125 -- Adjust_Global_Switches --
kono
parents:
diff changeset
126 ----------------------------
kono
parents:
diff changeset
127
kono
parents:
diff changeset
128 procedure Adjust_Global_Switches is
kono
parents:
diff changeset
129 procedure SPARK_Library_Warning (Kind : String);
kono
parents:
diff changeset
130 -- Issue a warning in GNATprove mode if the run-time library does not
kono
parents:
diff changeset
131 -- fully support IEEE-754 floating-point semantics.
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133 ---------------------------
kono
parents:
diff changeset
134 -- SPARK_Library_Warning --
kono
parents:
diff changeset
135 ---------------------------
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137 procedure SPARK_Library_Warning (Kind : String) is
kono
parents:
diff changeset
138 begin
kono
parents:
diff changeset
139 Write_Line
kono
parents:
diff changeset
140 ("warning: run-time library may be configured incorrectly");
kono
parents:
diff changeset
141 Write_Line
kono
parents:
diff changeset
142 ("warning: (SPARK analysis requires support for " & Kind & ')');
kono
parents:
diff changeset
143 end SPARK_Library_Warning;
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 -- Start of processing for Adjust_Global_Switches
kono
parents:
diff changeset
146
kono
parents:
diff changeset
147 begin
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
148 -- Define pragma GNAT_Annotate as an alias of pragma Annotate, to be
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
149 -- able to work around bootstrap limitations with the old syntax of
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
150 -- pragma Annotate, and use pragma GNAT_Annotate in compiler sources
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
151 -- when needed.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
152
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
153 Map_Pragma_Name (From => Name_Gnat_Annotate, To => Name_Annotate);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
154
111
kono
parents:
diff changeset
155 -- -gnatd.M enables Relaxed_RM_Semantics
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 if Debug_Flag_Dot_MM then
kono
parents:
diff changeset
158 Relaxed_RM_Semantics := True;
kono
parents:
diff changeset
159 end if;
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161 -- -gnatd.1 enables unnesting of subprograms
kono
parents:
diff changeset
162
kono
parents:
diff changeset
163 if Debug_Flag_Dot_1 then
kono
parents:
diff changeset
164 Unnest_Subprogram_Mode := True;
kono
parents:
diff changeset
165 end if;
kono
parents:
diff changeset
166
kono
parents:
diff changeset
167 -- -gnatd.u enables special C expansion mode
kono
parents:
diff changeset
168
kono
parents:
diff changeset
169 if Debug_Flag_Dot_U then
kono
parents:
diff changeset
170 Modify_Tree_For_C := True;
kono
parents:
diff changeset
171 end if;
kono
parents:
diff changeset
172
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
173 -- -gnatd_A disables generation of ALI files
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
174
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
175 if Debug_Flag_Underscore_AA then
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
176 Disable_ALI_File := True;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
177 end if;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
178
111
kono
parents:
diff changeset
179 -- Set all flags required when generating C code
kono
parents:
diff changeset
180
kono
parents:
diff changeset
181 if Generate_C_Code then
kono
parents:
diff changeset
182 Modify_Tree_For_C := True;
kono
parents:
diff changeset
183 Unnest_Subprogram_Mode := True;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
184 Building_Static_Dispatch_Tables := False;
111
kono
parents:
diff changeset
185 Minimize_Expression_With_Actions := True;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
186 Expand_Nonbinary_Modular_Ops := True;
111
kono
parents:
diff changeset
187
kono
parents:
diff changeset
188 -- Set operating mode to Generate_Code to benefit from full front-end
kono
parents:
diff changeset
189 -- expansion (e.g. generics).
kono
parents:
diff changeset
190
kono
parents:
diff changeset
191 Operating_Mode := Generate_Code;
kono
parents:
diff changeset
192
kono
parents:
diff changeset
193 -- Suppress alignment checks since we do not have access to alignment
kono
parents:
diff changeset
194 -- info on the target.
kono
parents:
diff changeset
195
kono
parents:
diff changeset
196 Suppress_Options.Suppress (Alignment_Check) := False;
kono
parents:
diff changeset
197 end if;
kono
parents:
diff changeset
198
kono
parents:
diff changeset
199 -- -gnatd.E sets Error_To_Warning mode, causing selected error messages
kono
parents:
diff changeset
200 -- to be treated as warnings instead of errors.
kono
parents:
diff changeset
201
kono
parents:
diff changeset
202 if Debug_Flag_Dot_EE then
kono
parents:
diff changeset
203 Error_To_Warning := True;
kono
parents:
diff changeset
204 end if;
kono
parents:
diff changeset
205
kono
parents:
diff changeset
206 -- -gnatdJ sets Include_Subprogram_In_Messages, adding the related
kono
parents:
diff changeset
207 -- subprogram as part of the error and warning messages.
kono
parents:
diff changeset
208
kono
parents:
diff changeset
209 if Debug_Flag_JJ then
kono
parents:
diff changeset
210 Include_Subprogram_In_Messages := True;
kono
parents:
diff changeset
211 end if;
kono
parents:
diff changeset
212
kono
parents:
diff changeset
213 -- Disable CodePeer_Mode in Check_Syntax, since we need front-end
kono
parents:
diff changeset
214 -- expansion.
kono
parents:
diff changeset
215
kono
parents:
diff changeset
216 if Operating_Mode = Check_Syntax then
kono
parents:
diff changeset
217 CodePeer_Mode := False;
kono
parents:
diff changeset
218 end if;
kono
parents:
diff changeset
219
kono
parents:
diff changeset
220 -- Set ASIS mode if -gnatt and -gnatc are set
kono
parents:
diff changeset
221
kono
parents:
diff changeset
222 if Operating_Mode = Check_Semantics and then Tree_Output then
kono
parents:
diff changeset
223 ASIS_Mode := True;
kono
parents:
diff changeset
224
kono
parents:
diff changeset
225 -- Set ASIS GNSA mode if -gnatd.H is set
kono
parents:
diff changeset
226
kono
parents:
diff changeset
227 if Debug_Flag_Dot_HH then
kono
parents:
diff changeset
228 ASIS_GNSA_Mode := True;
kono
parents:
diff changeset
229 end if;
kono
parents:
diff changeset
230
kono
parents:
diff changeset
231 -- Turn off inlining in ASIS mode, since ASIS cannot handle the extra
kono
parents:
diff changeset
232 -- information in the trees caused by inlining being active.
kono
parents:
diff changeset
233
kono
parents:
diff changeset
234 -- More specifically, the tree seems to be malformed from the ASIS
kono
parents:
diff changeset
235 -- point of view if -gnatc and -gnatn appear together???
kono
parents:
diff changeset
236
kono
parents:
diff changeset
237 Inline_Active := False;
kono
parents:
diff changeset
238
kono
parents:
diff changeset
239 -- Turn off SCIL generation and CodePeer mode in semantics mode,
kono
parents:
diff changeset
240 -- since SCIL requires front-end expansion.
kono
parents:
diff changeset
241
kono
parents:
diff changeset
242 Generate_SCIL := False;
kono
parents:
diff changeset
243 CodePeer_Mode := False;
kono
parents:
diff changeset
244 end if;
kono
parents:
diff changeset
245
kono
parents:
diff changeset
246 -- SCIL mode needs to disable front-end inlining since the generated
kono
parents:
diff changeset
247 -- trees (in particular order and consistency between specs compiled
kono
parents:
diff changeset
248 -- as part of a main unit or as part of a with-clause) are causing
kono
parents:
diff changeset
249 -- troubles.
kono
parents:
diff changeset
250
kono
parents:
diff changeset
251 if Generate_SCIL then
kono
parents:
diff changeset
252 Front_End_Inlining := False;
kono
parents:
diff changeset
253 end if;
kono
parents:
diff changeset
254
kono
parents:
diff changeset
255 -- Tune settings for optimal SCIL generation in CodePeer mode
kono
parents:
diff changeset
256
kono
parents:
diff changeset
257 if CodePeer_Mode then
kono
parents:
diff changeset
258
kono
parents:
diff changeset
259 -- Turn off gnatprove mode (which can be set via e.g. -gnatd.F), not
kono
parents:
diff changeset
260 -- compatible with CodePeer mode.
kono
parents:
diff changeset
261
kono
parents:
diff changeset
262 GNATprove_Mode := False;
kono
parents:
diff changeset
263 Debug_Flag_Dot_FF := False;
kono
parents:
diff changeset
264
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
265 -- Turn off length expansion. CodePeer has its own mechanism to
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
266 -- handle length attribute.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
267
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
268 Debug_Flag_Dot_PP := True;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
269
111
kono
parents:
diff changeset
270 -- Turn off C tree generation, not compatible with CodePeer mode. We
kono
parents:
diff changeset
271 -- do not expect this to happen in normal use, since both modes are
kono
parents:
diff changeset
272 -- enabled by special tools, but it is useful to turn off these flags
kono
parents:
diff changeset
273 -- this way when we are doing CodePeer tests on existing test suites
kono
parents:
diff changeset
274 -- that may have -gnateg set, to avoid the need for special casing.
kono
parents:
diff changeset
275
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
276 Modify_Tree_For_C := False;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
277 Generate_C_Code := False;
111
kono
parents:
diff changeset
278 Unnest_Subprogram_Mode := False;
kono
parents:
diff changeset
279
kono
parents:
diff changeset
280 -- Turn off inlining, confuses CodePeer output and gains nothing
kono
parents:
diff changeset
281
kono
parents:
diff changeset
282 Front_End_Inlining := False;
kono
parents:
diff changeset
283 Inline_Active := False;
kono
parents:
diff changeset
284
kono
parents:
diff changeset
285 -- Disable front-end optimizations, to keep the tree as close to the
kono
parents:
diff changeset
286 -- source code as possible, and also to avoid inconsistencies between
kono
parents:
diff changeset
287 -- trees when using different optimization switches.
kono
parents:
diff changeset
288
kono
parents:
diff changeset
289 Optimization_Level := 0;
kono
parents:
diff changeset
290
kono
parents:
diff changeset
291 -- Enable some restrictions systematically to simplify the generated
kono
parents:
diff changeset
292 -- code (and ease analysis). Note that restriction checks are also
kono
parents:
diff changeset
293 -- disabled in CodePeer mode, see Restrict.Check_Restriction, and
kono
parents:
diff changeset
294 -- user specified Restrictions pragmas are ignored, see
kono
parents:
diff changeset
295 -- Sem_Prag.Process_Restrictions_Or_Restriction_Warnings.
kono
parents:
diff changeset
296
kono
parents:
diff changeset
297 Restrict.Restrictions.Set (No_Exception_Registration) := True;
kono
parents:
diff changeset
298 Restrict.Restrictions.Set (No_Initialize_Scalars) := True;
kono
parents:
diff changeset
299 Restrict.Restrictions.Set (No_Task_Hierarchy) := True;
kono
parents:
diff changeset
300 Restrict.Restrictions.Set (No_Abort_Statements) := True;
kono
parents:
diff changeset
301 Restrict.Restrictions.Set (Max_Asynchronous_Select_Nesting) := True;
kono
parents:
diff changeset
302 Restrict.Restrictions.Value (Max_Asynchronous_Select_Nesting) := 0;
kono
parents:
diff changeset
303
kono
parents:
diff changeset
304 -- Enable pragma Ignore_Pragma (Global) to support legacy code. As a
kono
parents:
diff changeset
305 -- consequence, Refined_Global pragma should be ignored as well, as
kono
parents:
diff changeset
306 -- it is only allowed on a body when pragma Global is given for the
kono
parents:
diff changeset
307 -- spec.
kono
parents:
diff changeset
308
kono
parents:
diff changeset
309 Set_Name_Table_Boolean3 (Name_Global, True);
kono
parents:
diff changeset
310 Set_Name_Table_Boolean3 (Name_Refined_Global, True);
kono
parents:
diff changeset
311
kono
parents:
diff changeset
312 -- Suppress division by zero checks since they are handled
kono
parents:
diff changeset
313 -- implicitly by CodePeer.
kono
parents:
diff changeset
314
kono
parents:
diff changeset
315 -- Turn off dynamic elaboration checks: generates inconsistencies in
kono
parents:
diff changeset
316 -- trees between specs compiled as part of a main unit or as part of
kono
parents:
diff changeset
317 -- a with-clause.
kono
parents:
diff changeset
318
kono
parents:
diff changeset
319 -- Turn off alignment checks: these cannot be proved statically by
kono
parents:
diff changeset
320 -- CodePeer and generate false positives.
kono
parents:
diff changeset
321
kono
parents:
diff changeset
322 -- Enable all other language checks
kono
parents:
diff changeset
323
kono
parents:
diff changeset
324 Suppress_Options.Suppress :=
kono
parents:
diff changeset
325 (Alignment_Check => True,
kono
parents:
diff changeset
326 Division_Check => True,
kono
parents:
diff changeset
327 Elaboration_Check => True,
kono
parents:
diff changeset
328 others => False);
kono
parents:
diff changeset
329
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
330 -- Need to enable dynamic elaboration checks to disable strict
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
331 -- static checking performed by gnatbind. We are at the same time
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
332 -- suppressing actual compile time elaboration checks to simplify
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
333 -- the generated code.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
334
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
335 Dynamic_Elaboration_Checks := True;
111
kono
parents:
diff changeset
336
kono
parents:
diff changeset
337 -- Set STRICT mode for overflow checks if not set explicitly. This
kono
parents:
diff changeset
338 -- prevents suppressing of overflow checks by default, in code down
kono
parents:
diff changeset
339 -- below.
kono
parents:
diff changeset
340
kono
parents:
diff changeset
341 if Suppress_Options.Overflow_Mode_General = Not_Set then
kono
parents:
diff changeset
342 Suppress_Options.Overflow_Mode_General := Strict;
kono
parents:
diff changeset
343 Suppress_Options.Overflow_Mode_Assertions := Strict;
kono
parents:
diff changeset
344 end if;
kono
parents:
diff changeset
345
kono
parents:
diff changeset
346 -- CodePeer handles division and overflow checks directly, based on
kono
parents:
diff changeset
347 -- the marks set by the frontend, hence no special expansion should
kono
parents:
diff changeset
348 -- be performed in the frontend for division and overflow checks.
kono
parents:
diff changeset
349
kono
parents:
diff changeset
350 Backend_Divide_Checks_On_Target := True;
kono
parents:
diff changeset
351 Backend_Overflow_Checks_On_Target := True;
kono
parents:
diff changeset
352
kono
parents:
diff changeset
353 -- Kill debug of generated code, since it messes up sloc values
kono
parents:
diff changeset
354
kono
parents:
diff changeset
355 Debug_Generated_Code := False;
kono
parents:
diff changeset
356
kono
parents:
diff changeset
357 -- Ditto for -gnateG which interacts badly with handling of pragma
kono
parents:
diff changeset
358 -- Annotate in gnat2scil.
kono
parents:
diff changeset
359
kono
parents:
diff changeset
360 Generate_Processed_File := False;
kono
parents:
diff changeset
361
kono
parents:
diff changeset
362 -- Disable Exception_Extra_Info (-gnateE) which generates more
kono
parents:
diff changeset
363 -- complex trees with no added value, and may confuse CodePeer.
kono
parents:
diff changeset
364
kono
parents:
diff changeset
365 Exception_Extra_Info := False;
kono
parents:
diff changeset
366
kono
parents:
diff changeset
367 -- Turn cross-referencing on in case it was disabled (e.g. by -gnatD)
kono
parents:
diff changeset
368 -- to support source navigation.
kono
parents:
diff changeset
369
kono
parents:
diff changeset
370 Xref_Active := True;
kono
parents:
diff changeset
371
kono
parents:
diff changeset
372 -- Polling mode forced off, since it generates confusing junk
kono
parents:
diff changeset
373
kono
parents:
diff changeset
374 Polling_Required := False;
kono
parents:
diff changeset
375
kono
parents:
diff changeset
376 -- Set operating mode to Generate_Code to benefit from full front-end
kono
parents:
diff changeset
377 -- expansion (e.g. generics).
kono
parents:
diff changeset
378
kono
parents:
diff changeset
379 Operating_Mode := Generate_Code;
kono
parents:
diff changeset
380
kono
parents:
diff changeset
381 -- We need SCIL generation of course
kono
parents:
diff changeset
382
kono
parents:
diff changeset
383 Generate_SCIL := True;
kono
parents:
diff changeset
384
kono
parents:
diff changeset
385 -- Enable assertions, since they give CodePeer valuable extra info
kono
parents:
diff changeset
386
kono
parents:
diff changeset
387 Assertions_Enabled := True;
kono
parents:
diff changeset
388
kono
parents:
diff changeset
389 -- Set normal RM validity checking and checking of copies (to catch
kono
parents:
diff changeset
390 -- e.g. wrong values used in unchecked conversions).
kono
parents:
diff changeset
391 -- All other validity checking is turned off, since this can generate
kono
parents:
diff changeset
392 -- very complex trees that only confuse CodePeer and do not bring
kono
parents:
diff changeset
393 -- enough useful info.
kono
parents:
diff changeset
394
kono
parents:
diff changeset
395 Reset_Validity_Check_Options;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
396 Set_Validity_Check_Options ("dc");
111
kono
parents:
diff changeset
397 Check_Validity_Of_Parameters := False;
kono
parents:
diff changeset
398
kono
parents:
diff changeset
399 -- Turn off style check options and ignore any style check pragmas
kono
parents:
diff changeset
400 -- since we are not interested in any front-end warnings when we are
kono
parents:
diff changeset
401 -- getting CodePeer output.
kono
parents:
diff changeset
402
kono
parents:
diff changeset
403 Reset_Style_Check_Options;
kono
parents:
diff changeset
404 Ignore_Style_Checks_Pragmas := True;
kono
parents:
diff changeset
405
kono
parents:
diff changeset
406 -- Always perform semantics and generate ali files in CodePeer mode,
kono
parents:
diff changeset
407 -- so that a gnatmake -c -k will proceed further when possible.
kono
parents:
diff changeset
408
kono
parents:
diff changeset
409 Force_ALI_Tree_File := True;
kono
parents:
diff changeset
410 Try_Semantics := True;
kono
parents:
diff changeset
411
kono
parents:
diff changeset
412 -- Make the Ada front end more liberal so that the compiler will
kono
parents:
diff changeset
413 -- allow illegal code that is allowed by other compilers. CodePeer
kono
parents:
diff changeset
414 -- is in the business of finding problems, not enforcing rules.
kono
parents:
diff changeset
415 -- This is useful when using CodePeer mode with other compilers.
kono
parents:
diff changeset
416
kono
parents:
diff changeset
417 Relaxed_RM_Semantics := True;
kono
parents:
diff changeset
418
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
419 if Generate_CodePeer_Messages then
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
420
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
421 -- We do want to emit GNAT warnings when using -gnateC. But,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
422 -- in CodePeer mode, warnings about memory representation are not
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
423 -- meaningful, thus, suppress them.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
424
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
425 Warn_On_Biased_Representation := False; -- -gnatw.b
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
426 Warn_On_Unrepped_Components := False; -- -gnatw.c
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
427 Warn_On_Record_Holes := False; -- -gnatw.h
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
428 Warn_On_Unchecked_Conversion := False; -- -gnatwz
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
429 Warn_On_Size_Alignment := False; -- -gnatw.z
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
430 Warn_On_Questionable_Layout := False; -- -gnatw.q
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
431 Warn_On_Overridden_Size := False; -- -gnatw.s
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
432 Warn_On_Reverse_Bit_Order := False; -- -gnatw.v
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
433
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
434 else
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
435
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
436 -- Suppress compiler warnings by default when generating SCIL for
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
437 -- CodePeer, except when combined with -gnateC where we do want to
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
438 -- emit GNAT warnings.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
439
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
440 Warning_Mode := Suppress;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
441 end if;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
442
111
kono
parents:
diff changeset
443 -- Disable all simple value propagation. This is an optimization
kono
parents:
diff changeset
444 -- which is valuable for code optimization, and also for generation
kono
parents:
diff changeset
445 -- of compiler warnings, but these are being turned off by default,
kono
parents:
diff changeset
446 -- and CodePeer generates better messages (referencing original
kono
parents:
diff changeset
447 -- variables) this way.
kono
parents:
diff changeset
448 -- Do this only if -gnatws is set (the default with -gnatcC), so that
kono
parents:
diff changeset
449 -- if warnings are enabled, we'll get better messages from GNAT.
kono
parents:
diff changeset
450
kono
parents:
diff changeset
451 if Warning_Mode = Suppress then
kono
parents:
diff changeset
452 Debug_Flag_MM := True;
kono
parents:
diff changeset
453 end if;
kono
parents:
diff changeset
454 end if;
kono
parents:
diff changeset
455
kono
parents:
diff changeset
456 -- Enable some individual switches that are implied by relaxed RM
kono
parents:
diff changeset
457 -- semantics mode.
kono
parents:
diff changeset
458
kono
parents:
diff changeset
459 if Relaxed_RM_Semantics then
kono
parents:
diff changeset
460 Opt.Allow_Integer_Address := True;
kono
parents:
diff changeset
461 Overriding_Renamings := True;
kono
parents:
diff changeset
462 Treat_Categorization_Errors_As_Warnings := True;
kono
parents:
diff changeset
463 end if;
kono
parents:
diff changeset
464
kono
parents:
diff changeset
465 -- Enable GNATprove_Mode when using -gnatd.F switch
kono
parents:
diff changeset
466
kono
parents:
diff changeset
467 if Debug_Flag_Dot_FF then
kono
parents:
diff changeset
468 GNATprove_Mode := True;
kono
parents:
diff changeset
469 end if;
kono
parents:
diff changeset
470
kono
parents:
diff changeset
471 -- GNATprove_Mode is also activated by default in the gnat2why
kono
parents:
diff changeset
472 -- executable.
kono
parents:
diff changeset
473
kono
parents:
diff changeset
474 if GNATprove_Mode then
kono
parents:
diff changeset
475
kono
parents:
diff changeset
476 -- Turn off CodePeer mode (which can be set via e.g. -gnatC or
kono
parents:
diff changeset
477 -- -gnateC), not compatible with GNATprove mode.
kono
parents:
diff changeset
478
kono
parents:
diff changeset
479 CodePeer_Mode := False;
kono
parents:
diff changeset
480 Generate_SCIL := False;
kono
parents:
diff changeset
481
kono
parents:
diff changeset
482 -- Turn off C tree generation, not compatible with GNATprove mode. We
kono
parents:
diff changeset
483 -- do not expect this to happen in normal use, since both modes are
kono
parents:
diff changeset
484 -- enabled by special tools, but it is useful to turn off these flags
kono
parents:
diff changeset
485 -- this way when we are doing GNATprove tests on existing test suites
kono
parents:
diff changeset
486 -- that may have -gnateg set, to avoid the need for special casing.
kono
parents:
diff changeset
487
kono
parents:
diff changeset
488 Modify_Tree_For_C := False;
kono
parents:
diff changeset
489 Generate_C_Code := False;
kono
parents:
diff changeset
490 Unnest_Subprogram_Mode := False;
kono
parents:
diff changeset
491
kono
parents:
diff changeset
492 -- Turn off inlining, which would confuse formal verification output
kono
parents:
diff changeset
493 -- and gain nothing.
kono
parents:
diff changeset
494
kono
parents:
diff changeset
495 Front_End_Inlining := False;
kono
parents:
diff changeset
496 Inline_Active := False;
kono
parents:
diff changeset
497
kono
parents:
diff changeset
498 -- Issue warnings for failure to inline subprograms, as otherwise
kono
parents:
diff changeset
499 -- expected in GNATprove mode for the local subprograms without
kono
parents:
diff changeset
500 -- contracts.
kono
parents:
diff changeset
501
kono
parents:
diff changeset
502 Ineffective_Inline_Warnings := True;
kono
parents:
diff changeset
503
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
504 -- Do not issue warnings for possible propagation of exception.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
505 -- GNATprove already issues messages about possible exceptions.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
506
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
507 No_Warn_On_Non_Local_Exception := True;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
508 Warn_On_Non_Local_Exception := False;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
509
111
kono
parents:
diff changeset
510 -- Disable front-end optimizations, to keep the tree as close to the
kono
parents:
diff changeset
511 -- source code as possible, and also to avoid inconsistencies between
kono
parents:
diff changeset
512 -- trees when using different optimization switches.
kono
parents:
diff changeset
513
kono
parents:
diff changeset
514 Optimization_Level := 0;
kono
parents:
diff changeset
515
kono
parents:
diff changeset
516 -- Enable some restrictions systematically to simplify the generated
kono
parents:
diff changeset
517 -- code (and ease analysis).
kono
parents:
diff changeset
518
kono
parents:
diff changeset
519 Restrict.Restrictions.Set (No_Initialize_Scalars) := True;
kono
parents:
diff changeset
520
kono
parents:
diff changeset
521 -- Note: at this point we used to suppress various checks, but that
kono
parents:
diff changeset
522 -- is not what we want. We need the semantic processing for these
kono
parents:
diff changeset
523 -- checks (which will set flags like Do_Overflow_Check, showing the
kono
parents:
diff changeset
524 -- points at which potential checks are required semantically). We
kono
parents:
diff changeset
525 -- don't want the expansion associated with these checks, but that
kono
parents:
diff changeset
526 -- happens anyway because this expansion is simply not done in the
kono
parents:
diff changeset
527 -- SPARK version of the expander.
kono
parents:
diff changeset
528
kono
parents:
diff changeset
529 -- On the contrary, we need to enable explicitly all language checks,
kono
parents:
diff changeset
530 -- as they may have been suppressed by the use of switch -gnatp.
kono
parents:
diff changeset
531
kono
parents:
diff changeset
532 Suppress_Options.Suppress := (others => False);
kono
parents:
diff changeset
533
kono
parents:
diff changeset
534 -- Detect overflow on unconstrained floating-point types, such as
kono
parents:
diff changeset
535 -- the predefined types Float, Long_Float and Long_Long_Float from
kono
parents:
diff changeset
536 -- package Standard. Not necessary if float overflows are checked
kono
parents:
diff changeset
537 -- (Machine_Overflow true), since appropriate Do_Overflow_Check flags
kono
parents:
diff changeset
538 -- will be set in any case.
kono
parents:
diff changeset
539
kono
parents:
diff changeset
540 Check_Float_Overflow := not Machine_Overflows_On_Target;
kono
parents:
diff changeset
541
kono
parents:
diff changeset
542 -- Set STRICT mode for overflow checks if not set explicitly. This
kono
parents:
diff changeset
543 -- prevents suppressing of overflow checks by default, in code down
kono
parents:
diff changeset
544 -- below.
kono
parents:
diff changeset
545
kono
parents:
diff changeset
546 if Suppress_Options.Overflow_Mode_General = Not_Set then
kono
parents:
diff changeset
547 Suppress_Options.Overflow_Mode_General := Strict;
kono
parents:
diff changeset
548 Suppress_Options.Overflow_Mode_Assertions := Strict;
kono
parents:
diff changeset
549 end if;
kono
parents:
diff changeset
550
kono
parents:
diff changeset
551 -- Kill debug of generated code, since it messes up sloc values
kono
parents:
diff changeset
552
kono
parents:
diff changeset
553 Debug_Generated_Code := False;
kono
parents:
diff changeset
554
kono
parents:
diff changeset
555 -- Turn cross-referencing on in case it was disabled (e.g. by -gnatD)
kono
parents:
diff changeset
556 -- as it is needed for computing effects of subprograms in the formal
kono
parents:
diff changeset
557 -- verification backend.
kono
parents:
diff changeset
558
kono
parents:
diff changeset
559 Xref_Active := True;
kono
parents:
diff changeset
560
kono
parents:
diff changeset
561 -- Polling mode forced off, since it generates confusing junk
kono
parents:
diff changeset
562
kono
parents:
diff changeset
563 Polling_Required := False;
kono
parents:
diff changeset
564
kono
parents:
diff changeset
565 -- Set operating mode to Check_Semantics, but a light front-end
kono
parents:
diff changeset
566 -- expansion is still performed.
kono
parents:
diff changeset
567
kono
parents:
diff changeset
568 Operating_Mode := Check_Semantics;
kono
parents:
diff changeset
569
kono
parents:
diff changeset
570 -- Enable assertions, since they give valuable extra information for
kono
parents:
diff changeset
571 -- formal verification.
kono
parents:
diff changeset
572
kono
parents:
diff changeset
573 Assertions_Enabled := True;
kono
parents:
diff changeset
574
kono
parents:
diff changeset
575 -- Disable validity checks, since it generates code raising
kono
parents:
diff changeset
576 -- exceptions for invalid data, which confuses GNATprove. Invalid
kono
parents:
diff changeset
577 -- data is directly detected by GNATprove's flow analysis.
kono
parents:
diff changeset
578
kono
parents:
diff changeset
579 Validity_Checks_On := False;
kono
parents:
diff changeset
580 Check_Validity_Of_Parameters := False;
kono
parents:
diff changeset
581
kono
parents:
diff changeset
582 -- Turn off style check options since we are not interested in any
kono
parents:
diff changeset
583 -- front-end warnings when we are getting SPARK output.
kono
parents:
diff changeset
584
kono
parents:
diff changeset
585 Reset_Style_Check_Options;
kono
parents:
diff changeset
586
kono
parents:
diff changeset
587 -- Suppress the generation of name tables for enumerations, which are
kono
parents:
diff changeset
588 -- not needed for formal verification, and fall outside the SPARK
kono
parents:
diff changeset
589 -- subset (use of pointers).
kono
parents:
diff changeset
590
kono
parents:
diff changeset
591 Global_Discard_Names := True;
kono
parents:
diff changeset
592
kono
parents:
diff changeset
593 -- Suppress the expansion of tagged types and dispatching calls,
kono
parents:
diff changeset
594 -- which lead to the generation of non-SPARK code (use of pointers),
kono
parents:
diff changeset
595 -- which is more complex to formally verify than the original source.
kono
parents:
diff changeset
596
kono
parents:
diff changeset
597 Tagged_Type_Expansion := False;
kono
parents:
diff changeset
598
kono
parents:
diff changeset
599 -- Detect that the runtime library support for floating-point numbers
kono
parents:
diff changeset
600 -- may not be compatible with SPARK analysis of IEEE-754 floats.
kono
parents:
diff changeset
601
kono
parents:
diff changeset
602 if Denorm_On_Target = False then
kono
parents:
diff changeset
603 SPARK_Library_Warning ("float subnormals");
kono
parents:
diff changeset
604
kono
parents:
diff changeset
605 elsif Machine_Rounds_On_Target = False then
kono
parents:
diff changeset
606 SPARK_Library_Warning ("float rounding");
kono
parents:
diff changeset
607
kono
parents:
diff changeset
608 elsif Signed_Zeros_On_Target = False then
kono
parents:
diff changeset
609 SPARK_Library_Warning ("signed zeros");
kono
parents:
diff changeset
610 end if;
kono
parents:
diff changeset
611 end if;
kono
parents:
diff changeset
612
kono
parents:
diff changeset
613 -- Set Configurable_Run_Time mode if system.ads flag set or if the
kono
parents:
diff changeset
614 -- special debug flag -gnatdY is set.
kono
parents:
diff changeset
615
kono
parents:
diff changeset
616 if Targparm.Configurable_Run_Time_On_Target or Debug_Flag_YY then
kono
parents:
diff changeset
617 Configurable_Run_Time_Mode := True;
kono
parents:
diff changeset
618 end if;
kono
parents:
diff changeset
619
kono
parents:
diff changeset
620 -- Set -gnatRm mode if debug flag A set
kono
parents:
diff changeset
621
kono
parents:
diff changeset
622 if Debug_Flag_AA then
kono
parents:
diff changeset
623 Back_Annotate_Rep_Info := True;
kono
parents:
diff changeset
624 List_Representation_Info := 1;
kono
parents:
diff changeset
625 List_Representation_Info_Mechanisms := True;
kono
parents:
diff changeset
626 end if;
kono
parents:
diff changeset
627
kono
parents:
diff changeset
628 -- Force Target_Strict_Alignment true if debug flag -gnatd.a is set
kono
parents:
diff changeset
629
kono
parents:
diff changeset
630 if Debug_Flag_Dot_A then
kono
parents:
diff changeset
631 Ttypes.Target_Strict_Alignment := True;
kono
parents:
diff changeset
632 end if;
kono
parents:
diff changeset
633
kono
parents:
diff changeset
634 -- Increase size of allocated entities if debug flag -gnatd.N is set
kono
parents:
diff changeset
635
kono
parents:
diff changeset
636 if Debug_Flag_Dot_NN then
kono
parents:
diff changeset
637 Atree.Num_Extension_Nodes := Atree.Num_Extension_Nodes + 1;
kono
parents:
diff changeset
638 end if;
kono
parents:
diff changeset
639
kono
parents:
diff changeset
640 -- Disable static allocation of dispatch tables if -gnatd.t is enabled.
kono
parents:
diff changeset
641 -- The front end's layout phase currently treats types that have
kono
parents:
diff changeset
642 -- discriminant-dependent arrays as not being static even when a
kono
parents:
diff changeset
643 -- discriminant constraint on the type is static, and this leads to
kono
parents:
diff changeset
644 -- problems with subtypes of type Ada.Tags.Dispatch_Table_Wrapper. ???
kono
parents:
diff changeset
645
kono
parents:
diff changeset
646 if Debug_Flag_Dot_T then
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
647 Building_Static_Dispatch_Tables := False;
111
kono
parents:
diff changeset
648 end if;
kono
parents:
diff changeset
649
kono
parents:
diff changeset
650 -- Flip endian mode if -gnatd8 set
kono
parents:
diff changeset
651
kono
parents:
diff changeset
652 if Debug_Flag_8 then
kono
parents:
diff changeset
653 Ttypes.Bytes_Big_Endian := not Ttypes.Bytes_Big_Endian;
kono
parents:
diff changeset
654 end if;
kono
parents:
diff changeset
655
kono
parents:
diff changeset
656 -- Set and check exception mechanism. This is only meaningful when
kono
parents:
diff changeset
657 -- compiling, and in particular not meaningful for special modes used
kono
parents:
diff changeset
658 -- for program analysis rather than compilation: ASIS mode, CodePeer
kono
parents:
diff changeset
659 -- mode and GNATprove mode.
kono
parents:
diff changeset
660
kono
parents:
diff changeset
661 if Operating_Mode = Generate_Code
kono
parents:
diff changeset
662 and then not (ASIS_Mode or CodePeer_Mode or GNATprove_Mode)
kono
parents:
diff changeset
663 then
kono
parents:
diff changeset
664 case Targparm.Frontend_Exceptions_On_Target is
kono
parents:
diff changeset
665 when True =>
kono
parents:
diff changeset
666 case Targparm.ZCX_By_Default_On_Target is
kono
parents:
diff changeset
667 when True =>
kono
parents:
diff changeset
668 Write_Line
kono
parents:
diff changeset
669 ("Run-time library configured incorrectly");
kono
parents:
diff changeset
670 Write_Line
kono
parents:
diff changeset
671 ("(requesting support for Frontend ZCX exceptions)");
kono
parents:
diff changeset
672 raise Unrecoverable_Error;
kono
parents:
diff changeset
673
kono
parents:
diff changeset
674 when False =>
kono
parents:
diff changeset
675 Exception_Mechanism := Front_End_SJLJ;
kono
parents:
diff changeset
676 end case;
kono
parents:
diff changeset
677
kono
parents:
diff changeset
678 when False =>
kono
parents:
diff changeset
679 case Targparm.ZCX_By_Default_On_Target is
kono
parents:
diff changeset
680 when True =>
kono
parents:
diff changeset
681 Exception_Mechanism := Back_End_ZCX;
kono
parents:
diff changeset
682 when False =>
kono
parents:
diff changeset
683 Exception_Mechanism := Back_End_SJLJ;
kono
parents:
diff changeset
684 end case;
kono
parents:
diff changeset
685 end case;
kono
parents:
diff changeset
686 end if;
kono
parents:
diff changeset
687
kono
parents:
diff changeset
688 -- Set proper status for overflow check mechanism
kono
parents:
diff changeset
689
kono
parents:
diff changeset
690 -- If already set (by -gnato or above in SPARK or CodePeer mode) then we
kono
parents:
diff changeset
691 -- have nothing to do.
kono
parents:
diff changeset
692
kono
parents:
diff changeset
693 if Opt.Suppress_Options.Overflow_Mode_General /= Not_Set then
kono
parents:
diff changeset
694 null;
kono
parents:
diff changeset
695
kono
parents:
diff changeset
696 -- Otherwise set overflow mode defaults
kono
parents:
diff changeset
697
kono
parents:
diff changeset
698 else
kono
parents:
diff changeset
699 -- Overflow checks are on by default (Suppress set False) except in
kono
parents:
diff changeset
700 -- GNAT_Mode, where we want them off by default (we are not ready to
kono
parents:
diff changeset
701 -- enable overflow checks in the compiler yet, for one thing the case
kono
parents:
diff changeset
702 -- of 64-bit checks needs System.Arith_64 which is not a compiler
kono
parents:
diff changeset
703 -- unit and it is a pain to try to include it in the compiler.
kono
parents:
diff changeset
704
kono
parents:
diff changeset
705 Suppress_Options.Suppress (Overflow_Check) := GNAT_Mode;
kono
parents:
diff changeset
706
kono
parents:
diff changeset
707 -- Set appropriate default overflow handling mode. Note: at present
kono
parents:
diff changeset
708 -- we set STRICT in all three of the following cases. They are
kono
parents:
diff changeset
709 -- separated because in the future we may make different choices.
kono
parents:
diff changeset
710
kono
parents:
diff changeset
711 -- By default set STRICT mode if -gnatg in effect
kono
parents:
diff changeset
712
kono
parents:
diff changeset
713 if GNAT_Mode then
kono
parents:
diff changeset
714 Suppress_Options.Overflow_Mode_General := Strict;
kono
parents:
diff changeset
715 Suppress_Options.Overflow_Mode_Assertions := Strict;
kono
parents:
diff changeset
716
kono
parents:
diff changeset
717 -- If we have backend divide and overflow checks, then by default
kono
parents:
diff changeset
718 -- overflow checks are STRICT. Historically this code used to also
kono
parents:
diff changeset
719 -- activate overflow checks, although no target currently has these
kono
parents:
diff changeset
720 -- flags set, so this was dead code anyway.
kono
parents:
diff changeset
721
kono
parents:
diff changeset
722 elsif Targparm.Backend_Divide_Checks_On_Target
kono
parents:
diff changeset
723 and
kono
parents:
diff changeset
724 Targparm.Backend_Overflow_Checks_On_Target
kono
parents:
diff changeset
725 then
kono
parents:
diff changeset
726 Suppress_Options.Overflow_Mode_General := Strict;
kono
parents:
diff changeset
727 Suppress_Options.Overflow_Mode_Assertions := Strict;
kono
parents:
diff changeset
728
kono
parents:
diff changeset
729 -- Otherwise for now, default is STRICT mode. This may change in the
kono
parents:
diff changeset
730 -- future, but for now this is the compatible behavior with previous
kono
parents:
diff changeset
731 -- versions of GNAT.
kono
parents:
diff changeset
732
kono
parents:
diff changeset
733 else
kono
parents:
diff changeset
734 Suppress_Options.Overflow_Mode_General := Strict;
kono
parents:
diff changeset
735 Suppress_Options.Overflow_Mode_Assertions := Strict;
kono
parents:
diff changeset
736 end if;
kono
parents:
diff changeset
737 end if;
kono
parents:
diff changeset
738
kono
parents:
diff changeset
739 -- Set default for atomic synchronization. As this synchronization
kono
parents:
diff changeset
740 -- between atomic accesses can be expensive, and not typically needed
kono
parents:
diff changeset
741 -- on some targets, an optional target parameter can turn the option
kono
parents:
diff changeset
742 -- off. Note Atomic Synchronization is implemented as check.
kono
parents:
diff changeset
743
kono
parents:
diff changeset
744 Suppress_Options.Suppress (Atomic_Synchronization) :=
kono
parents:
diff changeset
745 not Atomic_Sync_Default_On_Target;
kono
parents:
diff changeset
746
kono
parents:
diff changeset
747 -- Set default for Alignment_Check, if we are on a machine with non-
kono
parents:
diff changeset
748 -- strict alignment, then we suppress this check, since it is over-
kono
parents:
diff changeset
749 -- zealous for such machines.
kono
parents:
diff changeset
750
kono
parents:
diff changeset
751 if not Ttypes.Target_Strict_Alignment then
kono
parents:
diff changeset
752 Suppress_Options.Suppress (Alignment_Check) := True;
kono
parents:
diff changeset
753 end if;
kono
parents:
diff changeset
754
kono
parents:
diff changeset
755 -- Set switch indicating if back end can handle limited types, and
kono
parents:
diff changeset
756 -- guarantee that no incorrect copies are made (e.g. in the context
kono
parents:
diff changeset
757 -- of an if or case expression).
kono
parents:
diff changeset
758
kono
parents:
diff changeset
759 -- Debug flag -gnatd.L decisively sets usage on
kono
parents:
diff changeset
760
kono
parents:
diff changeset
761 if Debug_Flag_Dot_LL then
kono
parents:
diff changeset
762 Back_End_Handles_Limited_Types := True;
kono
parents:
diff changeset
763
kono
parents:
diff changeset
764 -- If no debug flag, usage off for SCIL cases
kono
parents:
diff changeset
765
kono
parents:
diff changeset
766 elsif Generate_SCIL then
kono
parents:
diff changeset
767 Back_End_Handles_Limited_Types := False;
kono
parents:
diff changeset
768
kono
parents:
diff changeset
769 -- Otherwise normal gcc back end, for now still turn flag off by
kono
parents:
diff changeset
770 -- default, since there are unresolved problems in the front end.
kono
parents:
diff changeset
771
kono
parents:
diff changeset
772 else
kono
parents:
diff changeset
773 Back_End_Handles_Limited_Types := False;
kono
parents:
diff changeset
774 end if;
kono
parents:
diff changeset
775
kono
parents:
diff changeset
776 -- If the inlining level has not been set by the user, compute it from
kono
parents:
diff changeset
777 -- the optimization level: 1 at -O1/-O2 (and -Os), 2 at -O3 and above.
kono
parents:
diff changeset
778
kono
parents:
diff changeset
779 if Inline_Level = 0 then
kono
parents:
diff changeset
780 if Optimization_Level < 3 then
kono
parents:
diff changeset
781 Inline_Level := 1;
kono
parents:
diff changeset
782 else
kono
parents:
diff changeset
783 Inline_Level := 2;
kono
parents:
diff changeset
784 end if;
kono
parents:
diff changeset
785 end if;
kono
parents:
diff changeset
786
kono
parents:
diff changeset
787 -- Treat -gnatn as equivalent to -gnatN for non-GCC targets
kono
parents:
diff changeset
788
kono
parents:
diff changeset
789 if Inline_Active and not Front_End_Inlining then
kono
parents:
diff changeset
790
kono
parents:
diff changeset
791 -- We really should have a tag for this, what if we added a new
kono
parents:
diff changeset
792 -- back end some day, it would not be true for this test, but it
kono
parents:
diff changeset
793 -- would be non-GCC, so this is a bit troublesome ???
kono
parents:
diff changeset
794
kono
parents:
diff changeset
795 Front_End_Inlining := Generate_C_Code;
kono
parents:
diff changeset
796 end if;
kono
parents:
diff changeset
797
kono
parents:
diff changeset
798 -- Set back-end inlining indication
kono
parents:
diff changeset
799
kono
parents:
diff changeset
800 Back_End_Inlining :=
kono
parents:
diff changeset
801
kono
parents:
diff changeset
802 -- No back-end inlining available on C generation
kono
parents:
diff changeset
803
kono
parents:
diff changeset
804 not Generate_C_Code
kono
parents:
diff changeset
805
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
806 -- No back-end inlining available in ASIS mode
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
807
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
808 and then not ASIS_Mode
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
809
111
kono
parents:
diff changeset
810 -- No back-end inlining in GNATprove mode, since it just confuses
kono
parents:
diff changeset
811 -- the formal verification process.
kono
parents:
diff changeset
812
kono
parents:
diff changeset
813 and then not GNATprove_Mode
kono
parents:
diff changeset
814
kono
parents:
diff changeset
815 -- No back-end inlining if front-end inlining explicitly enabled.
kono
parents:
diff changeset
816 -- Done to minimize the output differences to customers still using
kono
parents:
diff changeset
817 -- this deprecated switch; in addition, this behavior reduces the
kono
parents:
diff changeset
818 -- output differences in old tests.
kono
parents:
diff changeset
819
kono
parents:
diff changeset
820 and then not Front_End_Inlining
kono
parents:
diff changeset
821
kono
parents:
diff changeset
822 -- Back-end inlining is disabled if debug flag .z is set
kono
parents:
diff changeset
823
kono
parents:
diff changeset
824 and then not Debug_Flag_Dot_Z;
kono
parents:
diff changeset
825
kono
parents:
diff changeset
826 -- Output warning if -gnateE specified and cannot be supported
kono
parents:
diff changeset
827
kono
parents:
diff changeset
828 if Exception_Extra_Info
kono
parents:
diff changeset
829 and then Restrict.No_Exception_Handlers_Set
kono
parents:
diff changeset
830 then
kono
parents:
diff changeset
831 Set_Standard_Error;
kono
parents:
diff changeset
832 Write_Str
kono
parents:
diff changeset
833 ("warning: extra exception information (-gnateE) was specified");
kono
parents:
diff changeset
834 Write_Eol;
kono
parents:
diff changeset
835 Write_Str
kono
parents:
diff changeset
836 ("warning: this capability is not available in this configuration");
kono
parents:
diff changeset
837 Write_Eol;
kono
parents:
diff changeset
838 Set_Standard_Output;
kono
parents:
diff changeset
839 end if;
kono
parents:
diff changeset
840
kono
parents:
diff changeset
841 -- Finally capture adjusted value of Suppress_Options as the initial
kono
parents:
diff changeset
842 -- value for Scope_Suppress, which will be modified as we move from
kono
parents:
diff changeset
843 -- scope to scope (by Suppress/Unsuppress/Overflow_Checks pragmas).
kono
parents:
diff changeset
844
kono
parents:
diff changeset
845 Sem.Scope_Suppress := Opt.Suppress_Options;
kono
parents:
diff changeset
846 end Adjust_Global_Switches;
kono
parents:
diff changeset
847
kono
parents:
diff changeset
848 --------------------
kono
parents:
diff changeset
849 -- Check_Bad_Body --
kono
parents:
diff changeset
850 --------------------
kono
parents:
diff changeset
851
kono
parents:
diff changeset
852 procedure Check_Bad_Body (Unit_Node : Node_Id; Unit_Kind : Node_Kind) is
kono
parents:
diff changeset
853 Fname : File_Name_Type;
kono
parents:
diff changeset
854
kono
parents:
diff changeset
855 procedure Bad_Body_Error (Msg : String);
kono
parents:
diff changeset
856 -- Issue message for bad body found
kono
parents:
diff changeset
857
kono
parents:
diff changeset
858 --------------------
kono
parents:
diff changeset
859 -- Bad_Body_Error --
kono
parents:
diff changeset
860 --------------------
kono
parents:
diff changeset
861
kono
parents:
diff changeset
862 procedure Bad_Body_Error (Msg : String) is
kono
parents:
diff changeset
863 begin
kono
parents:
diff changeset
864 Error_Msg_N (Msg, Unit_Node);
kono
parents:
diff changeset
865 Error_Msg_File_1 := Fname;
kono
parents:
diff changeset
866 Error_Msg_N ("remove incorrect body in file{!", Unit_Node);
kono
parents:
diff changeset
867 end Bad_Body_Error;
kono
parents:
diff changeset
868
kono
parents:
diff changeset
869 -- Local variables
kono
parents:
diff changeset
870
kono
parents:
diff changeset
871 Sname : Unit_Name_Type;
kono
parents:
diff changeset
872 Src_Ind : Source_File_Index;
kono
parents:
diff changeset
873
kono
parents:
diff changeset
874 -- Start of processing for Check_Bad_Body
kono
parents:
diff changeset
875
kono
parents:
diff changeset
876 begin
kono
parents:
diff changeset
877 -- Nothing to do if we are only checking syntax, because we don't know
kono
parents:
diff changeset
878 -- enough to know if we require or forbid a body in this case.
kono
parents:
diff changeset
879
kono
parents:
diff changeset
880 if Operating_Mode = Check_Syntax then
kono
parents:
diff changeset
881 return;
kono
parents:
diff changeset
882 end if;
kono
parents:
diff changeset
883
kono
parents:
diff changeset
884 -- Check for body not allowed
kono
parents:
diff changeset
885
kono
parents:
diff changeset
886 if (Unit_Kind = N_Package_Declaration
kono
parents:
diff changeset
887 and then not Body_Required (Unit_Node))
kono
parents:
diff changeset
888 or else (Unit_Kind = N_Generic_Package_Declaration
kono
parents:
diff changeset
889 and then not Body_Required (Unit_Node))
kono
parents:
diff changeset
890 or else Unit_Kind = N_Package_Renaming_Declaration
kono
parents:
diff changeset
891 or else Unit_Kind = N_Subprogram_Renaming_Declaration
kono
parents:
diff changeset
892 or else Nkind (Original_Node (Unit (Unit_Node)))
kono
parents:
diff changeset
893 in N_Generic_Instantiation
kono
parents:
diff changeset
894 then
kono
parents:
diff changeset
895 Sname := Unit_Name (Main_Unit);
kono
parents:
diff changeset
896
kono
parents:
diff changeset
897 -- If we do not already have a body name, then get the body name
kono
parents:
diff changeset
898
kono
parents:
diff changeset
899 if not Is_Body_Name (Sname) then
kono
parents:
diff changeset
900 Sname := Get_Body_Name (Sname);
kono
parents:
diff changeset
901 end if;
kono
parents:
diff changeset
902
kono
parents:
diff changeset
903 Fname := Get_File_Name (Sname, Subunit => False);
kono
parents:
diff changeset
904 Src_Ind := Load_Source_File (Fname);
kono
parents:
diff changeset
905
kono
parents:
diff changeset
906 -- Case where body is present and it is not a subunit. Exclude the
kono
parents:
diff changeset
907 -- subunit case, because it has nothing to do with the package we are
kono
parents:
diff changeset
908 -- compiling. It is illegal for a child unit and a subunit with the
kono
parents:
diff changeset
909 -- same expanded name (RM 10.2(9)) to appear together in a partition,
kono
parents:
diff changeset
910 -- but there is nothing to stop a compilation environment from having
kono
parents:
diff changeset
911 -- both, and the test here simply allows that. If there is an attempt
kono
parents:
diff changeset
912 -- to include both in a partition, this is diagnosed at bind time. In
kono
parents:
diff changeset
913 -- Ada 83 mode this is not a warning case.
kono
parents:
diff changeset
914
kono
parents:
diff changeset
915 -- Note that in general we do not give the message if the file in
kono
parents:
diff changeset
916 -- question does not look like a body. This includes weird cases,
kono
parents:
diff changeset
917 -- but in particular means that if the file is just a No_Body pragma,
kono
parents:
diff changeset
918 -- then we won't give the message (that's the whole point of this
kono
parents:
diff changeset
919 -- pragma, to be used this way and to cause the body file to be
kono
parents:
diff changeset
920 -- ignored in this context).
kono
parents:
diff changeset
921
kono
parents:
diff changeset
922 if Src_Ind > No_Source_File
kono
parents:
diff changeset
923 and then Source_File_Is_Body (Src_Ind)
kono
parents:
diff changeset
924 then
kono
parents:
diff changeset
925 Errout.Finalize (Last_Call => False);
kono
parents:
diff changeset
926
kono
parents:
diff changeset
927 Error_Msg_Unit_1 := Sname;
kono
parents:
diff changeset
928
kono
parents:
diff changeset
929 -- Ada 83 case of a package body being ignored. This is not an
kono
parents:
diff changeset
930 -- error as far as the Ada 83 RM is concerned, but it is almost
kono
parents:
diff changeset
931 -- certainly not what is wanted so output a warning. Give this
kono
parents:
diff changeset
932 -- message only if there were no errors, since otherwise it may
kono
parents:
diff changeset
933 -- be incorrect (we may have misinterpreted a junk spec as not
kono
parents:
diff changeset
934 -- needing a body when it really does).
kono
parents:
diff changeset
935
kono
parents:
diff changeset
936 if Unit_Kind = N_Package_Declaration
kono
parents:
diff changeset
937 and then Ada_Version = Ada_83
kono
parents:
diff changeset
938 and then Operating_Mode = Generate_Code
kono
parents:
diff changeset
939 and then Distribution_Stub_Mode /= Generate_Caller_Stub_Body
kono
parents:
diff changeset
940 and then not Compilation_Errors
kono
parents:
diff changeset
941 then
kono
parents:
diff changeset
942 Error_Msg_N
kono
parents:
diff changeset
943 ("package $$ does not require a body??", Unit_Node);
kono
parents:
diff changeset
944 Error_Msg_File_1 := Fname;
kono
parents:
diff changeset
945 Error_Msg_N ("body in file{ will be ignored??", Unit_Node);
kono
parents:
diff changeset
946
kono
parents:
diff changeset
947 -- Ada 95 cases of a body file present when no body is
kono
parents:
diff changeset
948 -- permitted. This we consider to be an error.
kono
parents:
diff changeset
949
kono
parents:
diff changeset
950 else
kono
parents:
diff changeset
951 -- For generic instantiations, we never allow a body
kono
parents:
diff changeset
952
kono
parents:
diff changeset
953 if Nkind (Original_Node (Unit (Unit_Node))) in
kono
parents:
diff changeset
954 N_Generic_Instantiation
kono
parents:
diff changeset
955 then
kono
parents:
diff changeset
956 Bad_Body_Error
kono
parents:
diff changeset
957 ("generic instantiation for $$ does not allow a body");
kono
parents:
diff changeset
958
kono
parents:
diff changeset
959 -- A library unit that is a renaming never allows a body
kono
parents:
diff changeset
960
kono
parents:
diff changeset
961 elsif Unit_Kind in N_Renaming_Declaration then
kono
parents:
diff changeset
962 Bad_Body_Error
kono
parents:
diff changeset
963 ("renaming declaration for $$ does not allow a body!");
kono
parents:
diff changeset
964
kono
parents:
diff changeset
965 -- Remaining cases are packages and generic packages. Here
kono
parents:
diff changeset
966 -- we only do the test if there are no previous errors,
kono
parents:
diff changeset
967 -- because if there are errors, they may lead us to
kono
parents:
diff changeset
968 -- incorrectly believe that a package does not allow a
kono
parents:
diff changeset
969 -- body when in fact it does.
kono
parents:
diff changeset
970
kono
parents:
diff changeset
971 elsif not Compilation_Errors then
kono
parents:
diff changeset
972 if Unit_Kind = N_Package_Declaration then
kono
parents:
diff changeset
973 Bad_Body_Error
kono
parents:
diff changeset
974 ("package $$ does not allow a body!");
kono
parents:
diff changeset
975
kono
parents:
diff changeset
976 elsif Unit_Kind = N_Generic_Package_Declaration then
kono
parents:
diff changeset
977 Bad_Body_Error
kono
parents:
diff changeset
978 ("generic package $$ does not allow a body!");
kono
parents:
diff changeset
979 end if;
kono
parents:
diff changeset
980 end if;
kono
parents:
diff changeset
981
kono
parents:
diff changeset
982 end if;
kono
parents:
diff changeset
983 end if;
kono
parents:
diff changeset
984 end if;
kono
parents:
diff changeset
985 end Check_Bad_Body;
kono
parents:
diff changeset
986
kono
parents:
diff changeset
987 --------------------
kono
parents:
diff changeset
988 -- Check_Rep_Info --
kono
parents:
diff changeset
989 --------------------
kono
parents:
diff changeset
990
kono
parents:
diff changeset
991 procedure Check_Rep_Info is
kono
parents:
diff changeset
992 begin
kono
parents:
diff changeset
993 if List_Representation_Info /= 0
kono
parents:
diff changeset
994 or else List_Representation_Info_Mechanisms
kono
parents:
diff changeset
995 then
kono
parents:
diff changeset
996 Set_Standard_Error;
kono
parents:
diff changeset
997 Write_Eol;
kono
parents:
diff changeset
998 Write_Str
kono
parents:
diff changeset
999 ("cannot generate representation information, no code generated");
kono
parents:
diff changeset
1000 Write_Eol;
kono
parents:
diff changeset
1001 Write_Eol;
kono
parents:
diff changeset
1002 Set_Standard_Output;
kono
parents:
diff changeset
1003 end if;
kono
parents:
diff changeset
1004 end Check_Rep_Info;
kono
parents:
diff changeset
1005
kono
parents:
diff changeset
1006 ----------------------------------------
kono
parents:
diff changeset
1007 -- Post_Compilation_Validation_Checks --
kono
parents:
diff changeset
1008 ----------------------------------------
kono
parents:
diff changeset
1009
kono
parents:
diff changeset
1010 procedure Post_Compilation_Validation_Checks is
kono
parents:
diff changeset
1011 begin
kono
parents:
diff changeset
1012 -- Validate alignment check warnings. In some cases we generate warnings
kono
parents:
diff changeset
1013 -- about possible alignment errors because we don't know the alignment
kono
parents:
diff changeset
1014 -- that will be chosen by the back end. This routine is in charge of
kono
parents:
diff changeset
1015 -- getting rid of those warnings if we can tell they are not needed.
kono
parents:
diff changeset
1016
kono
parents:
diff changeset
1017 Checks.Validate_Alignment_Check_Warnings;
kono
parents:
diff changeset
1018
kono
parents:
diff changeset
1019 -- Validate compile time warnings and errors (using the values for size
kono
parents:
diff changeset
1020 -- and alignment annotated by the backend where possible). We need to
kono
parents:
diff changeset
1021 -- unlock temporarily these tables to reanalyze their expression.
kono
parents:
diff changeset
1022
kono
parents:
diff changeset
1023 Atree.Unlock;
kono
parents:
diff changeset
1024 Nlists.Unlock;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1025 Elists.Unlock;
111
kono
parents:
diff changeset
1026 Sem.Unlock;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1027 Sem_Prag.Validate_Compile_Time_Warning_Errors;
111
kono
parents:
diff changeset
1028 Sem.Lock;
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1029 Elists.Lock;
111
kono
parents:
diff changeset
1030 Nlists.Lock;
kono
parents:
diff changeset
1031 Atree.Lock;
kono
parents:
diff changeset
1032
kono
parents:
diff changeset
1033 -- Validate unchecked conversions (using the values for size and
kono
parents:
diff changeset
1034 -- alignment annotated by the backend where possible).
kono
parents:
diff changeset
1035
kono
parents:
diff changeset
1036 Sem_Ch13.Validate_Unchecked_Conversions;
kono
parents:
diff changeset
1037
kono
parents:
diff changeset
1038 -- Validate address clauses (again using alignment values annotated
kono
parents:
diff changeset
1039 -- by the backend where possible).
kono
parents:
diff changeset
1040
kono
parents:
diff changeset
1041 Sem_Ch13.Validate_Address_Clauses;
kono
parents:
diff changeset
1042
kono
parents:
diff changeset
1043 -- Validate independence pragmas (again using values annotated by the
kono
parents:
diff changeset
1044 -- back end for component layout where possible) but only for non-GCC
kono
parents:
diff changeset
1045 -- back ends, as this is done a priori for GCC back ends.
kono
parents:
diff changeset
1046 -- ??? We use to test for AAMP_On_Target which is now gone, consider
kono
parents:
diff changeset
1047 --
kono
parents:
diff changeset
1048 -- if AAMP_On_Target then
kono
parents:
diff changeset
1049 -- Sem_Ch13.Validate_Independence;
kono
parents:
diff changeset
1050 -- end if;
kono
parents:
diff changeset
1051 end Post_Compilation_Validation_Checks;
kono
parents:
diff changeset
1052
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1053 -----------------------------------
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1054 -- Read_JSON_Files_For_Repinfo --
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1055 -----------------------------------
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1056
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1057 procedure Read_JSON_Files_For_Repinfo is
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1058 begin
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1059 -- This is the same loop construct as in Repinfo.List_Rep_Info
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1060
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1061 for U in Main_Unit .. Last_Unit loop
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1062 if In_Extended_Main_Source_Unit (Cunit_Entity (U)) then
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1063 declare
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1064 Nam : constant String :=
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1065 Get_Name_String
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1066 (File_Name (Source_Index (U))) & ".json";
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1067 Namid : constant File_Name_Type := Name_Enter (Nam);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1068 Index : constant Source_File_Index := Load_Config_File (Namid);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1069
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1070 begin
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1071 if Index = No_Source_File then
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1072 Write_Str ("cannot locate ");
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1073 Write_Line (Nam);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1074 raise Unrecoverable_Error;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1075 end if;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1076
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1077 Repinfo.Input.Read_JSON_Stream (Source_Text (Index).all, Nam);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1078 exception
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1079 when Repinfo.Input.Invalid_JSON_Stream =>
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1080 raise Unrecoverable_Error;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1081 end;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1082 end if;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1083 end loop;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1084 end Read_JSON_Files_For_Repinfo;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1085
111
kono
parents:
diff changeset
1086 -- Local variables
kono
parents:
diff changeset
1087
kono
parents:
diff changeset
1088 Back_End_Mode : Back_End.Back_End_Mode_Type;
kono
parents:
diff changeset
1089 Ecode : Exit_Code_Type;
kono
parents:
diff changeset
1090
kono
parents:
diff changeset
1091 Main_Unit_Kind : Node_Kind;
kono
parents:
diff changeset
1092 -- Kind of main compilation unit node
kono
parents:
diff changeset
1093
kono
parents:
diff changeset
1094 Main_Unit_Node : Node_Id;
kono
parents:
diff changeset
1095 -- Compilation unit node for main unit
kono
parents:
diff changeset
1096
kono
parents:
diff changeset
1097 -- Start of processing for Gnat1drv
kono
parents:
diff changeset
1098
kono
parents:
diff changeset
1099 begin
kono
parents:
diff changeset
1100 -- This inner block is set up to catch assertion errors and constraint
kono
parents:
diff changeset
1101 -- errors. Since the code for handling these errors can cause another
kono
parents:
diff changeset
1102 -- exception to be raised (namely Unrecoverable_Error), we need two
kono
parents:
diff changeset
1103 -- nested blocks, so that the outer one handles unrecoverable error.
kono
parents:
diff changeset
1104
kono
parents:
diff changeset
1105 begin
kono
parents:
diff changeset
1106 -- Initialize all packages. For the most part, these initialization
kono
parents:
diff changeset
1107 -- calls can be made in any order. Exceptions are as follows:
kono
parents:
diff changeset
1108
kono
parents:
diff changeset
1109 -- Lib.Initialize need to be called before Scan_Compiler_Arguments,
kono
parents:
diff changeset
1110 -- because it initializes a table filled by Scan_Compiler_Arguments.
kono
parents:
diff changeset
1111
kono
parents:
diff changeset
1112 Osint.Initialize;
kono
parents:
diff changeset
1113 Fmap.Reset_Tables;
kono
parents:
diff changeset
1114 Lib.Initialize;
kono
parents:
diff changeset
1115 Lib.Xref.Initialize;
kono
parents:
diff changeset
1116 Scan_Compiler_Arguments;
kono
parents:
diff changeset
1117 Osint.Add_Default_Search_Dirs;
kono
parents:
diff changeset
1118 Atree.Initialize;
kono
parents:
diff changeset
1119 Nlists.Initialize;
kono
parents:
diff changeset
1120 Sinput.Initialize;
kono
parents:
diff changeset
1121 Sem.Initialize;
kono
parents:
diff changeset
1122 Exp_CG.Initialize;
kono
parents:
diff changeset
1123 Csets.Initialize;
kono
parents:
diff changeset
1124 Uintp.Initialize;
kono
parents:
diff changeset
1125 Urealp.Initialize;
kono
parents:
diff changeset
1126 Errout.Initialize;
kono
parents:
diff changeset
1127 SCOs.Initialize;
kono
parents:
diff changeset
1128 Snames.Initialize;
kono
parents:
diff changeset
1129 Stringt.Initialize;
kono
parents:
diff changeset
1130 Ghost.Initialize;
kono
parents:
diff changeset
1131 Inline.Initialize;
kono
parents:
diff changeset
1132 Par_SCO.Initialize;
kono
parents:
diff changeset
1133 Sem_Ch8.Initialize;
kono
parents:
diff changeset
1134 Sem_Ch12.Initialize;
kono
parents:
diff changeset
1135 Sem_Ch13.Initialize;
kono
parents:
diff changeset
1136 Sem_Elim.Initialize;
kono
parents:
diff changeset
1137 Sem_Eval.Initialize;
kono
parents:
diff changeset
1138 Sem_Type.Init_Interp_Tables;
kono
parents:
diff changeset
1139
kono
parents:
diff changeset
1140 -- Capture compilation date and time
kono
parents:
diff changeset
1141
kono
parents:
diff changeset
1142 Opt.Compilation_Time := System.OS_Lib.Current_Time_String;
kono
parents:
diff changeset
1143
kono
parents:
diff changeset
1144 -- Get the target parameters only when -gnats is not used, to avoid
kono
parents:
diff changeset
1145 -- failing when there is no default runtime.
kono
parents:
diff changeset
1146
kono
parents:
diff changeset
1147 if Operating_Mode /= Check_Syntax then
kono
parents:
diff changeset
1148
kono
parents:
diff changeset
1149 -- Acquire target parameters from system.ads (package System source)
kono
parents:
diff changeset
1150
kono
parents:
diff changeset
1151 Targparm_Acquire : declare
kono
parents:
diff changeset
1152
kono
parents:
diff changeset
1153 S : Source_File_Index;
kono
parents:
diff changeset
1154 N : File_Name_Type;
kono
parents:
diff changeset
1155
kono
parents:
diff changeset
1156 begin
kono
parents:
diff changeset
1157 Name_Buffer (1 .. 10) := "system.ads";
kono
parents:
diff changeset
1158 Name_Len := 10;
kono
parents:
diff changeset
1159 N := Name_Find;
kono
parents:
diff changeset
1160 S := Load_Source_File (N);
kono
parents:
diff changeset
1161
kono
parents:
diff changeset
1162 -- Failed to read system.ads, fatal error
kono
parents:
diff changeset
1163
kono
parents:
diff changeset
1164 if S = No_Source_File then
kono
parents:
diff changeset
1165 Write_Line
kono
parents:
diff changeset
1166 ("fatal error, run-time library not installed correctly");
kono
parents:
diff changeset
1167 Write_Line ("cannot locate file system.ads");
kono
parents:
diff changeset
1168 raise Unrecoverable_Error;
kono
parents:
diff changeset
1169
kono
parents:
diff changeset
1170 elsif S = No_Access_To_Source_File then
kono
parents:
diff changeset
1171 Write_Line
kono
parents:
diff changeset
1172 ("fatal error, run-time library not installed correctly");
kono
parents:
diff changeset
1173 Write_Line ("no read access for file system.ads");
kono
parents:
diff changeset
1174 raise Unrecoverable_Error;
kono
parents:
diff changeset
1175
kono
parents:
diff changeset
1176 -- Read system.ads successfully, remember its source index
kono
parents:
diff changeset
1177
kono
parents:
diff changeset
1178 else
kono
parents:
diff changeset
1179 System_Source_File_Index := S;
kono
parents:
diff changeset
1180 end if;
kono
parents:
diff changeset
1181
kono
parents:
diff changeset
1182 -- Call to get target parameters. Note that the actual interface
kono
parents:
diff changeset
1183 -- routines are in Tbuild. They can't be in this procedure because
kono
parents:
diff changeset
1184 -- of accessibility issues.
kono
parents:
diff changeset
1185
kono
parents:
diff changeset
1186 Targparm.Get_Target_Parameters
kono
parents:
diff changeset
1187 (System_Text => Source_Text (S),
kono
parents:
diff changeset
1188 Source_First => Source_First (S),
kono
parents:
diff changeset
1189 Source_Last => Source_Last (S),
kono
parents:
diff changeset
1190 Make_Id => Tbuild.Make_Id'Access,
kono
parents:
diff changeset
1191 Make_SC => Tbuild.Make_SC'Access,
kono
parents:
diff changeset
1192 Set_NOD => Tbuild.Set_NOD'Access,
kono
parents:
diff changeset
1193 Set_NSA => Tbuild.Set_NSA'Access,
kono
parents:
diff changeset
1194 Set_NUA => Tbuild.Set_NUA'Access,
kono
parents:
diff changeset
1195 Set_NUP => Tbuild.Set_NUP'Access);
kono
parents:
diff changeset
1196
kono
parents:
diff changeset
1197 -- Acquire configuration pragma information from Targparm
kono
parents:
diff changeset
1198
kono
parents:
diff changeset
1199 Restrict.Restrictions := Targparm.Restrictions_On_Target;
kono
parents:
diff changeset
1200 end Targparm_Acquire;
kono
parents:
diff changeset
1201 end if;
kono
parents:
diff changeset
1202
kono
parents:
diff changeset
1203 -- Perform various adjustments and settings of global switches
kono
parents:
diff changeset
1204
kono
parents:
diff changeset
1205 Adjust_Global_Switches;
kono
parents:
diff changeset
1206
kono
parents:
diff changeset
1207 -- Output copyright notice if full list mode unless we have a list
kono
parents:
diff changeset
1208 -- file, in which case we defer this so that it is output in the file.
kono
parents:
diff changeset
1209
kono
parents:
diff changeset
1210 if (Verbose_Mode or else (Full_List and then Full_List_File_Name = null))
kono
parents:
diff changeset
1211
kono
parents:
diff changeset
1212 -- Debug flag gnatd7 suppresses this copyright notice
kono
parents:
diff changeset
1213
kono
parents:
diff changeset
1214 and then not Debug_Flag_7
kono
parents:
diff changeset
1215 then
kono
parents:
diff changeset
1216 Write_Eol;
kono
parents:
diff changeset
1217 Write_Str ("GNAT ");
kono
parents:
diff changeset
1218 Write_Str (Gnat_Version_String);
kono
parents:
diff changeset
1219 Write_Eol;
kono
parents:
diff changeset
1220 Write_Str ("Copyright 1992-" & Current_Year
kono
parents:
diff changeset
1221 & ", Free Software Foundation, Inc.");
kono
parents:
diff changeset
1222 Write_Eol;
kono
parents:
diff changeset
1223 end if;
kono
parents:
diff changeset
1224
kono
parents:
diff changeset
1225 -- Check we do not have more than one source file, this happens only in
kono
parents:
diff changeset
1226 -- the case where the driver is called directly, it cannot happen when
kono
parents:
diff changeset
1227 -- gnat1 is invoked from gcc in the normal case.
kono
parents:
diff changeset
1228
kono
parents:
diff changeset
1229 if Osint.Number_Of_Files /= 1 then
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1230
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1231 -- In GNATprove mode, gcc is not called, so we may end up with
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1232 -- switches wrongly interpreted as source file names when they are
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1233 -- written by mistake without a starting hyphen. Issue a specific
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1234 -- error message but do not print the internal 'usage' message.
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1235
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1236 if GNATprove_Mode then
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1237 Write_Str
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1238 ("one of the following is not a valid switch or source file "
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1239 & "name: ");
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1240 Osint.Dump_Command_Line_Source_File_Names;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1241 else
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1242 Usage;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1243 Write_Eol;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1244 end if;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1245
111
kono
parents:
diff changeset
1246 Osint.Fail ("you must provide one source file");
kono
parents:
diff changeset
1247
kono
parents:
diff changeset
1248 elsif Usage_Requested then
kono
parents:
diff changeset
1249 Usage;
kono
parents:
diff changeset
1250 end if;
kono
parents:
diff changeset
1251
kono
parents:
diff changeset
1252 -- Generate target dependent output file if requested
kono
parents:
diff changeset
1253
kono
parents:
diff changeset
1254 if Target_Dependent_Info_Write_Name /= null then
kono
parents:
diff changeset
1255 Set_Targ.Write_Target_Dependent_Values;
kono
parents:
diff changeset
1256 end if;
kono
parents:
diff changeset
1257
kono
parents:
diff changeset
1258 -- Call the front end
kono
parents:
diff changeset
1259
kono
parents:
diff changeset
1260 Original_Operating_Mode := Operating_Mode;
kono
parents:
diff changeset
1261 Frontend;
kono
parents:
diff changeset
1262
kono
parents:
diff changeset
1263 -- Exit with errors if the main source could not be parsed
kono
parents:
diff changeset
1264
kono
parents:
diff changeset
1265 if Sinput.Main_Source_File <= No_Source_File then
kono
parents:
diff changeset
1266 Errout.Finalize (Last_Call => True);
kono
parents:
diff changeset
1267 Errout.Output_Messages;
kono
parents:
diff changeset
1268 Exit_Program (E_Errors);
kono
parents:
diff changeset
1269 end if;
kono
parents:
diff changeset
1270
kono
parents:
diff changeset
1271 Main_Unit_Node := Cunit (Main_Unit);
kono
parents:
diff changeset
1272 Main_Unit_Kind := Nkind (Unit (Main_Unit_Node));
kono
parents:
diff changeset
1273
kono
parents:
diff changeset
1274 Check_Bad_Body (Main_Unit_Node, Main_Unit_Kind);
kono
parents:
diff changeset
1275
kono
parents:
diff changeset
1276 -- In CodePeer mode we always delete old SCIL files before regenerating
kono
parents:
diff changeset
1277 -- new ones, in case of e.g. errors, and also to remove obsolete scilx
kono
parents:
diff changeset
1278 -- files generated by CodePeer itself.
kono
parents:
diff changeset
1279
kono
parents:
diff changeset
1280 if CodePeer_Mode then
kono
parents:
diff changeset
1281 Comperr.Delete_SCIL_Files;
kono
parents:
diff changeset
1282 end if;
kono
parents:
diff changeset
1283
kono
parents:
diff changeset
1284 -- Ditto for old C files before regenerating new ones
kono
parents:
diff changeset
1285
kono
parents:
diff changeset
1286 if Generate_C_Code then
kono
parents:
diff changeset
1287 Delete_C_File;
kono
parents:
diff changeset
1288 Delete_H_File;
kono
parents:
diff changeset
1289 end if;
kono
parents:
diff changeset
1290
kono
parents:
diff changeset
1291 -- Exit if compilation errors detected
kono
parents:
diff changeset
1292
kono
parents:
diff changeset
1293 Errout.Finalize (Last_Call => False);
kono
parents:
diff changeset
1294
kono
parents:
diff changeset
1295 if Compilation_Errors then
kono
parents:
diff changeset
1296 Treepr.Tree_Dump;
kono
parents:
diff changeset
1297 Post_Compilation_Validation_Checks;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1298 Errout.Finalize (Last_Call => True);
111
kono
parents:
diff changeset
1299 Errout.Output_Messages;
kono
parents:
diff changeset
1300 Namet.Finalize;
kono
parents:
diff changeset
1301
kono
parents:
diff changeset
1302 -- Generate ALI file if specially requested
kono
parents:
diff changeset
1303
kono
parents:
diff changeset
1304 if Opt.Force_ALI_Tree_File then
kono
parents:
diff changeset
1305 Write_ALI (Object => False);
kono
parents:
diff changeset
1306 Tree_Gen;
kono
parents:
diff changeset
1307 end if;
kono
parents:
diff changeset
1308
kono
parents:
diff changeset
1309 Exit_Program (E_Errors);
kono
parents:
diff changeset
1310 end if;
kono
parents:
diff changeset
1311
kono
parents:
diff changeset
1312 -- Set Generate_Code on main unit and its spec. We do this even if are
kono
parents:
diff changeset
1313 -- not generating code, since Lib-Writ uses this to determine which
kono
parents:
diff changeset
1314 -- units get written in the ali file.
kono
parents:
diff changeset
1315
kono
parents:
diff changeset
1316 Set_Generate_Code (Main_Unit);
kono
parents:
diff changeset
1317
kono
parents:
diff changeset
1318 -- If we have a corresponding spec, and it comes from source or it is
kono
parents:
diff changeset
1319 -- not a generated spec for a child subprogram body, then we need object
kono
parents:
diff changeset
1320 -- code for the spec unit as well.
kono
parents:
diff changeset
1321
kono
parents:
diff changeset
1322 if Nkind (Unit (Main_Unit_Node)) in N_Unit_Body
kono
parents:
diff changeset
1323 and then not Acts_As_Spec (Main_Unit_Node)
kono
parents:
diff changeset
1324 then
kono
parents:
diff changeset
1325 if Nkind (Unit (Main_Unit_Node)) = N_Subprogram_Body
kono
parents:
diff changeset
1326 and then not Comes_From_Source (Library_Unit (Main_Unit_Node))
kono
parents:
diff changeset
1327 then
kono
parents:
diff changeset
1328 null;
kono
parents:
diff changeset
1329 else
kono
parents:
diff changeset
1330 Set_Generate_Code
kono
parents:
diff changeset
1331 (Get_Cunit_Unit_Number (Library_Unit (Main_Unit_Node)));
kono
parents:
diff changeset
1332 end if;
kono
parents:
diff changeset
1333 end if;
kono
parents:
diff changeset
1334
kono
parents:
diff changeset
1335 -- Case of no code required to be generated, exit indicating no error
kono
parents:
diff changeset
1336
kono
parents:
diff changeset
1337 if Original_Operating_Mode = Check_Syntax then
kono
parents:
diff changeset
1338 Treepr.Tree_Dump;
kono
parents:
diff changeset
1339 Errout.Finalize (Last_Call => True);
kono
parents:
diff changeset
1340 Errout.Output_Messages;
kono
parents:
diff changeset
1341 Tree_Gen;
kono
parents:
diff changeset
1342 Namet.Finalize;
kono
parents:
diff changeset
1343 Check_Rep_Info;
kono
parents:
diff changeset
1344
kono
parents:
diff changeset
1345 -- Use a goto instead of calling Exit_Program so that finalization
kono
parents:
diff changeset
1346 -- occurs normally.
kono
parents:
diff changeset
1347
kono
parents:
diff changeset
1348 goto End_Of_Program;
kono
parents:
diff changeset
1349
kono
parents:
diff changeset
1350 elsif Original_Operating_Mode = Check_Semantics then
kono
parents:
diff changeset
1351 Back_End_Mode := Declarations_Only;
kono
parents:
diff changeset
1352
kono
parents:
diff changeset
1353 -- All remaining cases are cases in which the user requested that code
kono
parents:
diff changeset
1354 -- be generated (i.e. no -gnatc or -gnats switch was used). Check if we
kono
parents:
diff changeset
1355 -- can in fact satisfy this request.
kono
parents:
diff changeset
1356
kono
parents:
diff changeset
1357 -- Cannot generate code if someone has turned off code generation for
kono
parents:
diff changeset
1358 -- any reason at all. We will try to figure out a reason below.
kono
parents:
diff changeset
1359
kono
parents:
diff changeset
1360 elsif Operating_Mode /= Generate_Code then
kono
parents:
diff changeset
1361 Back_End_Mode := Skip;
kono
parents:
diff changeset
1362
kono
parents:
diff changeset
1363 -- We can generate code for a subprogram body unless there were missing
kono
parents:
diff changeset
1364 -- subunits. Note that we always generate code for all generic units (a
kono
parents:
diff changeset
1365 -- change from some previous versions of GNAT).
kono
parents:
diff changeset
1366
kono
parents:
diff changeset
1367 elsif Main_Unit_Kind = N_Subprogram_Body
kono
parents:
diff changeset
1368 and then not Subunits_Missing
kono
parents:
diff changeset
1369 then
kono
parents:
diff changeset
1370 Back_End_Mode := Generate_Object;
kono
parents:
diff changeset
1371
kono
parents:
diff changeset
1372 -- We can generate code for a package body unless there are subunits
kono
parents:
diff changeset
1373 -- missing (note that we always generate code for generic units, which
kono
parents:
diff changeset
1374 -- is a change from some earlier versions of GNAT).
kono
parents:
diff changeset
1375
kono
parents:
diff changeset
1376 elsif Main_Unit_Kind = N_Package_Body and then not Subunits_Missing then
kono
parents:
diff changeset
1377 Back_End_Mode := Generate_Object;
kono
parents:
diff changeset
1378
kono
parents:
diff changeset
1379 -- We can generate code for a package declaration or a subprogram
kono
parents:
diff changeset
1380 -- declaration only if it does not required a body.
kono
parents:
diff changeset
1381
kono
parents:
diff changeset
1382 elsif Nkind_In (Main_Unit_Kind, N_Package_Declaration,
kono
parents:
diff changeset
1383 N_Subprogram_Declaration)
kono
parents:
diff changeset
1384 and then
kono
parents:
diff changeset
1385 (not Body_Required (Main_Unit_Node)
kono
parents:
diff changeset
1386 or else Distribution_Stub_Mode = Generate_Caller_Stub_Body)
kono
parents:
diff changeset
1387 then
kono
parents:
diff changeset
1388 Back_End_Mode := Generate_Object;
kono
parents:
diff changeset
1389
kono
parents:
diff changeset
1390 -- We can generate code for a generic package declaration of a generic
kono
parents:
diff changeset
1391 -- subprogram declaration only if does not require a body.
kono
parents:
diff changeset
1392
kono
parents:
diff changeset
1393 elsif Nkind_In (Main_Unit_Kind, N_Generic_Package_Declaration,
kono
parents:
diff changeset
1394 N_Generic_Subprogram_Declaration)
kono
parents:
diff changeset
1395 and then not Body_Required (Main_Unit_Node)
kono
parents:
diff changeset
1396 then
kono
parents:
diff changeset
1397 Back_End_Mode := Generate_Object;
kono
parents:
diff changeset
1398
kono
parents:
diff changeset
1399 -- Compilation units that are renamings do not require bodies, so we can
kono
parents:
diff changeset
1400 -- generate code for them.
kono
parents:
diff changeset
1401
kono
parents:
diff changeset
1402 elsif Nkind_In (Main_Unit_Kind, N_Package_Renaming_Declaration,
kono
parents:
diff changeset
1403 N_Subprogram_Renaming_Declaration)
kono
parents:
diff changeset
1404 then
kono
parents:
diff changeset
1405 Back_End_Mode := Generate_Object;
kono
parents:
diff changeset
1406
kono
parents:
diff changeset
1407 -- Compilation units that are generic renamings do not require bodies
kono
parents:
diff changeset
1408 -- so we can generate code for them.
kono
parents:
diff changeset
1409
kono
parents:
diff changeset
1410 elsif Main_Unit_Kind in N_Generic_Renaming_Declaration then
kono
parents:
diff changeset
1411 Back_End_Mode := Generate_Object;
kono
parents:
diff changeset
1412
kono
parents:
diff changeset
1413 -- It is not an error to analyze in CodePeer mode a spec which requires
kono
parents:
diff changeset
1414 -- a body, in order to generate SCIL for this spec.
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1415
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1416 elsif CodePeer_Mode then
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1417 Back_End_Mode := Generate_Object;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1418
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1419 -- Differentiate use of -gnatceg to generate a C header from an Ada spec
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1420 -- to the CCG case (standard.h found) where C code generation should
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1421 -- only be performed on full units.
111
kono
parents:
diff changeset
1422
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1423 elsif Generate_C_Code then
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1424 Name_Len := 10;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1425 Name_Buffer (1 .. Name_Len) := "standard.h";
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1426
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1427 if Find_File (Name_Find, Osint.Source, Full_Name => True) = No_File
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1428 then
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1429 Back_End_Mode := Generate_Object;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1430 else
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1431 Back_End_Mode := Skip;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1432 end if;
111
kono
parents:
diff changeset
1433
kono
parents:
diff changeset
1434 -- It is not an error to analyze in GNATprove mode a spec which requires
kono
parents:
diff changeset
1435 -- a body, when the body is not available. During frame condition
kono
parents:
diff changeset
1436 -- generation, the corresponding ALI file is generated. During
kono
parents:
diff changeset
1437 -- analysis, the spec is analyzed.
kono
parents:
diff changeset
1438
kono
parents:
diff changeset
1439 elsif GNATprove_Mode then
kono
parents:
diff changeset
1440 Back_End_Mode := Declarations_Only;
kono
parents:
diff changeset
1441
kono
parents:
diff changeset
1442 -- In all other cases (specs which have bodies, generics, and bodies
kono
parents:
diff changeset
1443 -- where subunits are missing), we cannot generate code and we generate
kono
parents:
diff changeset
1444 -- a warning message. Note that generic instantiations are gone at this
kono
parents:
diff changeset
1445 -- stage since they have been replaced by their instances.
kono
parents:
diff changeset
1446
kono
parents:
diff changeset
1447 else
kono
parents:
diff changeset
1448 Back_End_Mode := Skip;
kono
parents:
diff changeset
1449 end if;
kono
parents:
diff changeset
1450
kono
parents:
diff changeset
1451 -- At this stage Back_End_Mode is set to indicate if the backend should
kono
parents:
diff changeset
1452 -- be called to generate code. If it is Skip, then code generation has
kono
parents:
diff changeset
1453 -- been turned off, even though code was requested by the original
kono
parents:
diff changeset
1454 -- command. This is not an error from the user point of view, but it is
kono
parents:
diff changeset
1455 -- an error from the point of view of the gcc driver, so we must exit
kono
parents:
diff changeset
1456 -- with an error status.
kono
parents:
diff changeset
1457
kono
parents:
diff changeset
1458 -- We generate an informative message (from the gcc point of view, it
kono
parents:
diff changeset
1459 -- is an error message, but from the users point of view this is not an
kono
parents:
diff changeset
1460 -- error, just a consequence of compiling something that cannot
kono
parents:
diff changeset
1461 -- generate code).
kono
parents:
diff changeset
1462
kono
parents:
diff changeset
1463 if Back_End_Mode = Skip then
kono
parents:
diff changeset
1464
kono
parents:
diff changeset
1465 -- An ignored Ghost unit is rewritten into a null statement because
kono
parents:
diff changeset
1466 -- it must not produce an ALI or object file. Do not emit any errors
kono
parents:
diff changeset
1467 -- related to code generation because the unit does not exist.
kono
parents:
diff changeset
1468
kono
parents:
diff changeset
1469 if Is_Ignored_Ghost_Unit (Main_Unit_Node) then
kono
parents:
diff changeset
1470
kono
parents:
diff changeset
1471 -- Exit the gnat driver with success, otherwise external builders
kono
parents:
diff changeset
1472 -- such as gnatmake and gprbuild will treat the compilation of an
kono
parents:
diff changeset
1473 -- ignored Ghost unit as a failure. Note that this will produce
kono
parents:
diff changeset
1474 -- an empty object file for the unit.
kono
parents:
diff changeset
1475
kono
parents:
diff changeset
1476 Ecode := E_Success;
kono
parents:
diff changeset
1477
kono
parents:
diff changeset
1478 -- Otherwise the unit is missing a crucial piece that prevents code
kono
parents:
diff changeset
1479 -- generation.
kono
parents:
diff changeset
1480
kono
parents:
diff changeset
1481 else
kono
parents:
diff changeset
1482 Ecode := E_No_Code;
kono
parents:
diff changeset
1483
kono
parents:
diff changeset
1484 Set_Standard_Error;
kono
parents:
diff changeset
1485 Write_Str ("cannot generate code for file ");
kono
parents:
diff changeset
1486 Write_Name (Unit_File_Name (Main_Unit));
kono
parents:
diff changeset
1487
kono
parents:
diff changeset
1488 if Subunits_Missing then
kono
parents:
diff changeset
1489 Write_Str (" (missing subunits)");
kono
parents:
diff changeset
1490 Write_Eol;
kono
parents:
diff changeset
1491
kono
parents:
diff changeset
1492 -- Force generation of ALI file, for backward compatibility
kono
parents:
diff changeset
1493
kono
parents:
diff changeset
1494 Opt.Force_ALI_Tree_File := True;
kono
parents:
diff changeset
1495
kono
parents:
diff changeset
1496 elsif Main_Unit_Kind = N_Subunit then
kono
parents:
diff changeset
1497 Write_Str (" (subunit)");
kono
parents:
diff changeset
1498 Write_Eol;
kono
parents:
diff changeset
1499
kono
parents:
diff changeset
1500 -- Do not generate an ALI file in this case, because it would
kono
parents:
diff changeset
1501 -- become obsolete when the parent is compiled, and thus
kono
parents:
diff changeset
1502 -- confuse tools such as gnatfind.
kono
parents:
diff changeset
1503
kono
parents:
diff changeset
1504 elsif Main_Unit_Kind = N_Subprogram_Declaration then
kono
parents:
diff changeset
1505 Write_Str (" (subprogram spec)");
kono
parents:
diff changeset
1506 Write_Eol;
kono
parents:
diff changeset
1507
kono
parents:
diff changeset
1508 -- Generic package body in GNAT implementation mode
kono
parents:
diff changeset
1509
kono
parents:
diff changeset
1510 elsif Main_Unit_Kind = N_Package_Body and then GNAT_Mode then
kono
parents:
diff changeset
1511 Write_Str (" (predefined generic)");
kono
parents:
diff changeset
1512 Write_Eol;
kono
parents:
diff changeset
1513
kono
parents:
diff changeset
1514 -- Force generation of ALI file, for backward compatibility
kono
parents:
diff changeset
1515
kono
parents:
diff changeset
1516 Opt.Force_ALI_Tree_File := True;
kono
parents:
diff changeset
1517
kono
parents:
diff changeset
1518 -- Only other case is a package spec
kono
parents:
diff changeset
1519
kono
parents:
diff changeset
1520 else
kono
parents:
diff changeset
1521 Write_Str (" (package spec)");
kono
parents:
diff changeset
1522 Write_Eol;
kono
parents:
diff changeset
1523 end if;
kono
parents:
diff changeset
1524 end if;
kono
parents:
diff changeset
1525
kono
parents:
diff changeset
1526 Set_Standard_Output;
kono
parents:
diff changeset
1527
kono
parents:
diff changeset
1528 Post_Compilation_Validation_Checks;
kono
parents:
diff changeset
1529 Errout.Finalize (Last_Call => True);
kono
parents:
diff changeset
1530 Errout.Output_Messages;
kono
parents:
diff changeset
1531 Treepr.Tree_Dump;
kono
parents:
diff changeset
1532 Tree_Gen;
kono
parents:
diff changeset
1533
kono
parents:
diff changeset
1534 -- Generate ALI file if specially requested, or for missing subunits,
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1535 -- subunits or predefined generic. For ignored ghost code, the object
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1536 -- file IS generated, so Object should be True, and since the object
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1537 -- file is generated, we need to generate the ALI file. We never want
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1538 -- an object file without an ALI file.
111
kono
parents:
diff changeset
1539
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1540 if Is_Ignored_Ghost_Unit (Main_Unit_Node)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1541 or else Opt.Force_ALI_Tree_File
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1542 then
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1543 Write_ALI (Object => Is_Ignored_Ghost_Unit (Main_Unit_Node));
111
kono
parents:
diff changeset
1544 end if;
kono
parents:
diff changeset
1545
kono
parents:
diff changeset
1546 Namet.Finalize;
kono
parents:
diff changeset
1547 Check_Rep_Info;
kono
parents:
diff changeset
1548
kono
parents:
diff changeset
1549 -- Exit the driver with an appropriate status indicator. This will
kono
parents:
diff changeset
1550 -- generate an empty object file for ignored Ghost units, otherwise
kono
parents:
diff changeset
1551 -- no object file will be generated.
kono
parents:
diff changeset
1552
kono
parents:
diff changeset
1553 Exit_Program (Ecode);
kono
parents:
diff changeset
1554 end if;
kono
parents:
diff changeset
1555
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1556 -- In -gnatc mode we only do annotation if -gnatt or -gnatR is also set,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1557 -- or if -gnatwz is enabled (default setting) and there is an unchecked
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1558 -- conversion that involves a type whose size is not statically known,
111
kono
parents:
diff changeset
1559 -- as indicated by Back_Annotate_Rep_Info being set to True.
kono
parents:
diff changeset
1560
kono
parents:
diff changeset
1561 -- We don't call for annotations on a subunit, because to process those
kono
parents:
diff changeset
1562 -- the back end requires that the parent(s) be properly compiled.
kono
parents:
diff changeset
1563
kono
parents:
diff changeset
1564 -- Annotation is suppressed for targets where front-end layout is
kono
parents:
diff changeset
1565 -- enabled, because the front end determines representations.
kono
parents:
diff changeset
1566
kono
parents:
diff changeset
1567 -- The back end is not invoked in ASIS mode with GNSA because all type
kono
parents:
diff changeset
1568 -- representation information will be provided by the GNSA back end, not
kono
parents:
diff changeset
1569 -- gigi.
kono
parents:
diff changeset
1570
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1571 -- A special back end is always called in CodePeer and GNATprove modes,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1572 -- unless this is a subunit.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1573
111
kono
parents:
diff changeset
1574 if Back_End_Mode = Declarations_Only
kono
parents:
diff changeset
1575 and then
kono
parents:
diff changeset
1576 (not (Back_Annotate_Rep_Info or Generate_SCIL or GNATprove_Mode)
kono
parents:
diff changeset
1577 or else Main_Unit_Kind = N_Subunit
kono
parents:
diff changeset
1578 or else ASIS_GNSA_Mode)
kono
parents:
diff changeset
1579 then
kono
parents:
diff changeset
1580 Post_Compilation_Validation_Checks;
kono
parents:
diff changeset
1581 Errout.Finalize (Last_Call => True);
kono
parents:
diff changeset
1582 Errout.Output_Messages;
kono
parents:
diff changeset
1583 Write_ALI (Object => False);
kono
parents:
diff changeset
1584 Tree_Dump;
kono
parents:
diff changeset
1585 Tree_Gen;
kono
parents:
diff changeset
1586 Namet.Finalize;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1587
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1588 if not (Generate_SCIL or GNATprove_Mode) then
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1589 Check_Rep_Info;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1590 end if;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1591
111
kono
parents:
diff changeset
1592 return;
kono
parents:
diff changeset
1593 end if;
kono
parents:
diff changeset
1594
kono
parents:
diff changeset
1595 -- Ensure that we properly register a dependency on system.ads, since
kono
parents:
diff changeset
1596 -- even if we do not semantically depend on this, Targparm has read
kono
parents:
diff changeset
1597 -- system parameters from the system.ads file.
kono
parents:
diff changeset
1598
kono
parents:
diff changeset
1599 Lib.Writ.Ensure_System_Dependency;
kono
parents:
diff changeset
1600
kono
parents:
diff changeset
1601 -- Add dependencies, if any, on preprocessing data file and on
kono
parents:
diff changeset
1602 -- preprocessing definition file(s).
kono
parents:
diff changeset
1603
kono
parents:
diff changeset
1604 Prepcomp.Add_Dependencies;
kono
parents:
diff changeset
1605
kono
parents:
diff changeset
1606 if GNATprove_Mode then
kono
parents:
diff changeset
1607
kono
parents:
diff changeset
1608 -- In GNATprove mode we're writing the ALI much earlier than usual
kono
parents:
diff changeset
1609 -- as flow analysis needs the file present in order to append its
kono
parents:
diff changeset
1610 -- own globals to it.
kono
parents:
diff changeset
1611
kono
parents:
diff changeset
1612 -- Note: In GNATprove mode, an "object" file is always generated as
kono
parents:
diff changeset
1613 -- the result of calling gnat1 or gnat2why, although this is not the
kono
parents:
diff changeset
1614 -- same as the object file produced for compilation.
kono
parents:
diff changeset
1615
kono
parents:
diff changeset
1616 Write_ALI (Object => True);
kono
parents:
diff changeset
1617 end if;
kono
parents:
diff changeset
1618
kono
parents:
diff changeset
1619 -- Some back ends (for instance Gigi) are known to rely on SCOs for code
kono
parents:
diff changeset
1620 -- generation. Make sure they are available.
kono
parents:
diff changeset
1621
kono
parents:
diff changeset
1622 if Generate_SCO then
kono
parents:
diff changeset
1623 Par_SCO.SCO_Record_Filtered;
kono
parents:
diff changeset
1624 end if;
kono
parents:
diff changeset
1625
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1626 -- If -gnatd_j is specified, exercise the JSON parser of Repinfo
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1627
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1628 if Debug_Flag_Underscore_J then
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1629 Read_JSON_Files_For_Repinfo;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1630 end if;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1631
111
kono
parents:
diff changeset
1632 -- Back end needs to explicitly unlock tables it needs to touch
kono
parents:
diff changeset
1633
kono
parents:
diff changeset
1634 Atree.Lock;
kono
parents:
diff changeset
1635 Elists.Lock;
kono
parents:
diff changeset
1636 Fname.UF.Lock;
kono
parents:
diff changeset
1637 Ghost.Lock;
kono
parents:
diff changeset
1638 Inline.Lock;
kono
parents:
diff changeset
1639 Lib.Lock;
kono
parents:
diff changeset
1640 Namet.Lock;
kono
parents:
diff changeset
1641 Nlists.Lock;
kono
parents:
diff changeset
1642 Sem.Lock;
kono
parents:
diff changeset
1643 Sinput.Lock;
kono
parents:
diff changeset
1644 Stringt.Lock;
kono
parents:
diff changeset
1645
kono
parents:
diff changeset
1646 -- Here we call the back end to generate the output code
kono
parents:
diff changeset
1647
kono
parents:
diff changeset
1648 Generating_Code := True;
kono
parents:
diff changeset
1649 Back_End.Call_Back_End (Back_End_Mode);
kono
parents:
diff changeset
1650
kono
parents:
diff changeset
1651 -- Once the backend is complete, we unlock the names table. This call
kono
parents:
diff changeset
1652 -- allows a few extra entries, needed for example for the file name
kono
parents:
diff changeset
1653 -- for the library file output.
kono
parents:
diff changeset
1654
kono
parents:
diff changeset
1655 Namet.Unlock;
kono
parents:
diff changeset
1656
kono
parents:
diff changeset
1657 -- Generate the call-graph output of dispatching calls
kono
parents:
diff changeset
1658
kono
parents:
diff changeset
1659 Exp_CG.Generate_CG_Output;
kono
parents:
diff changeset
1660
kono
parents:
diff changeset
1661 -- Perform post compilation validation checks
kono
parents:
diff changeset
1662
kono
parents:
diff changeset
1663 Post_Compilation_Validation_Checks;
kono
parents:
diff changeset
1664
kono
parents:
diff changeset
1665 -- Now we complete output of errors, rep info and the tree info. These
kono
parents:
diff changeset
1666 -- are delayed till now, since it is perfectly possible for gigi to
kono
parents:
diff changeset
1667 -- generate errors, modify the tree (in particular by setting flags
kono
parents:
diff changeset
1668 -- indicating that elaboration is required, and also to back annotate
kono
parents:
diff changeset
1669 -- representation information for List_Rep_Info).
kono
parents:
diff changeset
1670
kono
parents:
diff changeset
1671 Errout.Finalize (Last_Call => True);
kono
parents:
diff changeset
1672 Errout.Output_Messages;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1673 Repinfo.List_Rep_Info (Ttypes.Bytes_Big_Endian);
111
kono
parents:
diff changeset
1674 Inline.List_Inlining_Info;
kono
parents:
diff changeset
1675
kono
parents:
diff changeset
1676 -- Only write the library if the backend did not generate any error
kono
parents:
diff changeset
1677 -- messages. Otherwise signal errors to the driver program so that
kono
parents:
diff changeset
1678 -- there will be no attempt to generate an object file.
kono
parents:
diff changeset
1679
kono
parents:
diff changeset
1680 if Compilation_Errors then
kono
parents:
diff changeset
1681 Treepr.Tree_Dump;
kono
parents:
diff changeset
1682 Exit_Program (E_Errors);
kono
parents:
diff changeset
1683 end if;
kono
parents:
diff changeset
1684
kono
parents:
diff changeset
1685 if not GNATprove_Mode then
kono
parents:
diff changeset
1686 Write_ALI (Object => (Back_End_Mode = Generate_Object));
kono
parents:
diff changeset
1687 end if;
kono
parents:
diff changeset
1688
kono
parents:
diff changeset
1689 if not Compilation_Errors then
kono
parents:
diff changeset
1690
kono
parents:
diff changeset
1691 -- In case of ada backends, we need to make sure that the generated
kono
parents:
diff changeset
1692 -- object file has a timestamp greater than the ALI file. We do this
kono
parents:
diff changeset
1693 -- to make gnatmake happy when checking the ALI and obj timestamps,
kono
parents:
diff changeset
1694 -- where it expects the object file being written after the ali file.
kono
parents:
diff changeset
1695
kono
parents:
diff changeset
1696 -- Gnatmake's assumption is true for gcc platforms where the gcc
kono
parents:
diff changeset
1697 -- wrapper needs to call the assembler after calling gnat1, but is
kono
parents:
diff changeset
1698 -- not true for ada backends, where the object files are created
kono
parents:
diff changeset
1699 -- directly by gnat1 (so are created before the ali file).
kono
parents:
diff changeset
1700
kono
parents:
diff changeset
1701 Back_End.Gen_Or_Update_Object_File;
kono
parents:
diff changeset
1702 end if;
kono
parents:
diff changeset
1703
kono
parents:
diff changeset
1704 -- Generate ASIS tree after writing the ALI file, since in ASIS mode,
kono
parents:
diff changeset
1705 -- Write_ALI may in fact result in further tree decoration from the
kono
parents:
diff changeset
1706 -- original tree file. Note that we dump the tree just before generating
kono
parents:
diff changeset
1707 -- it, so that the dump will exactly reflect what is written out.
kono
parents:
diff changeset
1708
kono
parents:
diff changeset
1709 Treepr.Tree_Dump;
kono
parents:
diff changeset
1710 Tree_Gen;
kono
parents:
diff changeset
1711
kono
parents:
diff changeset
1712 -- Finalize name table and we are all done
kono
parents:
diff changeset
1713
kono
parents:
diff changeset
1714 Namet.Finalize;
kono
parents:
diff changeset
1715
kono
parents:
diff changeset
1716 exception
kono
parents:
diff changeset
1717 -- Handle fatal internal compiler errors
kono
parents:
diff changeset
1718
kono
parents:
diff changeset
1719 when Rtsfind.RE_Not_Available =>
kono
parents:
diff changeset
1720 Comperr.Compiler_Abort ("RE_Not_Available");
kono
parents:
diff changeset
1721
kono
parents:
diff changeset
1722 when System.Assertions.Assert_Failure =>
kono
parents:
diff changeset
1723 Comperr.Compiler_Abort ("Assert_Failure");
kono
parents:
diff changeset
1724
kono
parents:
diff changeset
1725 when Constraint_Error =>
kono
parents:
diff changeset
1726 Comperr.Compiler_Abort ("Constraint_Error");
kono
parents:
diff changeset
1727
kono
parents:
diff changeset
1728 when Program_Error =>
kono
parents:
diff changeset
1729 Comperr.Compiler_Abort ("Program_Error");
kono
parents:
diff changeset
1730
kono
parents:
diff changeset
1731 -- Assume this is a bug. If it is real, the message will in any case
kono
parents:
diff changeset
1732 -- say Storage_Error, giving a strong hint.
kono
parents:
diff changeset
1733
kono
parents:
diff changeset
1734 when Storage_Error =>
kono
parents:
diff changeset
1735 Comperr.Compiler_Abort ("Storage_Error");
kono
parents:
diff changeset
1736
kono
parents:
diff changeset
1737 when Unrecoverable_Error =>
kono
parents:
diff changeset
1738 raise;
kono
parents:
diff changeset
1739
kono
parents:
diff changeset
1740 when others =>
kono
parents:
diff changeset
1741 Comperr.Compiler_Abort ("exception");
kono
parents:
diff changeset
1742 end;
kono
parents:
diff changeset
1743
kono
parents:
diff changeset
1744 <<End_Of_Program>>
kono
parents:
diff changeset
1745 null;
kono
parents:
diff changeset
1746
kono
parents:
diff changeset
1747 -- The outer exception handler handles an unrecoverable error
kono
parents:
diff changeset
1748
kono
parents:
diff changeset
1749 exception
kono
parents:
diff changeset
1750 when Unrecoverable_Error =>
kono
parents:
diff changeset
1751 Errout.Finalize (Last_Call => True);
kono
parents:
diff changeset
1752 Errout.Output_Messages;
kono
parents:
diff changeset
1753
kono
parents:
diff changeset
1754 Set_Standard_Error;
kono
parents:
diff changeset
1755 Write_Str ("compilation abandoned");
kono
parents:
diff changeset
1756 Write_Eol;
kono
parents:
diff changeset
1757
kono
parents:
diff changeset
1758 Set_Standard_Output;
kono
parents:
diff changeset
1759 Source_Dump;
kono
parents:
diff changeset
1760 Tree_Dump;
kono
parents:
diff changeset
1761 Exit_Program (E_Errors);
kono
parents:
diff changeset
1762
kono
parents:
diff changeset
1763 end Gnat1drv;