------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- O P T --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2009, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- . --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package contains global flags set by the initialization routine from
-- the command line and referenced throughout the compiler, the binder, or
-- other GNAT tools. The comments indicate which options are used by which
-- programs (GNAT, GNATBIND, GNATLINK, GNATMAKE, GPRMAKE, etc).
-- Some flags are labelled "PROJECT MANAGER". These are used by tools that
-- use the Project Manager. These tools include gnatmake, gnatname, the gnat
-- driver, gnatclean, gprbuild and gprclean.
with Debug;
with Hostparm; use Hostparm;
with Types; use Types;
with System.Strings; use System.Strings;
with System.WCh_Con; use System.WCh_Con;
package Opt is
----------------------------------------------
-- Settings of Modes for Current Processing --
----------------------------------------------
-- The following mode values represent the current state of processing.
-- The values set here are the default values. Unless otherwise noted,
-- the value may be reset in Switch-? with an appropriate switch. In
-- some cases, the values can also be modified by pragmas, and in the
-- case of some binder variables, Gnatbind.Scan_Bind_Arg may modify
-- the default values.
Ada_Bind_File : Boolean := True;
-- GNATBIND, GNATLINK
-- Set True if binder file to be generated in Ada rather than C
type Ada_Version_Type is (Ada_83, Ada_95, Ada_05);
pragma Warnings (Off, Ada_Version_Type);
-- Versions of Ada for Ada_Version below. Note that these are ordered,
-- so that tests like Ada_Version >= Ada_95 are legitimate and useful.
-- The Warnings_Off pragma stops warnings for Ada_Version >= Ada_05,
-- which we want to allow, so that things work OK when Ada_15 is added!
-- This warning is now removed, so this pragma can be removed some time???
Ada_Version_Default : Ada_Version_Type := Ada_05;
-- GNAT
-- Default Ada version if no switch given
Ada_Version : Ada_Version_Type := Ada_Version_Default;
-- GNAT
-- Current Ada version for compiler, as set by configuration pragmas,
-- compiler switches, or implicitly (to Ada_Version_Runtime) when a
-- predefined or internal file is compiled.
Ada_Version_Explicit : Ada_Version_Type := Ada_Version_Default;
-- GNAT
-- Like Ada_Version, but does not get set implicitly for predefined
-- or internal units, so it reflects the Ada version explicitly set
-- using configuration pragmas or compiler switches (or if neither
-- appears, it remains set to Ada_Version_Default). This is used in
-- the rare cases (notably for pragmas Preelaborate_05 and Pure_05)
-- where in the run-time we want the explicit version set.
Ada_Version_Runtime : Ada_Version_Type := Ada_05;
-- GNAT
-- Ada version used to compile the runtime. Used to set Ada_Version (but
-- not Ada_Version_Explicit) when compiling predefined or internal units.
Ada_Final_Suffix : constant String := "final";
Ada_Final_Name : String_Ptr := new String'("ada" & Ada_Final_Suffix);
-- GNATBIND
-- The name of the procedure that performs the finalization at the end of
-- execution. This variable may be modified by Gnatbind.Scan_Bind_Arg.
Ada_Init_Suffix : constant String := "init";
Ada_Init_Name : String_Ptr := new String'("ada" & Ada_Init_Suffix);
-- GNATBIND
-- The name of the procedure that performs initialization at the start
-- of execution. This variable may be modified by Gnatbind.Scan_Bind_Arg.
Ada_Main_Name_Suffix : constant String := "main";
-- GNATBIND
-- The suffix for Ada_Main_Name. Defined as a constant here so that it
-- can be referenced in a uniform manner to create either the default
-- value of Ada_Main_Name (declared below), or the non-default name
-- set by Gnatbind.Scan_Bind_Arg.
Ada_Main_Name : String_Ptr := new String'("ada_" & Ada_Main_Name_Suffix);
-- GNATBIND
-- The name of the Ada package generated by the binder (when in Ada mode).
-- This variable may be modified by Gnatbind.Scan_Bind_Arg.
Address_Clause_Overlay_Warnings : Boolean := True;
-- GNAT
-- Set False to disable address clause warnings
Address_Is_Private : Boolean := False;
-- GNAT, GNATBIND
-- Set True if package System has the line "type Address is private;"
All_Errors_Mode : Boolean := False;
-- GNAT
-- Flag set to force display of multiple errors on a single line and
-- also repeated error messages for references to undefined identifiers
-- and certain other repeated error messages. Set by use of -gnatf.
All_Sources : Boolean := False;
-- GNATBIND
-- Set to True to require all source files to be present. This flag is
-- directly modified by gnatmake to affect the shared binder routines.
Alternate_Main_Name : String_Ptr := null;
-- GNATBIND
-- Set to non null when Bind_Alternate_Main_Name is True. This value
-- is modified as needed by Gnatbind.Scan_Bind_Arg.
ASIS_Mode : Boolean := False;
-- GNAT
-- Enable semantic checks and tree transformations that are important
-- for ASIS but that are usually skipped if Operating_Mode is set to
-- Check_Semantics. This flag does not have the corresponding option to set
-- it ON. It is set ON when Tree_Output is set ON, it can also be set ON
-- from the code of GNSA-based tool (a client may need to set ON the
-- Back_Annotate_Rep_Info flag in this case. At the moment this does not
-- make very much sense, because GNSA cannot do back annotation).
Assertions_Enabled : Boolean := False;
-- GNAT
-- Enable assertions made using pragma Assert
Assume_No_Invalid_Values : Boolean := False;
-- GNAT
-- Normally, in accordance with (RM 13.9.1 (9-11)) the front end assumes
-- that values could have invalid representations, unless it can clearly
-- prove that the values are valid. If this switch is set (by -gnatB or by
-- pragma Assume_No_Invalid_Values (Off)), then the compiler assumes values
-- are valid and in range of their representations. This feature is now
-- fully enabled in the compiler.
Back_Annotate_Rep_Info : Boolean := False;
-- GNAT
-- If set True, enables back annotation of representation information
-- by gigi, even in -gnatc mode. This is set True by the use of -gnatR
-- (list representation information) or -gnatt (generate tree). It is
-- also set true if certain Unchecked_Conversion instantiations require
-- checking based on annotated values.
Bind_Alternate_Main_Name : Boolean := False;
-- GNATBIND
-- True if main should be called Alternate_Main_Name.all.
-- This variable may be set to True by Gnatbind.Scan_Bind_Arg.
Bind_Main_Program : Boolean := True;
-- GNATBIND
-- Set to False if not binding main Ada program
Bind_For_Library : Boolean := False;
-- GNATBIND
-- Set to True if the binder needs to generate a file designed for
-- building a library. May be set to True by Gnatbind.Scan_Bind_Arg.
Bind_Only : Boolean := False;
-- GNATMAKE, GPRMAKE, GPRBUILD
-- Set to True to skip compile and link steps
-- (except when Compile_Only and/or Link_Only are True).
Blank_Deleted_Lines : Boolean := False;
-- GNAT, GNATPREP
-- Output empty lines for each line of preprocessed input that is deleted
-- in the output, including preprocessor lines starting with a '#'.
Brief_Output : Boolean := False;
-- GNAT, GNATBIND
-- Force brief error messages to standard error, even if verbose mode is
-- set (so that main error messages go to standard output).
Build_Bind_And_Link_Full_Project : Boolean := False;
-- GNATMAKE
-- Set to True to build, bind and link all the sources of a project file
-- (switch -B)
Check_Object_Consistency : Boolean := False;
-- GNATBIND, GNATMAKE
-- Set to True to check whether every object file is consistent with
-- its corresponding ada library information (ALI) file. An object
-- file is inconsistent with the corresponding ALI file if the object
-- file does not exist or if it has an older time stamp than the ALI file.
-- Default above is for GNATBIND. GNATMAKE overrides this default to
-- True (see Make.Initialize) since we normally do need to check source
-- consistencies in gnatmake.
Check_Only : Boolean := False;
-- GNATBIND
-- Set to True to do checks only, no output of binder file
Check_Policy_List : Node_Id := Empty;
-- GNAT
-- This points to the list of N_Pragma nodes for Check_Policy pragmas
-- that are linked through the Next_Pragma fields, with the list being
-- terminated by Empty. The order is most recently processed first.
Check_Readonly_Files : Boolean := False;
-- GNATMAKE
-- Set to True to check readonly files during the make process
Check_Source_Files : Boolean := True;
-- GNATBIND, GNATMAKE
-- Set to True to enable consistency checking for any source files that
-- are present (i.e. date must match the date in the library info file).
-- Set to False for object file consistency check only. This flag is
-- directly modified by gnatmake, to affect the shared binder routines.
Check_Switches : Boolean := False;
-- GNATMAKE, GPRMAKE, GPBUILD
-- Set to True to check compiler options during the make process
Check_Unreferenced : Boolean := False;
-- GNAT
-- Set to True to enable checking for unreferenced entities other
-- than formal parameters (for which see Check_Unreferenced_Formals)
Check_Unreferenced_Formals : Boolean := False;
-- GNAT
-- Set True to check for unreferenced formals. This is turned on by
-- -gnatwa/wf/wu and turned off by -gnatwA/wF/wU.
Check_Withs : Boolean := False;
-- GNAT
-- Set to True to enable checking for unused withs, and also the case
-- of withing a package and using none of the entities in the package.
Commands_To_Stdout : Boolean := False;
-- GNATMAKE
-- True if echoed commands to be written to stdout instead of stderr
Comment_Deleted_Lines : Boolean := False;
-- GNATPREP
-- True if source lines removed by the preprocessor should be commented
-- in the output file.
Compile_Only : Boolean := False;
-- GNATMAKE, GNATCLEAN, GPRMAKE, GPBUILD, GPRCLEAN
-- GNATMAKE, GPRMAKE, GPRMAKE:
-- set to True to skip bind and link steps (except when Bind_Only is
-- True).
-- GNATCLEAN, GPRCLEAN:
-- set to True to delete only the files produced by the compiler but not
-- the library files or the executable files.
Config_File : Boolean := True;
-- GNAT
-- Set to False to inhibit reading and processing of gnat.adc file
Config_File_Names : String_List_Access := null;
-- GNAT
-- Names of configuration pragmas files (given by switches -gnatec)
Configurable_Run_Time_Mode : Boolean := False;
-- GNAT, GNATBIND
-- Set True if the compiler is operating in configurable run-time mode.
-- This happens if the flag Targparm.Configurable_Run_TimeMode_On_Target
-- is set True, or if pragma No_Run_Time is used. See the spec of Rtsfind
-- for details on the handling of the latter pragma.
Constant_Condition_Warnings : Boolean := False;
-- GNAT
-- Set to True to activate warnings on constant conditions
Create_Mapping_File : Boolean := False;
-- GNATMAKE, GPRMAKE
-- Set to True (-C switch) to indicate that the compiler will be invoked
-- with a mapping file (-gnatem compiler switch).
Debug_Pragmas_Enabled : Boolean := False;
-- GNAT
-- Enable debug statements from pragma Debug
subtype Debug_Level_Value is Nat range 0 .. 3;
Debugger_Level : Debug_Level_Value := 0;
-- GNATBIND
-- The value given to the -g parameter. The default value for -g with
-- no value is 2. This is usually ignored by GNATBIND, except in the
-- VMS version where it is passed as an argument to __gnat_initialize
-- to trigger the activation of the remote debugging interface.
-- Is this still true ???
Debug_Generated_Code : Boolean := False;
-- GNAT
-- Set True (-gnatD switch) to debug generated expanded code instead
-- of the original source code. Causes debugging information to be
-- written with respect to the generated code file that is written.
Default_Exit_Status : Int := 0;
-- GNATBIND
-- Set the default exit status value. Set by the -Xnnn switch for the
-- binder.
Default_Stack_Size : Int := -1;
-- GNATBIND
-- Set to default primary stack size in units of bytes. Set by
-- the -dnnn switch for the binder. A value of -1 indicates that no
-- default was set by the binder.
Default_Sec_Stack_Size : Int := -1;
-- GNATBIND
-- Set to default secondary stack size in units of bytes. Set by
-- the -Dnnn switch for the binder. A value of -1 indicates that no
-- default was set by the binder, and that the default should be the
-- initial value of System.Secondary_Stack.Default_Secondary_Stack_Size.
Detect_Blocking : Boolean := False;
-- GNAT
-- Set True to force the run time to raise Program_Error if calls to
-- potentially blocking operations are detected from protected actions.
Display_Compilation_Progress : Boolean := False;
-- GNATMAKE, GPRMAKE, GPRBUILD
-- Set True (-d switch) to display information on progress while compiling
-- files. Internal flag to be used in conjunction with an IDE (e.g GPS).
type Distribution_Stub_Mode_Type is
-- GNAT
(No_Stubs,
-- Normal mode, no generation/compilation of distribution stubs
Generate_Receiver_Stub_Body,
-- The unit being compiled is the RCI body, and the compiler will
-- generate the body for the receiver stubs and compile it.
Generate_Caller_Stub_Body);
-- The unit being compiled is the RCI spec, and the compiler will
-- generate the body for the caller stubs and compile it.
Distribution_Stub_Mode : Distribution_Stub_Mode_Type := No_Stubs;
-- GNAT
-- This enumeration variable indicates the five states of distribution
-- annex stub generation/compilation.
Do_Not_Execute : Boolean := False;
-- GNATMAKE
-- Set to True if no actual compilations should be undertaken.
Dump_Source_Text : Boolean := False;
-- GNAT
-- Set to True (by -gnatL) to dump source text intermingled with generated
-- code. Effective only if either of Debug/Print_Generated_Code is true.
Dynamic_Elaboration_Checks : Boolean := False;
-- GNAT
-- Set True for dynamic elaboration checking mode, as set by the -gnatE
-- switch or by the use of pragma Elaboration_Checks (Dynamic).
Dynamic_Stack_Measurement : Boolean := False;
-- GNATBIND
-- Set True to enable dynamic stack measurement (-u flag for gnatbind)
Dynamic_Stack_Measurement_Array_Size : Nat := 100;
-- GNATBIND
-- Number of measurements we want to store during dynamic stack analysis.
-- When the buffer is full, non-storable results will be output on the fly.
-- The value is relevant only if Dynamic_Stack_Measurement is set. Set
-- by processing of -u flag for gnatbind.
Elab_Dependency_Output : Boolean := False;
-- GNATBIND
-- Set to True to output complete list of elaboration constraints
Elab_Order_Output : Boolean := False;
-- GNATBIND
-- Set to True to output chosen elaboration order
Elab_Warnings : Boolean := False;
-- GNAT
-- Set to True to generate full elaboration warnings (-gnatwl)
Enable_Overflow_Checks : Boolean := False;
-- GNAT
-- Set to True if -gnato (enable overflow checks) switch is set,
-- but not -gnatp.
Error_Msg_Line_Length : Nat := 0;
-- GNAT
-- Records the error message line length limit. If this is set to zero,
-- then we get the old style behavior, in which each call to the error
-- message routines generates one line of output as a separate message.
-- If it is set to a non-zero value, then continuation lines are folded
-- to make a single long message, and then this message is split up into
-- multiple lines not exceeding the specified length. Set by -gnatj=nn.
Exception_Handler_Encountered : Boolean := False;
-- GNAT
-- This flag is set true if the parser encounters an exception handler.
-- It is used to set Warn_On_Exception_Propagation True if the restriction
-- No_Exception_Propagation is set.
Exception_Locations_Suppressed : Boolean := False;
-- GNAT
-- This flag is set True if a Suppress_Exception_Locations configuration
-- pragma is currently active.
type Exception_Mechanism_Type is
-- Determines the handling of exceptions. See Exp_Ch11 for details
--
(Front_End_Setjmp_Longjmp_Exceptions,
-- Exceptions use setjmp/longjmp generated explicitly by the
-- front end (this includes gigi or other equivalent parts of
-- the code generator). AT END handlers are converted into
-- exception handlers by the front end in this mode.
Back_End_Exceptions);
-- Exceptions are handled by the back end. The front end simply
-- generates the handlers as they appear in the source, and AT
-- END handlers are left untouched (they are not converted into
-- exception handlers when operating in this mode.
pragma Convention (C, Exception_Mechanism_Type);
Exception_Mechanism : Exception_Mechanism_Type :=
Front_End_Setjmp_Longjmp_Exceptions;
-- GNAT
-- Set to the appropriate value depending on the default as given in
-- system.ads (ZCX_By_Default, GCC_ZCX_Support).
-- The C convention is there to make this variable accessible to gigi.
Exception_Tracebacks : Boolean := False;
-- GNATBIND
-- Set to True to store tracebacks in exception occurrences (-E)
Extensions_Allowed : Boolean := False;
-- GNAT
-- Set to True by switch -gnatX if GNAT specific language extensions
-- are allowed. For example, the use of 'Constrained with objects of
-- generic types is a GNAT extension.
type External_Casing_Type is (
As_Is, -- External names cased as they appear in the Ada source
Uppercase, -- External names forced to all uppercase letters
Lowercase); -- External names forced to all lowercase letters
External_Name_Imp_Casing : External_Casing_Type := Lowercase;
-- GNAT
-- The setting of this flag determines the casing of external names
-- when the name is implicitly derived from an entity name (i.e. either
-- no explicit External_Name or Link_Name argument is used, or, in the
-- case of extended DEC pragmas, the external name is given using an
-- identifier. The As_Is setting is not permitted here (since this would
-- create Ada source programs that were case sensitive).
External_Name_Exp_Casing : External_Casing_Type := As_Is;
-- GNAT
-- The setting of this flag determines the casing of an external name
-- specified explicitly with a string literal. As_Is means the string
-- literal is used as given with no modification to the casing. If
-- Lowercase or Uppercase is set, then the string is forced to all
-- lowercase or all uppercase letters as appropriate. Note that this
-- setting has no effect if the external name is given using an identifier
-- in the case of extended DEC import/export pragmas (in this case the
-- casing is controlled by External_Name_Imp_Casing), and also has no
-- effect if an explicit Link_Name is supplied (a link name is always
-- used exactly as given).
External_Unit_Compilation_Allowed : Boolean := False;
-- GNATMAKE
-- When True (set by gnatmake switch -x), allow compilation of sources
-- that are not part of any project file.
Fast_Math : Boolean := False;
-- GNAT
-- Indicates the current setting of Fast_Math mode, as set by the use
-- of a Fast_Math pragma (set on by Fast_Math (On)).
Float_Format : Character := ' ';
-- GNAT
-- A non-blank value indicates that a Float_Format pragma has been
-- processed, in which case this variable is set to 'I' for IEEE or
-- to 'V' for VAX. The setting of 'V' is only possible on OpenVMS
-- versions of GNAT.
Float_Format_Long : Character := ' ';
-- GNAT
-- A non-blank value indicates that a Long_Float pragma has been
-- processed (this pragma is recognized only in OpenVMS versions
-- of GNAT), in which case this variable is set to D or G for
-- D_Float or G_Float.
Force_ALI_Tree_File : Boolean := False;
-- GNAT
-- Force generation of ALI file even if errors are encountered.
-- Also forces generation of tree file if -gnatt is also set.
Force_Checking_Of_Elaboration_Flags : Boolean := False;
-- GNATBIND
-- True if binding with forced checking of the elaboration flags
-- (-F switch set).
Force_Compilations : Boolean := False;
-- GNATMAKE, GPRMAKE, GPRBUILD
-- Set to force recompilations even when the objects are up-to-date.
Full_Path_Name_For_Brief_Errors : Boolean := False;
-- PROJECT MANAGER
-- When True, in Brief_Output mode, each error message line
-- will start with the full path name of the source.
-- When False, only the file name without directory information
-- is used.
Full_List : Boolean := False;
-- GNAT
-- Set True to generate full source listing with embedded errors
Full_List_File_Name : String_Ptr := null;
-- GNAT
-- Set to file name to generate full source listing to named file (or if
-- the name is of the form .xxx, then to name.xxx where name is the source
-- file name with extension stripped.
Generate_Processed_File : Boolean := False;
-- GNAT
-- True when switch -gnateG is used. When True, create in a file
--