OSDN Git Service

2011-08-04 Robert Dewar <dewar@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-2011, 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-95 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       --  Note: strictly the following should be Ada 2012 units, but it seems
177       --  harmless (and useful) to make then available in Ada 95 mode, since
178       --  they do not deal with Wide_Wide_Character.
179
180      "a-wichha",    -- Ada.Wide_Characters.Handling
181      "a-stuten",    -- Ada.Strings.UTF_Encoding
182      "a-suenco",    -- Ada.Strings.UTF_Encoding.Conversions
183      "a-suenst",    -- Ada.Strings.UTF_Encoding.Strings
184      "a-suewst",    -- Ada.Strings.UTF_Encoding.Wide_Strings
185
186    ---------------------------
187    -- GNAT Special IO Units --
188    ---------------------------
189
190    --  As further explained elsewhere (see Sem_Ch10), the internal packages of
191    --  Text_IO and Wide_Text_IO are actually implemented as separate children,
192    --  but this fact is intended to be hidden from the user completely. Any
193    --  attempt to WITH one of these units will be diagnosed as an error later
194    --  on, but for now we do not consider these internal implementation units
195    --  (if we did, then we would get a junk warning which would be confusing
196    --  and unnecessary, given that we generate a clear error message).
197
198      "a-tideio",    -- Ada.Text_IO.Decimal_IO
199      "a-tienio",    -- Ada.Text_IO.Enumeration_IO
200      "a-tifiio",    -- Ada.Text_IO.Fixed_IO
201      "a-tiflio",    -- Ada.Text_IO.Float_IO
202      "a-tiinio",    -- Ada.Text_IO.Integer_IO
203      "a-tiinio",    -- Ada.Text_IO.Integer_IO
204      "a-timoio",    -- Ada.Text_IO.Modular_IO
205      "a-wtdeio",    -- Ada.Wide_Text_IO.Decimal_IO
206      "a-wtenio",    -- Ada.Wide_Text_IO.Enumeration_IO
207      "a-wtfiio",    -- Ada.Wide_Text_IO.Fixed_IO
208      "a-wtflio",    -- Ada.Wide_Text_IO.Float_IO
209      "a-wtinio",    -- Ada.Wide_Text_IO.Integer_IO
210      "a-wtmoio",    -- Ada.Wide_Text_IO.Modular_IO
211
212    ------------------------
213    -- GNAT Library Units --
214    ------------------------
215
216      "g-altive",    -- GNAT.Altivec
217      "g-altcon",    -- GNAT.Altivec.Conversions
218      "g-alveop",    -- GNAT.Altivec.Vector_Operations
219      "g-alvety",    -- GNAT.Altivec.Vector_Types
220      "g-alvevi",    -- GNAT.Altivec.Vector_Views
221      "g-arrspl",    -- GNAT.Array_Split
222      "g-awk   ",    -- GNAT.AWK
223      "g-boubuf",    -- GNAT.Bounded_Buffers
224      "g-boumai",    -- GNAT.Bounded_Mailboxes
225      "g-bubsor",    -- GNAT.Bubble_Sort
226      "g-busora",    -- GNAT.Bubble_Sort_A
227      "g-busorg",    -- GNAT.Bubble_Sort_G
228      "g-byorma",    -- GNAT.Byte_Order_Mark
229      "g-bytswa",    -- GNAT.Byte_Swapping
230      "g-calend",    -- GNAT.Calendar
231      "g-catiio",    -- GNAT.Calendar.Time_IO
232      "g-casuti",    -- GNAT.Case_Util
233      "g-cgi   ",    -- GNAT.CGI
234      "g-cgicoo",    -- GNAT.CGI.Cookie
235      "g-cgideb",    -- GNAT.CGI.Debug
236      "g-comlin",    -- GNAT.Command_Line
237      "g-comver",    -- GNAT.Compiler_Version
238      "g-crc32 ",    -- GNAT.CRC32
239      "g-ctrl_c",    -- GNAT.Ctrl_C
240      "g-curexc",    -- GNAT.Current_Exception
241      "g-debpoo",    -- GNAT.Debug_Pools
242      "g-debuti",    -- GNAT.Debug_Utilities
243      "g-decstr",    -- GNAT.Decode_String
244      "g-deutst",    -- GNAT.Decode_UTF8_String
245      "g-dirope",    -- GNAT.Directory_Operations
246      "g-diopit",    -- GNAT.Directory_Operations.Iteration
247      "g-dynhta",    -- GNAT.Dynamic_HTables
248      "g-dyntab",    -- GNAT.Dynamic_Tables
249      "g-encstr",    -- GNAT.Encode_String
250      "g-enutst",    -- GNAT.Encode_UTF8_String
251      "g-excact",    -- GNAT.Exception_Actions
252      "g-except",    -- GNAT.Exceptions
253      "g-exctra",    -- GNAT.Exception_Traces
254      "g-expect",    -- GNAT.Expect
255      "g-flocon",    -- GNAT.Float_Control
256      "g-heasor",    -- GNAT.Heap_Sort
257      "g-hesora",    -- GNAT.Heap_Sort_A
258      "g-hesorg",    -- GNAT.Heap_Sort_G
259      "g-htable",    -- GNAT.Htable
260      "g-io    ",    -- GNAT.IO
261      "g-io_aux",    -- GNAT.IO_Aux
262      "g-locfil",    -- GNAT.Lock_Files
263      "g-mbdira",    -- GNAT.MBBS_Discrete_Random
264      "g-mbflra",    -- GNAT.MBBS_Float_Random
265      "g-md5   ",    -- GNAT.MD5
266      "g-memdum",    -- GNAT.Memory_Dump
267      "g-moreex",    -- GNAT.Most_Recent_Exception
268      "g-os_lib",    -- GNAT.Os_Lib
269      "g-pehage",    -- GNAT.Perfect_Hash_Generators
270      "g-rannum",    -- GNAT.Random_Numbers
271      "g-regexp",    -- GNAT.Regexp
272      "g-regist",    -- GNAT.Registry
273      "g-regpat",    -- GNAT.Regpat
274      "g-semaph",    -- GNAT.Semaphores
275      "g-sercom",    -- GNAT.Serial_Communications
276      "g-sestin",    -- GNAT.Secondary_Stack_Info
277      "g-sha1  ",    -- GNAT.SHA1
278      "g-sha224",    -- GNAT.SHA224
279      "g-sha256",    -- GNAT.SHA256
280      "g-sha384",    -- GNAT.SHA384
281      "g-sha512",    -- GNAT.SHA512
282      "g-signal",    -- GNAT.Signals
283      "g-socket",    -- GNAT.Sockets
284      "g-souinf",    -- GNAT.Source_Info
285      "g-speche",    -- GNAT.Spell_Checker
286      "g-spchge",    -- GNAT.Spell_Checker_Generic
287      "g-spitbo",    -- GNAT.Spitbol
288      "g-spipat",    -- GNAT.Spitbol.Patterns
289      "g-sptabo",    -- GNAT.Spitbol.Table_Boolean
290      "g-sptain",    -- GNAT.Spitbol.Table_Integer
291      "g-sptavs",    -- GNAT.Spitbol.Table_Vstring
292      "g-string",    -- GNAT.Strings
293      "g-strspl",    -- GNAT.String_Split
294      "g-sse   ",    -- GNAT.SSE
295      "g-ssvety",    -- GNAT.SSE.Vector_Types
296      "g-table ",    -- GNAT.Table
297      "g-tasloc",    -- GNAT.Task_Lock
298      "g-tastus",    -- GNAT.Task_Stack_Usage
299      "g-thread",    -- GNAT.Threads
300      "g-timsta",    -- GNAT.Time_Stamp
301      "g-traceb",    -- GNAT.Traceback
302      "g-trasym",    -- GNAT.Traceback.Symbolic
303      "g-utf_32",    -- GNAT.UTF_32
304      "g-u3spch",    -- GNAT.UTF_32_Spelling_Checker
305      "g-wispch",    -- GNAT.Wide_Spelling_Checker
306      "g-wistsp",    -- GNAT.Wide_String_Split
307
308    -----------------------------------------------------
309    -- Interface Hierarchy Units from Reference Manual --
310    -----------------------------------------------------
311
312      "i-c     ",    -- Interfaces.C
313      "i-cobol ",    -- Interfaces.Cobol
314      "i-cpoint",    -- Interfaces.C.Pointers
315      "i-cstrin",    -- Interfaces.C.Strings
316      "i-fortra",    -- Interfaces.Fortran
317
318    ------------------------------------------
319    -- GNAT Defined Additions to Interfaces --
320    ------------------------------------------
321
322      "i-cexten",    -- Interfaces.C.Extensions
323      "i-cil   ",    -- Interfaces.CIL
324      "i-cilobj",    -- Interfaces.CIL.Object
325      "i-cpp   ",    -- Interfaces.CPP
326      "i-cstrea",    -- Interfaces.C.Streams
327      "i-java  ",    -- Interfaces.Java
328      "i-javjni",    -- Interfaces.Java.JNI
329      "i-pacdec",    -- Interfaces.Packed_Decimal
330      "i-vxwoio",    -- Interfaces.VxWorks.IO
331      "i-vxwork",    -- Interfaces.VxWorks
332
333    --------------------------------------------------
334    -- System Hierarchy Units from Reference Manual --
335    --------------------------------------------------
336
337      "s-atacco",    -- System.Address_To_Access_Conversions
338      "s-maccod",    -- System.Machine_Code
339      "s-rpc   ",    -- System.Rpc
340      "s-stoele",    -- System.Storage_Elements
341      "s-stopoo",    -- System.Storage_Pools
342
343    --------------------------------------
344    -- GNAT Defined Additions to System --
345    --------------------------------------
346
347      "s-addima",    -- System.Address_Image
348      "s-assert",    -- System.Assertions
349      "s-memory",    -- System.Memory
350      "s-parint",    -- System.Partition_Interface
351      "s-pooglo",    -- System.Pool_Global
352      "s-pooloc",    -- System.Pool_Local
353      "s-restri",    -- System.Restrictions
354      "s-rident",    -- System.Rident
355      "s-ststop",    -- System.Strings.Stream_Ops
356      "s-tasinf",    -- System.Task_Info
357      "s-wchcnv",    -- System.Wch_Cnv
358      "s-wchcon");   -- System.Wch_Con
359
360    --------------------
361    -- Ada 2005 Units --
362    --------------------
363
364    --  The following units should be used only in Ada 05 mode
365
366    Non_Imp_File_Names_05 : constant File_List := (
367
368    --------------------------------------------------------
369    -- Ada Hierarchy Units from Ada 2005 Reference Manual --
370    --------------------------------------------------------
371
372      "a-assert",    -- Ada.Assertions
373      "a-calari",    -- Ada.Calendar.Arithmetic
374      "a-calfor",    -- Ada.Calendar.Formatting
375      "a-catizo",    -- Ada.Calendar.Time_Zones
376      "a-cdlili",    -- Ada.Containers.Doubly_Linked_Lists
377      "a-cgarso",    -- Ada.Containers.Generic_Array_Sort
378      "a-cgcaso",    -- Ada.Containers.Generic_Constrained_Array_Sort
379      "a-chacon",    -- Ada.Characters.Conversions
380      "a-cidlli",    -- Ada.Containers.Indefinite_Doubly_Linked_Lists
381      "a-cihama",    -- Ada.Containers.Indefinite_Hashed_Maps
382      "a-cihase",    -- Ada.Containers.Indefinite_Hashed_Sets
383      "a-ciorma",    -- Ada.Containers.Indefinite_Ordered_Maps
384      "a-ciorse",    -- Ada.Containers.Indefinite_Ordered_Sets
385      "a-cohama",    -- Ada.Containers.Hashed_Maps
386      "a-cohase",    -- Ada.Containers.Hashed_Sets
387      "a-coinve",    -- Ada.Containers.Indefinite_Vectors
388      "a-contai",    -- Ada.Containers
389      "a-convec",    -- Ada.Containers.Vectors
390      "a-coorma",    -- Ada.Containers.Ordered_Maps
391      "a-coorse",    -- Ada.Containers.Ordered_Sets
392      "a-coteio",    -- Ada.Complex_Text_IO
393      "a-direct",    -- Ada.Directories
394      "a-diroro",    -- Ada.Dispatching.Round_Robin
395      "a-disedf",    -- Ada.Dispatching.EDF
396      "a-dispat",    -- Ada.Dispatching
397      "a-envvar",    -- Ada.Environment_Variables
398      "a-etgrbu",    -- Ada.Execution_Time.Group_Budgets
399      "a-exetim",    -- Ada.Execution_Time
400      "a-extiti",    -- Ada.Execution_Time.Timers
401      "a-izteio",    -- Ada.Integer_Wide_Wide_Text_IO
402      "a-rttiev",    -- Ada.Real_Time.Timing_Events
403      "a-ngcoar",    -- Ada.Numerics.Generic_Complex_Arrays
404      "a-ngrear",    -- Ada.Numerics.Generic_Real_Arrays
405      "a-nucoar",    -- Ada.Numerics.Complex_Arrays
406      "a-nurear",    -- Ada.Numerics.Real_Arrays
407      "a-stboha",    -- Ada.Strings.Bounded.Hash
408      "a-stfiha",    -- Ada.Strings.Fixed.Hash
409      "a-strhas",    -- Ada.Strings.Hash
410      "a-stunha",    -- Ada.Strings.Unbounded.Hash
411      "a-stwiha",    -- Ada.Strings.Wide_Hash
412      "a-stzbou",    -- Ada.Strings.Wide_Wide_Bounded
413      "a-stzfix",    -- Ada.Strings.Wide_Wide_Fixed
414      "a-stzhas",    -- Ada.Strings.Wide_Wide_Hash
415      "a-stzmap",    -- Ada.Strings.Wide_Wide_Maps
416      "a-stzunb",    -- Ada.Strings.Wide_Wide_Unbounded
417      "a-swbwha",    -- Ada.Strings.Wide_Bounded.Wide_Hash
418      "a-swfwha",    -- Ada.Strings.Wide_Fixed.Wide_Hash
419      "a-swuwha",    -- Ada.Strings.Wide_Unbounded.Wide_Hash
420      "a-szbzha",    -- Ada.Strings.Wide_Wide_Bounded.Wide_Wide_Hash
421      "a-szfzha",    -- Ada.Strings.Wide_Wide_Fixed.Wide_Wide_Hash
422      "a-szmzco",    -- Ada.Strings.Wide_Wide_Maps.Wide_Wide_Constants
423      "a-szuzha",    -- Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Hash
424      "a-taster",    -- Ada.Task_Termination
425      "a-tgdico",    -- Ada.Tags.Generic_Dispatching_Constructor
426      "a-tiboio",    -- Ada.Text_IO.Bounded_IO
427      "a-tiunio",    -- Ada.Text_IO.Unbounded_IO
428      "a-wichun",    -- Ada.Wide_Characters.Unicode
429      "a-wwboio",    -- Ada.Wide_Text_IO.Wide_Bounded_IO
430      "a-wwunio",    -- Ada.Wide_Text_IO.Wide_Unbounded_IO
431      "a-zchara",    -- Ada.Wide_Wide_Characters
432      "a-zchhan",    -- Ada.Wide_Wide_Characters.Handling
433      "a-ztcoio",    -- Ada.Wide_Wide_Text_IO.Complex_IO
434      "a-ztedit",    -- Ada.Wide_Wide_Text_IO.Editing
435      "a-zttest",    -- Ada.Wide_Wide_Text_IO.Text_Streams
436      "a-ztexio",    -- Ada.Wide_Wide_Text_IO
437      "a-zzboio",    -- Ada.Wide_Wide_Text_IO.Wide_Wide_Bounded_IO
438      "a-zzunio",    -- Ada.Wide_Wide_Text_IO.Wide_Wide_Unbounded_IO
439
440    ------------------------------------------------------
441    -- RM Required Additions to Ada 2005 for GNAT Types --
442    ------------------------------------------------------
443
444      "a-lcteio",    -- Ada.Long_Complex_Text_IO
445      "a-lfztio",    -- Ada.Long_Float_Wide_Wide_Text_IO
446      "a-liztio",    -- Ada.Long_Integer_Wide_Wide_Text_IO
447      "a-llctio",    -- Ada.Long_Long_Complex_Text_IO
448      "a-llfzti",    -- Ada.Long_Long_Float_Wide_Wide_Text_IO
449      "a-llizti",    -- Ada.Long_Long_Integer_Wide_Wide_Text_IO
450      "a-nlcoar",    -- Ada.Numerics.Long_Complex_Arrays
451      "a-nllcar",    -- Ada.Numerics.Long_Long_Complex_Arrays
452      "a-nllrar",    -- Ada.Numerics.Long_Long_Real_Arrays
453      "a-nlrear",    -- Ada.Numerics.Long_Real_Arrays
454      "a-scteio",    -- Ada.Short_Complex_Text_IO
455      "a-sfztio",    -- Ada.Short_Float_Wide_Wide_Text_IO
456      "a-siztio",    -- Ada.Short_Integer_Wide_Wide_Text_IO
457      "a-ssizti",    -- Ada.Short_Short_Integer_Wide_Wide_Text_IO
458      "a-ztcstr",    -- Ada.Wide_Wide_Text_IO.C_Streams
459
460    ----------------------------------------
461    -- GNAT Defined Additions to Ada 2005 --
462    ----------------------------------------
463
464      "a-cgaaso",    -- Ada.Containers.Generic_Anonymous_Array_Sort
465      "a-chzla1",    -- Ada.Characters.Wide_Wide_Latin_1
466      "a-chzla9",    -- Ada.Characters.Wide_Wide_Latin_9
467      "a-ciormu",    -- Ada.Containers.Indefinite_Ordered_Multisets
468      "a-coormu",    -- Ada.Containers.Ordered_Multisets
469      "a-crdlli",    -- Ada.Containers.Restricted_Doubly_Linked_Lists
470      "a-secain",    -- Ada.Strings.Equal_Case_Insensitive
471      "a-shcain",    -- Ada.Strings.Hash_Case_Insensitive
472      "a-slcain",    -- Ada.Strings.Less_Case_Insensitive
473      "a-szuzti",    -- Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO
474      "a-zchuni",    -- Ada.Wide_Wide_Characters.Unicode
475
476       --  Note: strictly the following should be Ada 2012 units, but it seems
477       --  harmless (and useful) to make then available in Ada 2005 mode.
478
479      "a-suezst",    -- Ada.Strings.UTF_Encoding.Wide_Wide_Strings
480
481    ---------------------------
482    -- GNAT Special IO Units --
483    ---------------------------
484
485    --  See Ada 95 section for further information. These packages are for the
486    --  implementation of the Wide_Wide_Text_IO generic packages.
487
488      "a-ztdeio",    -- Ada.Wide_Wide_Text_IO.Decimal_IO
489      "a-ztenio",    -- Ada.Wide_Wide_Text_IO.Enumeration_IO
490      "a-ztfiio",    -- Ada.Wide_Wide_Text_IO.Fixed_IO
491      "a-ztflio",    -- Ada.Wide_Wide_Text_IO.Float_IO
492      "a-ztinio",    -- Ada.Wide_Wide_Text_IO.Integer_IO
493      "a-ztmoio",    -- Ada.Wide_Wide_Text_IO.Modular_IO
494
495    ------------------------
496    -- GNAT Library Units --
497    ------------------------
498
499      "g-zspche",    -- GNAT.Wide_Wide_Spelling_Checker
500      "g-zstspl");   -- GNAT.Wide_Wide_String_Split
501
502    --------------------
503    -- Ada 2012 Units --
504    --------------------
505
506    --  The following units should be used only in Ada 2012 mode
507
508    Non_Imp_File_Names_12 : constant File_List := (
509      "s-multip",    -- System.Multiprocessors
510      "s-mudido",    -- System.Multiprocessors.Dispatching_Domains
511      "a-cobove",    -- Ada.Containers.Bounded_Vectors
512      "a-cbdlli",    -- Ada.Containers.Bounded_Doubly_Linked_Lists
513      "a-cborse",    -- Ada.Containers.Bounded_Ordered_Sets
514      "a-cborma",    -- Ada.Containers.Bounded_Ordered_Maps
515      "a-cbhase",    -- Ada.Containers.Bounded_Hashed_Sets
516      "a-cbhama",    -- Ada.Containers.Bounded_Hashed_Maps
517      "a-coinho",    -- Ada.Containers.Indefinite_Holders
518      "a-extiin",    -- Ada.Execution_Time.Interrupts
519
520    -----------------------------------------
521    -- GNAT Defined Additions to Ada 20012 --
522    -----------------------------------------
523
524      "a-cofove",    -- Ada.Containers.Formal_Vectors
525      "a-cfdlli",    -- Ada.Containers.Formal_Doubly_Linked_Lists
526      "a-cforse",    -- Ada.Containers.Formal_Ordered_Sets
527      "a-cforma",    -- Ada.Containers.Formal_Ordered_Maps
528      "a-cfhase",    -- Ada.Containers.Formal_Hashed_Sets
529      "a-cfhama");   -- Ada.Containers.Formal_Hashed_Maps
530
531    -----------------------
532    -- Alternative Units --
533    -----------------------
534
535    --  For some implementation units, there is a unit in the GNAT library
536    --  that has identical functionality that is usable. If we have such a
537    --  case we record the appropriate Unit name in Error_Msg_String.
538
539    type Aunit_Record is record
540       Fname : String (1 .. 6);
541       Aname : String_Ptr;
542    end record;
543
544    --  Array of alternative unit names
545
546    Scasuti : aliased String := "GNAT.Case_Util";
547    Scrc32  : aliased String := "GNAT.CRC32";
548    Shtable : aliased String := "GNAT.HTable";
549    Sos_lib : aliased String := "GNAT.OS_Lib";
550    Sregexp : aliased String := "GNAT.Regexp";
551    Sregpat : aliased String := "GNAT.Regpat";
552    Sstring : aliased String := "GNAT.Strings";
553    Sstusta : aliased String := "GNAT.Task_Stack_Usage";
554    Stasloc : aliased String := "GNAT.Task_Lock";
555    Sutf_32 : aliased String := "GNAT.UTF_32";
556
557    --  Array giving mapping
558
559    Map_Array : constant array (1 .. 10) of Aunit_Record := (
560                  ("casuti", Scasuti'Access),
561                  ("crc32 ", Scrc32 'Access),
562                  ("htable", Shtable'Access),
563                  ("os_lib", Sos_lib'Access),
564                  ("regexp", Sregexp'Access),
565                  ("regpat", Sregpat'Access),
566                  ("string", Sstring'Access),
567                  ("stusta", Sstusta'Access),
568                  ("tasloc", Stasloc'Access),
569                  ("utf_32", Sutf_32'Access));
570
571    ----------------------
572    -- Get_Kind_Of_Unit --
573    ----------------------
574
575    function Get_Kind_Of_Unit (U : Unit_Number_Type) return Kind_Of_Unit is
576       Fname : constant File_Name_Type := Unit_File_Name (U);
577
578    begin
579       Error_Msg_Strlen := 0;
580
581       --  If length of file name is greater than 12, not predefined.
582       --  The value 12 here is an 8 char name with extension .ads.
583
584       if Length_Of_Name (Fname) > 12 then
585          return Not_Predefined_Unit;
586       end if;
587
588       --  Otherwise test file name
589
590       Get_Name_String (Fname);
591
592       --  Not predefined if file name does not start with a- g- s- i-
593
594       if Name_Len < 3
595         or else Name_Buffer (2) /= '-'
596         or else (Name_Buffer (1) /= 'a'
597                    and then
598                  Name_Buffer (1) /= 'g'
599                    and then
600                  Name_Buffer (1) /= 'i'
601                    and then
602                  Name_Buffer (1) /= 's')
603       then
604          return Not_Predefined_Unit;
605       end if;
606
607       --  Not predefined if file name does not end in .ads. This can
608       --  happen when non-standard file names are being used.
609
610       if Name_Buffer (Name_Len - 3 .. Name_Len) /= ".ads" then
611          return Not_Predefined_Unit;
612       end if;
613
614       --  Otherwise normalize file name to 8 characters
615
616       Name_Len := Name_Len - 4;
617       while Name_Len < 8 loop
618          Name_Len := Name_Len + 1;
619          Name_Buffer (Name_Len) := ' ';
620       end loop;
621
622       --  See if name is in 95 list
623
624       for J in Non_Imp_File_Names_95'Range loop
625          if Name_Buffer (1 .. 8) = Non_Imp_File_Names_95 (J) then
626             return Ada_95_Unit;
627          end if;
628       end loop;
629
630       --  See if name is in 2005 list
631
632       for J in Non_Imp_File_Names_05'Range loop
633          if Name_Buffer (1 .. 8) = Non_Imp_File_Names_05 (J) then
634             return Ada_2005_Unit;
635          end if;
636       end loop;
637
638       --  See if name is in 2012 list
639
640       for J in Non_Imp_File_Names_12'Range loop
641          if Name_Buffer (1 .. 8) = Non_Imp_File_Names_12 (J) then
642             return Ada_2012_Unit;
643          end if;
644       end loop;
645
646       --  Only remaining special possibilities are children of System.RPC and
647       --  System.Garlic and special files of the form System.Aux...
648
649       Get_Name_String (Unit_Name (U));
650
651       if Name_Len > 12
652         and then Name_Buffer (1 .. 11) = "system.rpc."
653       then
654          return Ada_95_Unit;
655       end if;
656
657       if Name_Len > 15
658         and then Name_Buffer (1 .. 14) = "system.garlic."
659       then
660          return Ada_95_Unit;
661       end if;
662
663       if Name_Len > 11
664         and then Name_Buffer (1 .. 10) = "system.aux"
665       then
666          return Ada_95_Unit;
667       end if;
668
669       --  All tests failed, this is definitely an implementation unit. See if
670       --  we have an alternative name.
671
672       Get_Name_String (Fname);
673
674       if Name_Len in 11 .. 12
675         and then Name_Buffer (1 .. 2) = "s-"
676         and then Name_Buffer (Name_Len - 3 .. Name_Len) = ".ads"
677       then
678          for J in Map_Array'Range loop
679             if (Name_Len = 12 and then
680                  Name_Buffer (3 .. 8) = Map_Array (J).Fname)
681               or else
682                (Name_Len = 11 and then
683                  Name_Buffer (3 .. 7) = Map_Array (J).Fname (1 .. 5))
684             then
685                Error_Msg_Strlen := Map_Array (J).Aname'Length;
686                Error_Msg_String (1 .. Error_Msg_Strlen) :=
687                  Map_Array (J).Aname.all;
688             end if;
689          end loop;
690       end if;
691
692       return Implementation_Unit;
693    end Get_Kind_Of_Unit;
694
695    -------------------
696    -- Is_Known_Unit --
697    -------------------
698
699    function Is_Known_Unit (Nam : Node_Id) return Boolean is
700       Unam : Unit_Name_Type;
701       Fnam : File_Name_Type;
702
703    begin
704       --  If selector is not an identifier (e.g. it is a character literal or
705       --  some junk from a previous error), then definitely not a known unit.
706
707       if Nkind (Selector_Name (Nam)) /= N_Identifier then
708          return False;
709       end if;
710
711       --  Otherwise get corresponding file name
712
713       Unam := Get_Unit_Name (Nam);
714       Fnam := Get_File_Name (Unam, Subunit => False);
715       Get_Name_String (Fnam);
716
717       --  Remove extension from file name
718
719       if Name_Buffer (Name_Len - 3 .. Name_Len) = ".adb" then
720          Name_Len := Name_Len - 4;
721       else
722          return False;
723       end if;
724
725       --  Pad name to 8 characters
726
727       while Name_Len < 8 loop
728          Name_Len := Name_Len + 1;
729          Name_Buffer (Name_Len) := ' ';
730       end loop;
731
732       --  If length more than 8, definitely not a match
733
734       if Name_Len /= 8 then
735          return False;
736       end if;
737
738       --  If length is 8, search our tables
739
740       for J in Non_Imp_File_Names_95'Range loop
741          if Name_Buffer (1 .. 8) = Non_Imp_File_Names_95 (J) then
742             return True;
743          end if;
744       end loop;
745
746       for J in Non_Imp_File_Names_05'Range loop
747          if Name_Buffer (1 .. 8) = Non_Imp_File_Names_05 (J) then
748             return True;
749          end if;
750       end loop;
751
752       --  If not found, not known
753
754       return False;
755
756    --  A safety guard, if we get an exception during this processing then it
757    --  is most likely the result of a previous error, or a peculiar case we
758    --  have not thought of. Since this routine is only used for error message
759    --  refinement, we will just return False.
760
761    exception
762       when others =>
763          return False;
764    end Is_Known_Unit;
765
766 end Impunit;