-- --
------------------------------------------------------------------------------
-pragma Ada_95;
+pragma Ada_2005;
+-- Explicit setting of Ada 2005 mode is required here, since we want to with a
+-- child unit (not possible in Ada 83 mode), and Text_IO is not considered to
+-- be an internal unit that is automatically compiled in Ada 2005 mode (since
+-- a user is allowed to redeclare Direct_IO).
+
with Ada.Direct_IO;
generic package Direct_IO renames Ada.Direct_IO;
-- --
------------------------------------------------------------------------------
-pragma Ada_95;
+pragma Ada_2005;
+-- Explicit setting of Ada 2005 mode is required here, since we want to with a
+-- child unit (not possible in Ada 83 mode), and Text_IO is not considered to
+-- be an internal unit that is automatically compiled in Ada 2005 mode (since
+-- a user is allowed to redeclare IO_Exceptions).
+
with Ada.IO_Exceptions;
+
package IO_Exceptions renames Ada.IO_Exceptions;
-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2006, 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- --
-- --
------------------------------------------------------------------------------
+with Gnatvsn; use Gnatvsn;
with System; use System;
with Tree_IO; use Tree_IO;
package body Opt is
- Immediate_Errors : Boolean := True;
- -- This is an obsolete flag that is no longer present in opt.ads. We
- -- retain it here because this flag was written to the tree and there
- -- is no point in making trees incomaptible just for the sake of saving
- -- one byte of data. The value written is ignored.
-
----------------------------------
-- Register_Opt_Config_Switches --
----------------------------------
-- Case of internal unit
if Internal_Unit then
+
+ -- Set standard switches. Note we do NOT set Ada_Version_Explicit
+ -- since the whole point of this is that it still properly indicates
+ -- the configuration setting even in a run time unit.
+
Ada_Version := Ada_Version_Runtime;
Dynamic_Elaboration_Checks := False;
Extensions_Allowed := True;
-- is the main unit and they were explicitly enabled.
if Main_Unit then
- Assertions_Enabled := Assertions_Enabled_Config;
+ Assertions_Enabled := Assertions_Enabled_Config;
Debug_Pragmas_Enabled := Debug_Pragmas_Enabled_Config;
else
- Assertions_Enabled := False;
+ Assertions_Enabled := False;
Debug_Pragmas_Enabled := False;
end if;
else
Ada_Version := Ada_Version_Config;
+ Ada_Version_Explicit := Ada_Version_Explicit_Config;
Assertions_Enabled := Assertions_Enabled_Config;
Debug_Pragmas_Enabled := Debug_Pragmas_Enabled_Config;
Dynamic_Elaboration_Checks := Dynamic_Elaboration_Checks_Config;
Exception_Locations_Suppressed := Exception_Locations_Suppressed_Config;
Polling_Required := Polling_Required_Config;
- Ada_Version_Explicit := Ada_Version_Explicit_Config;
end Set_Opt_Config_Switches;
---------------
Assertions_Enabled_Config :=
Boolean'Val (Assertions_Enabled_Config_Val);
- -- Read version string: we have to check the length first
+ -- Read version string: we have to get the length first
Tree_Read_Int (Tree_Version_String_Len);
- if Tree_Version_String_Len = Tree_Version_String'Length then
+ declare
+ Tmp : String (1 .. Integer (Tree_Version_String_Len));
+ begin
Tree_Read_Data
- (Tree_Version_String'Address, Tree_Version_String_Len);
- else
- Tree_Version_String := (others => '?');
-
- declare
- Tmp : String (1 .. Integer (Tree_Version_String_Len));
- begin
- Tree_Read_Data
- (Tmp'Address, Tree_Version_String_Len);
- end;
-
- end if;
+ (Tmp'Address, Tree_Version_String_Len);
+ GNAT.Strings.Free (Tree_Version_String);
+ Free (Tree_Version_String);
+ Tree_Version_String := new String'(Tmp);
+ end;
Tree_Read_Data (Distribution_Stub_Mode'Address,
Distribution_Stub_Mode_Type'Object_Size / Storage_Unit);
- Tree_Read_Bool (Immediate_Errors);
Tree_Read_Bool (Inline_Active);
Tree_Read_Bool (Inline_Processing_Required);
Tree_Read_Bool (List_Units);
procedure Tree_Write is
Version_String : String := Gnat_Version_String;
+
begin
Tree_Write_Int (ASIS_Version_Number);
Tree_Write_Bool (Brief_Output);
Version_String'Length);
Tree_Write_Data (Distribution_Stub_Mode'Address,
Distribution_Stub_Mode_Type'Object_Size / Storage_Unit);
- Tree_Write_Bool (Immediate_Errors);
Tree_Write_Bool (Inline_Active);
Tree_Write_Bool (Inline_Processing_Required);
Tree_Write_Bool (List_Units);
-- --
-- S p e c --
-- --
--- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2006, 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- --
-- other GNAT tools. The comments indicate which options are used by which
-- programs (GNAT, GNATBIND, GNATLINK, GNATMAKE, GPRMAKE, etc).
-with Gnatvsn; use Gnatvsn;
with Hostparm; use Hostparm;
with Types; use Types;
-- 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 appropropiate switch. In
+ -- the value may be reset in Switch-? with an appropropiate 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.
-- 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);
+ 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);
+ 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.
-- 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 kilobytes. Set by
+ -- 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.
-- GNATMAKE, GNATLINK
-- Set to False when no run_path_option should be issued to the linker
+ Search_Directory_Present : Boolean := False;
+ -- GNAT
+ -- Set to True when argument is -I. Reset to False when next argument,
+ -- a search directory path is taken into account. Note that this is
+ -- quite different from other switches in this section in that it is
+ -- only set in a transitory manner as a result of scanning a -I switch
+ -- with no file name, and if set, is an indication that the next argument
+ -- is to be treated as a file name.
+
Sec_Stack_Used : Boolean := False;
-- GNAT, GBATBIND
-- Set True if generated code uses the System.Secondary_Stack package.
Ada_Version_Explicit_Config : Ada_Version_Type;
-- GNAT
- -- Same as above but used to initialize Ada_Version_Explicit. Currently
- -- this will always have the same value as Ada_Version_Config.
+ -- This is set in the same manner as Ada_Version_Config. The difference is
+ -- that the setting of this flag is not ignored for internal and predefined
+ -- units, which for some purposes do indeed access this value, regardless
+ -- of the fact that they are compiled the the most up to date ada version).
Assertions_Enabled_Config : Boolean;
-- GNAT
-- tree, and they are supposed to be compared with the corresponding values
-- from the Gnatvsn package which is a part of ASIS implementation.
- Tree_Version_String : String (Gnat_Version_String'Range);
+ Tree_Version_String : String_Access;
-- Used to store the compiler version string read from a tree file to check
- -- if it is the same as stored in the version string in Gnatvsn. Therefore
- -- its length is taken directly from the version string in Gnatvsn. If the
- -- length of the version string stored in the tree is different, then
- -- versions are for sure different, and a string containing '?' characters
- -- is assigned to this variable as a result of tree read.
+ -- if it is from the same date as stored in the version string in Gnatvsn.
+ -- We require that ASIS Pro can be used only with GNAT Pro, but we allow
+ -- non-Pro ASIS and ASIS-based tools to be used with any version of the
+ -- GNAT compiler. Therefore, we need the possibility to compare the dates
+ -- of the corresponding source sets, using version strings that may be
+ -- of different lengths.
Tree_ASIS_Version_Number : Int;
-- Used to store the ASIS version number read from a tree file to check if
private
+ -- The following type is used to save and restore settings of switches in
+ -- Opt that represent the configuration (i.e. result of config pragmas).
+
+ -- Note that Ada_Version_Explicit is not included, since this is a sticky
+ -- flag that once set does not get reset, since the whole idea of this flag
+ -- is to record the setting for the main unit.
+
type Config_Switches_Type is record
Ada_Version : Ada_Version_Type;
Ada_Version_Explicit : Ada_Version_Type;
-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2006, 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- --
Ada_Version := Ada_95;
Ada_Version_Explicit := Ada_Version;
- ------------
- -- Ada_05 --
- ------------
+ ---------------------
+ -- Ada_05/Ada_2005 --
+ ---------------------
-- This pragma must be processed at parse time, since we want to set
-- the Ada version properly at parse time to recognize the appropriate
-- Ada version syntax. However, it is only the zero argument form that
-- must be processed at parse time.
- when Pragma_Ada_05 =>
+ when Pragma_Ada_05 | Pragma_Ada_2005 =>
if Arg_Count = 0 then
Ada_Version := Ada_05;
- Ada_Version_Explicit := Ada_Version;
+ Ada_Version_Explicit := Ada_05;
end if;
-----------
-- --
------------------------------------------------------------------------------
-pragma Ada_95;
+pragma Ada_2005;
+-- Explicit setting of Ada 2005 mode is required here, since we want to with a
+-- child unit (not possible in Ada 83 mode), and Text_IO is not considered to
+-- be an internal unit that is automatically compiled in Ada 2005 mode (since
+-- a user is allowed to redeclare Sequential_IO).
+
with Ada.Sequential_IO;
generic package Sequential_IO renames Ada.Sequential_IO;
-- --
------------------------------------------------------------------------------
-pragma Ada_95;
+pragma Ada_2005;
+-- Explicit setting of Ada 2005 mode is required here, since we want to with a
+-- child unit (not possible in Ada 83 mode), and Text_IO is not considered to
+-- be an internal unit that is automatically compiled in Ada 2005 mode (since
+-- a user is allowed to redeclare Text_IO).
+
with Ada.Text_IO;
package Text_IO renames Ada.Text_IO;