OSDN Git Service

More improvements to sparc VIS vec_init code generation.
[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 Opt;      use Opt;
33 with Uname;    use Uname;
34
35 --  Note: this package body is used by GPS and GNATBench to supply a list of
36 --  entries for help on available library routines.
37
38 package body Impunit is
39
40    subtype File_Name_8 is String (1 .. 8);
41
42    type File_Name_Record is record
43       Fname : File_Name_8;
44       --  8 character name of unit
45
46       RMdef : Boolean;
47       --  True if unit is RM defined. False for any unit that is implementation
48       --  defined (and thus not with'able in No_Implementation_Units mode).
49    end record;
50
51    type File_List is array (Nat range <>) of File_Name_Record;
52
53    T : constant Boolean := True;
54    F : constant Boolean := False;
55    --  Short hand for RM_Defined values in lists below
56
57    ------------------
58    -- Ada 95 Units --
59    ------------------
60
61    --  The following is a giant string list containing the names of all non-
62    --  implementation internal files, i.e. the complete list of files for
63    --  internal units which a program may legitimately WITH when operating in
64    --  either Ada 95 or Ada 2005 mode.
65
66    --  Note that this list should match the list of units documented in the
67    --  "GNAT Library" section of the GNAT Reference Manual. A unit listed here
68    --  must either be documented in that section or described in the Ada RM.
69
70    Non_Imp_File_Names_95 : constant File_List := (
71
72    ------------------------------------------------------
73    -- Ada Hierarchy Units from Ada-95 Reference Manual --
74    ------------------------------------------------------
75
76     ("a-astaco", T),  -- Ada.Asynchronous_Task_Control
77     ("a-calend", T),  -- Ada.Calendar
78     ("a-chahan", T),  -- Ada.Characters.Handling
79     ("a-charac", T),  -- Ada.Characters
80     ("a-chlat1", T),  -- Ada.Characters.Latin_1
81     ("a-comlin", T),  -- Ada.Command_Line
82     ("a-decima", T),  -- Ada.Decimal
83     ("a-direio", T),  -- Ada.Direct_IO
84     ("a-dynpri", T),  -- Ada.Dynamic_Priorities
85     ("a-except", T),  -- Ada.Exceptions
86     ("a-finali", T),  -- Ada.Finalization
87     ("a-flteio", T),  -- Ada.Float_Text_IO
88     ("a-fwteio", T),  -- Ada.Float_Wide_Text_IO
89     ("a-inteio", T),  -- Ada.Integer_Text_IO
90     ("a-interr", T),  -- Ada.Interrupts
91     ("a-intnam", T),  -- Ada.Interrupts.Names
92     ("a-ioexce", T),  -- Ada.IO_Exceptions
93     ("a-iwteio", T),  -- Ada.Integer_Wide_Text_IO
94     ("a-ncelfu", T),  -- Ada.Numerics.Complex_Elementary_Functions
95     ("a-ngcefu", T),  -- Ada.Numerics.Generic_Complex_Elementary_Functions
96     ("a-ngcoty", T),  -- Ada.Numerics.Generic_Complex_Types
97     ("a-ngelfu", T),  -- Ada.Numerics.Generic_Elementary_Functions
98     ("a-nucoty", T),  -- Ada.Numerics.Complex_Types
99     ("a-nudira", T),  -- Ada.Numerics.Discrete_Random
100     ("a-nuelfu", T),  -- Ada.Numerics.Elementary_Functions
101     ("a-nuflra", T),  -- Ada.Numerics.Float_Random
102     ("a-numeri", T),  -- Ada.Numerics
103     ("a-reatim", T),  -- Ada.Real_Time
104     ("a-sequio", T),  -- Ada.Sequential_IO
105     ("a-stmaco", T),  -- Ada.Strings.Maps.Constants
106     ("a-storio", T),  -- Ada.Storage_IO
107     ("a-strbou", T),  -- Ada.Strings.Bounded
108     ("a-stream", T),  -- Ada.Streams
109     ("a-strfix", T),  -- Ada.Strings.Fixed
110     ("a-string", T),  -- Ada.Strings
111     ("a-strmap", T),  -- Ada.Strings.Maps
112     ("a-strunb", T),  -- Ada.Strings.Unbounded
113     ("a-ststio", T),  -- Ada.Streams.Stream_IO
114     ("a-stwibo", T),  -- Ada.Strings.Wide_Bounded
115     ("a-stwifi", T),  -- Ada.Strings.Wide_Fixed
116     ("a-stwima", T),  -- Ada.Strings.Wide_Maps
117     ("a-stwiun", T),  -- Ada.Strings.Wide_Unbounded
118     ("a-swmwco", T),  -- Ada.Strings.Wide_Maps.Wide_Constants
119     ("a-sytaco", T),  -- Ada.Synchronous_Task_Control
120     ("a-tags  ", T),  -- Ada.Tags
121     ("a-tasatt", T),  -- Ada.Task_Attributes
122     ("a-taside", T),  -- Ada.Task_Identification
123     ("a-teioed", T),  -- Ada.Text_IO.Editing
124     ("a-textio", T),  -- Ada.Text_IO
125     ("a-ticoio", T),  -- Ada.Text_IO.Complex_IO
126     ("a-titest", T),  -- Ada.Text_IO.Text_Streams
127     ("a-unccon", T),  -- Ada.Unchecked_Conversion
128     ("a-uncdea", T),  -- Ada.Unchecked_Deallocation
129     ("a-witeio", T),  -- Ada.Wide_Text_IO
130     ("a-wtcoio", T),  -- Ada.Wide_Text_IO.Complex_IO
131     ("a-wtedit", T),  -- Ada.Wide_Text_IO.Editing
132     ("a-wttest", T),  -- Ada.Wide_Text_IO.Text_Streams
133
134    -------------------------------------------------
135    -- RM Required Additions to Ada for GNAT Types --
136    -------------------------------------------------
137
138    --  Note: Long versions are considered RM defined, but not the Long Long,
139    --  Short, or Short_Short versions.
140
141     ("a-lfteio", T),  -- Ada.Long_Float_Text_IO
142     ("a-lfwtio", T),  -- Ada.Long_Float_Wide_Text_IO
143     ("a-liteio", T),  -- Ada.Long_Integer_Text_IO
144     ("a-liwtio", T),  -- Ada.Long_Integer_Wide_Text_IO
145     ("a-llftio", T),  -- Ada.Long_Long_Float_Text_IO
146     ("a-llfwti", T),  -- Ada.Long_Long_Float_Wide_Text_IO
147     ("a-llitio", T),  -- Ada.Long_Long_Integer_Text_IO
148     ("a-lliwti", F),  -- Ada.Long_Long_Integer_Wide_Text_IO
149     ("a-nlcefu", F),  -- Ada.Long_Complex_Elementary_Functions
150     ("a-nlcoty", T),  -- Ada.Numerics.Long_Complex_Types
151     ("a-nlelfu", T),  -- Ada.Numerics.Long_Elementary_Functions
152     ("a-nllcef", F),  -- Ada.Long_Long_Complex_Elementary_Functions
153     ("a-nllefu", F),  -- Ada.Numerics.Long_Long_Elementary_Functions
154     ("a-nllcty", F),  -- Ada.Numerics.Long_Long_Complex_Types
155     ("a-nscefu", F),  -- Ada.Short_Complex_Elementary_Functions
156     ("a-nscoty", F),  -- Ada.Numerics.Short_Complex_Types
157     ("a-nselfu", F),  -- Ada.Numerics.Short_Elementary_Functions
158     ("a-sfteio", F),  -- Ada.Short_Float_Text_IO
159     ("a-sfwtio", F),  -- Ada.Short_Float_Wide_Text_IO
160     ("a-siteio", F),  -- Ada.Short_Integer_Text_IO
161     ("a-siwtio", F),  -- Ada.Short_Integer_Wide_Text_IO
162     ("a-ssitio", F),  -- Ada.Short_Short_Integer_Text_IO
163     ("a-ssiwti", F),  -- Ada.Short_Short_Integer_Wide_Text_IO
164
165    -----------------------------------
166    -- GNAT Defined Additions to Ada --
167    -----------------------------------
168
169     ("a-calcon", F),  -- Ada.Calendar.Conversions
170     ("a-chlat9", F),  -- Ada.Characters.Latin_9
171     ("a-clrefi", F),  -- Ada.Command_Line.Response_File
172     ("a-colien", F),  -- Ada.Command_Line.Environment
173     ("a-colire", F),  -- Ada.Command_Line.Remove
174     ("a-cwila1", F),  -- Ada.Characters.Wide_Latin_1
175     ("a-cwila9", F),  -- Ada.Characters.Wide_Latin_9
176     ("a-diocst", F),  -- Ada.Direct_IO.C_Streams
177     ("a-einuoc", F),  -- Ada.Exceptions.Is_Null_Occurrence
178     ("a-elchha", F),  -- Ada.Exceptions.Last_Chance_Handler
179     ("a-exctra", F),  -- Ada.Exceptions.Traceback
180     ("a-siocst", F),  -- Ada.Sequential_IO.C_Streams
181     ("a-ssicst", F),  -- Ada.Streams.Stream_IO.C_Streams
182     ("a-suteio", F),  -- Ada.Strings.Unbounded.Text_IO
183     ("a-swuwti", F),  -- Ada.Strings.Wide_Unbounded.Wide_Text_IO
184     ("a-tiocst", F),  -- Ada.Text_IO.C_Streams
185     ("a-wtcstr", F),  -- Ada.Wide_Text_IO.C_Streams
186
187       --  Note: strictly the next two should be Ada 2005 units, but it seems
188       --  harmless (and useful) to make then available in Ada 95 mode, since
189       --  they only deal with Wide_Character, not Wide_Wide_Character.
190
191     ("a-wichun", F),  -- Ada.Wide_Characters.Unicode
192     ("a-widcha", F),  -- Ada.Wide_Characters
193
194       --  Note: strictly the following should be Ada 2012 units, but it seems
195       --  harmless (and useful) to make then available in Ada 95 mode, since
196       --  they do not deal with Wide_Wide_Character.
197
198     ("a-wichha", F),  -- Ada.Wide_Characters.Handling
199     ("a-stuten", F),  -- Ada.Strings.UTF_Encoding
200     ("a-suenco", F),  -- Ada.Strings.UTF_Encoding.Conversions
201     ("a-suenst", F),  -- Ada.Strings.UTF_Encoding.Strings
202     ("a-suewst", F),  -- Ada.Strings.UTF_Encoding.Wide_Strings
203
204    ---------------------------
205    -- GNAT Special IO Units --
206    ---------------------------
207
208    --  As further explained elsewhere (see Sem_Ch10), the internal packages of
209    --  Text_IO and Wide_Text_IO are actually implemented as separate children,
210    --  but this fact is intended to be hidden from the user completely. Any
211    --  attempt to WITH one of these units will be diagnosed as an error later
212    --  on, but for now we do not consider these internal implementation units
213    --  (if we did, then we would get a junk warning which would be confusing
214    --  and unnecessary, given that we generate a clear error message).
215
216     ("a-tideio", F),  -- Ada.Text_IO.Decimal_IO
217     ("a-tienio", F),  -- Ada.Text_IO.Enumeration_IO
218     ("a-tifiio", F),  -- Ada.Text_IO.Fixed_IO
219     ("a-tiflio", F),  -- Ada.Text_IO.Float_IO
220     ("a-tiinio", F),  -- Ada.Text_IO.Integer_IO
221     ("a-tiinio", F),  -- Ada.Text_IO.Integer_IO
222     ("a-timoio", F),  -- Ada.Text_IO.Modular_IO
223     ("a-wtdeio", F),  -- Ada.Wide_Text_IO.Decimal_IO
224     ("a-wtenio", F),  -- Ada.Wide_Text_IO.Enumeration_IO
225     ("a-wtfiio", F),  -- Ada.Wide_Text_IO.Fixed_IO
226     ("a-wtflio", F),  -- Ada.Wide_Text_IO.Float_IO
227     ("a-wtinio", F),  -- Ada.Wide_Text_IO.Integer_IO
228     ("a-wtmoio", F),  -- Ada.Wide_Text_IO.Modular_IO
229
230    ------------------------
231    -- GNAT Library Units --
232    ------------------------
233
234     ("g-altive", F),  -- GNAT.Altivec
235     ("g-altcon", F),  -- GNAT.Altivec.Conversions
236     ("g-alveop", F),  -- GNAT.Altivec.Vector_Operations
237     ("g-alvety", F),  -- GNAT.Altivec.Vector_Types
238     ("g-alvevi", F),  -- GNAT.Altivec.Vector_Views
239     ("g-arrspl", F),  -- GNAT.Array_Split
240     ("g-awk   ", F),  -- GNAT.AWK
241     ("g-boubuf", F),  -- GNAT.Bounded_Buffers
242     ("g-boumai", F),  -- GNAT.Bounded_Mailboxes
243     ("g-bubsor", F),  -- GNAT.Bubble_Sort
244     ("g-busora", F),  -- GNAT.Bubble_Sort_A
245     ("g-busorg", F),  -- GNAT.Bubble_Sort_G
246     ("g-byorma", F),  -- GNAT.Byte_Order_Mark
247     ("g-bytswa", F),  -- GNAT.Byte_Swapping
248     ("g-calend", F),  -- GNAT.Calendar
249     ("g-catiio", F),  -- GNAT.Calendar.Time_IO
250     ("g-casuti", F),  -- GNAT.Case_Util
251     ("g-cgi   ", F),  -- GNAT.CGI
252     ("g-cgicoo", F),  -- GNAT.CGI.Cookie
253     ("g-cgideb", F),  -- GNAT.CGI.Debug
254     ("g-comlin", F),  -- GNAT.Command_Line
255     ("g-comver", F),  -- GNAT.Compiler_Version
256     ("g-crc32 ", F),  -- GNAT.CRC32
257     ("g-ctrl_c", F),  -- GNAT.Ctrl_C
258     ("g-curexc", F),  -- GNAT.Current_Exception
259     ("g-debpoo", F),  -- GNAT.Debug_Pools
260     ("g-debuti", F),  -- GNAT.Debug_Utilities
261     ("g-decstr", F),  -- GNAT.Decode_String
262     ("g-deutst", F),  -- GNAT.Decode_UTF8_String
263     ("g-dirope", F),  -- GNAT.Directory_Operations
264     ("g-diopit", F),  -- GNAT.Directory_Operations.Iteration
265     ("g-dynhta", F),  -- GNAT.Dynamic_HTables
266     ("g-dyntab", F),  -- GNAT.Dynamic_Tables
267     ("g-encstr", F),  -- GNAT.Encode_String
268     ("g-enutst", F),  -- GNAT.Encode_UTF8_String
269     ("g-excact", F),  -- GNAT.Exception_Actions
270     ("g-except", F),  -- GNAT.Exceptions
271     ("g-exctra", F),  -- GNAT.Exception_Traces
272     ("g-expect", F),  -- GNAT.Expect
273     ("g-flocon", F),  -- GNAT.Float_Control
274     ("g-heasor", F),  -- GNAT.Heap_Sort
275     ("g-hesora", F),  -- GNAT.Heap_Sort_A
276     ("g-hesorg", F),  -- GNAT.Heap_Sort_G
277     ("g-htable", F),  -- GNAT.Htable
278     ("g-io    ", F),  -- GNAT.IO
279     ("g-io_aux", F),  -- GNAT.IO_Aux
280     ("g-locfil", F),  -- GNAT.Lock_Files
281     ("g-mbdira", F),  -- GNAT.MBBS_Discrete_Random
282     ("g-mbflra", F),  -- GNAT.MBBS_Float_Random
283     ("g-md5   ", F),  -- GNAT.MD5
284     ("g-memdum", F),  -- GNAT.Memory_Dump
285     ("g-moreex", F),  -- GNAT.Most_Recent_Exception
286     ("g-os_lib", F),  -- GNAT.Os_Lib
287     ("g-pehage", F),  -- GNAT.Perfect_Hash_Generators
288     ("g-rannum", F),  -- GNAT.Random_Numbers
289     ("g-regexp", F),  -- GNAT.Regexp
290     ("g-regist", F),  -- GNAT.Registry
291     ("g-regpat", F),  -- GNAT.Regpat
292     ("g-semaph", F),  -- GNAT.Semaphores
293     ("g-sercom", F),  -- GNAT.Serial_Communications
294     ("g-sestin", F),  -- GNAT.Secondary_Stack_Info
295     ("g-sha1  ", F),  -- GNAT.SHA1
296     ("g-sha224", F),  -- GNAT.SHA224
297     ("g-sha256", F),  -- GNAT.SHA256
298     ("g-sha384", F),  -- GNAT.SHA384
299     ("g-sha512", F),  -- GNAT.SHA512
300     ("g-signal", F),  -- GNAT.Signals
301     ("g-socket", F),  -- GNAT.Sockets
302     ("g-souinf", F),  -- GNAT.Source_Info
303     ("g-speche", F),  -- GNAT.Spell_Checker
304     ("g-spchge", F),  -- GNAT.Spell_Checker_Generic
305     ("g-spitbo", F),  -- GNAT.Spitbol
306     ("g-spipat", F),  -- GNAT.Spitbol.Patterns
307     ("g-sptabo", F),  -- GNAT.Spitbol.Table_Boolean
308     ("g-sptain", F),  -- GNAT.Spitbol.Table_Integer
309     ("g-sptavs", F),  -- GNAT.Spitbol.Table_Vstring
310     ("g-string", F),  -- GNAT.Strings
311     ("g-strspl", F),  -- GNAT.String_Split
312     ("g-sse   ", F),  -- GNAT.SSE
313     ("g-ssvety", F),  -- GNAT.SSE.Vector_Types
314     ("g-table ", F),  -- GNAT.Table
315     ("g-tasloc", F),  -- GNAT.Task_Lock
316     ("g-tastus", F),  -- GNAT.Task_Stack_Usage
317     ("g-thread", F),  -- GNAT.Threads
318     ("g-timsta", F),  -- GNAT.Time_Stamp
319     ("g-traceb", F),  -- GNAT.Traceback
320     ("g-trasym", F),  -- GNAT.Traceback.Symbolic
321     ("g-utf_32", F),  -- GNAT.UTF_32
322     ("g-u3spch", F),  -- GNAT.UTF_32_Spelling_Checker
323     ("g-wispch", F),  -- GNAT.Wide_Spelling_Checker
324     ("g-wistsp", F),  -- GNAT.Wide_String_Split
325
326    -----------------------------------------------------
327    -- Interface Hierarchy Units from Reference Manual --
328    -----------------------------------------------------
329
330     ("i-c     ", T),  -- Interfaces.C
331     ("i-cobol ", T),  -- Interfaces.Cobol
332     ("i-cpoint", T),  -- Interfaces.C.Pointers
333     ("i-cstrin", T),  -- Interfaces.C.Strings
334     ("i-fortra", T),  -- Interfaces.Fortran
335
336    ------------------------------------------
337    -- GNAT Defined Additions to Interfaces --
338    ------------------------------------------
339
340     ("i-cexten", F),  -- Interfaces.C.Extensions
341     ("i-cil   ", F),  -- Interfaces.CIL
342     ("i-cilobj", F),  -- Interfaces.CIL.Object
343     ("i-cpp   ", F),  -- Interfaces.CPP
344     ("i-cstrea", F),  -- Interfaces.C.Streams
345     ("i-java  ", F),  -- Interfaces.Java
346     ("i-javjni", F),  -- Interfaces.Java.JNI
347     ("i-pacdec", F),  -- Interfaces.Packed_Decimal
348     ("i-vxwoio", F),  -- Interfaces.VxWorks.IO
349     ("i-vxwork", F),  -- Interfaces.VxWorks
350
351    --------------------------------------------------
352    -- System Hierarchy Units from Reference Manual --
353    --------------------------------------------------
354
355     ("s-atacco", T),  -- System.Address_To_Access_Conversions
356     ("s-maccod", T),  -- System.Machine_Code
357     ("s-rpc   ", T),  -- System.Rpc
358     ("s-stoele", T),  -- System.Storage_Elements
359     ("s-stopoo", T),  -- System.Storage_Pools
360
361    --------------------------------------
362    -- GNAT Defined Additions to System --
363    --------------------------------------
364
365     ("s-addima", F),  -- System.Address_Image
366     ("s-assert", F),  -- System.Assertions
367     ("s-memory", F),  -- System.Memory
368     ("s-parint", F),  -- System.Partition_Interface
369     ("s-pooglo", F),  -- System.Pool_Global
370     ("s-pooloc", F),  -- System.Pool_Local
371     ("s-restri", F),  -- System.Restrictions
372     ("s-rident", F),  -- System.Rident
373     ("s-ststop", F),  -- System.Strings.Stream_Ops
374     ("s-tasinf", F),  -- System.Task_Info
375     ("s-wchcnv", F),  -- System.Wch_Cnv
376     ("s-wchcon", F)); -- System.Wch_Con
377
378    --------------------
379    -- Ada 2005 Units --
380    --------------------
381
382    --  The following units should be used only in Ada 05 mode
383
384    Non_Imp_File_Names_05 : constant File_List := (
385
386    --------------------------------------------------------
387    -- Ada Hierarchy Units from Ada 2005 Reference Manual --
388    --------------------------------------------------------
389
390     ("a-assert", T),  -- Ada.Assertions
391     ("a-calari", T),  -- Ada.Calendar.Arithmetic
392     ("a-calfor", T),  -- Ada.Calendar.Formatting
393     ("a-catizo", T),  -- Ada.Calendar.Time_Zones
394     ("a-cdlili", T),  -- Ada.Containers.Doubly_Linked_Lists
395     ("a-cgarso", T),  -- Ada.Containers.Generic_Array_Sort
396     ("a-cgcaso", T),  -- Ada.Containers.Generic_Constrained_Array_Sort
397     ("a-chacon", T),  -- Ada.Characters.Conversions
398     ("a-cidlli", T),  -- Ada.Containers.Indefinite_Doubly_Linked_Lists
399     ("a-cihama", T),  -- Ada.Containers.Indefinite_Hashed_Maps
400     ("a-cihase", T),  -- Ada.Containers.Indefinite_Hashed_Sets
401     ("a-ciorma", T),  -- Ada.Containers.Indefinite_Ordered_Maps
402     ("a-ciorse", T),  -- Ada.Containers.Indefinite_Ordered_Sets
403     ("a-cohama", T),  -- Ada.Containers.Hashed_Maps
404     ("a-cohase", T),  -- Ada.Containers.Hashed_Sets
405     ("a-coinve", T),  -- Ada.Containers.Indefinite_Vectors
406     ("a-contai", T),  -- Ada.Containers
407     ("a-convec", T),  -- Ada.Containers.Vectors
408     ("a-coorma", T),  -- Ada.Containers.Ordered_Maps
409     ("a-coorse", T),  -- Ada.Containers.Ordered_Sets
410     ("a-coteio", T),  -- Ada.Complex_Text_IO
411     ("a-direct", T),  -- Ada.Directories
412     ("a-diroro", T),  -- Ada.Dispatching.Round_Robin
413     ("a-disedf", T),  -- Ada.Dispatching.EDF
414     ("a-dispat", T),  -- Ada.Dispatching
415     ("a-envvar", T),  -- Ada.Environment_Variables
416     ("a-etgrbu", T),  -- Ada.Execution_Time.Group_Budgets
417     ("a-exetim", T),  -- Ada.Execution_Time
418     ("a-extiti", T),  -- Ada.Execution_Time.Timers
419     ("a-izteio", T),  -- Ada.Integer_Wide_Wide_Text_IO
420     ("a-rttiev", T),  -- Ada.Real_Time.Timing_Events
421     ("a-ngcoar", T),  -- Ada.Numerics.Generic_Complex_Arrays
422     ("a-ngrear", T),  -- Ada.Numerics.Generic_Real_Arrays
423     ("a-nucoar", T),  -- Ada.Numerics.Complex_Arrays
424     ("a-nurear", T),  -- Ada.Numerics.Real_Arrays
425     ("a-stboha", T),  -- Ada.Strings.Bounded.Hash
426     ("a-stfiha", T),  -- Ada.Strings.Fixed.Hash
427     ("a-strhas", T),  -- Ada.Strings.Hash
428     ("a-stunha", T),  -- Ada.Strings.Unbounded.Hash
429     ("a-stwiha", T),  -- Ada.Strings.Wide_Hash
430     ("a-stzbou", T),  -- Ada.Strings.Wide_Wide_Bounded
431     ("a-stzfix", T),  -- Ada.Strings.Wide_Wide_Fixed
432     ("a-stzhas", T),  -- Ada.Strings.Wide_Wide_Hash
433     ("a-stzmap", T),  -- Ada.Strings.Wide_Wide_Maps
434     ("a-stzunb", T),  -- Ada.Strings.Wide_Wide_Unbounded
435     ("a-swbwha", T),  -- Ada.Strings.Wide_Bounded.Wide_Hash
436     ("a-swfwha", T),  -- Ada.Strings.Wide_Fixed.Wide_Hash
437     ("a-swuwha", T),  -- Ada.Strings.Wide_Unbounded.Wide_Hash
438     ("a-szbzha", T),  -- Ada.Strings.Wide_Wide_Bounded.Wide_Wide_Hash
439     ("a-szfzha", T),  -- Ada.Strings.Wide_Wide_Fixed.Wide_Wide_Hash
440     ("a-szmzco", T),  -- Ada.Strings.Wide_Wide_Maps.Wide_Wide_Constants
441     ("a-szuzha", T),  -- Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Hash
442     ("a-taster", T),  -- Ada.Task_Termination
443     ("a-tgdico", T),  -- Ada.Tags.Generic_Dispatching_Constructor
444     ("a-tiboio", T),  -- Ada.Text_IO.Bounded_IO
445     ("a-tiunio", T),  -- Ada.Text_IO.Unbounded_IO
446     ("a-wichun", T),  -- Ada.Wide_Characters.Unicode
447     ("a-wwboio", T),  -- Ada.Wide_Text_IO.Wide_Bounded_IO
448     ("a-wwunio", T),  -- Ada.Wide_Text_IO.Wide_Unbounded_IO
449     ("a-zchara", T),  -- Ada.Wide_Wide_Characters
450     ("a-zchhan", T),  -- Ada.Wide_Wide_Characters.Handling
451     ("a-ztcoio", T),  -- Ada.Wide_Wide_Text_IO.Complex_IO
452     ("a-ztedit", T),  -- Ada.Wide_Wide_Text_IO.Editing
453     ("a-zttest", T),  -- Ada.Wide_Wide_Text_IO.Text_Streams
454     ("a-ztexio", T),  -- Ada.Wide_Wide_Text_IO
455     ("a-zzboio", T),  -- Ada.Wide_Wide_Text_IO.Wide_Wide_Bounded_IO
456     ("a-zzunio", T),  -- Ada.Wide_Wide_Text_IO.Wide_Wide_Unbounded_IO
457
458    ------------------------------------------------------
459    -- RM Required Additions to Ada 2005 for GNAT Types --
460    ------------------------------------------------------
461
462    --  Note: Long versions are considered RM defined, but not the Long Long,
463    --  Short, or Short_Short versions.
464
465     ("a-lcteio", T),  -- Ada.Long_Complex_Text_IO
466     ("a-lfztio", T),  -- Ada.Long_Float_Wide_Wide_Text_IO
467     ("a-liztio", T),  -- Ada.Long_Integer_Wide_Wide_Text_IO
468     ("a-llctio", T),  -- Ada.Long_Long_Complex_Text_IO
469     ("a-llfzti", T),  -- Ada.Long_Long_Float_Wide_Wide_Text_IO
470     ("a-llizti", T),  -- Ada.Long_Long_Integer_Wide_Wide_Text_IO
471     ("a-nlcoar", T),  -- Ada.Numerics.Long_Complex_Arrays
472     ("a-nllcar", T),  -- Ada.Numerics.Long_Long_Complex_Arrays
473     ("a-nllrar", T),  -- Ada.Numerics.Long_Long_Real_Arrays
474     ("a-nlrear", T),  -- Ada.Numerics.Long_Real_Arrays
475     ("a-scteio", F),  -- Ada.Short_Complex_Text_IO
476     ("a-sfztio", F),  -- Ada.Short_Float_Wide_Wide_Text_IO
477     ("a-siztio", F),  -- Ada.Short_Integer_Wide_Wide_Text_IO
478     ("a-ssizti", F),  -- Ada.Short_Short_Integer_Wide_Wide_Text_IO
479
480    ----------------------------------------
481    -- GNAT Defined Additions to Ada 2005 --
482    ----------------------------------------
483
484     ("a-cgaaso", F),  -- Ada.Containers.Generic_Anonymous_Array_Sort
485     ("a-chzla1", F),  -- Ada.Characters.Wide_Wide_Latin_1
486     ("a-chzla9", F),  -- Ada.Characters.Wide_Wide_Latin_9
487     ("a-ciormu", F),  -- Ada.Containers.Indefinite_Ordered_Multisets
488     ("a-coormu", F),  -- Ada.Containers.Ordered_Multisets
489     ("a-crdlli", F),  -- Ada.Containers.Restricted_Doubly_Linked_Lists
490     ("a-szuzti", F),  -- Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO
491     ("a-zchuni", F),  -- Ada.Wide_Wide_Characters.Unicode
492     ("a-ztcstr", F),  -- Ada.Wide_Wide_Text_IO.C_Streams
493
494       --  Note: strictly the following should be Ada 2012 units, but it seems
495       --  harmless (and useful) to make then available in Ada 2005 mode.
496
497     ("a-cogeso", T),  -- Ada.Containers.Generic_Sort
498     ("a-secain", T),  -- Ada.Strings.Equal_Case_Insensitive
499     ("a-shcain", T),  -- Ada.Strings.Hash_Case_Insensitive
500     ("a-slcain", T),  -- Ada.Strings.Less_Case_Insensitive
501     ("a-sfecin", T),  -- Ada.Strings.Fixed.Equal_Case_Insensitive
502     ("a-sfhcin", T),  -- Ada.Strings.Fixed.Hash_Case_Insensitive
503     ("a-sflcin", T),  -- Ada.Strings.Fixed.Less_Case_Insensitive
504     ("a-sbecin", T),  -- Ada.Strings.Bounded.Equal_Case_Insensitive
505     ("a-sbhcin", T),  -- Ada.Strings.Bounded.Hash_Case_Insensitive
506     ("a-sblcin", T),  -- Ada.Strings.Bounded.Less_Case_Insensitive
507     ("a-suecin", T),  -- Ada.Strings.Unbounded.Equal_Case_Insensitive
508     ("a-suhcin", T),  -- Ada.Strings.Unbounded.Hash_Case_Insensitive
509     ("a-sulcin", T),  -- Ada.Strings.Unbounded.Less_Case_Insensitive
510     ("a-suezst", T),  -- Ada.Strings.UTF_Encoding.Wide_Wide_Strings
511
512    ---------------------------
513    -- GNAT Special IO Units --
514    ---------------------------
515
516    --  See Ada 95 section for further information. These packages are for the
517    --  implementation of the Wide_Wide_Text_IO generic packages.
518
519     ("a-ztdeio", F),  -- Ada.Wide_Wide_Text_IO.Decimal_IO
520     ("a-ztenio", F),  -- Ada.Wide_Wide_Text_IO.Enumeration_IO
521     ("a-ztfiio", F),  -- Ada.Wide_Wide_Text_IO.Fixed_IO
522     ("a-ztflio", F),  -- Ada.Wide_Wide_Text_IO.Float_IO
523     ("a-ztinio", F),  -- Ada.Wide_Wide_Text_IO.Integer_IO
524     ("a-ztmoio", F),  -- Ada.Wide_Wide_Text_IO.Modular_IO
525
526    ------------------------
527    -- GNAT Library Units --
528    ------------------------
529
530     ("g-zspche", F),  -- GNAT.Wide_Wide_Spelling_Checker
531     ("g-zstspl", F)); -- GNAT.Wide_Wide_String_Split
532
533    --------------------
534    -- Ada 2012 Units --
535    --------------------
536
537    --  The following units should be used only in Ada 2012 mode
538
539    Non_Imp_File_Names_12 : constant File_List := (
540     ("s-multip", T),  -- System.Multiprocessors
541     ("s-mudido", T),  -- System.Multiprocessors.Dispatching_Domains
542     ("s-stposu", T),  -- System.Storage_Pools.Subpools
543     ("a-cobove", T),  -- Ada.Containers.Bounded_Vectors
544     ("a-cbdlli", T),  -- Ada.Containers.Bounded_Doubly_Linked_Lists
545     ("a-cborse", T),  -- Ada.Containers.Bounded_Ordered_Sets
546     ("a-cborma", T),  -- Ada.Containers.Bounded_Ordered_Maps
547     ("a-cbhase", T),  -- Ada.Containers.Bounded_Hashed_Sets
548     ("a-cbhama", T),  -- Ada.Containers.Bounded_Hashed_Maps
549     ("a-coinho", T),  -- Ada.Containers.Indefinite_Holders
550     ("a-comutr", T),  -- Ada.Containers.Multiway_Trees
551     ("a-cimutr", T),  -- Ada.Containers.Indefinite_Multiway_Trees
552     ("a-cbmutr", T),  -- Ada.Containers.Bounded_Multiway_Trees
553     ("a-csquin", T),  -- Ada.Containers.Synchronized_Queue_Interfaces
554     ("a-cusyqu", T),  -- Ada.Containers.Unbounded_Synchronized_Queues
555     ("a-cuprqu", T),  -- Ada.Containers.Unbounded_Priority_Queues
556     ("a-cbsyqu", T),  -- Ada.Containers.Bounded_Synchronized_Queues
557     ("a-cbprqu", T),  -- Ada.Containers.Bounded_Priority_Queues
558     ("a-extiin", T),  -- Ada.Execution_Time.Interrupts
559     ("a-iteint", T),  -- Ada.Iterator_Interfaces
560     ("a-synbar", T),  -- Ada.Synchronous_Barriers
561     ("a-undesu", T),  -- Ada.Unchecked_Deallocate_Subpool
562
563    ----------------------------------------
564    -- GNAT Defined Additions to Ada 2012 --
565    ----------------------------------------
566
567     ("a-cofove", F),  -- Ada.Containers.Formal_Vectors
568     ("a-cfdlli", F),  -- Ada.Containers.Formal_Doubly_Linked_Lists
569     ("a-cforse", F),  -- Ada.Containers.Formal_Ordered_Sets
570     ("a-cforma", F),  -- Ada.Containers.Formal_Ordered_Maps
571     ("a-cfhase", F),  -- Ada.Containers.Formal_Hashed_Sets
572     ("a-cfhama", F)); -- Ada.Containers.Formal_Hashed_Maps
573
574    -----------------------
575    -- Alternative Units --
576    -----------------------
577
578    --  For some implementation units, there is a unit in the GNAT library
579    --  that has identical functionality that is usable. If we have such a
580    --  case we record the appropriate Unit name in Error_Msg_String.
581
582    type Aunit_Record is record
583       Fname : String (1 .. 6);
584       Aname : String_Ptr;
585    end record;
586
587    --  Array of alternative unit names
588
589    Scasuti : aliased String := "GNAT.Case_Util";
590    Scrc32  : aliased String := "GNAT.CRC32";
591    Shtable : aliased String := "GNAT.HTable";
592    Sos_lib : aliased String := "GNAT.OS_Lib";
593    Sregexp : aliased String := "GNAT.Regexp";
594    Sregpat : aliased String := "GNAT.Regpat";
595    Sstring : aliased String := "GNAT.Strings";
596    Sstusta : aliased String := "GNAT.Task_Stack_Usage";
597    Stasloc : aliased String := "GNAT.Task_Lock";
598    Sutf_32 : aliased String := "GNAT.UTF_32";
599
600    --  Array giving mapping
601
602    Map_Array : constant array (1 .. 10) of Aunit_Record := (
603                  ("casuti", Scasuti'Access),
604                  ("crc32 ", Scrc32 'Access),
605                  ("htable", Shtable'Access),
606                  ("os_lib", Sos_lib'Access),
607                  ("regexp", Sregexp'Access),
608                  ("regpat", Sregpat'Access),
609                  ("string", Sstring'Access),
610                  ("stusta", Sstusta'Access),
611                  ("tasloc", Stasloc'Access),
612                  ("utf_32", Sutf_32'Access));
613
614    ----------------------
615    -- Get_Kind_Of_Unit --
616    ----------------------
617
618    function Get_Kind_Of_Unit (U : Unit_Number_Type) return Kind_Of_Unit is
619       Fname : constant File_Name_Type := Unit_File_Name (U);
620
621    begin
622       Error_Msg_Strlen := 0;
623       Get_Name_String (Fname);
624
625       --  Ada/System/Interfaces are all Ada 95 units
626
627       if (Name_Len =  7 and then Name_Buffer (1 ..  7) = "ada.ads")
628            or else
629          (Name_Len = 10 and then Name_Buffer (1 .. 10) = "system.ads")
630            or else
631          (Name_Len = 12 and then Name_Buffer (1 .. 12) = "interfac.ads")
632       then
633          return Ada_95_Unit;
634       end if;
635
636       --  If length of file name is greater than 12, not predefined. The value
637       --  12 here is an 8 char name with extension .ads.
638
639       if Name_Len > 12 then
640          return Not_Predefined_Unit;
641       end if;
642
643       --  Not predefined if file name does not start with a- g- s- i-
644
645       if Name_Len < 3
646         or else Name_Buffer (2) /= '-'
647         or else (Name_Buffer (1) /= 'a'
648                    and then
649                  Name_Buffer (1) /= 'g'
650                    and then
651                  Name_Buffer (1) /= 'i'
652                    and then
653                  Name_Buffer (1) /= 's')
654       then
655          return Not_Predefined_Unit;
656       end if;
657
658       --  Not predefined if file name does not end in .ads. This can
659       --  happen when non-standard file names are being used.
660
661       if Name_Buffer (Name_Len - 3 .. Name_Len) /= ".ads" then
662          return Not_Predefined_Unit;
663       end if;
664
665       --  Otherwise normalize file name to 8 characters
666
667       Name_Len := Name_Len - 4;
668       while Name_Len < 8 loop
669          Name_Len := Name_Len + 1;
670          Name_Buffer (Name_Len) := ' ';
671       end loop;
672
673       --  See if name is in 95 list
674
675       for J in Non_Imp_File_Names_95'Range loop
676          if Name_Buffer (1 .. 8) = Non_Imp_File_Names_95 (J).Fname then
677             return Ada_95_Unit;
678          end if;
679       end loop;
680
681       --  See if name is in 2005 list
682
683       for J in Non_Imp_File_Names_05'Range loop
684          if Name_Buffer (1 .. 8) = Non_Imp_File_Names_05 (J).Fname then
685             return Ada_2005_Unit;
686          end if;
687       end loop;
688
689       --  See if name is in 2012 list
690
691       for J in Non_Imp_File_Names_12'Range loop
692          if Name_Buffer (1 .. 8) = Non_Imp_File_Names_12 (J).Fname then
693             return Ada_2012_Unit;
694          end if;
695       end loop;
696
697       --  Only remaining special possibilities are children of System.RPC and
698       --  System.Garlic and special files of the form System.Aux...
699
700       Get_Name_String (Unit_Name (U));
701
702       if Name_Len > 12
703         and then Name_Buffer (1 .. 11) = "system.rpc."
704       then
705          return Ada_95_Unit;
706       end if;
707
708       if Name_Len > 15
709         and then Name_Buffer (1 .. 14) = "system.garlic."
710       then
711          return Ada_95_Unit;
712       end if;
713
714       if Name_Len > 11
715         and then Name_Buffer (1 .. 10) = "system.aux"
716       then
717          return Ada_95_Unit;
718       end if;
719
720       --  All tests failed, this is definitely an implementation unit. See if
721       --  we have an alternative name.
722
723       Get_Name_String (Fname);
724
725       if Name_Len in 11 .. 12
726         and then Name_Buffer (1 .. 2) = "s-"
727         and then Name_Buffer (Name_Len - 3 .. Name_Len) = ".ads"
728       then
729          for J in Map_Array'Range loop
730             if (Name_Len = 12 and then
731                  Name_Buffer (3 .. 8) = Map_Array (J).Fname)
732               or else
733                (Name_Len = 11 and then
734                  Name_Buffer (3 .. 7) = Map_Array (J).Fname (1 .. 5))
735             then
736                Error_Msg_Strlen := Map_Array (J).Aname'Length;
737                Error_Msg_String (1 .. Error_Msg_Strlen) :=
738                  Map_Array (J).Aname.all;
739             end if;
740          end loop;
741       end if;
742
743       return Implementation_Unit;
744    end Get_Kind_Of_Unit;
745
746    -------------------
747    -- Is_Known_Unit --
748    -------------------
749
750    function Is_Known_Unit (Nam : Node_Id) return Boolean is
751       Unam : Unit_Name_Type;
752       Fnam : File_Name_Type;
753
754    begin
755       --  If selector is not an identifier (e.g. it is a character literal or
756       --  some junk from a previous error), then definitely not a known unit.
757
758       if Nkind (Selector_Name (Nam)) /= N_Identifier then
759          return False;
760       end if;
761
762       --  Otherwise get corresponding file name
763
764       Unam := Get_Unit_Name (Nam);
765       Fnam := Get_File_Name (Unam, Subunit => False);
766       Get_Name_String (Fnam);
767
768       Error_Msg_Strlen := 0;
769
770       --  Ada/System/Interfaces are all Ada 95 units
771
772       if (Name_Len =  7 and then Name_Buffer (1 ..  7) = "ada.ads")
773            or else
774          (Name_Len = 10 and then Name_Buffer (1 .. 10) = "system.ads")
775            or else
776          (Name_Len = 12 and then Name_Buffer (1 .. 12) = "interfac.ads")
777       then
778          return True;
779       end if;
780
781       --  Remove extension from file name
782
783       if Name_Buffer (Name_Len - 3 .. Name_Len) = ".adb"
784            or else
785          Name_Buffer (Name_Len - 3 .. Name_Len) = ".ads"
786       then
787          Name_Len := Name_Len - 4;
788       else
789          return False;
790       end if;
791
792       --  Pad name to 8 characters
793
794       while Name_Len < 8 loop
795          Name_Len := Name_Len + 1;
796          Name_Buffer (Name_Len) := ' ';
797       end loop;
798
799       --  If length more than 8, definitely not a match
800
801       if Name_Len /= 8 then
802          return False;
803       end if;
804
805       --  If length is 8, search our tables
806
807       for J in Non_Imp_File_Names_95'Range loop
808          if Name_Buffer (1 .. 8) = Non_Imp_File_Names_95 (J).Fname then
809             return True;
810          end if;
811       end loop;
812
813       for J in Non_Imp_File_Names_05'Range loop
814          if Name_Buffer (1 .. 8) = Non_Imp_File_Names_05 (J).Fname then
815             return True;
816          end if;
817       end loop;
818
819       for J in Non_Imp_File_Names_12'Range loop
820          if Name_Buffer (1 .. 8) = Non_Imp_File_Names_12 (J).Fname then
821             return True;
822          end if;
823       end loop;
824
825       --  If not found, not known
826
827       return False;
828
829    --  A safety guard, if we get an exception during this processing then it
830    --  is most likely the result of a previous error, or a peculiar case we
831    --  have not thought of. Since this routine is only used for error message
832    --  refinement, we will just return False.
833
834    exception
835       when others =>
836          return False;
837    end Is_Known_Unit;
838
839    ---------------------------
840    -- Not_Impl_Defined_Unit --
841    ---------------------------
842
843    function Not_Impl_Defined_Unit (U : Unit_Number_Type) return Boolean is
844       Fname : constant File_Name_Type := Unit_File_Name (U);
845
846    begin
847       Error_Msg_Strlen := 0;
848       Get_Name_String (Fname);
849
850       --  Ada/System/Interfaces are all RM-defined Ada 95 units
851
852       if (Name_Len =  7 and then Name_Buffer (1 ..  7) = "ada.ads")
853            or else
854          (Name_Len = 10 and then Name_Buffer (1 .. 10) = "system.ads")
855            or else
856          (Name_Len = 12 and then Name_Buffer (1 .. 12) = "interfac.ads")
857       then
858          return True;
859       end if;
860
861       --  If length of file name is greater than 12, then it's a user unit
862       --  and not a GNAT implementation defined unit.
863
864       if Name_Len > 12 then
865          return True;
866       end if;
867
868       --  Implementation defined if unit in the gnat hierarchy
869
870       if (Name_Len = 8 and then Name_Buffer (1 .. 8) = "gnat.ads")
871         or else (Name_Len > 2 and then Name_Buffer (1 .. 2) = "g-")
872       then
873          return False;
874       end if;
875
876       --  Not implementation defined if file name does not start with a- s- i-
877
878       if Name_Len < 3
879         or else Name_Buffer (2) /= '-'
880         or else (Name_Buffer (1) /= 'a'
881                    and then
882                  Name_Buffer (1) /= 'i'
883                    and then
884                  Name_Buffer (1) /= 's')
885       then
886          return True;
887       end if;
888
889       --  Not impl-defined if file name does not end in .ads. This can happen
890       --  when non-standard file names are being used.
891
892       if Name_Buffer (Name_Len - 3 .. Name_Len) /= ".ads" then
893          return True;
894       end if;
895
896       --  Otherwise normalize file name to 8 characters
897
898       Name_Len := Name_Len - 4;
899       while Name_Len < 8 loop
900          Name_Len := Name_Len + 1;
901          Name_Buffer (Name_Len) := ' ';
902       end loop;
903
904       --  Check our lists of names, if we find a match, return corresponding
905       --  indication of whether the file is RM defined, respecting the RM
906       --  version in which it is defined.
907
908       for J in Non_Imp_File_Names_95'Range loop
909          if Name_Buffer (1 .. 8) = Non_Imp_File_Names_95 (J).Fname then
910             return Non_Imp_File_Names_95 (J).RMdef;
911          end if;
912       end loop;
913
914       for J in Non_Imp_File_Names_05'Range loop
915          if Name_Buffer (1 .. 8) = Non_Imp_File_Names_05 (J).Fname then
916             return Non_Imp_File_Names_05 (J).RMdef
917               and then Ada_Version >= Ada_2005;
918          end if;
919       end loop;
920
921       for J in Non_Imp_File_Names_12'Range loop
922          if Name_Buffer (1 .. 8) = Non_Imp_File_Names_12 (J).Fname then
923             return Non_Imp_File_Names_95 (J).RMdef
924               and then Ada_Version >= Ada_2012;
925          end if;
926       end loop;
927
928       --  If unit is in System, Ada or Interfaces hierarchies and did not match
929       --  any entry in the list, means it is an internal implementation defined
930       --  unit which the restriction should definition forbid.
931
932       return True;
933    end Not_Impl_Defined_Unit;
934
935 end Impunit;