OSDN Git Service

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