OSDN Git Service

* gimplify.c (gimplify_type_sizes) [POINTER_TYPE, REFERENCE_TYPE]:
[pf3gnuchains/gcc-fork.git] / gcc / ada / impunit.adb
index d2a8645..a720a28 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---           Copyright (C) 2000-2003 Free Software Foundation, Inc.         --
+--           Copyright (C) 2000-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- --
@@ -16,8 +16,8 @@
 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
 -- for  more details.  You should have  received  a copy of the GNU General --
 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
--- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
--- MA 02111-1307, USA.                                                      --
+-- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
+-- Boston, MA 02110-1301, USA.                                              --
 --                                                                          --
 -- GNAT was originally developed  by the GNAT team at  New York University. --
 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
 
 with Lib;   use Lib;
 with Namet; use Namet;
-with Opt;   use Opt;
 
 package body Impunit is
 
    subtype File_Name_8 is String (1 .. 8);
    type File_List is array (Nat range <>) of File_Name_8;
 
-   --  The following is a giant string containing the concenated names
-   --  of all non-implementation internal files, i.e. the complete list
-   --  of files for internal units which a program may legitimately WITH.
+   ------------------
+   -- Ada 95 Units --
+   ------------------
 
-   --  Note that this list should match the list of units documented in
-   --  the "GNAT Library" section of the GNAT Reference Manual.
+   --  The following is a giant string list containing the names of all
+   --  non-implementation internal files, i.e. the complete list of files for
+   --  internal units which a program may legitimately WITH when operating in
+   --  either Ada 95 or Ada 05 mode.
 
