OSDN Git Service

2007-04-06 Geert Bosch <bosch@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / impunit.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                              I M P U N I T                               --
6 --                                                                          --
7 --                                 B o d y                                  --
8 --                                                                          --
9 --           Copyright (C) 2000-2006, Free Software Foundation, Inc.        --
10 --                                                                          --
11 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
12 -- terms of the  GNU General Public License as published  by the Free Soft- --
13 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
14 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
17 -- for  more details.  You should have  received  a copy of the GNU General --
18 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
19 -- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
20 -- Boston, MA 02110-1301, USA.                                              --
21 --                                                                          --
22 -- GNAT was originally developed  by the GNAT team at  New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
24 --                                                                          --
25 ------------------------------------------------------------------------------
26
27 with Atree;    use Atree;
28 with Sinfo;    use Sinfo;
29 with Fname.UF; use Fname.UF;
30 with Lib;      use Lib;
31 with Namet;    use Namet;
32 with Uname;    use Uname;
33
34 package body Impunit is
35
36    subtype File_Name_8 is String (1 .. 8);
37    type File_List is array (Nat range <>) of File_Name_8;
38
39    ------------------
40    -- Ada 95 Units --
41    ------------------
42
43    --  The following is a giant string list containing the names of all
44    --  non-implementation internal files, i.e. the complete list of files for
45    --  internal units which a program may legitimately WITH when operating in
46    --  either Ada 95 or Ada 05 mode.
47
48    --  Note that this list should match the list of units documented in the
49    --  "GNAT Library" section of the GNAT Reference Manual.
50
51    Non_Imp_File_Names_95 : constant File_List := (
52
53    ------------------------------------------------------
54    -- Ada Hierarchy Units from Ada-83 Reference Manual --
55    ------------------------------------------------------
56
57      "a-astaco",    -- Ada.Asynchronous_Task_Control
58      "a-calend",    -- Ada.Calendar
59      "a-chahan",    -- Ada.Characters.Handling
60      "a-charac",    -- Ada.Characters
61      "a-chlat1",    -- Ada.Characters.Latin_1
62      "a-comlin",    -- Ada.Command_Line
63      "a-decima",    -- Ada.Decimal
64      "a-direio",    -- Ada.Direct_IO
65      "a-dynpri",    -- Ada.Dynamic_Priorities
66      "a-except",    -- Ada.Exceptions
67      "a-finali",    -- Ada.Finalization
68      "a-flteio",    -- Ada.Float_Text_IO
69      "a-fwteio",    -- Ada.Float_Wide_Text_IO
70      "a-inteio",    -- Ada.Integer_Text_IO
71      "a-interr",    -- Ada.Interrupts
72      "a-intnam",    -- Ada.Interrupts.Names
73      "a-ioexce",    -- Ada.IO_Exceptions
74      "a-iwteio",    -- Ada.Integer_Wide_Text_IO
75      "a-ncelfu",    -- Ada.Numerics.Complex_Elementary_Functions
76      "a-ngcefu",    -- Ada.Numerics.Generic_Complex_Elementary_Functions
77      "a-ngcoty",    -- Ada.Numerics.Generic_Complex_Types
78      "a-ngelfu",    -- Ada.Numerics.Generic_Elementary_Functions
79      "a-nucoty",    -- Ada.Numerics.Complex_Types
80      "a-nudira",    -- Ada.Numerics.Discrete_Random
81      "a-nuelfu",    -- Ada.Numerics.Elementary_Functions
82      "a-nuflra",    -- Ada.Numerics.Float_Random
83      "a-numeri",    -- Ada.Numerics
84      "a-reatim",    -- Ada.Real_Time
85      "a-sequio",    -- Ada.Sequential_IO
86      "a-stmaco",    -- Ada.Strings.Maps.Constants
87      "a-storio",    -- Ada.Storage_IO
88      "a-strbou",    -- Ada.Strings.Bounded
89      "a-stream",    -- Ada.Streams
90      "a-strfix",    -- Ada.Strings.Fixed
91      "a-string",    -- Ada.Strings
92      "a-strmap",    -- Ada.Strings.Maps
93      "a-strunb",    -- Ada.Strings.Unbounded
94      "a-ststio",    -- Ada.Streams.Stream_IO
95      "a-stwibo",    -- Ada.Strings.Wide_Bounded
96      "a-stwifi",    -- Ada.Strings.Wide_Fixed
97      "a-stwima",    -- Ada.Strings.Wide_Maps
98      "a-stwiun",    -- Ada.Strings.Wide_Unbounded
99      "a-swmwco",    -- Ada.Strings.Wide_Maps.Wide_Constants
100      "a-sytaco",    -- Ada.Synchronous_Task_Control
101      "a-tags  ",    -- Ada.Tags
102      "a-tasatt",    -- Ada.Task_Attributes
103      "a-taside",    -- Ada.Task_Identification
104      "a-teioed",    -- Ada.Text_IO.Editing
105      "a-textio",    -- Ada.Text_IO
106      "a-ticoio",    -- Ada.Text_IO.Complex_IO
107      "a-titest",    -- Ada.Text_IO.Text_Streams
108      "a-unccon",    -- Ada.Unchecked_Conversion
109      "a-uncdea",    -- Ada.Unchecked_Deallocation
110      "a-witeio",    -- Ada.Wide_Text_IO
111      "a-wtcoio",    -- Ada.Wide_Text_IO.Complex_IO
112      "a-wtedit",    -- Ada.Wide_Text_IO.Editing
113      "a-wttest",    -- Ada.Wide_Text_IO.Text_Streams
114
115    -------------------------------------------------
116    -- RM Required Additions to Ada for GNAT Types --
117    -------------------------------------------------
118
119      "a-lfteio",    -- Ada.Long_Float_Text_IO
120      "a-lfwtio",    -- Ada.Long_Float_Wide_Text_IO
121      "a-liteio",    -- Ada.Long_Integer_Text_IO
122      "a-liwtio",    -- Ada.Long_Integer_Wide_Text_IO
123      "a-llftio",    -- Ada.Long_Long_Float_Text_IO
124      "a-llfwti",    -- Ada.Long_Long_Float_Wide_Text_IO
125      "a-llitio",    -- Ada.Long_Long_Integer_Text_IO
126      "a-lliwti",    -- Ada.Long_Long_Integer_Wide_Text_IO
127      "a-nlcefu",    -- Ada.Long_Complex_Elementary_Functions
128      "a-nlcoty",    -- Ada.Numerics.Long_Complex_Types
129      "a-nlelfu",    -- Ada.Numerics.Long_Elementary_Functions
130      "a-nllcef",    -- Ada.Long_Long_Complex_Elementary_Functions
131      "a-nllefu",    -- Ada.Numerics.Long_Long_Elementary_Functions
132      "a-nllcty",    -- Ada.Numerics.Long_Long_Complex_Types
133      "a-nscefu",    -- Ada.Short_Complex_Elementary_Functions
134      "a-nscoty",    -- Ada.Numerics.Short_Complex_Types
135      "a-nselfu",    -- Ada.Numerics.Short_Elementary_Functions
136      "a-sfteio",    -- Ada.Short_Float_Text_IO
137      "a-sfwtio",    -- Ada.Short_Float_Wide_Text_IO
138      "a-siteio",    -- Ada.Short_Integer_Text_IO
139      "a-siwtio",    -- Ada.Short_Integer_Wide_Text_IO
140      "a-ssitio",    -- Ada.Short_Short_Integer_Text_IO
141      "a-ssiwti",    -- Ada.Short_Short_Integer_Wide_Text_IO
142
143    -----------------------------------
144    -- GNAT Defined Additions to Ada --
145    -----------------------------------
146
147      "a-chlat9",    -- Ada.Characters.Latin_9
148      "a-colien",    -- Ada.Command_Line.Environment
149      "a-colire",    -- Ada.Command_Line.Remove
150      "a-cwila1",    -- Ada.Characters.Wide_Latin_1
151      "a-cwila9",    -- Ada.Characters.Wide_Latin_9
152      "a-diocst",    -- Ada.Direct_IO.C_Streams
153      "a-einuoc",    -- Ada.Exceptions.Is_Null_Occurrence
154      "a-elchha",    -- Ada.Exceptions.Last_Chance_Handler
155      "a-exctra",    -- Ada.Exceptions.Traceback
156      "a-siocst",    -- Ada.Sequential_IO.C_Streams
157      "a-ssicst",    -- Ada.Streams.Stream_IO.C_Streams
158      "a-suteio",    -- Ada.Strings.Unbounded.Text_IO
159      "a-swuwti",    -- Ada.Strings.Wide_Unbounded.Wide_Text_IO
160      "a-taidim",    -- Ada.Task_Identification.Image
161      "a-tiocst",    -- Ada.Text_IO.C_Streams
162      "a-wtcstr",    -- Ada.Wide_Text_IO.C_Streams
163
164       --  Note: strictly the next two should be Ada 2005 units, but it seems
165       --  harmless (and useful) to make then available in Ada 95 mode, since
166       --  they only deal with Wide_Character, not Wide_Wide_Character.
167
168      "a-wichun",    -- Ada.Wide_Characters.Unicode
169      "a-widcha",    -- Ada.Wide_Characters
170
171    ---------------------------
172    -- GNAT Special IO Units --
173    ---------------------------
174
175    --  As further explained elsewhere (see Sem_Ch10), the internal
176    --  packages of Text_IO and Wide_Text_IO are actually implemented
177    --  as separate children, but this fact is intended to be hidden
178    --  from the user completely. Any attempt to WITH one of these
179    --  units will be diagnosed as an error later on, but for now we
180    --  do not consider these internal implementation units (if we did,
181    --  then we would get a junk warning which would be confusing and
182    --  unecessary, given that we generate a clear error message).
183
184      "a-tideio",    -- Ada.Text_IO.Decimal_IO
185      "a-tienio",    -- Ada.Text_IO.Enumeration_IO
186      "a-tifiio",    -- Ada.Text_IO.Fixed_IO
187      "a-tiflio",    -- Ada.Text_IO.Float_IO
188      "a-tiinio",    -- Ada.Text_IO.Integer_IO
189      "a-tiinio",    -- Ada.Text_IO.Integer_IO
190      "a-timoio",    -- Ada.Text_IO.Modular_IO
191      "a-wtdeio",    -- Ada.Wide_Text_IO.Decimal_IO
192      "a-wtenio",    -- Ada.Wide_Text_IO.Enumeration_IO
193      "a-wtfiio",    -- Ada.Wide_Text_IO.Fixed_IO
194      "a-wtflio",    -- Ada.Wide_Text_IO.Float_IO
195      "a-wtinio",    -- Ada.Wide_Text_IO.Integer_IO
196      "a-wtmoio",    -- Ada.Wide_Text_IO.Modular_IO
197
198    ------------------------
199    -- GNAT Library Units --
200    ------------------------
201
202      "g-altive",    -- GNAT.Altivec
203      "g-alvety",    -- GNAT.Altivec.Vector_Types
204      "g-alvevi",    -- GNAT.Altivec.Vector_Views
205      "g-alveop",    -- GNAT.Altivec.Vector_Operations
206      "g-altcon",    -- GNAT.Altivec.Conversions
207      "g-arrspl",    -- GNAT.Array_Split
208      "g-awk   ",    -- GNAT.AWK
209      "g-boubuf",    -- GNAT.Bounded_Buffers
210      "g-boumai",    -- GNAT.Bounded_Mailboxes
211      "g-bubsor",    -- GNAT.Bubble_Sort
212      "g-busora",    -- GNAT.Bubble_Sort_A
213      "g-busorg",    -- GNAT.Bubble_Sort_G
214      "g-bytswa",    -- Gnat.Byte_Swapping
215      "g-calend",    -- GNAT.Calendar
216      "g-casuti",    -- GNAT.Case_Util
217      "g-catiio",    -- GNAT.Calendar.Time_IO
218      "g-cgi   ",    -- GNAT.CGI
219      "g-cgicoo",    -- GNAT.CGI.Cookie
220      "g-cgideb",    -- GNAT.CGI.Debug
221      "g-comlin",    -- GNAT.Command_Line
222      "g-comver",    -- GNAT.Compiler_Version
223      "g-crc32 ",    -- GNAT.CRC32
224      "g-ctrl_c",    -- GNAT.Ctrl_C
225      "g-curexc",    -- GNAT.Current_Exception
226      "g-debpoo",    -- GNAT.Debug_Pools
227      "g-debuti",    -- GNAT.Debug_Utilities
228      "g-diopit",    -- GNAT.Directory_Operations.Iteration
229      "g-dirope",    -- GNAT.Directory_Operations
230      "g-dynhta",    -- GNAT.Dynamic_HTables
231      "g-dyntab",    -- GNAT.Dynamic_Tables
232      "g-excact",    -- GNAT.Exception_Actions
233      "g-except",    -- GNAT.Exceptions
234      "g-exctra",    -- GNAT.Exception_Traces
235      "g-expect",    -- GNAT.Expect
236      "g-flocon",    -- GNAT.Float_Control
237      "g-heasor",    -- GNAT.Heap_Sort
238      "g-hesora",    -- GNAT.Heap_Sort_A
239      "g-hesorg",    -- GNAT.Heap_Sort_G
240      "g-htable",    -- GNAT.Htable
241      "g-io    ",    -- GNAT.IO
242      "g-io_aux",    -- GNAT.IO_Aux
243      "g-locfil",    -- GNAT.Lock_Files
244      "g-md5   ",    -- GNAT.MD5
245      "g-memdum",    -- GNAT.Memory_Dump
246      "g-moreex",    -- GNAT.Most_Recent_Exception
247      "g-os_lib",    -- GNAT.Os_Lib
248      "g-pehage",    -- GNAT.Perfect_Hash_Generators
249      "g-regexp",    -- GNAT.Regexp
250      "g-regist",    -- GNAT.Registry
251      "g-regpat",    -- GNAT.Regpat
252      "g-semaph",    -- GNAT.Semaphores
253      "g-sestin",    -- GNAT.Secondary_Stack_Info
254      "g-sha1  ",    -- GNAT.SHA1
255      "g-signal",    -- GNAT.Signals
256      "g-socket",    -- GNAT.Sockets
257      "g-souinf",    -- GNAT.Source_Info
258      "g-speche",    -- GNAT.Spell_Checker
259      "g-spipat",    -- GNAT.Spitbol.Patterns
260      "g-spitbo",    -- GNAT.Spitbol
261      "g-sptabo",    -- GNAT.Spitbol.Table_Boolean
262      "g-sptain",    -- GNAT.Spitbol.Table_Integer
263      "g-sptavs",    -- GNAT.Spitbol.Table_Vstring
264      "g-string",    -- GNAT.Strings
265      "g-strspl",    -- GNAT.String_Split
266      "g-table ",    -- GNAT.Table
267      "g-tasloc",    -- GNAT.Task_Lock
268      "g-thread",    -- GNAT.Threads
269      "g-traceb",    -- GNAT.Traceback
270      "g-trasym",    -- GNAT.Traceback.Symbolic
271      "g-utf_32",    -- GNAT.UTF_32
272      "g-wistsp",    -- GNAT.Wide_String_Split
273
274    -----------------------------------------------------
275    -- Interface Hierarchy Units from Reference Manual --
276    -----------------------------------------------------
277
278      "i-c     ",    -- Interfaces.C
279      "i-cobol ",    -- Interfaces.Cobol
280      "i-cpoint",    -- Interfaces.C.Pointers
281      "i-cstrin",    -- Interfaces.C.Strings
282      "i-fortra",    -- Interfaces.Fortran
283
284    ------------------------------------------
285    -- GNAT Defined Additions to Interfaces --
286    ------------------------------------------
287
288      "i-cexten",    -- Interfaces.C.Extensions
289      "i-cpp   ",    -- Interfaces.CPP
290      "i-cstrea",    -- Interfaces.C.Streams
291      "i-jalaob",    -- Interfaces.Java.Lang.Object
292      "i-jalasy",    -- Interfaces.Java.Lang.System
293      "i-jalath",    -- Interfaces.Java.Lang.Thread
294      "i-java  ",    -- Interfaces.Java
295      "i-javlan",    -- Interfaces.Java.Lang
296      "i-os2err",    -- Interfaces.Os2lib.Errors
297      "i-os2lib",    -- Interfaces.Os2lib
298      "i-os2syn",    -- Interfaces.Os2lib.Synchronization
299      "i-os2thr",    -- Interfaces.Os2lib.Threads
300      "i-pacdec",    -- Interfaces.Packed_Decimal
301      "i-vthrea",    -- Interfaces.Vthreads
302      "i-vxwoio",    -- Interfaces.VxWorks.IO
303      "i-vxwork",    -- Interfaces.VxWorks
304
305    --------------------------------------------------
306    -- System Hierarchy Units from Reference Manual --
307    --------------------------------------------------
308
309      "s-atacco",    -- System.Address_To_Access_Conversions
310      "s-maccod",    -- System.Machine_Code
311      "s-rpc   ",    -- System.Rpc
312      "s-stoele",    -- System.Storage_Elements
313      "s-stopoo",    -- System.Storage_Pools
314
315    --------------------------------------
316    -- GNAT Defined Additions to System --
317    --------------------------------------
318
319      "s-addima",    -- System.Address_Image
320      "s-assert",    -- System.Assertions
321      "s-memory",    -- System.Memory
322      "s-parint",    -- System.Partition_Interface
323      "s-pooglo",    -- System.Pool_Global
324      "s-pooloc",    -- System.Pool_Local
325      "s-restri",    -- System.Restrictions
326      "s-rident",    -- System.Rident
327      "s-tasinf",    -- System.Task_Info
328      "s-wchcnv",    -- System.Wch_Cnv
329      "s-wchcon");   -- System.Wch_Con
330
331    --------------------
332    -- Ada 2005 Units --
333    --------------------
334
335    --  The following units should be used only in Ada 05 mode
336
337    Non_Imp_File_Names_05 : constant File_List := (
338
339    --------------------------------------------------------
340    -- Ada Hierarchy Units from Ada 2005 Reference Manual --
341    --------------------------------------------------------
342
343      "a-calari",    -- Ada.Calendar.Arithmetic
344      "a-calfor",    -- Ada.Calendar.Formatting
345      "a-catizo",    -- Ada.Calendar.Time_Zones
346      "a-cdlili",    -- Ada.Containers.Doubly_Linked_Lists
347      "a-cgarso",    -- Ada.Containers.Generic_Array_Sort
348      "a-cgcaso",    -- Ada.Containers.Generic_Constrained_Array_Sort
349      "a-chacon",    -- Ada.Characters.Conversions
350      "a-cidlli",    -- Ada.Containers.Indefinite_Doubly_Linked_Lists
351      "a-cihama",    -- Ada.Containers.Indefinite_Hashed_Maps
352      "a-cihase",    -- Ada.Containers.Indefinite_Hashed_Sets
353      "a-ciorma",    -- Ada.Containers.Indefinite_Ordered_Maps
354      "a-ciorse",    -- Ada.Containers.Indefinite_Ordered_Sets
355      "a-cohama",    -- Ada.Containers.Hashed_Maps
356      "a-cohase",    -- Ada.Containers.Hashed_Sets
357      "a-coinve",    -- Ada.Containers.Indefinite_Vectors
358      "a-contai",    -- Ada.Containers
359      "a-convec",    -- Ada.Containers.Vectors
360      "a-coorma",    -- Ada.Containers.Ordered_Maps
361      "a-coorse",    -- Ada.Containers.Ordered_Sets
362      "a-coteio",    -- Ada.Complex_Text_IO
363      "a-direct",    -- Ada.Directories
364      "a-diroro",    -- Ada.Dispatching.Round_Robin
365      "a-dispat",    -- Ada.Dispatching
366      "a-envvar",    -- Ada.Environment_Variables
367      "a-rttiev",    -- Ada.Real_Time.Timing_Events
368      "a-ngcoar",    -- Ada.Numerics.Generic_Complex_Arrays
369      "a-ngrear",    -- Ada.Numerics.Generic_Real_Arrays
370      "a-nucoar",    -- Ada.Numerics.Complex_Arrays
371      "a-nurear",    -- Ada.Numerics.Real_Arrays
372      "a-stboha",    -- Ada.Strings.Bounded.Hash
373      "a-stfiha",    -- Ada.Strings.Fixed.Hash
374      "a-strhas",    -- Ada.Strings.Hash
375      "a-stunha",    -- Ada.Strings.Unbounded.Hash
376      "a-stwiha",    -- Ada.Strings.Wide_Hash
377      "a-stzbou",    -- Ada.Strings.Wide_Wide_Bounded
378      "a-stzfix",    -- Ada.Strings.Wide_Wide_Fixed
379      "a-stzhas",    -- Ada.Strings.Wide_Wide_Hash
380      "a-stzmap",    -- Ada.Strings.Wide_Wide_Maps
381      "a-stzunb",    -- Ada.Strings.Wide_Wide_Unbounded
382      "a-swbwha",    -- Ada.Strings.Wide_Bounded.Wide_Hash
383      "a-swfwha",    -- Ada.Strings.Wide_Fixed.Wide_Hash
384      "a-swuwha",    -- Ada.Strings.Wide_Unbounded.Wide_Hash
385      "a-szbzha",    -- Ada.Strings.Wide_Wide_Bounded.Wide_Wide_Hash
386      "a-szfzha",    -- Ada.Strings.Wide_Wide_Fixed.Wide_Wide_Hash
387      "a-szmzco",    -- Ada.Strings.Wide_Wide_Maps.Wide_Wide_Constants
388      "a-szuzha",    -- Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Hash
389      "a-taster",    -- Ada.Task_Termination
390      "a-tgdico",    -- Ada.Tags.Generic_Dispatching_Constructor
391      "a-tiboio",    -- Ada.Text_IO.Bounded_IO
392      "a-tiunio",    -- Ada.Text_IO.Unbounded_IO
393      "a-wichun",    -- Ada.Wide_Characters.Unicode
394      "a-wwboio",    -- Ada.Wide_Text_IO.Wide_Bounded_IO
395      "a-wwunio",    -- Ada.Wide_Text_IO.Wide_Unbounded_IO
396      "a-zchara",    -- Ada.Wide_Wide_Characters
397      "a-ztcoio",    -- Ada.Wide_Wide_Text_IO.Complex_IO
398      "a-ztedit",    -- Ada.Wide_Wide_Text_IO.Editing
399      "a-zttest",    -- Ada.Wide_Wide_Text_IO.Text_Streams
400      "a-ztexio",    -- Ada.Wide_Wide_Text_IO
401      "a-zzboio",    -- Ada.Wide_Wide_Text_IO.Wide_Wide_Bounded_IO
402      "a-zzunio",    -- Ada.Wide_Wide_Text_IO.Wide_Wide_Unbounded_IO
403
404    ------------------------------------------------------
405    -- RM Required Additions to Ada 2005 for GNAT Types --
406    ------------------------------------------------------
407
408      "a-lcteio",    -- Ada.Long_Complex_Text_IO
409      "a-lfztio",    -- Ada.Long_Float_Wide_Wide_Text_IO
410      "a-liztio",    -- Ada.Long_Integer_Wide_Wide_Text_IO
411      "a-llctio",    -- Ada.Long_Long_Complex_Text_IO
412      "a-llfzti",    -- Ada.Long_Long_Float_Wide_Wide_Text_IO
413      "a-llizti",    -- Ada.Long_Long_Integer_Wide_Wide_Text_IO
414      "a-nlcoar",    -- Ada.Numerics.Long_Complex_Arrays
415      "a-nllcar",    -- Ada.Numerics.Long_Long_Complex_Arrays
416      "a-nllrar",    -- Ada.Numerics.Long_Long_Real_Arrays
417      "a-nlrear",    -- Ada.Numerics.Long_Real_Arrays
418      "a-scteio",    -- Ada.Short_Complex_Text_IO
419      "a-sfztio",    -- Ada.Short_Float_Wide_Wide_Text_IO
420      "a-siztio",    -- Ada.Short_Integer_Wide_Wide_Text_IO
421      "a-ssizti",    -- Ada.Short_Short_Integer_Wide_Wide_Text_IO
422      "a-ztcstr",    -- Ada.Wide_Wide_Text_IO.C_Streams
423
424    ----------------------------------------
425    -- GNAT Defined Additions to Ada 2005 --
426    ----------------------------------------
427
428      "a-cgaaso",    -- Ada.Containers.Generic_Anonymous_Array_Sort
429      "a-chzla1",    -- Ada.Characters.Wide_Wide_Latin_1
430      "a-chzla9",    -- Ada.Characters.Wide_Wide_Latin_9
431      "a-ciormu",    -- Ada.Containers.Indefinite_Ordered_Multisets
432      "a-coormu",    -- Ada.Containers.Ordered_Multisets
433      "a-crdlli",    -- Ada.Containers.Restricted_Doubly_Linked_Lists
434      "a-secain",    -- Ada.Strings.Equal_Case_Insensitive
435      "a-shcain",    -- Ada.Strings.Hash_Case_Insensitive
436      "a-slcain",    -- Ada.Strings.Less_Case_Insensitive
437      "a-szuzti",    -- Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO
438      "a-zchuni",    -- Ada.Wide_Wide_Characters.Unicode
439
440    ---------------------------
441    -- GNAT Special IO Units --
442    ---------------------------
443
444    --  See Ada 95 section for further information. These packages are for the
445    --  implementation of the Wide_Wide_Text_IO generic packages.
446
447      "a-ztdeio",    -- Ada.Wide_Wide_Text_IO.Decimal_IO
448      "a-ztenio",    -- Ada.Wide_Wide_Text_IO.Enumeration_IO
449      "a-ztfiio",    -- Ada.Wide_Wide_Text_IO.Fixed_IO
450      "a-ztflio",    -- Ada.Wide_Wide_Text_IO.Float_IO
451      "a-ztinio",    -- Ada.Wide_Wide_Text_IO.Integer_IO
452      "a-ztmoio",    -- Ada.Wide_Wide_Text_IO.Modular_IO
453
454    ------------------------
455    -- GNAT Library Units --
456    ------------------------
457
458      "g-zstspl");   -- GNAT.Wide_Wide_String_Split
459
460    ----------------------
461    -- Get_Kind_Of_Unit --
462    ----------------------
463
464    function Get_Kind_Of_Unit (U : Unit_Number_Type) return Kind_Of_Unit is
465       Fname : constant File_Name_Type := Unit_File_Name (U);
466
467    begin
468       --  If length of file name is greater than 12, not predefined.
469       --  The value 12 here is an 8 char name with extension .ads.
470
471       if Length_Of_Name (Fname) > 12 then
472          return Not_Predefined_Unit;
473       end if;
474
475       --  Otherwise test file name
476
477       Get_Name_String (Fname);
478
479       --  Not predefined if file name does not start with a- g- s- i-
480
481       if Name_Len < 3
482         or else Name_Buffer (2) /= '-'
483         or else (Name_Buffer (1) /= 'a'
484                    and then
485                  Name_Buffer (1) /= 'g'
486                    and then
487                  Name_Buffer (1) /= 'i'
488                    and then
489                  Name_Buffer (1) /= 's')
490       then
491          return Not_Predefined_Unit;
492       end if;
493
494       --  Not predefined if file name does not end in .ads. This can
495       --  happen when non-standard file names are being used.
496
497       if Name_Buffer (Name_Len - 3 .. Name_Len) /= ".ads" then
498          return Not_Predefined_Unit;
499       end if;
500
501       --  Otherwise normalize file name to 8 characters
502
503       Name_Len := Name_Len - 4;
504       while Name_Len < 8 loop
505          Name_Len := Name_Len + 1;
506          Name_Buffer (Name_Len) := ' ';
507       end loop;
508
509       --  See if name is in 95 list
510
511       for J in Non_Imp_File_Names_95'Range loop
512          if Name_Buffer (1 .. 8) = Non_Imp_File_Names_95 (J) then
513             return Ada_95_Unit;
514          end if;
515       end loop;
516
517       --  See if name is in 05 list
518
519       for J in Non_Imp_File_Names_05'Range loop
520          if Name_Buffer (1 .. 8) = Non_Imp_File_Names_05 (J) then
521             return Ada_05_Unit;
522          end if;
523       end loop;
524
525       --  Only remaining special possibilities are children of System.RPC and
526       --  System.Garlic and special files of the form System.Aux...
527
528       Get_Name_String (Unit_Name (U));
529
530       if Name_Len > 12
531         and then Name_Buffer (1 .. 11) = "system.rpc."
532       then
533          return Ada_95_Unit;
534       end if;
535
536       if Name_Len > 15
537         and then Name_Buffer (1 .. 14) = "system.garlic."
538       then
539          return Ada_95_Unit;
540       end if;
541
542       if Name_Len > 11
543         and then Name_Buffer (1 .. 10) = "system.aux"
544       then
545          return Ada_95_Unit;
546       end if;
547
548       --  All tests failed, this is definitely an implementation unit
549
550       return Implementation_Unit;
551    end Get_Kind_Of_Unit;
552
553    -------------------
554    -- Is_Known_Unit --
555    -------------------
556
557    function Is_Known_Unit (Nam : Node_Id) return Boolean is
558       Unam : Unit_Name_Type;
559       Fnam : File_Name_Type;
560
561    begin
562       --  If selector is not an identifier (e.g. it is a character literal or
563       --  some junk from a previous error), then definitely not a known unit.
564
565       if Nkind (Selector_Name (Nam)) /= N_Identifier then
566          return False;
567       end if;
568
569       --  Otherwise get corresponding file name
570
571       Unam := Get_Unit_Name (Nam);
572       Fnam := Get_File_Name (Unam, Subunit => False);
573       Get_Name_String (Fnam);
574
575       --  Remove extension from file name
576
577       if Name_Buffer (Name_Len - 3 .. Name_Len) = ".adb" then
578          Name_Len := Name_Len - 4;
579       else
580          return False;
581       end if;
582
583       --  Pad name to 8 characters
584
585       while Name_Len < 8 loop
586          Name_Len := Name_Len + 1;
587          Name_Buffer (Name_Len) := ' ';
588       end loop;
589
590       --  If length more than 8, definitely not a match
591
592       if Name_Len /= 8 then
593          return False;
594       end if;
595
596       --  If length is 8, search our tables
597
598       for J in Non_Imp_File_Names_95'Range loop
599          if Name_Buffer (1 .. 8) = Non_Imp_File_Names_95 (J) then
600             return True;
601          end if;
602       end loop;
603
604       for J in Non_Imp_File_Names_05'Range loop
605          if Name_Buffer (1 .. 8) = Non_Imp_File_Names_05 (J) then
606             return True;
607          end if;
608       end loop;
609
610       --  If not found, not known
611
612       return False;
613
614    --  A safety guard, if we get an exception during this processing then it
615    --  is most likely the result of a previous error, or a peculiar case we
616    --  have not thought of. Since this routine is only used for error message
617    --  refinement, we will just return False.
618
619    exception
620       when others =>
621          return False;
622    end Is_Known_Unit;
623
624 end Impunit;