OSDN Git Service

2010-06-22 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-2010, 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-mbdira",    -- GNAT.MBBS_Discrete_Random
254      "g-mbflra",    -- GNAT.MBBS_Float_Random
255      "g-md5   ",    -- GNAT.MD5
256      "g-memdum",    -- GNAT.Memory_Dump
257      "g-moreex",    -- GNAT.Most_Recent_Exception
258      "g-os_lib",    -- GNAT.Os_Lib
259      "g-pehage",    -- GNAT.Perfect_Hash_Generators
260      "g-rannum",    -- GNAT.Random_Numbers
261      "g-regexp",    -- GNAT.Regexp
262      "g-regist",    -- GNAT.Registry
263      "g-regpat",    -- GNAT.Regpat
264      "g-semaph",    -- GNAT.Semaphores
265      "g-sercom",    -- GNAT.Serial_Communications
266      "g-sestin",    -- GNAT.Secondary_Stack_Info
267      "g-sha1  ",    -- GNAT.SHA1
268      "g-sha224",    -- GNAT.SHA224
269      "g-sha256",    -- GNAT.SHA256
270      "g-sha384",    -- GNAT.SHA384
271      "g-sha512",    -- GNAT.SHA512
272      "g-signal",    -- GNAT.Signals
273      "g-socket",    -- GNAT.Sockets
274      "g-souinf",    -- GNAT.Source_Info
275      "g-speche",    -- GNAT.Spell_Checker
276      "g-spchge",    -- GNAT.Spell_Checker_Generic
277      "g-spitbo",    -- GNAT.Spitbol
278      "g-spipat",    -- GNAT.Spitbol.Patterns
279      "g-sptabo",    -- GNAT.Spitbol.Table_Boolean
280      "g-sptain",    -- GNAT.Spitbol.Table_Integer
281      "g-sptavs",    -- GNAT.Spitbol.Table_Vstring
282      "g-string",    -- GNAT.Strings
283      "g-strspl",    -- GNAT.String_Split
284      "g-sse   ",    -- GNAT.SSE
285      "g-ssvety",    -- GNAT.SSE.Vector_Types
286      "g-table ",    -- GNAT.Table
287      "g-tasloc",    -- GNAT.Task_Lock
288      "g-thread",    -- GNAT.Threads
289      "g-timsta",    -- GNAT.Time_Stamp
290      "g-traceb",    -- GNAT.Traceback
291      "g-trasym",    -- GNAT.Traceback.Symbolic
292      "g-utf_32",    -- GNAT.UTF_32
293      "g-u3spch",    -- GNAT.UTF_32_Spelling_Checker
294      "g-wispch",    -- GNAT.Wide_Spelling_Checker
295      "g-wistsp",    -- GNAT.Wide_String_Split
296
297    -----------------------------------------------------
298    -- Interface Hierarchy Units from Reference Manual --
299    -----------------------------------------------------
300
301      "i-c     ",    -- Interfaces.C
302      "i-cobol ",    -- Interfaces.Cobol
303      "i-cpoint",    -- Interfaces.C.Pointers
304      "i-cstrin",    -- Interfaces.C.Strings
305      "i-fortra",    -- Interfaces.Fortran
306
307    ------------------------------------------
308    -- GNAT Defined Additions to Interfaces --
309    ------------------------------------------
310
311      "i-cexten",    -- Interfaces.C.Extensions
312      "i-cil   ",    -- Interfaces.CIL
313      "i-cilobj",    -- Interfaces.CIL.Object
314      "i-cpp   ",    -- Interfaces.CPP
315      "i-cstrea",    -- Interfaces.C.Streams
316      "i-java  ",    -- Interfaces.Java
317      "i-javjni",    -- Interfaces.Java.JNI
318      "i-pacdec",    -- Interfaces.Packed_Decimal
319      "i-vxwoio",    -- Interfaces.VxWorks.IO
320      "i-vxwork",    -- Interfaces.VxWorks
321
322    --------------------------------------------------
323    -- System Hierarchy Units from Reference Manual --
324    --------------------------------------------------
325
326      "s-atacco",    -- System.Address_To_Access_Conversions
327      "s-maccod",    -- System.Machine_Code
328      "s-rpc   ",    -- System.Rpc
329      "s-stoele",    -- System.Storage_Elements
330      "s-stopoo",    -- System.Storage_Pools
331
332    --------------------------------------
333    -- GNAT Defined Additions to System --
334    --------------------------------------
335
336      "s-addima",    -- System.Address_Image
337      "s-assert",    -- System.Assertions
338      "s-memory",    -- System.Memory
339      "s-parint",    -- System.Partition_Interface
340      "s-pooglo",    -- System.Pool_Global
341      "s-pooloc",    -- System.Pool_Local
342      "s-restri",    -- System.Restrictions
343      "s-rident",    -- System.Rident
344      "s-ststop",    -- System.Strings.Stream_Ops
345      "s-tasinf",    -- System.Task_Info
346      "s-wchcnv",    -- System.Wch_Cnv
347      "s-wchcon");   -- System.Wch_Con
348
349    --------------------
350    -- Ada 2005 Units --
351    --------------------
352
353    --  The following units should be used only in Ada 05 mode
354
355    Non_Imp_File_Names_05 : constant File_List := (
356
357    --------------------------------------------------------
358    -- Ada Hierarchy Units from Ada 2005 Reference Manual --
359    --------------------------------------------------------
360
361      "a-assert",    -- Ada.Assertions
362      "a-calari",    -- Ada.Calendar.Arithmetic
363      "a-calfor",    -- Ada.Calendar.Formatting
364      "a-catizo",    -- Ada.Calendar.Time_Zones
365      "a-cdlili",    -- Ada.Containers.Doubly_Linked_Lists
366      "a-cgarso",    -- Ada.Containers.Generic_Array_Sort
367      "a-cgcaso",    -- Ada.Containers.Generic_Constrained_Array_Sort
368      "a-chacon",    -- Ada.Characters.Conversions
369      "a-cidlli",    -- Ada.Containers.Indefinite_Doubly_Linked_Lists
370      "a-cihama",    -- Ada.Containers.Indefinite_Hashed_Maps
371      "a-cihase",    -- Ada.Containers.Indefinite_Hashed_Sets
372      "a-ciorma",    -- Ada.Containers.Indefinite_Ordered_Maps
373      "a-ciorse",    -- Ada.Containers.Indefinite_Ordered_Sets
374      "a-cohama",    -- Ada.Containers.Hashed_Maps
375      "a-cohase",    -- Ada.Containers.Hashed_Sets
376      "a-coinve",    -- Ada.Containers.Indefinite_Vectors
377      "a-contai",    -- Ada.Containers
378      "a-convec",    -- Ada.Containers.Vectors
379      "a-coorma",    -- Ada.Containers.Ordered_Maps
380      "a-coorse",    -- Ada.Containers.Ordered_Sets
381      "a-coteio",    -- Ada.Complex_Text_IO
382      "a-direct",    -- Ada.Directories
383      "a-diroro",    -- Ada.Dispatching.Round_Robin
384      "a-disedf",    -- Ada.Dispatching.EDF
385      "a-dispat",    -- Ada.Dispatching
386      "a-envvar",    -- Ada.Environment_Variables
387      "a-exetim",    -- Ada.Execution_Time
388      "a-extiti",    -- Ada.Execution_Time.Timers
389      "a-rttiev",    -- Ada.Real_Time.Timing_Events
390      "a-ngcoar",    -- Ada.Numerics.Generic_Complex_Arrays
391      "a-ngrear",    -- Ada.Numerics.Generic_Real_Arrays
392      "a-nucoar",    -- Ada.Numerics.Complex_Arrays
393      "a-nurear",    -- Ada.Numerics.Real_Arrays
394      "a-stboha",    -- Ada.Strings.Bounded.Hash
395      "a-stfiha",    -- Ada.Strings.Fixed.Hash
396      "a-strhas",    -- Ada.Strings.Hash
397      "a-stunha",    -- Ada.Strings.Unbounded.Hash
398      "a-stwiha",    -- Ada.Strings.Wide_Hash
399      "a-stzbou",    -- Ada.Strings.Wide_Wide_Bounded
400      "a-stzfix",    -- Ada.Strings.Wide_Wide_Fixed
401      "a-stzhas",    -- Ada.Strings.Wide_Wide_Hash
402      "a-stzmap",    -- Ada.Strings.Wide_Wide_Maps
403      "a-stzunb",    -- Ada.Strings.Wide_Wide_Unbounded
404      "a-swbwha",    -- Ada.Strings.Wide_Bounded.Wide_Hash
405      "a-swfwha",    -- Ada.Strings.Wide_Fixed.Wide_Hash
406      "a-swuwha",    -- Ada.Strings.Wide_Unbounded.Wide_Hash
407      "a-szbzha",    -- Ada.Strings.Wide_Wide_Bounded.Wide_Wide_Hash
408      "a-szfzha",    -- Ada.Strings.Wide_Wide_Fixed.Wide_Wide_Hash
409      "a-szmzco",    -- Ada.Strings.Wide_Wide_Maps.Wide_Wide_Constants
410      "a-szuzha",    -- Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Hash
411      "a-taster",    -- Ada.Task_Termination
412      "a-tgdico",    -- Ada.Tags.Generic_Dispatching_Constructor
413      "a-tiboio",    -- Ada.Text_IO.Bounded_IO
414      "a-tiunio",    -- Ada.Text_IO.Unbounded_IO
415      "a-wichun",    -- Ada.Wide_Characters.Unicode
416      "a-wwboio",    -- Ada.Wide_Text_IO.Wide_Bounded_IO
417      "a-wwunio",    -- Ada.Wide_Text_IO.Wide_Unbounded_IO
418      "a-zchara",    -- Ada.Wide_Wide_Characters
419      "a-ztcoio",    -- Ada.Wide_Wide_Text_IO.Complex_IO
420      "a-ztedit",    -- Ada.Wide_Wide_Text_IO.Editing
421      "a-zttest",    -- Ada.Wide_Wide_Text_IO.Text_Streams
422      "a-ztexio",    -- Ada.Wide_Wide_Text_IO
423      "a-zzboio",    -- Ada.Wide_Wide_Text_IO.Wide_Wide_Bounded_IO
424      "a-zzunio",    -- Ada.Wide_Wide_Text_IO.Wide_Wide_Unbounded_IO
425
426    ------------------------------------------------------
427    -- RM Required Additions to Ada 2005 for GNAT Types --
428    ------------------------------------------------------
429
430      "a-lcteio",    -- Ada.Long_Complex_Text_IO
431      "a-lfztio",    -- Ada.Long_Float_Wide_Wide_Text_IO
432      "a-liztio",    -- Ada.Long_Integer_Wide_Wide_Text_IO
433      "a-llctio",    -- Ada.Long_Long_Complex_Text_IO
434      "a-llfzti",    -- Ada.Long_Long_Float_Wide_Wide_Text_IO
435      "a-llizti",    -- Ada.Long_Long_Integer_Wide_Wide_Text_IO
436      "a-nlcoar",    -- Ada.Numerics.Long_Complex_Arrays
437      "a-nllcar",    -- Ada.Numerics.Long_Long_Complex_Arrays
438      "a-nllrar",    -- Ada.Numerics.Long_Long_Real_Arrays
439      "a-nlrear",    -- Ada.Numerics.Long_Real_Arrays
440      "a-scteio",    -- Ada.Short_Complex_Text_IO
441      "a-sfztio",    -- Ada.Short_Float_Wide_Wide_Text_IO
442      "a-siztio",    -- Ada.Short_Integer_Wide_Wide_Text_IO
443      "a-ssizti",    -- Ada.Short_Short_Integer_Wide_Wide_Text_IO
444      "a-ztcstr",    -- Ada.Wide_Wide_Text_IO.C_Streams
445
446    ----------------------------------------
447    -- GNAT Defined Additions to Ada 2005 --
448    ----------------------------------------
449
450      "a-cgaaso",    -- Ada.Containers.Generic_Anonymous_Array_Sort
451      "a-chzla1",    -- Ada.Characters.Wide_Wide_Latin_1
452      "a-chzla9",    -- Ada.Characters.Wide_Wide_Latin_9
453      "a-ciormu",    -- Ada.Containers.Indefinite_Ordered_Multisets
454      "a-coormu",    -- Ada.Containers.Ordered_Multisets
455      "a-crdlli",    -- Ada.Containers.Restricted_Doubly_Linked_Lists
456      "a-secain",    -- Ada.Strings.Equal_Case_Insensitive
457      "a-shcain",    -- Ada.Strings.Hash_Case_Insensitive
458      "a-slcain",    -- Ada.Strings.Less_Case_Insensitive
459      "a-szuzti",    -- Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO
460      "a-zchuni",    -- Ada.Wide_Wide_Characters.Unicode
461
462    ---------------------------
463    -- GNAT Special IO Units --
464    ---------------------------
465
466    --  See Ada 95 section for further information. These packages are for the
467    --  implementation of the Wide_Wide_Text_IO generic packages.
468
469      "a-ztdeio",    -- Ada.Wide_Wide_Text_IO.Decimal_IO
470      "a-ztenio",    -- Ada.Wide_Wide_Text_IO.Enumeration_IO
471      "a-ztfiio",    -- Ada.Wide_Wide_Text_IO.Fixed_IO
472      "a-ztflio",    -- Ada.Wide_Wide_Text_IO.Float_IO
473      "a-ztinio",    -- Ada.Wide_Wide_Text_IO.Integer_IO
474      "a-ztmoio",    -- Ada.Wide_Wide_Text_IO.Modular_IO
475
476    ------------------------
477    -- GNAT Library Units --
478    ------------------------
479
480      "g-zspche",    -- GNAT.Wide_Wide_Spelling_Checker
481      "g-zstspl");   -- GNAT.Wide_Wide_String_Split
482
483    -----------------------
484    -- Alternative Units --
485    -----------------------
486
487    --  For some implementation units, there is a unit in the GNAT library
488    --  that has identical functionality that is usable. If we have such a
489    --  case we record the appropriate Unit name in Error_Msg_String.
490
491    type Aunit_Record is record
492       Fname : String (1 .. 6);
493       Aname : String_Ptr;
494    end record;
495
496    --  Array of alternative unit names
497
498    Scasuti : aliased String := "GNAT.Case_Util";
499    Scrc32  : aliased String := "GNAT.CRC32";
500    Shtable : aliased String := "GNAT.HTable";
501    Sos_lib : aliased String := "GNAT.OS_Lib";
502    Sregexp : aliased String := "GNAT.Regexp";
503    Sregpat : aliased String := "GNAT.Regpat";
504    Sstring : aliased String := "GNAT.Strings";
505    Sstusta : aliased String := "GNAT.Task_Stack_Usage";
506    Stasloc : aliased String := "GNAT.Task_Lock";
507    Sutf_32 : aliased String := "GNAT.UTF_32";
508
509    --  Array giving mapping
510
511    Map_Array : constant array (1 .. 10) of Aunit_Record := (
512                  ("casuti", Scasuti'Access),
513                  ("crc32 ", Scrc32 'Access),
514                  ("htable", Shtable'Access),
515                  ("os_lib", Sos_lib'Access),
516                  ("regexp", Sregexp'Access),
517                  ("regpat", Sregpat'Access),
518                  ("string", Sstring'Access),
519                  ("stusta", Sstusta'Access),
520                  ("tasloc", Stasloc'Access),
521                  ("utf_32", Sutf_32'Access));
522
523    ----------------------
524    -- Get_Kind_Of_Unit --
525    ----------------------
526
527    function Get_Kind_Of_Unit (U : Unit_Number_Type) return Kind_Of_Unit is
528       Fname : constant File_Name_Type := Unit_File_Name (U);
529
530    begin
531       Error_Msg_Strlen := 0;
532
533       --  If length of file name is greater than 12, not predefined.
534       --  The value 12 here is an 8 char name with extension .ads.
535
536       if Length_Of_Name (Fname) > 12 then
537          return Not_Predefined_Unit;
538       end if;
539
540       --  Otherwise test file name
541
542       Get_Name_String (Fname);
543
544       --  Not predefined if file name does not start with a- g- s- i-
545
546       if Name_Len < 3
547         or else Name_Buffer (2) /= '-'
548         or else (Name_Buffer (1) /= 'a'
549                    and then
550                  Name_Buffer (1) /= 'g'
551                    and then
552                  Name_Buffer (1) /= 'i'
553                    and then
554                  Name_Buffer (1) /= 's')
555       then
556          return Not_Predefined_Unit;
557       end if;
558
559       --  Not predefined if file name does not end in .ads. This can
560       --  happen when non-standard file names are being used.
561
562       if Name_Buffer (Name_Len - 3 .. Name_Len) /= ".ads" then
563          return Not_Predefined_Unit;
564       end if;
565
566       --  Otherwise normalize file name to 8 characters
567
568       Name_Len := Name_Len - 4;
569       while Name_Len < 8 loop
570          Name_Len := Name_Len + 1;
571          Name_Buffer (Name_Len) := ' ';
572       end loop;
573
574       --  See if name is in 95 list
575
576       for J in Non_Imp_File_Names_95'Range loop
577          if Name_Buffer (1 .. 8) = Non_Imp_File_Names_95 (J) then
578             return Ada_95_Unit;
579          end if;
580       end loop;
581
582       --  See if name is in 05 list
583
584       for J in Non_Imp_File_Names_05'Range loop
585          if Name_Buffer (1 .. 8) = Non_Imp_File_Names_05 (J) then
586             return Ada_05_Unit;
587          end if;
588       end loop;
589
590       --  Only remaining special possibilities are children of System.RPC and
591       --  System.Garlic and special files of the form System.Aux...
592
593       Get_Name_String (Unit_Name (U));
594
595       if Name_Len > 12
596         and then Name_Buffer (1 .. 11) = "system.rpc."
597       then
598          return Ada_95_Unit;
599       end if;
600
601       if Name_Len > 15
602         and then Name_Buffer (1 .. 14) = "system.garlic."
603       then
604          return Ada_95_Unit;
605       end if;
606
607       if Name_Len > 11
608         and then Name_Buffer (1 .. 10) = "system.aux"
609       then
610          return Ada_95_Unit;
611       end if;
612
613       --  All tests failed, this is definitely an implementation unit. See if
614       --  we have an alternative name.
615
616       Get_Name_String (Fname);
617
618       if Name_Len in 11 .. 12
619         and then Name_Buffer (1 .. 2) = "s-"
620         and then Name_Buffer (Name_Len - 3 .. Name_Len) = ".ads"
621       then
622          for J in Map_Array'Range loop
623             if (Name_Len = 12 and then
624                  Name_Buffer (3 .. 8) = Map_Array (J).Fname)
625               or else
626                (Name_Len = 11 and then
627                  Name_Buffer (3 .. 7) = Map_Array (J).Fname (1 .. 5))
628             then
629                Error_Msg_Strlen := Map_Array (J).Aname'Length;
630                Error_Msg_String (1 .. Error_Msg_Strlen) :=
631                  Map_Array (J).Aname.all;
632             end if;
633          end loop;
634       end if;
635
636       return Implementation_Unit;
637    end Get_Kind_Of_Unit;
638
639    -------------------
640    -- Is_Known_Unit --
641    -------------------
642
643    function Is_Known_Unit (Nam : Node_Id) return Boolean is
644       Unam : Unit_Name_Type;
645       Fnam : File_Name_Type;
646
647    begin
648       --  If selector is not an identifier (e.g. it is a character literal or
649       --  some junk from a previous error), then definitely not a known unit.
650
651       if Nkind (Selector_Name (Nam)) /= N_Identifier then
652          return False;
653       end if;
654
655       --  Otherwise get corresponding file name
656
657       Unam := Get_Unit_Name (Nam);
658       Fnam := Get_File_Name (Unam, Subunit => False);
659       Get_Name_String (Fnam);
660
661       --  Remove extension from file name
662
663       if Name_Buffer (Name_Len - 3 .. Name_Len) = ".adb" then
664          Name_Len := Name_Len - 4;
665       else
666          return False;
667       end if;
668
669       --  Pad name to 8 characters
670
671       while Name_Len < 8 loop
672          Name_Len := Name_Len + 1;
673          Name_Buffer (Name_Len) := ' ';
674       end loop;
675
676       --  If length more than 8, definitely not a match
677
678       if Name_Len /= 8 then
679          return False;
680       end if;
681
682       --  If length is 8, search our tables
683
684       for J in Non_Imp_File_Names_95'Range loop
685          if Name_Buffer (1 .. 8) = Non_Imp_File_Names_95 (J) then
686             return True;
687          end if;
688       end loop;
689
690       for J in Non_Imp_File_Names_05'Range loop
691          if Name_Buffer (1 .. 8) = Non_Imp_File_Names_05 (J) then
692             return True;
693          end if;
694       end loop;
695
696       --  If not found, not known
697
698       return False;
699
700    --  A safety guard, if we get an exception during this processing then it
701    --  is most likely the result of a previous error, or a peculiar case we
702    --  have not thought of. Since this routine is only used for error message
703    --  refinement, we will just return False.
704
705    exception
706       when others =>
707          return False;
708    end Is_Known_Unit;
709
710 end Impunit;