-- --
-- B o d y --
-- --
--- Copyright (C) 2000-2005 Free Software Foundation, Inc. --
+-- Copyright (C) 2000-2007, 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- --
-- 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 Atree; use Atree;
+with Sinfo; use Sinfo;
+with Fname.UF; use Fname.UF;
+with Lib; use Lib;
+with Namet; use Namet;
+with Uname; use Uname;
package body Impunit is
-----------------------------------
"a-chlat9", -- Ada.Characters.Latin_9
+ "a-clrefi", -- Ada.Command_Line.Response_File
"a-colien", -- Ada.Command_Line.Environment
"a-colire", -- Ada.Command_Line.Remove
"a-cwila1", -- Ada.Characters.Wide_Latin_1
"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 --
---------------------------
-- 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
"g-bubsor", -- GNAT.Bubble_Sort
"g-busora", -- GNAT.Bubble_Sort_A
"g-busorg", -- GNAT.Bubble_Sort_G
+ "g-bytswa", -- Gnat.Byte_Swapping
"g-calend", -- GNAT.Calendar
"g-casuti", -- GNAT.Case_Util
"g-catiio", -- GNAT.Calendar.Time_IO
"g-regpat", -- GNAT.Regpat
"g-semaph", -- GNAT.Semaphores
"g-sestin", -- GNAT.Secondary_Stack_Info
+ "g-sha1 ", -- GNAT.SHA1
"g-signal", -- GNAT.Signals
"g-socket", -- GNAT.Sockets
"g-souinf", -- GNAT.Source_Info
"i-cexten", -- Interfaces.C.Extensions
"i-cpp ", -- Interfaces.CPP
"i-cstrea", -- Interfaces.C.Streams
- "i-jalaob", -- Interfaces.Java.Lang.Object
- "i-jalasy", -- Interfaces.Java.Lang.System
- "i-jalath", -- Interfaces.Java.Lang.Thread
"i-java ", -- Interfaces.Java
- "i-javlan", -- Interfaces.Java.Lang
- "i-os2err", -- Interfaces.Os2lib.Errors
- "i-os2lib", -- Interfaces.Os2lib
- "i-os2syn", -- Interfaces.Os2lib.Synchronization
- "i-os2thr", -- Interfaces.Os2lib.Threads
"i-pacdec", -- Interfaces.Packed_Decimal
- "i-vthrea", -- Interfaces.Vthreads
"i-vxwoio", -- Interfaces.VxWorks.IO
"i-vxwork", -- Interfaces.VxWorks
"s-addima", -- System.Address_Image
"s-assert", -- System.Assertions
"s-memory", -- System.Memory
+ "s-os_lib", -- System.Os_Lib
"s-parint", -- System.Partition_Interface
"s-pooglo", -- System.Pool_Global
"s-pooloc", -- System.Pool_Local
-- Ada Hierarchy Units from Ada 2005 Reference Manual --
--------------------------------------------------------
+ "a-calari", -- Ada.Calendar.Arithmetic
+ "a-calfor", -- Ada.Calendar.Formatting
+ "a-catizo", -- Ada.Calendar.Time_Zones
"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-chtgke", -- Ada.Containers.Hash_Tables.Generic_Keys
- "a-chtgop", -- Ada.Containers.Hash_Tables.Generic_Operations
+ "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-ciormu", -- Ada.Containers.Indefinite_Ordered_Multisets
"a-ciorse", -- Ada.Containers.Indefinite_Ordered_Sets
"a-cohama", -- Ada.Containers.Hashed_Maps
"a-cohase", -- Ada.Containers.Hashed_Sets
- "a-cohata", -- Ada.Containers.Hash_Tables
"a-coinve", -- Ada.Containers.Indefinite_Vectors
"a-contai", -- Ada.Containers
"a-convec", -- Ada.Containers.Vectors
"a-coorma", -- Ada.Containers.Ordered_Maps
- "a-coormu", -- Ada.Containers.Ordered_Multisets
"a-coorse", -- Ada.Containers.Ordered_Sets
- "a-coprnu", -- Ada.Containers.Prime_Numbers
- "a-crbltr", -- Ada.Containers.Red_Black_Trees
- "a-crbtgk", -- Ada.Containers.Red_Black_Trees.Generic_Keys
- "a-crbtgo", -- Ada.Containers.Red_Black_Trees.Generic_Operations
+ "a-coteio", -- Ada.Complex_Text_IO
"a-direct", -- Ada.Directories
- "a-rbtgso", -- Ada.Containers.Red_Black_Trees.Generic_Set_Operations
- "a-secain", -- Ada.Strings.Equal_Case_Insensitive
- "a-shcain", -- Ada.Strings.Hash_Case_Insensitive
- "a-slcain", -- Ada.Strings.Less_Case_Insensitive
+ "a-diroro", -- Ada.Dispatching.Round_Robin
+ "a-dispat", -- Ada.Dispatching
+ "a-envvar", -- Ada.Environment_Variables
+ "a-exetim", -- Ada.Execution_Time
+ "a-extiti", -- Ada.Execution_Time.Timers
+ "a-rttiev", -- Ada.Real_Time.Timing_Events
+ "a-ngcoar", -- Ada.Numerics.Generic_Complex_Arrays
+ "a-ngrear", -- Ada.Numerics.Generic_Real_Arrays
+ "a-nucoar", -- Ada.Numerics.Complex_Arrays
+ "a-nurear", -- Ada.Numerics.Real_Arrays
+ "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-stzhas", -- Ada.Strings.Wide_Wide_Hash
"a-stzmap", -- Ada.Strings.Wide_Wide_Maps
"a-stzunb", -- Ada.Strings.Wide_Wide_Unbounded
- "a-swunha", -- Ada.Strings.Wide_Unbounded.Hash
- "a-szmzco", -- Ada.Strings.Wide_Wide_Maps.Wide_Wide_Constants;
- "a-szunha", -- Ada.Strings.Wide_Wide_Unbounded.Hash
- "a-tiunio", -- Ada.Text_IO.Unbounded_IO;
- "a-wwunio", -- Ada.Wide_Text_IO.Wide_Unbounded_IO;
+ "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-ztcoio", -- Ada.Wide_Wide_Text_IO.Complex_IO
+ "a-ztedit", -- Ada.Wide_Wide_Text_IO.Editing
"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-nlcoar", -- Ada.Numerics.Long_Complex_Arrays
+ "a-nllcar", -- Ada.Numerics.Long_Long_Complex_Arrays
+ "a-nllrar", -- Ada.Numerics.Long_Long_Real_Arrays
+ "a-nlrear", -- Ada.Numerics.Long_Real_Arrays
+ "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
-- GNAT Defined Additions to Ada 2005 --
----------------------------------------
+ "a-cgaaso", -- Ada.Containers.Generic_Anonymous_Array_Sort
"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-crdlli", -- Ada.Containers.Restricted_Doubly_Linked_Lists
+ "a-secain", -- Ada.Strings.Equal_Case_Insensitive
+ "a-shcain", -- Ada.Strings.Hash_Case_Insensitive
+ "a-slcain", -- Ada.Strings.Less_Case_Insensitive
"a-szuzti", -- Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO
+ "a-zchuni", -- Ada.Wide_Wide_Characters.Unicode
---------------------------
-- GNAT Special IO Units --
return Implementation_Unit;
end Get_Kind_Of_Unit;
+ -------------------
+ -- Is_Known_Unit --
+ -------------------
+
+ function Is_Known_Unit (Nam : Node_Id) return Boolean is
+ Unam : Unit_Name_Type;
+ Fnam : File_Name_Type;
+
+ begin
+ -- If selector is not an identifier (e.g. it is a character literal or
+ -- some junk from a previous error), then definitely not a known unit.
+
+ if Nkind (Selector_Name (Nam)) /= N_Identifier then
+ return False;
+ end if;
+
+ -- Otherwise get corresponding file name
+
+ Unam := Get_Unit_Name (Nam);
+ Fnam := Get_File_Name (Unam, Subunit => False);
+ Get_Name_String (Fnam);
+
+ -- Remove extension from file name
+
+ if Name_Buffer (Name_Len - 3 .. Name_Len) = ".adb" then
+ Name_Len := Name_Len - 4;
+ else
+ return False;
+ end if;
+
+ -- Pad name to 8 characters
+
+ while Name_Len < 8 loop
+ Name_Len := Name_Len + 1;
+ Name_Buffer (Name_Len) := ' ';
+ end loop;
+
+ -- If length more than 8, definitely not a match
+
+ if Name_Len /= 8 then
+ return False;
+ end if;
+
+ -- If length is 8, search our tables
+
+ for J in Non_Imp_File_Names_95'Range loop
+ if Name_Buffer (1 .. 8) = Non_Imp_File_Names_95 (J) then
+ return True;
+ end if;
+ end loop;
+
+ for J in Non_Imp_File_Names_05'Range loop
+ if Name_Buffer (1 .. 8) = Non_Imp_File_Names_05 (J) then
+ return True;
+ end if;
+ end loop;
+
+ -- If not found, not known
+
+ return False;
+
+ -- A safety guard, if we get an exception during this processing then it
+ -- is most likely the result of a previous error, or a peculiar case we
+ -- have not thought of. Since this routine is only used for error message
+ -- refinement, we will just return False.
+
+ exception
+ when others =>
+ return False;
+ end Is_Known_Unit;
+
end Impunit;