1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2009, Free Software Foundation, Inc. --
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. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 with Atree; use Atree;
27 with Back_End; use Back_End;
29 with Csets; use Csets;
30 with Debug; use Debug;
32 with Errout; use Errout;
34 with Fname; use Fname;
35 with Fname.UF; use Fname.UF;
37 with Gnatvsn; use Gnatvsn;
41 with Lib.Writ; use Lib.Writ;
43 with Namet; use Namet;
46 with Osint; use Osint;
47 with Output; use Output;
50 with Repinfo; use Repinfo;
61 with Sinfo; use Sinfo;
62 with Sinput.L; use Sinput.L;
64 with Sprint; use Sprint;
66 with Stylesw; use Stylesw;
67 with Targparm; use Targparm;
69 with Treepr; use Treepr;
71 with Types; use Types;
72 with Uintp; use Uintp;
73 with Uname; use Uname;
76 with Validsw; use Validsw;
78 with System.Assertions;
81 Main_Unit_Node : Node_Id;
82 -- Compilation unit node for main unit
84 Main_Kind : Node_Kind;
85 -- Kind of main compilation unit node
87 Back_End_Mode : Back_End.Back_End_Mode_Type;
88 -- Record back end mode
90 procedure Adjust_Global_Switches;
91 -- There are various interactions between front end switch settings,
92 -- including debug switch settings and target dependent parameters.
93 -- This procedure takes care of properly handling these interactions.
94 -- We do it after scanning out all the switches, so that we are not
95 -- depending on the order in which switches appear.
97 procedure Check_Bad_Body;
98 -- Called to check if the unit we are compiling has a bad body
100 procedure Check_Rep_Info;
101 -- Called when we are not generating code, to check if -gnatR was requested
102 -- and if so, explain that we will not be honoring the request.
104 procedure Check_Library_Items;
105 -- For debugging -- checks the behavior of Walk_Library_Items
106 pragma Warnings (Off, Check_Library_Items);
107 -- In case the call below is commented out
109 ----------------------------
110 -- Adjust_Global_Switches --
111 ----------------------------
113 procedure Adjust_Global_Switches is
115 -- Debug flag -gnatd.I is a synonym of Generate_SCIL
117 if Debug_Flag_Dot_II then
118 Generate_SCIL := True;
121 -- Set ASIS mode if -gnatt and -gnatc are set
123 if Operating_Mode = Check_Semantics and then Tree_Output then
126 -- Turn off inlining in ASIS mode, since ASIS cannot handle the extra
127 -- information in the trees caused by inlining being active.
129 -- More specifically, the tree seems to be malformed from the ASIS
130 -- point of view if -gnatc and -gnatn appear together???
132 Inline_Active := False;
134 -- Turn off SCIL generation in ASIS mode, since SCIL requires front-
137 Generate_SCIL := False;
140 -- SCIL mode needs to disable front-end inlining since the generated
141 -- trees (in particular order and consistency between specs compiled
142 -- as part of a main unit or as part of a with-clause) are causing
145 if Generate_SCIL then
146 Front_End_Inlining := False;
149 -- Tune settings for optimal SCIL generation in CodePeer_Mode
151 if CodePeer_Mode then
153 -- Turn off inlining, confuses CodePeer output and gains nothing
155 Front_End_Inlining := False;
156 Inline_Active := False;
158 -- Turn off ASIS mode: incompatible with front-end expansion.
162 -- Suppress overflow, division by zero and access checks since they
163 -- are handled implicitly by CodePeer.
165 -- Turn off dynamic elaboration checks: generates inconsistencies in
166 -- trees between specs compiled as part of a main unit or as part of
169 -- Turn off alignment checks: these cannot be proved statically by
170 -- CodePeer and generate false positives.
172 -- Enable all other language checks
175 (Access_Check => True,
176 Alignment_Check => True,
177 Division_Check => True,
178 Elaboration_Check => True,
179 Overflow_Check => True,
181 Enable_Overflow_Checks := False;
182 Dynamic_Elaboration_Checks := False;
184 -- Kill debug of generated code, since it messes up sloc values
186 Debug_Generated_Code := False;
188 -- Turn cross-referencing on in case it was disabled (by e.g. -gnatD)
189 -- Do we really need to spend time generating xref in CodePeer
190 -- mode??? Consider setting Xref_Active to False.
194 -- Polling mode forced off, since it generates confusing junk
196 Polling_Required := False;
198 -- Set operating mode to Generate_Code to benefit from full
199 -- front-end expansion (e.g. generics).
201 Operating_Mode := Generate_Code;
203 -- We need SCIL generation of course
205 Generate_SCIL := True;
207 -- Enable assertions and debug pragmas, since they give CodePeer
208 -- valuable extra information.
210 Assertions_Enabled := True;
211 Debug_Pragmas_Enabled := True;
213 -- Suppress compiler warnings, since what we are interested in here
214 -- is what CodePeer can find out. Also disable all simple value
215 -- propagation. This is an optimization which is valuable for code
216 -- optimization, and also for generation of compiler warnings, but
217 -- these are being turned off anyway, and CodePeer understands
218 -- things more clearly if references are not optimized in this way.
220 Warning_Mode := Suppress;
221 Debug_Flag_MM := True;
223 -- Set normal RM validity checking, and checking of IN OUT parameters
224 -- (this might give CodePeer more useful checks to analyze, to be
225 -- confirmed???). All other validity checking is turned off, since
226 -- this can generate very complex trees that only confuse CodePeer
227 -- and do not bring enough useful info.
229 Reset_Validity_Check_Options;
230 Validity_Check_Default := True;
231 Validity_Check_In_Out_Params := True;
232 Validity_Check_In_Params := True;
234 -- Turn off style check options since we are not interested in any
235 -- front-end warnings when we are getting CodePeer output.
237 Reset_Style_Check_Options;
240 -- Set Configurable_Run_Time mode if system.ads flag set
242 if Targparm.Configurable_Run_Time_On_Target or Debug_Flag_YY then
243 Configurable_Run_Time_Mode := True;
246 -- Set -gnatR3m mode if debug flag A set
248 if Debug_Flag_AA then
249 Back_Annotate_Rep_Info := True;
250 List_Representation_Info := 1;
251 List_Representation_Info_Mechanisms := True;
254 -- Force Target_Strict_Alignment true if debug flag -gnatd.a is set
256 if Debug_Flag_Dot_A then
257 Ttypes.Target_Strict_Alignment := True;
260 -- Disable static allocation of dispatch tables if -gnatd.t or if layout
261 -- is enabled. The front end's layout phase currently treats types that
262 -- have discriminant-dependent arrays as not being static even when a
263 -- discriminant constraint on the type is static, and this leads to
264 -- problems with subtypes of type Ada.Tags.Dispatch_Table_Wrapper. ???
266 if Debug_Flag_Dot_T or else Frontend_Layout_On_Target then
267 Static_Dispatch_Tables := False;
270 -- Flip endian mode if -gnatd8 set
273 Ttypes.Bytes_Big_Endian := not Ttypes.Bytes_Big_Endian;
276 -- Deal with forcing OpenVMS switches True if debug flag M is set, but
277 -- record the setting of Targparm.Open_VMS_On_Target in True_VMS_Target
278 -- before doing this, so we know if we are in real OpenVMS or not!
280 Opt.True_VMS_Target := Targparm.OpenVMS_On_Target;
283 Targparm.OpenVMS_On_Target := True;
284 Hostparm.OpenVMS := True;
287 -- Activate front end layout if debug flag -gnatdF is set
289 if Debug_Flag_FF then
290 Targparm.Frontend_Layout_On_Target := True;
293 -- Set and check exception mechnism
295 if Targparm.ZCX_By_Default_On_Target then
296 if Targparm.GCC_ZCX_Support_On_Target then
297 Exception_Mechanism := Back_End_Exceptions;
299 Osint.Fail ("Zero Cost Exceptions not supported on this target");
303 -- Set proper status for overflow checks. We turn on overflow checks
304 -- if -gnatp was not specified, and either -gnato is set or the back
305 -- end takes care of overflow checks. Otherwise we suppress overflow
306 -- checks by default (since front end checks are expensive).
308 if not Opt.Suppress_Checks
309 and then (Opt.Enable_Overflow_Checks
311 (Targparm.Backend_Divide_Checks_On_Target
313 Targparm.Backend_Overflow_Checks_On_Target))
315 Suppress_Options (Overflow_Check) := False;
317 Suppress_Options (Overflow_Check) := True;
319 end Adjust_Global_Switches;
325 procedure Check_Bad_Body is
326 Sname : Unit_Name_Type;
327 Src_Ind : Source_File_Index;
328 Fname : File_Name_Type;
330 procedure Bad_Body_Error (Msg : String);
331 -- Issue message for bad body found
337 procedure Bad_Body_Error (Msg : String) is
339 Error_Msg_N (Msg, Main_Unit_Node);
340 Error_Msg_File_1 := Fname;
341 Error_Msg_N ("remove incorrect body in file{!", Main_Unit_Node);
344 -- Start of processing for Check_Bad_Body
347 -- Nothing to do if we are only checking syntax, because we don't know
348 -- enough to know if we require or forbid a body in this case.
350 if Operating_Mode = Check_Syntax then
354 -- Check for body not allowed
356 if (Main_Kind = N_Package_Declaration
357 and then not Body_Required (Main_Unit_Node))
358 or else (Main_Kind = N_Generic_Package_Declaration
359 and then not Body_Required (Main_Unit_Node))
360 or else Main_Kind = N_Package_Renaming_Declaration
361 or else Main_Kind = N_Subprogram_Renaming_Declaration
362 or else Nkind (Original_Node (Unit (Main_Unit_Node)))
363 in N_Generic_Instantiation
365 Sname := Unit_Name (Main_Unit);
367 -- If we do not already have a body name, then get the body name
368 -- (but how can we have a body name here ???)
370 if not Is_Body_Name (Sname) then
371 Sname := Get_Body_Name (Sname);
374 Fname := Get_File_Name (Sname, Subunit => False);
375 Src_Ind := Load_Source_File (Fname);
377 -- Case where body is present and it is not a subunit. Exclude
378 -- the subunit case, because it has nothing to do with the
379 -- package we are compiling. It is illegal for a child unit and a
380 -- subunit with the same expanded name (RM 10.2(9)) to appear
381 -- together in a partition, but there is nothing to stop a
382 -- compilation environment from having both, and the test here
383 -- simply allows that. If there is an attempt to include both in
384 -- a partition, this is diagnosed at bind time. In Ada 83 mode
385 -- this is not a warning case.
387 -- Note: if weird file names are being used, we can have
388 -- situation where the file name that supposedly contains body,
389 -- in fact contains a spec, or we can't tell what it contains.
390 -- Skip the error message in these cases.
392 -- Also ignore body that is nothing but pragma No_Body; (that's the
393 -- whole point of this pragma, to be used this way and to cause the
394 -- body file to be ignored in this context).
396 if Src_Ind /= No_Source_File
397 and then Get_Expected_Unit_Type (Fname) = Expect_Body
398 and then not Source_File_Is_Subunit (Src_Ind)
399 and then not Source_File_Is_No_Body (Src_Ind)
401 Errout.Finalize (Last_Call => False);
403 Error_Msg_Unit_1 := Sname;
405 -- Ada 83 case of a package body being ignored. This is not an
406 -- error as far as the Ada 83 RM is concerned, but it is almost
407 -- certainly not what is wanted so output a warning. Give this
408 -- message only if there were no errors, since otherwise it may
409 -- be incorrect (we may have misinterpreted a junk spec as not
410 -- needing a body when it really does).
412 if Main_Kind = N_Package_Declaration
413 and then Ada_Version = Ada_83
414 and then Operating_Mode = Generate_Code
415 and then Distribution_Stub_Mode /= Generate_Caller_Stub_Body
416 and then not Compilation_Errors
419 ("package $$ does not require a body?", Main_Unit_Node);
420 Error_Msg_File_1 := Fname;
421 Error_Msg_N ("body in file{? will be ignored", Main_Unit_Node);
423 -- Ada 95 cases of a body file present when no body is
424 -- permitted. This we consider to be an error.
427 -- For generic instantiations, we never allow a body
429 if Nkind (Original_Node (Unit (Main_Unit_Node)))
430 in N_Generic_Instantiation
433 ("generic instantiation for $$ does not allow a body");
435 -- A library unit that is a renaming never allows a body
437 elsif Main_Kind in N_Renaming_Declaration then
439 ("renaming declaration for $$ does not allow a body!");
441 -- Remaining cases are packages and generic packages. Here
442 -- we only do the test if there are no previous errors,
443 -- because if there are errors, they may lead us to
444 -- incorrectly believe that a package does not allow a body
445 -- when in fact it does.
447 elsif not Compilation_Errors then
448 if Main_Kind = N_Package_Declaration then
450 ("package $$ does not allow a body!");
452 elsif Main_Kind = N_Generic_Package_Declaration then
454 ("generic package $$ does not allow a body!");
467 procedure Check_Rep_Info is
469 if List_Representation_Info /= 0
470 or else List_Representation_Info_Mechanisms
475 ("cannot generate representation information, no code generated");
482 -------------------------
483 -- Check_Library_Items --
484 -------------------------
486 -- Walk_Library_Items has plenty of assertions, so all we need to do is
487 -- call it, just for these assertions, not actually doing anything else.
489 procedure Check_Library_Items is
491 procedure Action (Item : Node_Id);
492 -- Action passed to Walk_Library_Items to do nothing
498 procedure Action (Item : Node_Id) is
503 procedure Walk is new Sem.Walk_Library_Items (Action);
505 -- Start of processing for Check_Library_Items
509 end Check_Library_Items;
511 -- Start of processing for Gnat1drv
514 -- This inner block is set up to catch assertion errors and constraint
515 -- errors. Since the code for handling these errors can cause another
516 -- exception to be raised (namely Unrecoverable_Error), we need two
517 -- nested blocks, so that the outer one handles unrecoverable error.
520 -- Initialize all packages. For the most part, these initialization
521 -- calls can be made in any order. Exceptions are as follows:
523 -- Lib.Initialize need to be called before Scan_Compiler_Arguments,
524 -- because it initializes a table filled by Scan_Compiler_Arguments.
530 Scan_Compiler_Arguments;
531 Osint.Add_Default_Search_Dirs;
551 Sem_Type.Init_Interp_Tables;
553 -- Acquire target parameters from system.ads (source of package System)
558 S : Source_File_Index;
562 Name_Buffer (1 .. 10) := "system.ads";
565 S := Load_Source_File (N);
567 if S = No_Source_File then
569 ("fatal error, run-time library not installed correctly");
571 ("cannot locate file system.ads");
572 raise Unrecoverable_Error;
574 -- Remember source index of system.ads (which was read successfully)
577 System_Source_File_Index := S;
580 Targparm.Get_Target_Parameters
581 (System_Text => Source_Text (S),
582 Source_First => Source_First (S),
583 Source_Last => Source_Last (S));
585 -- Acquire configuration pragma information from Targparm
587 Restrict.Restrictions := Targparm.Restrictions_On_Target;
590 Adjust_Global_Switches;
592 -- Output copyright notice if full list mode unless we have a list
593 -- file, in which case we defer this so that it is output in the file
595 if (Verbose_Mode or else (Full_List and then Full_List_File_Name = null))
596 and then not Debug_Flag_7
600 Write_Str (Gnat_Version_String);
602 Write_Str ("Copyright 1992-" &
604 ", Free Software Foundation, Inc.");
608 -- Check we do not have more than one source file, this happens only in
609 -- the case where the driver is called directly, it cannot happen when
610 -- gnat1 is invoked from gcc in the normal case.
612 if Osint.Number_Of_Files /= 1 then
615 Osint.Fail ("you must provide one source file");
617 elsif Usage_Requested then
621 Original_Operating_Mode := Operating_Mode;
624 -- Exit with errors if the main source could not be parsed
626 if Sinput.Main_Source_File = No_Source_File then
627 Errout.Finalize (Last_Call => True);
628 Errout.Output_Messages;
629 Exit_Program (E_Errors);
632 Main_Unit_Node := Cunit (Main_Unit);
633 Main_Kind := Nkind (Unit (Main_Unit_Node));
636 -- Exit if compilation errors detected
638 Errout.Finalize (Last_Call => False);
640 if Compilation_Errors then
642 Sem_Ch13.Validate_Unchecked_Conversions;
643 Sem_Ch13.Validate_Address_Clauses;
644 Errout.Output_Messages;
647 -- Generate ALI file if specially requested
649 if Opt.Force_ALI_Tree_File then
650 Write_ALI (Object => False);
654 Errout.Finalize (Last_Call => True);
655 Exit_Program (E_Errors);
658 -- Set Generate_Code on main unit and its spec. We do this even if are
659 -- not generating code, since Lib-Writ uses this to determine which
660 -- units get written in the ali file.
662 Set_Generate_Code (Main_Unit);
664 -- If we have a corresponding spec, and it comes from source
665 -- or it is not a generated spec for a child subprogram body,
666 -- then we need object code for the spec unit as well.
668 if Nkind (Unit (Main_Unit_Node)) in N_Unit_Body
669 and then not Acts_As_Spec (Main_Unit_Node)
671 if Nkind (Unit (Main_Unit_Node)) = N_Subprogram_Body
672 and then not Comes_From_Source (Library_Unit (Main_Unit_Node))
677 (Get_Cunit_Unit_Number (Library_Unit (Main_Unit_Node)));
681 -- Case of no code required to be generated, exit indicating no error
683 if Original_Operating_Mode = Check_Syntax then
685 Errout.Finalize (Last_Call => True);
686 Errout.Output_Messages;
691 -- Use a goto instead of calling Exit_Program so that finalization
696 elsif Original_Operating_Mode = Check_Semantics then
697 Back_End_Mode := Declarations_Only;
699 -- All remaining cases are cases in which the user requested that code
700 -- be generated (i.e. no -gnatc or -gnats switch was used). Check if
701 -- we can in fact satisfy this request.
703 -- Cannot generate code if someone has turned off code generation for
704 -- any reason at all. We will try to figure out a reason below.
706 elsif Operating_Mode /= Generate_Code then
707 Back_End_Mode := Skip;
709 -- We can generate code for a subprogram body unless there were missing
710 -- subunits. Note that we always generate code for all generic units (a
711 -- change from some previous versions of GNAT).
713 elsif Main_Kind = N_Subprogram_Body
714 and then not Subunits_Missing
716 Back_End_Mode := Generate_Object;
718 -- We can generate code for a package body unless there are subunits
719 -- missing (note that we always generate code for generic units, which
720 -- is a change from some earlier versions of GNAT).
722 elsif Main_Kind = N_Package_Body
723 and then not Subunits_Missing
725 Back_End_Mode := Generate_Object;
727 -- We can generate code for a package declaration or a subprogram
728 -- declaration only if it does not required a body.
730 elsif (Main_Kind = N_Package_Declaration
732 Main_Kind = N_Subprogram_Declaration)
734 (not Body_Required (Main_Unit_Node)
736 Distribution_Stub_Mode = Generate_Caller_Stub_Body)
738 Back_End_Mode := Generate_Object;
740 -- We can generate code for a generic package declaration of a generic
741 -- subprogram declaration only if does not require a body.
743 elsif (Main_Kind = N_Generic_Package_Declaration
745 Main_Kind = N_Generic_Subprogram_Declaration)
746 and then not Body_Required (Main_Unit_Node)
748 Back_End_Mode := Generate_Object;
750 -- Compilation units that are renamings do not require bodies,
751 -- so we can generate code for them.
753 elsif Main_Kind = N_Package_Renaming_Declaration
754 or else Main_Kind = N_Subprogram_Renaming_Declaration
756 Back_End_Mode := Generate_Object;
758 -- Compilation units that are generic renamings do not require bodies
759 -- so we can generate code for them.
761 elsif Main_Kind in N_Generic_Renaming_Declaration then
762 Back_End_Mode := Generate_Object;
764 -- It's not an error to generate SCIL for e.g. a spec which has a body
766 elsif CodePeer_Mode then
767 Back_End_Mode := Generate_Object;
769 -- In all other cases (specs which have bodies, generics, and bodies
770 -- where subunits are missing), we cannot generate code and we generate
771 -- a warning message. Note that generic instantiations are gone at this
772 -- stage since they have been replaced by their instances.
775 Back_End_Mode := Skip;
778 -- At this stage Back_End_Mode is set to indicate if the backend should
779 -- be called to generate code. If it is Skip, then code generation has
780 -- been turned off, even though code was requested by the original
781 -- command. This is not an error from the user point of view, but it is
782 -- an error from the point of view of the gcc driver, so we must exit
783 -- with an error status.
785 -- We generate an informative message (from the gcc point of view, it
786 -- is an error message, but from the users point of view this is not an
787 -- error, just a consequence of compiling something that cannot
790 if Back_End_Mode = Skip then
792 Write_Str ("cannot generate code for ");
794 Write_Name (Unit_File_Name (Main_Unit));
796 if Subunits_Missing then
797 Write_Str (" (missing subunits)");
799 Write_Str ("to check parent unit");
801 elsif Main_Kind = N_Subunit then
802 Write_Str (" (subunit)");
804 Write_Str ("to check subunit");
806 elsif Main_Kind = N_Subprogram_Declaration then
807 Write_Str (" (subprogram spec)");
809 Write_Str ("to check subprogram spec");
811 -- Generic package body in GNAT implementation mode
813 elsif Main_Kind = N_Package_Body and then GNAT_Mode then
814 Write_Str (" (predefined generic)");
816 Write_Str ("to check predefined generic");
818 -- Only other case is a package spec
821 Write_Str (" (package spec)");
823 Write_Str ("to check package spec");
826 Write_Str (" for errors, use ");
828 if Hostparm.OpenVMS then
829 Write_Str ("/NOLOAD");
831 Write_Str ("-gnatc");
837 Sem_Ch13.Validate_Unchecked_Conversions;
838 Sem_Ch13.Validate_Address_Clauses;
839 Errout.Finalize (Last_Call => True);
840 Errout.Output_Messages;
843 Write_ALI (Object => False);
847 -- Exit program with error indication, to kill object file
849 Exit_Program (E_No_Code);
852 -- In -gnatc mode, we only do annotation if -gnatt or -gnatR is also
853 -- set as indicated by Back_Annotate_Rep_Info being set to True.
855 -- We don't call for annotations on a subunit, because to process those
856 -- the back-end requires that the parent(s) be properly compiled.
858 -- Annotation is suppressed for targets where front-end layout is
859 -- enabled, because the front end determines representations.
861 -- Annotation is also suppressed in the case of compiling for
862 -- a VM, since representations are largely symbolic there.
864 if Back_End_Mode = Declarations_Only
865 and then (not (Back_Annotate_Rep_Info or Generate_SCIL)
866 or else Main_Kind = N_Subunit
867 or else Targparm.Frontend_Layout_On_Target
868 or else Targparm.VM_Target /= No_VM)
870 Sem_Ch13.Validate_Unchecked_Conversions;
871 Sem_Ch13.Validate_Address_Clauses;
872 Errout.Finalize (Last_Call => True);
873 Errout.Output_Messages;
874 Write_ALI (Object => False);
882 -- Ensure that we properly register a dependency on system.ads, since
883 -- even if we do not semantically depend on this, Targparm has read
884 -- system parameters from the system.ads file.
886 Lib.Writ.Ensure_System_Dependency;
888 -- Add dependencies, if any, on preprocessing data file and on
889 -- preprocessing definition file(s).
891 Prepcomp.Add_Dependencies;
893 -- Back end needs to explicitly unlock tables it needs to touch
906 -- ???Check_Library_Items under control of a debug flag, because it
907 -- currently does not work if the -gnatn switch (back end inlining) is
910 if Debug_Flag_Dot_WW then
914 -- Here we call the back end to generate the output code
916 Generating_Code := True;
917 Back_End.Call_Back_End (Back_End_Mode);
919 -- Once the backend is complete, we unlock the names table. This call
920 -- allows a few extra entries, needed for example for the file name for
921 -- the library file output.
925 -- Validate unchecked conversions (using the values for size and
926 -- alignment annotated by the backend where possible).
928 Sem_Ch13.Validate_Unchecked_Conversions;
930 -- Validate address clauses (again using alignment values annotated
931 -- by the backend where possible).
933 Sem_Ch13.Validate_Address_Clauses;
935 -- Now we complete output of errors, rep info and the tree info. These
936 -- are delayed till now, since it is perfectly possible for gigi to
937 -- generate errors, modify the tree (in particular by setting flags
938 -- indicating that elaboration is required, and also to back annotate
939 -- representation information for List_Rep_Info.
941 Errout.Finalize (Last_Call => True);
942 Errout.Output_Messages;
945 -- Only write the library if the backend did not generate any error
946 -- messages. Otherwise signal errors to the driver program so that
947 -- there will be no attempt to generate an object file.
949 if Compilation_Errors then
951 Exit_Program (E_Errors);
954 Write_ALI (Object => (Back_End_Mode = Generate_Object));
956 -- Generate the ASIS tree after writing the ALI file, since in ASIS
957 -- mode, Write_ALI may in fact result in further tree decoration from
958 -- the original tree file. Note that we dump the tree just before
959 -- generating it, so that the dump will exactly reflect what is written
965 -- Finalize name table and we are all done
970 -- Handle fatal internal compiler errors
972 when Rtsfind.RE_Not_Available =>
973 Comperr.Compiler_Abort ("RE_Not_Available");
975 when System.Assertions.Assert_Failure =>
976 Comperr.Compiler_Abort ("Assert_Failure");
978 when Constraint_Error =>
979 Comperr.Compiler_Abort ("Constraint_Error");
981 when Program_Error =>
982 Comperr.Compiler_Abort ("Program_Error");
984 when Storage_Error =>
986 -- Assume this is a bug. If it is real, the message will in any case
987 -- say Storage_Error, giving a strong hint!
989 Comperr.Compiler_Abort ("Storage_Error");
995 -- The outer exception handles an unrecoverable error
998 when Unrecoverable_Error =>
999 Errout.Finalize (Last_Call => True);
1000 Errout.Output_Messages;
1003 Write_Str ("compilation abandoned");
1006 Set_Standard_Output;
1009 Exit_Program (E_Errors);