opt.ads opt.adb: Add Ada_Version_Explicit_Config along with save/restore routines.
authorRobert Dewar <dewar@adacore.com>
Wed, 15 Feb 2006 09:36:57 +0000 (10:36 +0100)
committerArnaud Charlet <charlet@gcc.gnu.org>
Wed, 15 Feb 2006 09:36:57 +0000 (10:36 +0100)
2006-02-13  Robert Dewar  <dewar@adacore.com>
    Serguei Rybin  <rybin@adacore.com>

* opt.ads opt.adb: Add Ada_Version_Explicit_Config along with
save/restore routines.
Properly handle Ada_Version_Explicit and Ada_Version_Config, which
were not always properly handled previously.
Since we are changing the tree format anyway, also get rid of the
junk obsolete Immediate_Errors flag.
(Tree_Read): Change the way of reading Tree_Version_String - now we
read the version string from the tree even if its length is not the
same as the length of the version string computed from Gnatvsn.
(Search_Directory_Present): New Boolean flag for the compiler.
Define Tree_Version_String as a dynamic string.
(Default_Stack_Size): new variable, used to handle switch -d.

* par-prag.adb:
For pragma Ada_2005, remove stuff about setting Ada_Version_Explicit
only for main unit.
Add pragma Ada_2005 (synonym for Ada_05)
Properly handle Ada_Version_Explicit and Ada_Version_Config, which
were not always properly handled previously.

* directio.ads, ioexcept.ads, sequenio.ads, text_io.ads: Change
explicit Ada_95 to Ada_2005.

From-SVN: r111054

gcc/ada/directio.ads
gcc/ada/ioexcept.ads
gcc/ada/opt.adb
gcc/ada/opt.ads
gcc/ada/par-prag.adb
gcc/ada/sequenio.ads
gcc/ada/text_io.ads

index 48068c605757787a45c509ea09998058f5da8b92..c8239ec60048148e712ce85d2c2db8211968cfcd 100644 (file)
 --                                                                          --
 ------------------------------------------------------------------------------
 
-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;
index c34e36dc2232dbdb6b05c8b48a8e489da3617384..548fd37fd663687769a7c8c97f1e3cafac477dcc 100644 (file)
 --                                                                          --
 ------------------------------------------------------------------------------
 
-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;
index 576c0d85ecad7a583185a19e7f4b9f975acdfa64..8c11718e1897d340c31646cf462228a74d6c89ac 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 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 --
    ----------------------------------
@@ -114,6 +109,11 @@ package body Opt is
       --  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;
@@ -126,10 +126,10 @@ package body Opt is
          --  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;
 
@@ -137,6 +137,7 @@ package body Opt is
 
       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;
@@ -149,7 +150,6 @@ package body Opt is
 
       Exception_Locations_Suppressed := Exception_Locations_Suppressed_Config;
       Polling_Required               := Polling_Required_Config;
-      Ada_Version_Explicit           := Ada_Version_Explicit_Config;
    end Set_Opt_Config_Switches;
 
    ---------------
@@ -189,28 +189,22 @@ package body Opt is
       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);
@@ -231,6 +225,7 @@ package body Opt is
 
    procedure Tree_Write is
       Version_String : String := Gnat_Version_String;
+
    begin
       Tree_Write_Int  (ASIS_Version_Number);
       Tree_Write_Bool (Brief_Output);
@@ -255,7 +250,6 @@ package body Opt is
                        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);
index f125939ddc2665feb32b02102d4297daf9fb8e89..0db00ea1e677eca5aa393d4cf9863f824f9c1c32 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 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- --
@@ -36,7 +36,6 @@
 --  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;
 
@@ -51,7 +50,7 @@ package Opt is
 
    --  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.
@@ -93,13 +92,13 @@ package Opt is
    --  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.
@@ -300,9 +299,15 @@ package Opt is
    --  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.
@@ -857,6 +862,15 @@ package Opt is
    --  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.
@@ -1161,8 +1175,10 @@ package Opt is
 
    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
@@ -1306,13 +1322,14 @@ package Opt is
    --  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
@@ -1320,6 +1337,13 @@ package Opt is
 
 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;
index 7489d9decc0e1768fdfb1812199248d5616938d3..7646f6e03fe1f118e7076c9928ba4940255fd4cd 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 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- --
@@ -302,19 +302,19 @@ begin
          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;
 
       -----------
index f4a2726608f5a24f24aa9701ca30871cf50b6428..8ea1890585198c43e93839d831dfebbd4cb83c77 100644 (file)
 --                                                                          --
 ------------------------------------------------------------------------------
 
-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;
index 6b5d08cb021269992973a50b1bc7df0dce18ecd0..f51e1c22da95af4ec1164b42ade9bad3d3e5e5fb 100644 (file)
 --                                                                          --
 ------------------------------------------------------------------------------
 
-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;