-   Non_Imp_File_Names : constant File_List := (
+   --  Note that this list should match the list of units documented in the
+   --  "GNAT Library" section of the GNAT Reference Manual.
 
-   -----------------------------------------------
-   -- Ada Hierarchy Units from Reference Manual --
-   -----------------------------------------------
+   Non_Imp_File_Names_95 : constant File_List := (
+
+   ------------------------------------------------------
+   -- Ada Hierarchy Units from Ada-83 Reference Manual --
+   ------------------------------------------------------
 
      "a-astaco",    -- Ada.Asynchronous_Task_Control
      "a-calend",    -- Ada.Calendar
@@ -121,7 +125,7 @@ package body Impunit is
      "a-nlelfu",    -- Ada.Numerics.Long_Elementary_Functions
      "a-nllcef",    -- Ada.Long_Long_Complex_Elementary_Functions
      "a-nllefu",    -- Ada.Numerics.Long_Long_Elementary_Functions
-     "a-nltcty",    -- Ada.Numerics.Long_Long_Complex_Types
+     "a-nllcty",    -- Ada.Numerics.Long_Long_Complex_Types
      "a-nscefu",    -- Ada.Short_Complex_Elementary_Functions
      "a-nscoty",    -- Ada.Numerics.Short_Complex_Types
      "a-nselfu",    -- Ada.Numerics.Short_Elementary_Functions
@@ -143,6 +147,7 @@ package body Impunit is
      "a-cwila9",    -- Ada.Characters.Wide_Latin_9
      "a-diocst",    -- Ada.Direct_IO.C_Streams
      "a-einuoc",    -- Ada.Exceptions.Is_Null_Occurrence
+     "a-elchha",    -- Ada.Exceptions.Last_Chance_Handler
      "a-exctra",    -- Ada.Exceptions.Traceback
      "a-siocst",    -- Ada.Sequential_IO.C_Streams
      "a-ssicst",    -- Ada.Streams.Stream_IO.C_Streams
@@ -152,6 +157,13 @@ package body Impunit is
      "a-tiocst",    -- Ada.Text_IO.C_Streams
      "a-wtcstr",    -- Ada.Wide_Text_IO.C_Streams
 
+      --  Note: strictly the next two should be Ada 2005 units, but it seems
+      --  harmless (and useful) to make then available in Ada 95 mode, since
+      --  they only deal with Wide_Character, not Wide_Wide_Character.
+
+     "a-wichun",    -- Ada.Wide_Characters.Unicode
+     "a-widcha",    -- Ada.Wide_Characters
+
    ---------------------------
    -- GNAT Special IO Units --
    ---------------------------
@@ -183,6 +195,11 @@ package body Impunit is
    -- GNAT Library Units --
    ------------------------
 
+     "g-altive",    -- GNAT.Altivec
+     "g-alvety",    -- GNAT.Altivec.Vector_Types
+     "g-alvevi",    -- GNAT.Altivec.Vector_Views
+     "g-alveop",    -- GNAT.Altivec.Vector_Operations
+     "g-altcon",    -- GNAT.Altivec.Conversions
      "g-arrspl",    -- GNAT.Array_Split
      "g-awk   ",    -- GNAT.AWK
      "g-boubuf",    -- GNAT.Bounded_Buffers
@@ -223,12 +240,12 @@ package body Impunit is
      "g-memdum",    -- GNAT.Memory_Dump
      "g-moreex",    -- GNAT.Most_Recent_Exception
      "g-os_lib",    -- GNAT.Os_Lib
-     "g-pehage",    -- GNAT.Perfect_Hash.Generators
-     "g-perhas",    -- GNAT.Perfect_Hash
+     "g-pehage",    -- GNAT.Perfect_Hash_Generators
      "g-regexp",    -- GNAT.Regexp
      "g-regist",    -- GNAT.Registry
      "g-regpat",    -- GNAT.Regpat
      "g-semaph",    -- GNAT.Semaphores
+     "g-sestin",    -- GNAT.Secondary_Stack_Info
      "g-signal",    -- GNAT.Signals
      "g-socket",    -- GNAT.Sockets
      "g-souinf",    -- GNAT.Source_Info
@@ -245,6 +262,7 @@ package body Impunit is
      "g-thread",    -- GNAT.Threads
      "g-traceb",    -- GNAT.Traceback
      "g-trasym",    -- GNAT.Traceback.Symbolic
+     "g-utf_32",    -- GNAT.UTF_32
      "g-wistsp",    -- GNAT.Wide_String_Split
 
    -----------------------------------------------------
@@ -296,36 +314,147 @@ package body Impunit is
      "s-assert",    -- System.Assertions
      "s-memory",    -- System.Memory
      "s-parint",    -- System.Partition_Interface
+     "s-pooglo",    -- System.Pool_Global
+     "s-pooloc",    -- System.Pool_Local
+     "s-restri",    -- System.Restrictions
+     "s-rident",    -- System.Rident
      "s-tasinf",    -- System.Task_Info
      "s-wchcnv",    -- System.Wch_Cnv
      "s-wchcon");   -- System.Wch_Con
 
-   -------------------------
-   -- Implementation_Unit --
-   -------------------------
+   --------------------
+   -- Ada 2005 Units --
+   --------------------
+
+   --  The following units should be used only in Ada 05 mode
+
+   Non_Imp_File_Names_05 : constant File_List := (
+
+   --------------------------------------------------------
+   -- Ada Hierarchy Units from Ada 2005 Reference Manual --
+   --------------------------------------------------------
+
+     "a-cdlili",    -- Ada.Containers.Doubly_Linked_Lists
+     "a-cgaaso",    -- Ada.Containers.Generic_Anonymous_Array_Sort
+     "a-cgarso",    -- Ada.Containers.Generic_Array_Sort
+     "a-cgcaso",    -- Ada.Containers.Generic_Constrained_Array_Sort
+     "a-chacon",    -- Ada.Characters.Conversions
+     "a-cidlli",    -- Ada.Containers.Indefinite_Doubly_Linked_Lists
+     "a-cihama",    -- Ada.Containers.Indefinite_Hashed_Maps
+     "a-cihase",    -- Ada.Containers.Indefinite_Hashed_Sets
+     "a-ciorma",    -- Ada.Containers.Indefinite_Ordered_Maps
+     "a-ciorse",    -- Ada.Containers.Indefinite_Ordered_Sets
+     "a-cohama",    -- Ada.Containers.Hashed_Maps
+     "a-cohase",    -- Ada.Containers.Hashed_Sets
+     "a-coinve",    -- Ada.Containers.Indefinite_Vectors
+     "a-contai",    -- Ada.Containers
+     "a-convec",    -- Ada.Containers.Vectors
+     "a-coorma",    -- Ada.Containers.Ordered_Maps
+     "a-coorse",    -- Ada.Containers.Ordered_Sets
+     "a-coteio",    -- Ada.Complex_Text_IO
+     "a-direct",    -- Ada.Directories
+     "a-envvar",    -- Ada.Environment_Variables
+     "a-rttiev",    -- Ada.Real_Time.Timing_Events
+     "a-secain",    -- Ada.Strings.Equal_Case_Insensitive
+     "a-shcain",    -- Ada.Strings.Hash_Case_Insensitive
+     "a-slcain",    -- Ada.Strings.Less_Case_Insensitive
+     "a-stboha",    -- Ada.Strings.Bounded.Hash
+     "a-stfiha",    -- Ada.Strings.Fixed.Hash
+     "a-strhas",    -- Ada.Strings.Hash
+     "a-stunha",    -- Ada.Strings.Unbounded.Hash
+     "a-stwiha",    -- Ada.Strings.Wide_Hash
+     "a-stzbou",    -- Ada.Strings.Wide_Wide_Bounded
+     "a-stzfix",    -- Ada.Strings.Wide_Wide_Fixed
+     "a-stzhas",    -- Ada.Strings.Wide_Wide_Hash
+     "a-stzmap",    -- Ada.Strings.Wide_Wide_Maps
+     "a-stzunb",    -- Ada.Strings.Wide_Wide_Unbounded
+     "a-swbwha",    -- Ada.Strings.Wide_Bounded.Wide_Hash
+     "a-swfwha",    -- Ada.Strings.Wide_Fixed.Wide_Hash
+     "a-swuwha",    -- Ada.Strings.Wide_Unbounded.Wide_Hash
+     "a-szbzha",    -- Ada.Strings.Wide_Wide_Bounded.Wide_Wide_Hash
+     "a-szfzha",    -- Ada.Strings.Wide_Wide_Fixed.Wide_Wide_Hash
+     "a-szmzco",    -- Ada.Strings.Wide_Wide_Maps.Wide_Wide_Constants
+     "a-szuzha",    -- Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Hash
+     "a-taster",    -- Ada.Task_Termination
+     "a-tgdico",    -- Ada.Tags.Generic_Dispatching_Constructor
+     "a-tiboio",    -- Ada.Text_IO.Bounded_IO
+     "a-tiunio",    -- Ada.Text_IO.Unbounded_IO
+     "a-wichun",    -- Ada.Wide_Characters.Unicode
+     "a-wwboio",    -- Ada.Wide_Text_IO.Wide_Bounded_IO
+     "a-wwunio",    -- Ada.Wide_Text_IO.Wide_Unbounded_IO
+     "a-zchara",    -- Ada.Wide_Wide_Characters
+     "a-zttest",    -- Ada.Wide_Wide_Text_IO.Text_Streams
+     "a-ztexio",    -- Ada.Wide_Wide_Text_IO
+     "a-zzboio",    -- Ada.Wide_Wide_Text_IO.Wide_Wide_Bounded_IO
+     "a-zzunio",    -- Ada.Wide_Wide_Text_IO.Wide_Wide_Unbounded_IO
+
+   ------------------------------------------------------
+   -- RM Required Additions to Ada 2005 for GNAT Types --
+   ------------------------------------------------------
+
+     "a-lcteio",    -- Ada.Long_Complex_Text_IO
+     "a-lfztio",    -- Ada.Long_Float_Wide_Wide_Text_IO
+     "a-liztio",    -- Ada.Long_Integer_Wide_Wide_Text_IO
+     "a-llctio",    -- Ada.Long_Long_Complex_Text_IO
+     "a-llfzti",    -- Ada.Long_Long_Float_Wide_Wide_Text_IO
+     "a-llizti",    -- Ada.Long_Long_Integer_Wide_Wide_Text_IO
+     "a-scteio",    -- Ada.Short_Complex_Text_IO
+     "a-sfztio",    -- Ada.Short_Float_Wide_Wide_Text_IO
+     "a-siztio",    -- Ada.Short_Integer_Wide_Wide_Text_IO
+     "a-ssizti",    -- Ada.Short_Short_Integer_Wide_Wide_Text_IO
+     "a-ztcstr",    -- Ada.Wide_Wide_Text_IO.C_Streams
+
+   ----------------------------------------
+   -- GNAT Defined Additions to Ada 2005 --
+   ----------------------------------------
+
+     "a-chzla1",    -- Ada.Characters.Wide_Wide_Latin_1
+     "a-chzla9",    -- Ada.Characters.Wide_Wide_Latin_9
+     "a-ciormu",    -- Ada.Containers.Indefinite_Ordered_Multisets
+     "a-coormu",    -- Ada.Containers.Ordered_Multisets
+     "a-szuzti",    -- Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO
+     "a-zchuni",    -- Ada.Wide_Wide_Characters.Unicode
 
-   function Implementation_Unit (U : Unit_Number_Type) return Boolean is
-      Fname : constant File_Name_Type := Unit_File_Name (U);
+   ---------------------------
+   -- GNAT Special IO Units --
+   ---------------------------
 
-   begin
-      --  All units are OK in GNAT mode
+   --  See Ada 95 section for further information. These packages are for the
+   --  implementation of the Wide_Wide_Text_IO generic packages.
 
-      if GNAT_Mode then
-         return False;
-      end if;
+     "a-ztdeio",    -- Ada.Wide_Wide_Text_IO.Decimal_IO
+     "a-ztenio",    -- Ada.Wide_Wide_Text_IO.Enumeration_IO
+     "a-ztfiio",    -- Ada.Wide_Wide_Text_IO.Fixed_IO
+     "a-ztflio",    -- Ada.Wide_Wide_Text_IO.Float_IO
+     "a-ztinio",    -- Ada.Wide_Wide_Text_IO.Integer_IO
+     "a-ztmoio",    -- Ada.Wide_Wide_Text_IO.Modular_IO
 
-      --  If length of file name is greater than 12, definitely OK!
+   ------------------------
+   -- GNAT Library Units --
+   ------------------------
+
+     "g-zstspl");   -- GNAT.Wide_Wide_String_Split
+
+   ----------------------
+   -- Get_Kind_Of_Unit --
+   ----------------------
+
+   function Get_Kind_Of_Unit (U : Unit_Number_Type) return Kind_Of_Unit is
+      Fname : constant File_Name_Type := Unit_File_Name (U);
+
+   begin
+      --  If length of file name is greater than 12, not predefined.
       --  The value 12 here is an 8 char name with extension .ads.
 
       if Length_Of_Name (Fname) > 12 then
-         return False;
+         return Not_Predefined_Unit;
       end if;
 
       --  Otherwise test file name
 
       Get_Name_String (Fname);
 
-      --  Definitely OK if file name does not start with a- g- s- i-
+      --  Not predefined if file name does not start with a- g- s- i-
 
       if Name_Len < 3
         or else Name_Buffer (2) /= '-'
@@ -337,14 +466,14 @@ package body Impunit is
                    and then
                  Name_Buffer (1) /= 's')
       then
