1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2004, 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 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, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
32 ------------------------------------------------------------------------------
34 -- This package contains global flags set by the initialization
35 -- routine from the command line and referenced throughout the compiler,
36 -- the binder, gnatmake or other GNAT tools. The comments indicate which
37 -- options are used by which programs (GNAT, GNATBIND, GNATMAKE, etc).
39 with Gnatvsn; use Gnatvsn;
40 with Hostparm; use Hostparm;
41 with Types; use Types;
43 with System.WCh_Con; use System.WCh_Con;
44 with GNAT.Strings; use GNAT.Strings;
48 ----------------------------------------------
49 -- Settings of Modes for Current Processing --
50 ----------------------------------------------
52 -- The following mode values represent the current state of processing.
53 -- The values set here are the default values. Unless otherwise noted,
54 -- the value may be reset in Switch with an appropropiate switch. In
55 -- some cases, the values can also be modified by pragmas, and in the
56 -- case of some binder variables, Gnatbind.Scan_Bind_Arg may modify
57 -- the default values.
59 Ada_Bind_File : Boolean := True;
61 -- Set True if binder file to be generated in Ada rather than C
63 type Ada_Version_Type is (Ada_83, Ada_95, Ada_05);
64 -- Versions of Ada for Ada_Version below. Note that these are ordered,
65 -- so that tests like Ada_Version >= Ada_95 are legitimate and useful.
67 Ada_Version_Default : Ada_Version_Type := Ada_95;
69 -- Default Ada version if no switch given
71 Ada_Version : Ada_Version_Type := Ada_Version_Default;
73 -- Current Ada version for compiler
75 Ada_Final_Suffix : constant String := "final";
76 Ada_Final_Name : String_Ptr := new String'("ada" & Ada_Final_Suffix);
78 -- The name of the procedure that performs the finalization at the end of
79 -- execution. This variable may be modified by Gnatbind.Scan_Bind_Arg.
81 Ada_Init_Suffix : constant String := "init";
82 Ada_Init_Name : String_Ptr := new String'("ada" & Ada_Init_Suffix);
84 -- The name of the procedure that performs initialization at the start
85 -- of execution. This variable may be modified by Gnatbind.Scan_Bind_Arg.
87 Ada_Main_Name_Suffix : constant String := "main";
89 -- The suffix for Ada_Main_Name. Defined as a constant here so that it
90 -- can be referenced in a uniform manner to create either the default
91 -- value of Ada_Main_Name (declared below), or the non-default name
92 -- set by Gnatbind.Scan_Bind_Arg.
94 Ada_Main_Name : String_Ptr := new String'("ada_" & Ada_Main_Name_Suffix);
96 -- The name of the Ada package generated by the binder (when in Ada mode).
97 -- This variable may be modified by Gnatbind.Scan_Bind_Arg.
99 Address_Clause_Overlay_Warnings : Boolean := True;
101 -- Set False to disable address clause warnings
103 All_Errors_Mode : Boolean := False;
105 -- Flag set to force display of multiple errors on a single line and
106 -- also repeated error messages for references to undefined identifiers
107 -- and certain other repeated error messages.
109 All_Sources : Boolean := False;
111 -- Set to True to require all source files to be present. This flag is
112 -- directly modified by gnatmake to affect the shared binder routines.
114 Alternate_Main_Name : String_Ptr := null;
116 -- Set to non null when Bind_Alternate_Main_Name is True. This value
117 -- is modified as needed by Gnatbind.Scan_Bind_Arg.
119 Assertions_Enabled : Boolean := False;
121 -- Enable assertions made using pragma Assert.
123 ASIS_Mode : Boolean := False;
125 -- Enable semantic checks and tree transformations that are important
126 -- for ASIS but that are usually skipped if Operating_Mode is set to
127 -- Check_Semantics. This flag does not have the corresponding option to set
128 -- it ON. It is set ON when Tree_Output is set ON, it can also be set ON
129 -- from the code of GNSA-based tool (a client may need to set ON the
130 -- Back_Annotate_Rep_Info flag in this case. At the moment this does not
131 -- make very much sense, because GNSA can not do back annotation).
133 Back_Annotate_Rep_Info : Boolean := False;
135 -- If set True, enables back annotation of representation information
136 -- by gigi, even in -gnatc mode. This is set True by the use of -gnatR
137 -- (list representation information) or -gnatt (generate tree). It is
138 -- also set true if certain Unchecked_Conversion instantiations require
139 -- checking based on annotated values.
141 Bind_Alternate_Main_Name : Boolean := False;
143 -- True if main should be called Alternate_Main_Name.all.
144 -- This variable may be set to True by Gnatbind.Scan_Bind_Arg.
146 Bind_Main_Program : Boolean := True;
148 -- Set to False if not binding main Ada program.
150 Bind_For_Library : Boolean := False;
152 -- Set to True if the binder needs to generate a file designed for
153 -- building a library. May be set to True by Gnatbind.Scan_Bind_Arg.
155 Bind_Only : Boolean := False;
157 -- Set to True to skip compile and link steps
158 -- (except when Compile_Only and/or Link_Only are True).
160 Blank_Deleted_Lines : Boolean := False;
162 -- Output empty lines for each line of preprocessed input that is deleted
163 -- in the output, including preprocessor lines starting with a '#'.
165 Brief_Output : Boolean := False;
167 -- Force brief error messages to standard error, even if verbose mode is
168 -- set (so that main error messages go to standard output).
170 Build_Bind_And_Link_Full_Project : Boolean := False;
172 -- Set to True to build, bind and link all the sources of a project file
175 Check_Object_Consistency : Boolean := False;
176 -- GNATBIND, GNATMAKE
177 -- Set to True to check whether every object file is consistent with
178 -- its corresponding ada library information (ALI) file. An object
179 -- file is inconsistent with the corresponding ALI file if the object
180 -- file does not exist or if it has an older time stamp than the ALI file.
181 -- Default above is for GNATBIND. GNATMAKE overrides this default to
182 -- True (see Make.Initialize) since we normally do need to check source
183 -- consistencies in gnatmake.
185 Check_Only : Boolean := False;
187 -- Set to True to do checks only, no output of binder file.
189 Check_Readonly_Files : Boolean := False;
191 -- Set to True to check readonly files during the make process.
193 Check_Source_Files : Boolean := True;
194 -- GNATBIND, GNATMAKE
195 -- Set to True to enable consistency checking for any source files that
196 -- are present (i.e. date must match the date in the library info file).
197 -- Set to False for object file consistency check only. This flag is
198 -- directly modified by gnatmake, to affect the shared binder routines.
200 Check_Switches : Boolean := False;
202 -- Set to True to check compiler options during the make process.
204 Check_Unreferenced : Boolean := False;
206 -- Set to True to enable checking for unreferenced entities other
207 -- than formal parameters (for which see Check_Unreferenced_Formals)
209 Check_Unreferenced_Formals : Boolean := False;
211 -- Set True to check for unreferenced formals. This is turned
212 -- on by -gnatwa/wf/wu and turned off by -gnatwA/wF/wU.
214 Check_Withs : Boolean := False;
216 -- Set to True to enable checking for unused withs, and also the case
217 -- of withing a package and using none of the entities in the package.
219 Comment_Deleted_Lines : Boolean := False;
221 -- True if source lines removed by the preprocessor should be commented
222 -- in the output file.
224 Compile_Only : Boolean := False;
225 -- GNATMAKE, GNATCLEAN
226 -- GNATMAKE: set to True to skip bind and link steps (except when
227 -- Bind_Only is True).
228 -- GNATCLEAN: set to True to only the files produced by the compiler are to
229 -- be deleted, but not the library files or executable files.
231 Config_File : Boolean := True;
233 -- Set to False to inhibit reading and processing of gnat.adc file
235 Config_File_Names : String_List_Access := null;
237 -- Names of configuration pragmas files (given by switches -gnatec)
239 Configurable_Run_Time_Mode : Boolean := False;
241 -- Set True if the compiler is operating in configurable run-time mode.
242 -- This happens if the flag Targparm.Configurable_Run_TimeMode_On_Target
243 -- is set True, or if pragma No_Run_Time is used. See the spec of Rtsfind
244 -- for details on the handling of the latter pragma.
246 Constant_Condition_Warnings : Boolean := False;
248 -- Set to True to activate warnings on constant conditions
250 Create_Mapping_File : Boolean := False;
252 -- Set to True (-C switch) to indicate that gnatmake will invoke
253 -- the compiler with a mapping file (-gnatem compiler switch).
255 subtype Debug_Level_Value is Nat range 0 .. 3;
256 Debugger_Level : Debug_Level_Value := 0;
258 -- The value given to the -g parameter. The default value for -g with
259 -- no value is 2. This is usually ignored by GNATBIND, except in the
260 -- VMS version where it is passed as an argument to __gnat_initialize
261 -- to trigger the activation of the remote debugging interface.
262 -- Is this still true ???
264 Debug_Generated_Code : Boolean := False;
266 -- Set True (-gnatD switch) to debug generated expanded code instead
267 -- of the original source code. Causes debugging information to be
268 -- written with respect to the generated code file that is written.
270 Default_Sec_Stack_Size : Int := -1;
272 -- Set to default secondary stack size in units of kilobytes. Set by
273 -- the -Dnnn switch for the binder. A value of -1 indicates that no
274 -- default was set by the binder, and that the default should be the
275 -- initial value of System.Secondary_Stack.Default_Secondary_Stack_Size.
277 Detect_Blocking : Boolean := False;
279 -- Set True to force the run time to raise Program_Error if calls to
280 -- potentially blocking operations are detected from protected actions.
282 Display_Compilation_Progress : Boolean := False;
284 -- Set True (-d switch) to display information on progress while compiling
285 -- files. Internal flag to be used in conjunction with an IDE (e.g GPS).
287 type Distribution_Stub_Mode_Type is
290 -- Normal mode, no generation/compilation of distribution stubs
292 Generate_Receiver_Stub_Body,
293 -- The unit being compiled is the RCI body, and the compiler will
294 -- generate the body for the receiver stubs and compile it.
296 Generate_Caller_Stub_Body);
297 -- The unit being compiled is the RCI spec, and the compiler will
298 -- generate the body for the caller stubs and compile it.
300 Distribution_Stub_Mode : Distribution_Stub_Mode_Type := No_Stubs;
302 -- This enumeration variable indicates the five states of distribution
303 -- annex stub generation/compilation.
305 Do_Not_Execute : Boolean := False;
307 -- Set to True if no actual compilations should be undertaken.
309 Dynamic_Elaboration_Checks : Boolean := False;
311 -- Set True for dynamic elaboration checking mode, as set by the -gnatE
312 -- switch or by the use of pragma Elaboration_Checks (Dynamic).
314 Elab_Dependency_Output : Boolean := False;
316 -- Set to True to output complete list of elaboration constraints
318 Elab_Order_Output : Boolean := False;
320 -- Set to True to output chosen elaboration order
322 Elab_Warnings : Boolean := False;
324 -- Set to True to generate full elaboration warnings (-gnatwl)
326 Enable_Overflow_Checks : Boolean := False;
328 -- Set to True if -gnato (enable overflow checks) switch is set,
331 Exception_Locations_Suppressed : Boolean := False;
333 -- This flag is set True if a Suppress_Exception_Locations configuration
334 -- pragma is currently active.
336 type Exception_Mechanism_Type is
337 -- Determines the handling of exceptions. See Exp_Ch11 for details
339 (Front_End_Setjmp_Longjmp_Exceptions,
340 -- Exceptions use setjmp/longjmp generated explicitly by the
341 -- front end (this includes gigi or other equivalent parts of
342 -- the code generator). AT END handlers are converted into
343 -- exception handlers by the front end in this mode.
345 Front_End_ZCX_Exceptions,
346 -- Exceptions use the zero cost table mechanism with explicit
347 -- tables and exception regions generated by the front end.
348 -- AT END handlers are converted into exception handlers by
349 -- the front end in this mode.
351 Back_End_ZCX_Exceptions);
352 -- Exceptions are handled by the back end. The front end simply
353 -- generates the handlers as they appear in the source, and AT
354 -- END handlers are left untouched (they are not converted into
355 -- exception handlers when operating in this mode. Note that the
356 -- name includes ZCX, since the expectation is that the back end
357 -- mechanism will in fact be a ZCX approach, but nothing in the
358 -- compiler depends on this, so for example if GNAT is run with
359 -- a version of GCC configured for setjmp/longjmp exception handling,
360 -- then everything will work fine.
361 pragma Convention (C, Exception_Mechanism_Type);
363 Exception_Mechanism : Exception_Mechanism_Type :=
364 Front_End_Setjmp_Longjmp_Exceptions;
366 -- Set to the appropriate value depending on the default as given in
367 -- system.ads (ZCX_By_Default, GCC_ZCX_Support, Front_End_ZCX_Support)
368 -- and the use of -gnatL -gnatZ (and -gnatdX). The C convention is
369 -- there to make this variable accessible to gigi.
371 Exception_Tracebacks : Boolean := False;
373 -- Set to True to store tracebacks in exception occurrences (-E)
375 Extensions_Allowed : Boolean := False;
377 -- Set to True by switch -gnatX if GNAT specific language extensions
378 -- are allowed. For example, "limited with" is a GNAT extension.
380 type External_Casing_Type is (
381 As_Is, -- External names cased as they appear in the Ada source
382 Uppercase, -- External names forced to all uppercase letters
383 Lowercase); -- External names forced to all lowercase letters
385 External_Name_Imp_Casing : External_Casing_Type := Lowercase;
387 -- The setting of this flag determines the casing of external names
388 -- when the name is implicitly derived from an entity name (i.e. either
389 -- no explicit External_Name or Link_Name argument is used, or, in the
390 -- case of extended DEC pragmas, the external name is given using an
391 -- identifier. The As_Is setting is not permitted here (since this would
392 -- create Ada source programs that were case sensitive).
394 External_Name_Exp_Casing : External_Casing_Type := As_Is;
396 -- The setting of this flag determines the casing of an external name
397 -- specified explicitly with a string literal. As_Is means the string
398 -- literal is used as given with no modification to the casing. If
399 -- Lowercase or Uppercase is set, then the string is forced to all
400 -- lowercase or all uppercase letters as appropriate. Note that this
401 -- setting has no effect if the external name is given using an identifier
402 -- in the case of extended DEC import/export pragmas (in this case the
403 -- casing is controlled by External_Name_Imp_Casing), and also has no
404 -- effect if an explicit Link_Name is supplied (a link name is always
405 -- used exactly as given).
407 External_Unit_Compilation_Allowed : Boolean := False;
409 -- When True (set by gnatmake switch -x), allow compilation of sources
410 -- that are not part of any project file.
412 Float_Format : Character := ' ';
414 -- A non-blank value indicates that a Float_Format pragma has been
415 -- processed, in which case this variable is set to 'I' for IEEE or
416 -- to 'V' for VAX. The setting of 'V' is only possible on OpenVMS
419 Float_Format_Long : Character := ' ';
421 -- A non-blank value indicates that a Long_Float pragma has been
422 -- processed (this pragma is recognized only in OpenVMS versions
423 -- of GNAT), in which case this variable is set to D or G for
424 -- D_Float or G_Float.
426 Force_ALI_Tree_File : Boolean := False;
428 -- Force generation of ALI file even if errors are encountered.
429 -- Also forces generation of tree file if -gnatt is also set.
431 Force_Checking_Of_Elaboration_Flags : Boolean := False;
433 -- True if binding with forced checking of the elaboration flags
436 Force_Compilations : Boolean := False;
438 -- Set to force recompilations even when the objects are up-to-date.
440 Force_RM_Elaboration_Order : Boolean := False;
442 -- True if binding with forced RM elaboration order (-f switch set)
443 -- Note: this is considered an obsolescent option, to be removed in
444 -- some future release. It is no longer documented. The proper way
445 -- to get this effect is to use -gnatE and suppress elab checks.
447 Full_Path_Name_For_Brief_Errors : Boolean := False;
448 -- GNAT, GNATMAKE, GNATCLEAN
449 -- When True, in Brief_Output mode, each error message line
450 -- will start with the full path name of the source.
451 -- When False, only the file name without directory information
454 Full_List : Boolean := False;
456 -- Set True to generate full source listing with embedded errors
458 function get_gcc_version return Int;
459 pragma Import (C, get_gcc_version, "get_gcc_version");
461 GCC_Version : constant Nat := get_gcc_version;
463 -- Indicates which version of gcc is in use (2 = 2.8.1, 3 = 3.x).
465 Global_Discard_Names : Boolean := False;
467 -- Set true if a pragma Discard_Names applies to the current unit
469 GNAT_Mode : Boolean := False;
471 -- True if compiling in GNAT system mode (-gnatg switch)
473 HLO_Active : Boolean := False;
475 -- True if High Level Optimizer is activated (-gnatH switch)
477 Implementation_Unit_Warnings : Boolean := True;
479 -- Set True to active warnings for use of implementation internal units.
480 -- Can be controlled by use of -gnatwi/-gnatwI.
482 Identifier_Character_Set : Character;
484 -- This variable indicates the character set to be used for identifiers.
485 -- The possible settings are:
486 -- '1' Latin-5 (ISO-8859-1)
487 -- '2' Latin-5 (ISO-8859-2)
488 -- '3' Latin-5 (ISO-8859-3)
489 -- '4' Latin-5 (ISO-8859-4)
490 -- '5' Latin-5 (ISO-8859-5, Cyrillic)
491 -- '9' Latin-5 (ISO-8859-9)
492 -- 'p' PC (US, IBM page 437)
493 -- '8' PC (European, IBM page 850)
494 -- 'f' Full upper set (all distinct)
495 -- 'n' No upper characters (Ada 83 rules)
496 -- 'w' Latin-1 plus wide characters allowed in identifiers
498 -- The setting affects the set of letters allowed in identifiers and the
499 -- upper/lower case equivalences. It does not affect the interpretation of
500 -- character and string literals, which are always stored using the actual
501 -- coding in the source program. This variable is initialized to the
502 -- default value appropriate to the system (in Osint.Initialize), and then
503 -- reset if a command line switch is used to change the setting.
505 Ineffective_Inline_Warnings : Boolean := False;
507 -- Set True to activate warnings if front-end inlining (-gnatN) is not
508 -- able to actually inline a particular call (or all calls). Can be
509 -- controlled by use of -gnatwp/-gnatwP.
511 Init_Or_Norm_Scalars : Boolean := False;
513 -- Set True if a pragma Initialize_Scalars applies to the current unit.
514 -- Also set True if a pragma Normalize_Scalars applies.
516 Initialize_Scalars : Boolean := False;
518 -- Set True if a pragma Initialize_Scalars applies to the current unit.
519 -- Note that Init_Or_Norm_Scalars is also set to True if this is True.
521 Initialize_Scalars_Mode1 : Character := 'I';
522 Initialize_Scalars_Mode2 : Character := 'N';
524 -- Set to two characters from -S switch (IN/LO/HI/EV/xx). The default
525 -- is IN (invalid values), used if no -S switch is used.
527 Inline_Active : Boolean := False;
529 -- Set True to activate pragma Inline processing across modules. Default
530 -- for now is not to inline across module boundaries.
532 Interface_Library_Unit : Boolean := False;
534 -- Set to True to indicate that at least one ALI file is an interface ALI:
535 -- then elaboration flag checks are to be generated in the binder
538 Follow_Links : Boolean := False;
540 -- Set to True (-eL) to process the project files in trusted mode
542 Front_End_Inlining : Boolean := False;
544 -- Set True to activate inlining by front-end expansion.
546 Inline_Processing_Required : Boolean := False;
548 -- Set True if inline processing is required. Inline processing is
549 -- required if an active Inline pragma is processed. The flag is set
550 -- for a pragma Inline or Inline_Always that is actually active.
552 In_Place_Mode : Boolean := False;
554 -- Set True to store ALI and object files in place ie in the object
555 -- directory if these files already exist or in the source directory
558 Keep_Going : Boolean := False;
560 -- When True signals gnatmake to ignore compilation errors and keep
561 -- processing sources until there is no more work.
563 Keep_Temporary_Files : Boolean := False;
565 -- When True the temporary files created by the GNAT driver are not
566 -- deleted. Set by switch -dn or qualifier /KEEP_TEMPORARY_FILES.
568 Link_Only : Boolean := False;
570 -- Set to True to skip compile and bind steps
571 -- (except when Bind_Only is set to True).
573 List_Restrictions : Boolean := False;
575 -- Set to True to list restrictions pragmas that could apply to partition
577 List_Units : Boolean := False;
579 -- List units in the active library for a compilation (-gnatu switch)
581 List_Dependencies : Boolean := False;
583 -- When True gnatmake verifies that the objects are up to date and
584 -- outputs the list of object dependencies (-M switch).
585 -- Output depends if -a switch is used or not.
586 -- This list can be used directly in a Makefile.
588 List_Representation_Info : Int range 0 .. 3 := 0;
590 -- Set non-zero by -gnatR switch to list representation information.
591 -- The settings are as follows:
593 -- 0 = no listing of representation information (default as above)
594 -- 1 = list rep info for user defined record and array types
595 -- 2 = list rep info for all user defined types and objects
596 -- 3 = like 2, but variable fields are decoded symbolically
598 List_Representation_Info_To_File : Boolean := False;
600 -- Set true by -gnatRs switch. Causes information from -gnatR/1/2/3
601 -- to be written to file.rep (where file is the name of the source
602 -- file) instead of stdout. For example, if file x.adb is compiled
603 -- using -gnatR2s then representation info is written to x.adb.ref.
605 List_Representation_Info_Mechanisms : Boolean := False;
607 -- Set true by -gnatRm switch. Causes information on mechanisms to
608 -- be included in the representation output information.
610 List_Preprocessing_Symbols : Boolean := False;
612 -- Set to True if symbols for preprocessing a source are to be listed
613 -- before preprocessing occurs. Set to True by switch -s of gnatprep
614 -- or -s in preprocessing data file for the compiler.
616 type Creat_Repinfo_File_Proc is access procedure (Src : File_Name_Type);
617 type Write_Repinfo_Line_Proc is access procedure (Info : String);
618 type Close_Repinfo_File_Proc is access procedure;
619 -- Types used for procedure addresses below
621 Creat_Repinfo_File_Access : Creat_Repinfo_File_Proc := null;
622 Write_Repinfo_Line_Access : Write_Repinfo_Line_Proc := null;
623 Close_Repinfo_File_Access : Close_Repinfo_File_Proc := null;
625 -- These three locations are left null when operating in non-compiler
626 -- (e.g. ASIS mode), but when operating in compiler mode, they are
627 -- set to point to the three corresponding procedures in Osint. The
628 -- reason for this slightly strange interface is to prevent Repinfo
629 -- from dragging in Osint in ASIS mode, which would include a lot of
630 -- unwanted units in the ASIS build.
632 Locking_Policy : Character := ' ';
634 -- Set to ' ' for the default case (no locking policy specified).
635 -- Reset to first character (uppercase) of locking policy name if a
636 -- valid pragma Locking_Policy is encountered.
638 Locking_Policy_Sloc : Source_Ptr := No_Location;
640 -- Remember location of previous Locking_Policy pragma. This is used
641 -- for inconsistency error messages. A value of System_Location is
642 -- used if the policy is set in package System.
644 Look_In_Primary_Dir : Boolean := True;
645 -- GNAT, GNATBIND, GNATMAKE, GNATCLEAN
646 -- Set to False if a -I- was present on the command line.
647 -- When True we are allowed to look in the primary directory to locate
648 -- other source or library files.
650 Make_Steps : Boolean := False;
652 -- Set to True when either Compile_Only, Bind_Only or Link_Only is
655 Main_Index : Int := 0;
657 -- This is set to non-zero by gnatmake switch -eInnn to indicate that
658 -- the main program is the nnn unit in a multi-unit source file.
660 Mapping_File_Name : String_Ptr := null;
662 -- File name of mapping between unit names, file names and path names.
663 -- (given by switch -gnatem)
665 Maximum_Errors : Int := 9999;
667 -- Maximum default number of errors before compilation is terminated.
668 -- Can be overridden using -gnatm (GNAT) or -m (GNATBIND) switch.
670 Maximum_File_Name_Length : Int;
672 -- Maximum number of characters allowed in a file name, not counting the
673 -- extension, as set by the appropriate switch. If no switch is given,
674 -- then this value is initialized by Osint to the appropriate value.
676 Max_Line_Length : Int := Hostparm.Max_Line_Length;
677 -- This is a copy of Max_Line_Length used by the scanner. It is usually
678 -- set to be a copy of Hostparm.Max_Line_Length, and is used to check
679 -- the maximum line length in the scanner when style checking is inactive.
680 -- The only time it is set to a different value is during the scanning of
681 -- configuration pragma files, where we want to turn off all checking and
682 -- in particular we want to allow long lines. So we reset this value to
683 -- Column_Number'Last during scanning of configuration pragma files.
685 Maximum_Processes : Positive := 1;
687 -- Maximum number of processes that should be spawned to carry out
690 Minimal_Recompilation : Boolean := False;
692 -- Set to True if minimal recompilation mode requested.
694 Multiple_Unit_Index : Int;
696 -- This is set non-zero if the current unit is being compiled in multiple
697 -- unit per file mode, meaning that the current unit is selected from the
698 -- sequence of units in the current source file, using the value stored
699 -- in this variable (e.g. 2 = select second unit in file). A value of
700 -- zero indicates that we are in normal (one unit per file) mode.
702 No_Main_Subprogram : Boolean := False;
703 -- GNATMAKE, GNATBIND
704 -- Set to True if compilation/binding of a program without main
705 -- subprogram requested.
707 No_Run_Time_Mode : Boolean := False;
709 -- This flag is set True if a No_Run_Time pragma is encountered. See
710 -- spec of Rtsfind for a full description of handling of this pragma.
712 No_Stdinc : Boolean := False;
713 -- GNAT, GNATBIND, GNATMAKE, GNATFIND, GNATXREF
714 -- Set to True if no default source search dirs added to search list
716 No_Stdlib : Boolean := False;
717 -- GNATMAKE, GNATBIND, GNATFIND, GNATXREF
718 -- Set to True if no default library search dirs added to search list
720 No_Strict_Aliasing : Boolean := False;
722 -- Set True if pragma No_Strict_Aliasing with no parameters encountered
724 Normalize_Scalars : Boolean := False;
726 -- Set True if a pragma Normalize_Scalars applies to the current unit.
727 -- Note that Init_Or_Norm_Scalars is also set to True if this is True.
729 Object_Directory_Present : Boolean := False;
731 -- Set to True when an object directory is specified with option -D
733 type Operating_Mode_Type is (Check_Syntax, Check_Semantics, Generate_Code);
734 Operating_Mode : Operating_Mode_Type := Generate_Code;
736 -- Indicates the operating mode of the compiler. The default is generate
737 -- code, which runs the parser, semantics and backend. Switches can be
738 -- used to set syntax checking only mode, or syntax and semantics checking
739 -- only mode. Operating_Mode can also be modified as a result of detecting
740 -- errors during the compilation process. In particular if any serious
741 -- error is detected then this flag is reset from Generate_Code to
742 -- Check_Semantics after generating an error message.
744 Original_Operating_Mode : Operating_Mode_Type := Generate_Code;
746 -- Indicates the original operating mode of the compiler as set by
747 -- compiler options. This is identical to Operating_Mode except that
748 -- this is not affected by errors.
750 Optimization_Level : Int;
751 pragma Import (C, Optimization_Level, "optimize");
752 -- This constant reflects the optimization level (0,1,2 for -O0,-O1,-O2)
754 Output_File_Name_Present : Boolean := False;
755 -- GNATBIND, GNAT, GNATMAKE
756 -- Set to True when the output C file name is given with option -o
757 -- for GNATBIND, when the object file name is given with option
758 -- -gnatO for GNAT or when the executable is given with option -o
761 Output_Linker_Option_List : Boolean := False;
763 -- True if output of list of linker options is requested (-K switch set)
765 Output_Object_List : Boolean := False;
767 -- True if output of list of objects is requested (-O switch set)
769 Pessimistic_Elab_Order : Boolean := False;
771 -- True if pessimistic elaboration order is to be chosen (-p switch set)
773 Polling_Required : Boolean := False;
775 -- Set to True if polling for asynchronous abort is enabled by using
776 -- the -gnatP option for GNAT.
778 Preprocessing_Data_File : String_Ptr := null;
780 -- Set by switch -gnatep=. The file name of the prepocessing data file.
782 Print_Generated_Code : Boolean := False;
784 -- Set to True to enable output of generated code in source form. This
785 -- flag is set by the -gnatG switch.
787 Print_Standard : Boolean := False;
789 -- Set to true to enable printing of package standard in source form.
790 -- This flag is set by the -gnatS switch
792 Propagate_Exceptions : Boolean := False;
794 -- Indicates if subprogram descriptor exception tables should be
795 -- built for imported subprograms. Set True if a Propagate_Exceptions
796 -- pragma applies to the extended main unit.
798 type Usage is (Unknown, Not_In_Use, In_Use);
799 Project_File_In_Use : Usage := Unknown;
801 -- Indicates if a project file is used or not.
802 -- Set to In_Use by the first SFNP pragma.
804 Queuing_Policy : Character := ' ';
806 -- Set to ' ' for the default case (no queuing policy specified).
807 -- Reset to first character (uppercase) of locking policy name if a valid
808 -- Queuing_Policy pragma is encountered.
810 Queuing_Policy_Sloc : Source_Ptr := No_Location;
812 -- Remember location of previous Queuing_Policy pragma. This is used
813 -- for inconsistency error messages. A value of System_Location is
814 -- used if the policy is set in package System.
816 Quiet_Output : Boolean := False;
817 -- GNATMAKE, GNATCLEAN, GPR2MAKE
818 -- Set to True if the tool should not have any output if there are no
819 -- errors or warnings.
821 RTS_Lib_Path_Name : String_Ptr := null;
822 RTS_Src_Path_Name : String_Ptr := null;
824 -- Set to the "adalib" and "adainclude" directories of the run time
825 -- specified by --RTS=.
827 RTS_Switch : Boolean := False;
828 -- GNAT, GNATMAKE, GNATBIND, GNATLS, GNATFIND, GNATXREF
829 -- Set to True when the --RTS switch is set
831 Run_Path_Option : Boolean := True;
832 -- GNATMAKE, GNATLINK
833 -- Set to False when no run_path_option should be issued to the linker
835 Sec_Stack_Used : Boolean := False;
837 -- Set True if generated code uses the System.Secondary_Stack package.
838 -- For the binder, set if any unit uses the secondary stack package.
840 Shared_Libgnat : Boolean;
842 -- Set to True if a shared libgnat is requested by using the -shared
843 -- option for GNATBIND and to False when using the -static option. The
844 -- value of this flag is set by Gnatbind.Scan_Bind_Arg.
846 Stack_Checking_Enabled : Boolean;
848 -- Set to indicate if -fstack-check switch is set for the compilation.
849 -- True means that the switch is set, so that stack checking is enabled.
850 -- False means that the switch is not set (no stack checking). This
851 -- value is obtained from the external imported value flag_stack_check
852 -- in the gcc backend (see Frontend) and may be referenced throughout
853 -- the compilation phases.
855 Style_Check : Boolean := False;
857 -- Set True to perform style checks. Activates checks carried out
858 -- in package Style (see body of this package for details of checks)
859 -- This flag is set True by either the -gnatg or -gnaty switches.
861 System_Extend_Pragma_Arg : Node_Id := Empty;
863 -- Set non-empty if and only if a correct Extend_System pragma was present
864 -- in which case it points to the argument of the pragma, and the name can
865 -- be located as Chars (Expression (System_Extend_Pragma_Arg)).
867 System_Extend_Unit : Node_Id := Empty;
869 -- This is set to Empty if GNAT_Mode is set, since pragma Extend_System
870 -- is never appropriate in GNAT_Mode (and causes troubles, including
871 -- bogus circularities, if we try to compile the run-time library with
872 -- a System extension). If GNAT_Mode is not set, then System_Extend_Unit
873 -- is a copy of the value set in System_Extend_Pragma_Ary.
875 Subunits_Missing : Boolean := False;
877 -- This flag is set true if missing subunits are detected with code
878 -- generation active. This causes code generation to be skipped.
880 Suppress_Checks : Boolean := False;
882 -- Set to True if -gnatp (suppress all checks) switch present.
884 Suppress_Options : Suppress_Array;
886 -- Flags set True to suppress corresponding check, i.e. add an implicit
887 -- pragma Suppress at the outer level of each unit compiled. Note that
888 -- these suppress actions can be overridden by the use of the Unsuppress
889 -- pragma. This variable is initialized by Osint.Initialize.
891 Suppress_Back_Annotation : Boolean := False;
893 -- This flag is set True if back annotation of representation information
894 -- is to be suppressed. This is set if neither -gnatt or -gnatR0-3 is set.
895 -- This avoids unnecessary time being spent on back annotation.
897 Table_Factor : Int := 1;
899 -- Factor by which all initial table sizes set in Alloc are multiplied.
900 -- Used in Table to calculate initial table sizes (the initial table
901 -- size is the value in Alloc, used as the Table_Initial parameter
902 -- value, multiplied by the factor given here. The default value is
903 -- used if no -gnatT switch appears.
905 Task_Dispatching_Policy : Character := ' ';
907 -- Set to ' ' for the default case (no task dispatching policy specified).
908 -- Reset to first character (uppercase) of task dispatching policy name
909 -- if a valid Task_Dispatching_Policy pragma is encountered.
911 Task_Dispatching_Policy_Sloc : Source_Ptr := No_Location;
913 -- Remember location of previous Task_Dispatching_Policy pragma. This is
914 -- used for inconsistency error messages. A value of System_Location is
915 -- used if the policy is set in package System.
917 Tasking_Used : Boolean := False;
918 -- Set True if any tasking construct is encountered. Used to activate the
919 -- output of the Q, L and T lines in ALI files.
921 Time_Slice_Set : Boolean := False;
923 -- Set True if a pragma Time_Slice is processed in the main unit, or
924 -- if the -gnatTnn switch is present to set a time slice value.
926 Time_Slice_Value : Nat;
928 -- Time slice value. Valid only if Time_Slice_Set is True, i.e. if a
929 -- Time_Slice pragma has been processed. Set to the time slice value
930 -- in microseconds. Negative values are stored as zero, and the value
931 -- is not larger than 1_000_000_000 (1000 seconds). Values larger than
932 -- this are reset to this maximum. This can also be set with the -gnatTnn
935 Tolerate_Consistency_Errors : Boolean := False;
937 -- Tolerate time stamp and other consistency errors. If this flag is
938 -- set to True (-t), then inconsistencies result in warnings rather than
941 Tree_Output : Boolean := False;
943 -- Set to True (-gnatt) to generate output tree file
945 Try_Semantics : Boolean := False;
947 -- Flag set to force attempt at semantic analysis, even if parser errors
948 -- occur. This will probably cause blowups at this stage in the game. On
949 -- the other hand, most such blowups will be caught cleanly and simply
950 -- say compilation abandoned. This flag is set to True by -gnatq or -gnatQ.
952 Undefined_Symbols_Are_False : Boolean := False;
954 -- Set to True by switch -u of gnatprep or -u in the preprocessing data
955 -- file for the compiler. Indicates that while preprocessing sources,
956 -- symbols that are not defined have the value FALSE.
958 Unique_Error_Tag : Boolean := Tag_Errors;
960 -- Indicates if error messages are to be prefixed by the string error:
961 -- Initialized from Tag_Errors, can be forced on with the -gnatU switch.
963 Universal_Addressing_On_AAMP : Boolean := False;
965 -- Indicates if library-level objects should be accessed and updated
966 -- using universal addressing instructions on the AAMP architecture.
967 -- This flag is set to True when pragma Universal_Data is given as
968 -- a configuration pragma.
970 Unreserve_All_Interrupts : Boolean := False;
972 -- Normally set False, set True if a valid Unreserve_All_Interrupts
973 -- pragma appears anywhere in the main unit for GNAT, or if any ALI
974 -- file has the corresponding attribute set in GNATBIND.
976 Upper_Half_Encoding : Boolean := False;
978 -- Normally set False, indicating that upper half ASCII characters are
979 -- used in the normal way to represent themselves. If the wide character
980 -- encoding method uses the upper bit for this encoding, then this flag
981 -- is set True, and upper half characters in the source indicate the
982 -- start of a wide character sequence.
984 Usage_Requested : Boolean := False;
985 -- GNAT, GNATBIND, GNATMAKE
986 -- Set to True if -h (-gnath for the compiler) switch encountered
987 -- requesting usage information
989 Use_VADS_Size : Boolean := False;
991 -- Set to True if a valid pragma Use_VADS_Size is processed
993 Validity_Checks_On : Boolean := True;
995 -- This flag determines if validity checking is on or off. The initial
996 -- state is on, and the required default validity checks are active. The
997 -- actual set of checks that is performed if Validity_Checks_On is set
998 -- is defined by the switches in package Sem_Val. The Validity_Checks_On
999 -- flag is controlled by pragma Validity_Checks (On | Off), and also
1000 -- some generated compiler code (typically code that has to do with
1001 -- validity check generation) is compiled with this flag set to False.
1002 -- This flag is set to False by the -gnatp switch.
1004 Verbose_Mode : Boolean := False;
1005 -- GNAT, GNATBIND, GNATMAKE, GNATLINK, GNATLS, GNATCHOP, GNATNAME,
1007 -- Set to True to get verbose mode (full error message text and location
1008 -- information sent to standard output, also header, copyright and summary)
1010 Warn_On_Constant : Boolean := False;
1012 -- Set to True to generate warnings for variables that could be declared
1013 -- as constants. Modified by use of -gnatwk/K.
1015 Warn_On_Dereference : Boolean := False;
1017 -- Set to True to generate warnings for implicit dereferences for array
1018 -- indexing and record component access. Modified by use of -gnatwd/D.
1020 Warn_On_Export_Import : Boolean := True;
1022 -- Set to True to generate warnings for suspicious use of export or
1023 -- import pragmas. Modified by use of -gnatwx/X.
1025 Warn_On_Hiding : Boolean := False;
1027 -- Set to True to generate warnings if a declared entity hides another
1028 -- entity. The default is that this warning is suppressed.
1030 Warn_On_Modified_Unread : Boolean := False;
1032 -- Set to True to generate warnings if a variable is assigned but is
1033 -- never read. The default is that this warning is suppressed.
1035 Warn_On_No_Value_Assigned : Boolean := True;
1037 -- Set to True to generate warnings if no value is ever assigned to a
1038 -- variable that is at least partially uninitialized. Set to false to
1039 -- suppress such warnings. The default is that such warnings are enabled.
1041 Warn_On_Obsolescent_Feature : Boolean := False;
1043 -- Set to True to generate warnings on use of any feature in Annex J
1044 -- or if a subprogram is called for which a pragma Obsolescent applies.
1046 Warn_On_Redundant_Constructs : Boolean := False;
1048 -- Set to True to generate warnings for redundant constructs (e.g. useless
1049 -- assignments/conversions). The default is that this warning is disabled.
1051 Warn_On_Unchecked_Conversion : Boolean := True;
1053 -- Set to True to generate warnings for unchecked conversions that may have
1054 -- non-portable semantics (e.g. because sizes of types differ). The default
1055 -- is that this warning is enabled.
1057 Warn_On_Unrecognized_Pragma : Boolean := True;
1059 -- Set to True to generate warnings for unrecognized pragmas. The default
1060 -- is that this warning is enabled.
1062 type Warning_Mode_Type is (Suppress, Normal, Treat_As_Error);
1063 Warning_Mode : Warning_Mode_Type := Normal;
1065 -- Controls treatment of warning messages. If set to Suppress, warning
1066 -- messages are not generated at all. In Normal mode, they are generated
1067 -- but do not count as errors. In Treat_As_Error mode, warning messages
1068 -- are generated and are treated as errors.
1070 Wide_Character_Encoding_Method : WC_Encoding_Method := WCEM_Brackets;
1072 -- Method used for encoding wide characters in the source program. See
1073 -- description of type in unit System.WCh_Con for a list of the methods
1074 -- that are currently supported. Note that brackets notation is always
1075 -- recognized in source programs regardless of the setting of this
1076 -- variable. The default setting causes only the brackets notation
1077 -- to be recognized. If this is the main unit, this setting also
1078 -- controls the output of the W=? parameter in the ALI file, which
1079 -- is used to provide the default for Wide_Text_IO files.
1081 Xref_Active : Boolean := True;
1083 -- Set if cross-referencing is enabled (i.e. xref info in ALI files)
1085 Zero_Cost_Exceptions_Val : Boolean;
1086 Zero_Cost_Exceptions_Set : Boolean := False;
1088 -- These values are to record the setting of the zero cost exception
1089 -- handling mode set by argument switches (-gnatZ/-gnatL). If the
1090 -- value is set by one of these switches, then Zero_Cost_Exceptions_Set
1091 -- is set to True, and Zero_Cost_Exceptions_Val indicates the setting.
1093 ----------------------------
1094 -- Configuration Settings --
1095 ----------------------------
1097 -- These are settings that are used to establish the mode at the start
1098 -- of each unit. The values defined below can be affected either by
1099 -- command line switches, or by the use of appropriate configuration
1100 -- pragmas in the gnat.adc file.
1102 Ada_Version_Config : Ada_Version_Type;
1104 -- This is the value of the configuration switch for the Ada 83 mode, as
1105 -- set by the command line switches -gnat83/95/05, and possibly modified
1106 -- by the use of configuration pragmas Ada_83/Ada95/Ada05. This switch
1107 -- is used to set the initial value for Ada_Version mode at the start
1108 -- of analysis of a unit. Note however, that the setting of this flag
1109 -- is ignored for internal and predefined units (which are always compiled
1110 -- in the most up to date version of Ada).
1112 Dynamic_Elaboration_Checks_Config : Boolean := False;
1114 -- Set True for dynamic elaboration checking mode, as set by the -gnatE
1115 -- switch or by the use of pragma Elaboration_Checking (Dynamic).
1117 Exception_Locations_Suppressed_Config : Boolean := False;
1119 -- Set True by use of the configuration pragma Suppress_Exception_Messages
1121 Extensions_Allowed_Config : Boolean;
1123 -- This is the flag that indicates whether extensions are allowed.
1124 -- It can be set True either by use of the -gnatX switch, or by use
1125 -- of the configuration pragma Extensions_Allowed (On). It is always
1126 -- set to True for internal GNAT units, since extensions are always
1127 -- permitted in such units.
1129 External_Name_Exp_Casing_Config : External_Casing_Type;
1131 -- This is the value of the configuration switch that controls casing
1132 -- of external symbols for which an explicit external name is given. It
1133 -- can be set to Uppercase by the command line switch -gnatF, and further
1134 -- modified by the use of the configuration pragma External_Name_Casing
1135 -- in the gnat.adc file. This flag is used to set the initial value
1136 -- for External_Name_Exp_Casing at the start of analyzing each unit.
1137 -- Note however that the setting of this flag is ignored for internal
1138 -- and predefined units (which are always compiled with As_Is mode).
1140 External_Name_Imp_Casing_Config : External_Casing_Type;
1142 -- This is the value of the configuration switch that controls casing
1143 -- of external symbols where the external name is implicitly given. It
1144 -- can be set to Uppercase by the command line switch -gnatF, and further
1145 -- modified by the use of the configuration pragma External_Name_Casing
1146 -- in the gnat.adc file. This flag is used to set the initial value
1147 -- for External_Name_Imp_Casing at the start of analyzing each unit.
1148 -- Note however that the setting of this flag is ignored for internal
1149 -- and predefined units (which are always compiled with Lowercase mode).
1151 Polling_Required_Config : Boolean;
1153 -- This is the value of the configuration switch that controls polling
1154 -- mode. It can be set True by the command line switch -gnatP, and then
1155 -- further modified by the use of pragma Polling in the gnat.adc file.
1156 -- This flag is used to set the initial value for Polling_Required
1157 -- at the start of analyzing each unit.
1159 Use_VADS_Size_Config : Boolean;
1161 -- This is the value of the configuration switch that controls the use
1162 -- of VADS_Size instead of Size whereever the attribute Size is used.
1163 -- It can be set True by the use of the pragma Use_VADS_Size in the
1164 -- gnat.adc file. This flag is used to set the initial value for
1165 -- Use_VADS_Size at the start of analyzing each unit. Note however that
1166 -- the setting of this flag is ignored for internal and predefined
1167 -- units (which are always compiled with the standard Size semantics).
1169 type Config_Switches_Type is private;
1170 -- Type used to save values of the switches set from Config values
1172 procedure Save_Opt_Config_Switches (Save : out Config_Switches_Type);
1173 -- This procedure saves the current values of the switches which are
1174 -- initialized from the above Config values, and then resets these
1175 -- switches according to the Config value settings.
1177 procedure Set_Opt_Config_Switches (Internal_Unit : Boolean);
1178 -- This procedure sets the switches to the appropriate initial values.
1179 -- The parameter Internal_Unit is True for an internal or predefined
1180 -- unit, and affects the way the switches are set (see above).
1182 procedure Restore_Opt_Config_Switches (Save : Config_Switches_Type);
1183 -- This procedure restores a set of switch values previously saved
1184 -- by a call to Save_Opt_Switches.
1186 procedure Register_Opt_Config_Switches;
1187 -- This procedure is called after processing the gnat.adc file to record
1188 -- the values of the Config switches, as possibly modified by the use
1189 -- of command line switches and configuration pragmas.
1191 ------------------------
1192 -- Other Global Flags --
1193 ------------------------
1195 Expander_Active : Boolean := False;
1196 -- A flag that indicates if expansion is active (True) or deactivated
1197 -- (False). When expansion is deactivated all calls to expander routines
1198 -- have no effect. Note that the initial setting of False is merely to
1199 -- prevent saving of an undefined value for an initial call to the
1200 -- Expander_Mode_Save_And_Set procedure. For more information on the
1201 -- use of this flag, see package Expander. Indeed this flag might more
1202 -- logically be in the spec of Expander, but it is referenced by Errout,
1203 -- and it really seems wrong for Errout to depend on Expander.
1205 -----------------------
1206 -- Tree I/O Routines --
1207 -----------------------
1209 procedure Tree_Read;
1210 -- Reads switch settings from current tree file using Tree_Read
1212 procedure Tree_Write;
1213 -- Writes out switch settings to current tree file using Tree_Write
1215 --------------------------
1216 -- ASIS Version Control --
1217 --------------------------
1219 -- These two variables (Tree_Version_String and Tree_ASIS_Version_Number)
1220 -- are supposed to be used in the GNAT/ASIS version check performed in
1221 -- the ASIS code (this package is also a part of the ASIS implementation).
1222 -- They are set by Tree_Read procedure, so they represent the version
1223 -- number (and the version string) of the compiler which has created the
1224 -- tree, and they are supposed to be compared with the corresponding values
1225 -- from the Gnatvsn package which is a part of ASIS implementation.
1227 Tree_Version_String : String (Gnat_Version_String'Range);
1228 -- Used to store the compiler version string read from a tree file to
1229 -- check if it is the same as stored in the version string in Gnatvsn.
1230 -- Therefore its length is taken directly from the version string in
1231 -- Gnatvsn. If the length of the version string stored in the tree is
1232 -- different, then versions are for sure different, and a string containing
1233 -- '?' characters is assigned to this variable as a result of tree read.
1235 Tree_ASIS_Version_Number : Int;
1236 -- Used to store the ASIS version number read from a tree file to check if
1237 -- it is the same as stored in the ASIS version number in Gnatvsn.
1241 type Config_Switches_Type is record
1242 Ada_Version : Ada_Version_Type;
1243 Dynamic_Elaboration_Checks : Boolean;
1244 Exception_Locations_Suppressed : Boolean;
1245 Extensions_Allowed : Boolean;
1246 External_Name_Exp_Casing : External_Casing_Type;
1247 External_Name_Imp_Casing : External_Casing_Type;
1248 Polling_Required : Boolean;
1249 Use_VADS_Size : Boolean;