OSDN Git Service

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