-         return False;
+         return Not_Predefined_Unit;
       end if;
 
-      --  Definitely OK if file name does not end in .ads. This can
+      --  Not predefined if file name does not end in .ads. This can
       --  happen when non-standard file names are being used.
 
       if Name_Buffer (Name_Len - 3 .. Name_Len) /= ".ads" then
-         return False;
+         return Not_Predefined_Unit;
       end if;
 
       --  Otherwise normalize file name to 8 characters
@@ -355,42 +484,48 @@ package body Impunit is
          Name_Buffer (Name_Len) := ' ';
       end loop;
 
-      --  Definitely OK if name is in list
+      --  See if name is in 95 list
 
-      for J in Non_Imp_File_Names'Range loop
-         if Name_Buffer (1 .. 8) = Non_Imp_File_Names (J) then
-            return False;
+      for J in Non_Imp_File_Names_95'Range loop
+         if Name_Buffer (1 .. 8) = Non_Imp_File_Names_95 (J) then
+            return Ada_95_Unit;
          end if;
       end loop;
 
-      --  Only remaining special possibilities are children of
-      --  System.RPC and System.Garlic and special files of the
-      --  form System.Aux...
+      --  See if name is in 05 list
+
+      for J in Non_Imp_File_Names_05'Range loop
+         if Name_Buffer (1 .. 8) = Non_Imp_File_Names_05 (J) then
+            return Ada_05_Unit;
+         end if;
+      end loop;
+
+      --  Only remaining special possibilities are children of System.RPC and
+      --  System.Garlic and special files of the form System.Aux...
 
       Get_Name_String (Unit_Name (U));
 
       if Name_Len > 12
         and then Name_Buffer (1 .. 11) = "system.rpc."
       then
-         return False;
+         return Ada_95_Unit;
       end if;
 
       if Name_Len > 15
         and then Name_Buffer (1 .. 14) = "system.garlic."
       then
-         return False;
+         return Ada_95_Unit;
       end if;
 
       if Name_Len > 11
         and then Name_Buffer (1 .. 10) = "system.aux"
       then
-         return False;
+         return Ada_95_Unit;
       end if;
 
       --  All tests failed, this is definitely an implementation unit
 
-      return True;
-
-   end Implementation_Unit;
+      return Implementation_Unit;
+   end Get_Kind_Of_Unit;
 
 end Impunit;