Merge -r 127928:132243 from trunk
[official-gcc.git] / gcc / ada / gnat1drv.adb
blobdda21ce8e98cb4526ed66908d83e6d431fe2639a
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- G N A T 1 D R V --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1992-2007, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
20 -- --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
23 -- --
24 ------------------------------------------------------------------------------
26 with Atree; use Atree;
27 with Back_End; use Back_End;
28 with Comperr;
29 with Csets; use Csets;
30 with Debug; use Debug;
31 with Elists;
32 with Errout; use Errout;
33 with Fmap;
34 with Fname; use Fname;
35 with Fname.UF; use Fname.UF;
36 with Frontend;
37 with Gnatvsn; use Gnatvsn;
38 with Hostparm;
39 with Inline;
40 with Lib; use Lib;
41 with Lib.Writ; use Lib.Writ;
42 with Lib.Xref;
43 with Namet; use Namet;
44 with Nlists;
45 with Opt; use Opt;
46 with Osint; use Osint;
47 with Output; use Output;
48 with Prepcomp;
49 with Repinfo; use Repinfo;
50 with Restrict;
51 with Rtsfind;
52 with Sem;
53 with Sem_Ch8;
54 with Sem_Ch12;
55 with Sem_Ch13;
56 with Sem_Elim;
57 with Sem_Eval;
58 with Sem_Type;
59 with Sinfo; use Sinfo;
60 with Sinput.L; use Sinput.L;
61 with Snames;
62 with Sprint; use Sprint;
63 with Stringt;
64 with Targparm; use Targparm;
65 with Tree_Gen;
66 with Treepr; use Treepr;
67 with Ttypes;
68 with Types; use Types;
69 with Uintp; use Uintp;
70 with Uname; use Uname;
71 with Urealp;
72 with Usage;
74 with System.Assertions;
76 procedure Gnat1drv is
77 Main_Unit_Node : Node_Id;
78 -- Compilation unit node for main unit
80 Main_Kind : Node_Kind;
81 -- Kind of main compilation unit node
83 Back_End_Mode : Back_End.Back_End_Mode_Type;
84 -- Record back end mode
86 procedure Check_Bad_Body;
87 -- Called to check if the unit we are compiling has a bad body
89 procedure Check_Rep_Info;
90 -- Called when we are not generating code, to check if -gnatR was requested
91 -- and if so, explain that we will not be honoring the request.
93 --------------------
94 -- Check_Bad_Body --
95 --------------------
97 procedure Check_Bad_Body is
98 Sname : Unit_Name_Type;
99 Src_Ind : Source_File_Index;
100 Fname : File_Name_Type;
102 procedure Bad_Body_Error (Msg : String);
103 -- Issue message for bad body found
105 --------------------
106 -- Bad_Body_Error --
107 --------------------
109 procedure Bad_Body_Error (Msg : String) is
110 begin
111 Error_Msg_N (Msg, Main_Unit_Node);
112 Error_Msg_File_1 := Fname;
113 Error_Msg_N ("remove incorrect body in file{!", Main_Unit_Node);
114 end Bad_Body_Error;
116 -- Start of processing for Check_Bad_Body
118 begin
119 -- Nothing to do if we are only checking syntax, because we don't know
120 -- enough to know if we require or forbid a body in this case.
122 if Operating_Mode = Check_Syntax then
123 return;
124 end if;
126 -- Check for body not allowed
128 if (Main_Kind = N_Package_Declaration
129 and then not Body_Required (Main_Unit_Node))
130 or else (Main_Kind = N_Generic_Package_Declaration
131 and then not Body_Required (Main_Unit_Node))
132 or else Main_Kind = N_Package_Renaming_Declaration
133 or else Main_Kind = N_Subprogram_Renaming_Declaration
134 or else Nkind (Original_Node (Unit (Main_Unit_Node)))
135 in N_Generic_Instantiation
136 then
137 Sname := Unit_Name (Main_Unit);
139 -- If we do not already have a body name, then get the body name
140 -- (but how can we have a body name here ???)
142 if not Is_Body_Name (Sname) then
143 Sname := Get_Body_Name (Sname);
144 end if;
146 Fname := Get_File_Name (Sname, Subunit => False);
147 Src_Ind := Load_Source_File (Fname);
149 -- Case where body is present and it is not a subunit. Exclude
150 -- the subunit case, because it has nothing to do with the
151 -- package we are compiling. It is illegal for a child unit and a
152 -- subunit with the same expanded name (RM 10.2(9)) to appear
153 -- together in a partition, but there is nothing to stop a
154 -- compilation environment from having both, and the test here
155 -- simply allows that. If there is an attempt to include both in
156 -- a partition, this is diagnosed at bind time. In Ada 83 mode
157 -- this is not a warning case.
159 -- Note: if weird file names are being used, we can have
160 -- situation where the file name that supposedly contains body,
161 -- in fact contains a spec, or we can't tell what it contains.
162 -- Skip the error message in these cases.
164 -- Also ignore body that is nothing but pragma No_Body; (that's the
165 -- whole point of this pragma, to be used this way and to cause the
166 -- body file to be ignored in this context).
168 if Src_Ind /= No_Source_File
169 and then Get_Expected_Unit_Type (Fname) = Expect_Body
170 and then not Source_File_Is_Subunit (Src_Ind)
171 and then not Source_File_Is_No_Body (Src_Ind)
172 then
173 Errout.Finalize (Last_Call => False);
175 Error_Msg_Unit_1 := Sname;
177 -- Ada 83 case of a package body being ignored. This is not an
178 -- error as far as the Ada 83 RM is concerned, but it is almost
179 -- certainly not what is wanted so output a warning. Give this
180 -- message only if there were no errors, since otherwise it may
181 -- be incorrect (we may have misinterpreted a junk spec as not
182 -- needing a body when it really does).
184 if Main_Kind = N_Package_Declaration
185 and then Ada_Version = Ada_83
186 and then Operating_Mode = Generate_Code
187 and then Distribution_Stub_Mode /= Generate_Caller_Stub_Body
188 and then not Compilation_Errors
189 then
190 Error_Msg_N
191 ("package $$ does not require a body?", Main_Unit_Node);
192 Error_Msg_File_1 := Fname;
193 Error_Msg_N ("body in file{? will be ignored", Main_Unit_Node);
195 -- Ada 95 cases of a body file present when no body is
196 -- permitted. This we consider to be an error.
198 else
199 -- For generic instantiations, we never allow a body
201 if Nkind (Original_Node (Unit (Main_Unit_Node)))
202 in N_Generic_Instantiation
203 then
204 Bad_Body_Error
205 ("generic instantiation for $$ does not allow a body");
207 -- A library unit that is a renaming never allows a body
209 elsif Main_Kind in N_Renaming_Declaration then
210 Bad_Body_Error
211 ("renaming declaration for $$ does not allow a body!");
213 -- Remaining cases are packages and generic packages. Here
214 -- we only do the test if there are no previous errors,
215 -- because if there are errors, they may lead us to
216 -- incorrectly believe that a package does not allow a body
217 -- when in fact it does.
219 elsif not Compilation_Errors then
220 if Main_Kind = N_Package_Declaration then
221 Bad_Body_Error
222 ("package $$ does not allow a body!");
224 elsif Main_Kind = N_Generic_Package_Declaration then
225 Bad_Body_Error
226 ("generic package $$ does not allow a body!");
227 end if;
228 end if;
230 end if;
231 end if;
232 end if;
233 end Check_Bad_Body;
235 --------------------
236 -- Check_Rep_Info --
237 --------------------
239 procedure Check_Rep_Info is
240 begin
241 if List_Representation_Info /= 0
242 or else List_Representation_Info_Mechanisms
243 then
244 Write_Eol;
245 Write_Str
246 ("cannot generate representation information, no code generated");
247 Write_Eol;
248 Write_Eol;
249 end if;
250 end Check_Rep_Info;
252 -- Start of processing for Gnat1drv
254 begin
255 -- This inner block is set up to catch assertion errors and constraint
256 -- errors. Since the code for handling these errors can cause another
257 -- exception to be raised (namely Unrecoverable_Error), we need two
258 -- nested blocks, so that the outer one handles unrecoverable error.
260 begin
261 -- Lib.Initialize need to be called before Scan_Compiler_Arguments,
262 -- because it initializes a table filled by Scan_Compiler_Arguments.
264 Osint.Initialize;
265 Fmap.Reset_Tables;
266 Lib.Initialize;
267 Lib.Xref.Initialize;
268 Scan_Compiler_Arguments;
269 Osint.Add_Default_Search_Dirs;
271 Nlists.Initialize;
272 Sinput.Initialize;
273 Sem.Initialize;
274 Csets.Initialize;
275 Uintp.Initialize;
276 Urealp.Initialize;
277 Errout.Initialize;
278 Namet.Initialize;
279 Snames.Initialize;
280 Stringt.Initialize;
281 Inline.Initialize;
282 Sem_Ch8.Initialize;
283 Sem_Ch12.Initialize;
284 Sem_Ch13.Initialize;
285 Sem_Elim.Initialize;
286 Sem_Eval.Initialize;
287 Sem_Type.Init_Interp_Tables;
289 -- Acquire target parameters from system.ads (source of package System)
291 declare
292 use Sinput;
294 S : Source_File_Index;
295 N : File_Name_Type;
297 begin
298 Name_Buffer (1 .. 10) := "system.ads";
299 Name_Len := 10;
300 N := Name_Find;
301 S := Load_Source_File (N);
303 if S = No_Source_File then
304 Write_Line
305 ("fatal error, run-time library not installed correctly");
306 Write_Line
307 ("cannot locate file system.ads");
308 raise Unrecoverable_Error;
310 -- Remember source index of system.ads (which was read successfully)
312 else
313 System_Source_File_Index := S;
314 end if;
316 Targparm.Get_Target_Parameters
317 (System_Text => Source_Text (S),
318 Source_First => Source_First (S),
319 Source_Last => Source_Last (S));
321 -- Acquire configuration pragma information from Targparm
323 Restrict.Restrictions := Targparm.Restrictions_On_Target;
324 end;
326 -- Set Configurable_Run_Time mode if system.ads flag set
328 if Targparm.Configurable_Run_Time_On_Target or Debug_Flag_YY then
329 Configurable_Run_Time_Mode := True;
330 end if;
332 -- Set -gnatR3m mode if debug flag A set
334 if Debug_Flag_AA then
335 Back_Annotate_Rep_Info := True;
336 List_Representation_Info := 1;
337 List_Representation_Info_Mechanisms := True;
338 end if;
340 -- Disable static allocation of dispatch tables if -gnatd.t or if layout
341 -- is enabled. The front end's layout phase currently treats types that
342 -- have discriminant-dependent arrays as not being static even when a
343 -- discriminant constraint on the type is static, and this leads to
344 -- problems with subtypes of type Ada.Tags.Dispatch_Table_Wrapper. ???
346 if Debug_Flag_Dot_T or else Frontend_Layout_On_Target then
347 Static_Dispatch_Tables := False;
348 end if;
350 -- Output copyright notice if full list mode unless we have a list
351 -- file, in which case we defer this so that it is output in the file
353 if (Verbose_Mode or else (Full_List and then Full_List_File_Name = null))
354 and then not Debug_Flag_7
355 then
356 Write_Eol;
357 Write_Str ("GNAT ");
358 Write_Str (Gnat_Version_String);
359 Write_Eol;
360 Write_Str ("Copyright 1992-" &
361 Current_Year &
362 ", Free Software Foundation, Inc.");
363 Write_Eol;
364 end if;
366 -- Before we do anything else, adjust certain global values for
367 -- debug switches which modify their normal natural settings.
369 if Debug_Flag_8 then
370 Ttypes.Bytes_Big_Endian := not Ttypes.Bytes_Big_Endian;
371 end if;
373 -- Deal with forcing OpenVMS switches Ture if debug flag M is set, but
374 -- record the setting of Targparm.Open_VMS_On_Target in True_VMS_Target
375 -- before doing this.
377 Opt.True_VMS_Target := Targparm.OpenVMS_On_Target;
379 if Debug_Flag_M then
380 Targparm.OpenVMS_On_Target := True;
381 Hostparm.OpenVMS := True;
382 end if;
384 if Debug_Flag_FF then
385 Targparm.Frontend_Layout_On_Target := True;
386 end if;
388 -- We take the default exception mechanism into account
390 if Targparm.ZCX_By_Default_On_Target then
391 if Targparm.GCC_ZCX_Support_On_Target then
392 Exception_Mechanism := Back_End_Exceptions;
393 else
394 Osint.Fail
395 ("Zero Cost Exceptions not supported on this target");
396 end if;
397 end if;
399 -- Set proper status for overflow checks. We turn on overflow checks
400 -- if -gnatp was not specified, and either -gnato is set or the back
401 -- end takes care of overflow checks. Otherwise we suppress overflow
402 -- checks by default (since front end checks are expensive).
404 if not Opt.Suppress_Checks
405 and then (Opt.Enable_Overflow_Checks
406 or else
407 (Targparm.Backend_Divide_Checks_On_Target
409 Targparm.Backend_Overflow_Checks_On_Target))
410 then
411 Suppress_Options (Overflow_Check) := False;
412 else
413 Suppress_Options (Overflow_Check) := True;
414 end if;
416 -- Check we do not have more than one source file, this happens only in
417 -- the case where the driver is called directly, it cannot happen when
418 -- gnat1 is invoked from gcc in the normal case.
420 if Osint.Number_Of_Files /= 1 then
421 Usage;
422 Write_Eol;
423 Osint.Fail ("you must provide one source file");
425 elsif Usage_Requested then
426 Usage;
427 end if;
429 Original_Operating_Mode := Operating_Mode;
430 Frontend;
432 -- Exit with errors if the main source could not be parsed
434 if Sinput.Main_Source_File = No_Source_File then
435 Errout.Finalize (Last_Call => True);
436 Errout.Output_Messages;
437 Exit_Program (E_Errors);
438 end if;
440 Main_Unit_Node := Cunit (Main_Unit);
441 Main_Kind := Nkind (Unit (Main_Unit_Node));
442 Check_Bad_Body;
444 -- Exit if compilation errors detected
446 Errout.Finalize (Last_Call => False);
448 if Compilation_Errors then
449 Treepr.Tree_Dump;
450 Sem_Ch13.Validate_Unchecked_Conversions;
451 Sem_Ch13.Validate_Address_Clauses;
452 Errout.Output_Messages;
453 Namet.Finalize;
455 -- Generate ALI file if specially requested
457 if Opt.Force_ALI_Tree_File then
458 Write_ALI (Object => False);
459 Tree_Gen;
460 end if;
462 Errout.Finalize (Last_Call => True);
463 Exit_Program (E_Errors);
464 end if;
466 -- Set Generate_Code on main unit and its spec. We do this even if are
467 -- not generating code, since Lib-Writ uses this to determine which
468 -- units get written in the ali file.
470 Set_Generate_Code (Main_Unit);
472 -- If we have a corresponding spec, then we need object
473 -- code for the spec unit as well
475 if Nkind (Unit (Main_Unit_Node)) in N_Unit_Body
476 and then not Acts_As_Spec (Main_Unit_Node)
477 then
478 Set_Generate_Code
479 (Get_Cunit_Unit_Number (Library_Unit (Main_Unit_Node)));
480 end if;
482 -- Case of no code required to be generated, exit indicating no error
484 if Original_Operating_Mode = Check_Syntax then
485 Treepr.Tree_Dump;
486 Errout.Finalize (Last_Call => True);
487 Errout.Output_Messages;
488 Tree_Gen;
489 Namet.Finalize;
490 Check_Rep_Info;
492 -- Use a goto instead of calling Exit_Program so that finalization
493 -- occurs normally.
495 goto End_Of_Program;
497 elsif Original_Operating_Mode = Check_Semantics then
498 Back_End_Mode := Declarations_Only;
500 -- All remaining cases are cases in which the user requested that code
501 -- be generated (i.e. no -gnatc or -gnats switch was used). Check if
502 -- we can in fact satisfy this request.
504 -- Cannot generate code if someone has turned off code generation for
505 -- any reason at all. We will try to figure out a reason below.
507 elsif Operating_Mode /= Generate_Code then
508 Back_End_Mode := Skip;
510 -- We can generate code for a subprogram body unless there were missing
511 -- subunits. Note that we always generate code for all generic units (a
512 -- change from some previous versions of GNAT).
514 elsif Main_Kind = N_Subprogram_Body
515 and then not Subunits_Missing
516 then
517 Back_End_Mode := Generate_Object;
519 -- We can generate code for a package body unless there are subunits
520 -- missing (note that we always generate code for generic units, which
521 -- is a change from some earlier versions of GNAT).
523 elsif Main_Kind = N_Package_Body
524 and then not Subunits_Missing
525 then
526 Back_End_Mode := Generate_Object;
528 -- We can generate code for a package declaration or a subprogram
529 -- declaration only if it does not required a body.
531 elsif (Main_Kind = N_Package_Declaration
532 or else
533 Main_Kind = N_Subprogram_Declaration)
534 and then
535 (not Body_Required (Main_Unit_Node)
536 or else
537 Distribution_Stub_Mode = Generate_Caller_Stub_Body)
538 then
539 Back_End_Mode := Generate_Object;
541 -- We can generate code for a generic package declaration of a generic
542 -- subprogram declaration only if does not require a body.
544 elsif (Main_Kind = N_Generic_Package_Declaration
545 or else
546 Main_Kind = N_Generic_Subprogram_Declaration)
547 and then not Body_Required (Main_Unit_Node)
548 then
549 Back_End_Mode := Generate_Object;
551 -- Compilation units that are renamings do not require bodies,
552 -- so we can generate code for them.
554 elsif Main_Kind = N_Package_Renaming_Declaration
555 or else Main_Kind = N_Subprogram_Renaming_Declaration
556 then
557 Back_End_Mode := Generate_Object;
559 -- Compilation units that are generic renamings do not require bodies
560 -- so we can generate code for them.
562 elsif Main_Kind in N_Generic_Renaming_Declaration then
563 Back_End_Mode := Generate_Object;
565 -- In all other cases (specs which have bodies, generics, and bodies
566 -- where subunits are missing), we cannot generate code and we generate
567 -- a warning message. Note that generic instantiations are gone at this
568 -- stage since they have been replaced by their instances.
570 else
571 Back_End_Mode := Skip;
572 end if;
574 -- At this stage Call_Back_End is set to indicate if the backend should
575 -- be called to generate code. If it is not set, then code generation
576 -- has been turned off, even though code was requested by the original
577 -- command. This is not an error from the user point of view, but it is
578 -- an error from the point of view of the gcc driver, so we must exit
579 -- with an error status.
581 -- We generate an informative message (from the gcc point of view, it
582 -- is an error message, but from the users point of view this is not an
583 -- error, just a consequence of compiling something that cannot
584 -- generate code).
586 if Back_End_Mode = Skip then
587 Write_Str ("cannot generate code for ");
588 Write_Str ("file ");
589 Write_Name (Unit_File_Name (Main_Unit));
591 if Subunits_Missing then
592 Write_Str (" (missing subunits)");
593 Write_Eol;
594 Write_Str ("to check parent unit");
596 elsif Main_Kind = N_Subunit then
597 Write_Str (" (subunit)");
598 Write_Eol;
599 Write_Str ("to check subunit");
601 elsif Main_Kind = N_Subprogram_Declaration then
602 Write_Str (" (subprogram spec)");
603 Write_Eol;
604 Write_Str ("to check subprogram spec");
606 -- Generic package body in GNAT implementation mode
608 elsif Main_Kind = N_Package_Body and then GNAT_Mode then
609 Write_Str (" (predefined generic)");
610 Write_Eol;
611 Write_Str ("to check predefined generic");
613 -- Only other case is a package spec
615 else
616 Write_Str (" (package spec)");
617 Write_Eol;
618 Write_Str ("to check package spec");
619 end if;
621 Write_Str (" for errors, use ");
623 if Hostparm.OpenVMS then
624 Write_Str ("/NOLOAD");
625 else
626 Write_Str ("-gnatc");
627 end if;
629 Write_Eol;
631 Sem_Ch13.Validate_Unchecked_Conversions;
632 Sem_Ch13.Validate_Address_Clauses;
633 Errout.Finalize (Last_Call => True);
634 Errout.Output_Messages;
635 Treepr.Tree_Dump;
636 Tree_Gen;
637 Write_ALI (Object => False);
638 Namet.Finalize;
639 Check_Rep_Info;
641 -- Exit program with error indication, to kill object file
643 Exit_Program (E_No_Code);
644 end if;
646 -- In -gnatc mode, we only do annotation if -gnatt or -gnatR is also
647 -- set as indicated by Back_Annotate_Rep_Info being set to True.
649 -- We don't call for annotations on a subunit, because to process those
650 -- the back-end requires that the parent(s) be properly compiled.
652 -- Annotation is suppressed for targets where front-end layout is
653 -- enabled, because the front end determines representations.
655 -- Annotation is also suppressed in the case of compiling for
656 -- a VM, since representations are largely symbolic there.
658 if Back_End_Mode = Declarations_Only
659 and then (not Back_Annotate_Rep_Info
660 or else Main_Kind = N_Subunit
661 or else Targparm.Frontend_Layout_On_Target
662 or else Targparm.VM_Target /= No_VM)
663 then
664 Sem_Ch13.Validate_Unchecked_Conversions;
665 Sem_Ch13.Validate_Address_Clauses;
666 Errout.Finalize (Last_Call => True);
667 Errout.Output_Messages;
668 Write_ALI (Object => False);
669 Tree_Dump;
670 Tree_Gen;
671 Namet.Finalize;
672 Check_Rep_Info;
673 return;
674 end if;
676 -- Ensure that we properly register a dependency on system.ads, since
677 -- even if we do not semantically depend on this, Targparm has read
678 -- system parameters from the system.ads file.
680 Lib.Writ.Ensure_System_Dependency;
682 -- Add dependencies, if any, on preprocessing data file and on
683 -- preprocessing definition file(s).
685 Prepcomp.Add_Dependencies;
687 -- Back end needs to explicitly unlock tables it needs to touch
689 Atree.Lock;
690 Elists.Lock;
691 Fname.UF.Lock;
692 Inline.Lock;
693 Lib.Lock;
694 Nlists.Lock;
695 Sem.Lock;
696 Sinput.Lock;
697 Namet.Lock;
698 Stringt.Lock;
700 -- Here we call the back end to generate the output code
702 Generating_Code := True;
703 Back_End.Call_Back_End (Back_End_Mode);
705 -- Once the backend is complete, we unlock the names table. This call
706 -- allows a few extra entries, needed for example for the file name for
707 -- the library file output.
709 Namet.Unlock;
711 -- Validate unchecked conversions (using the values for size and
712 -- alignment annotated by the backend where possible).
714 Sem_Ch13.Validate_Unchecked_Conversions;
716 -- Validate address clauses (again using alignment values annotated
717 -- by the backend where possible).
719 Sem_Ch13.Validate_Address_Clauses;
721 -- Now we complete output of errors, rep info and the tree info. These
722 -- are delayed till now, since it is perfectly possible for gigi to
723 -- generate errors, modify the tree (in particular by setting flags
724 -- indicating that elaboration is required, and also to back annotate
725 -- representation information for List_Rep_Info.
727 Errout.Finalize (Last_Call => True);
728 Errout.Output_Messages;
729 List_Rep_Info;
731 -- Only write the library if the backend did not generate any error
732 -- messages. Otherwise signal errors to the driver program so that
733 -- there will be no attempt to generate an object file.
735 if Compilation_Errors then
736 Treepr.Tree_Dump;
737 Exit_Program (E_Errors);
738 end if;
740 Write_ALI (Object => (Back_End_Mode = Generate_Object));
742 -- Generate the ASIS tree after writing the ALI file, since in ASIS
743 -- mode, Write_ALI may in fact result in further tree decoration from
744 -- the original tree file. Note that we dump the tree just before
745 -- generating it, so that the dump will exactly reflect what is written
746 -- out.
748 Treepr.Tree_Dump;
749 Tree_Gen;
751 -- Finalize name table and we are all done
753 Namet.Finalize;
755 exception
756 -- Handle fatal internal compiler errors
758 when Rtsfind.RE_Not_Available =>
759 Comperr.Compiler_Abort ("RE_Not_Available");
761 when System.Assertions.Assert_Failure =>
762 Comperr.Compiler_Abort ("Assert_Failure");
764 when Constraint_Error =>
765 Comperr.Compiler_Abort ("Constraint_Error");
767 when Program_Error =>
768 Comperr.Compiler_Abort ("Program_Error");
770 when Storage_Error =>
772 -- Assume this is a bug. If it is real, the message will in any case
773 -- say Storage_Error, giving a strong hint!
775 Comperr.Compiler_Abort ("Storage_Error");
776 end;
778 <<End_Of_Program>>
779 null;
781 -- The outer exception handles an unrecoverable error
783 exception
784 when Unrecoverable_Error =>
785 Errout.Finalize (Last_Call => True);
786 Errout.Output_Messages;
788 Set_Standard_Error;
789 Write_Str ("compilation abandoned");
790 Write_Eol;
792 Set_Standard_Output;
793 Source_Dump;
794 Tree_Dump;
795 Exit_Program (E_Errors);
797 end Gnat1drv;