cselib.c (cselib_current_insn_in_libcall): New static variable.
[official-gcc.git] / gcc / ada / impunit.adb
blob1c30177425fc46023d4ecb20f8b9afcdee968688
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- I M P U N I T --
6 -- --
7 -- B o d y --
8 -- --
9 -- --
10 -- Copyright (C) 2000-2002 Free Software Foundation, Inc. --
11 -- --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNAT; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, USA. --
22 -- --
23 -- GNAT was originally developed by the GNAT team at New York University. --
24 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 -- --
26 ------------------------------------------------------------------------------
28 with Lib; use Lib;
29 with Namet; use Namet;
30 with Opt; use Opt;
32 package body Impunit is
34 subtype File_Name_8 is String (1 .. 8);
35 type File_List is array (Nat range <>) of File_Name_8;
37 -- The following is a giant string containing the concenated names
38 -- of all non-implementation internal files, i.e. the complete list
39 -- of files for internal units which a program may legitimately WITH.
41 -- Note that this list should match the list of units documented in
42 -- the "GNAT Library" section of the GNAT Reference Manual.
44 Non_Imp_File_Names : File_List := (
46 -----------------------------------------------
47 -- Ada Hierarchy Units from Reference Manual --
48 -----------------------------------------------
50 "a-astaco", -- Ada.Asynchronous_Task_Control
51 "a-calend", -- Ada.Calendar
52 "a-chahan", -- Ada.Characters.Handling
53 "a-charac", -- Ada.Characters
54 "a-chlat1", -- Ada.Characters.Latin_1
55 "a-comlin", -- Ada.Command_Line
56 "a-decima", -- Ada.Decimal
57 "a-direio", -- Ada.Direct_IO
58 "a-dynpri", -- Ada.Dynamic_Priorities
59 "a-except", -- Ada.Exceptions
60 "a-finali", -- Ada.Finalization
61 "a-flteio", -- Ada.Float_Text_IO
62 "a-fwteio", -- Ada.Float_Wide_Text_IO
63 "a-inteio", -- Ada.Integer_Text_IO
64 "a-interr", -- Ada.Interrupts
65 "a-intnam", -- Ada.Interrupts.Names
66 "a-ioexce", -- Ada.IO_Exceptions
67 "a-iwteio", -- Ada.Integer_Wide_Text_IO
68 "a-ncelfu", -- Ada.Numerics.Complex_Elementary_Functions
69 "a-ngcefu", -- Ada.Numerics.Generic_Complex_Elementary_Functions
70 "a-ngcoty", -- Ada.Numerics.Generic_Complex_Types
71 "a-ngelfu", -- Ada.Numerics.Generic_Elementary_Functions
72 "a-nucoty", -- Ada.Numerics.Complex_Types
73 "a-nudira", -- Ada.Numerics.Discrete_Random
74 "a-nuelfu", -- Ada.Numerics.Elementary_Functions
75 "a-nuflra", -- Ada.Numerics.Float_Random
76 "a-numeri", -- Ada.Numerics
77 "a-reatim", -- Ada.Real_Time
78 "a-sequio", -- Ada.Sequential_IO
79 "a-stmaco", -- Ada.Strings.Maps.Constants
80 "a-storio", -- Ada.Storage_IO
81 "a-strbou", -- Ada.Strings.Bounded
82 "a-stream", -- Ada.Streams
83 "a-strfix", -- Ada.Strings.Fixed
84 "a-string", -- Ada.Strings
85 "a-strmap", -- Ada.Strings.Maps
86 "a-strunb", -- Ada.Strings.Unbounded
87 "a-ststio", -- Ada.Streams.Stream_IO
88 "a-stwibo", -- Ada.Strings.Wide_Bounded
89 "a-stwifi", -- Ada.Strings.Wide_Fixed
90 "a-stwima", -- Ada.Strings.Wide_Maps
91 "a-stwiun", -- Ada.Strings.Wide_Unbounded
92 "a-swmwco", -- Ada.Strings.Wide_Maps.Wide_Constants
93 "a-sytaco", -- Ada.Synchronous_Task_Control
94 "a-tags ", -- Ada.Tags
95 "a-tasatt", -- Ada.Task_Attributes
96 "a-taside", -- Ada.Task_Identification
97 "a-teioed", -- Ada.Text_IO.Editing
98 "a-textio", -- Ada.Text_IO
99 "a-ticoio", -- Ada.Text_IO.Complex_IO
100 "a-titest", -- Ada.Text_IO.Text_Streams
101 "a-unccon", -- Ada.Unchecked_Conversion
102 "a-uncdea", -- Ada.Unchecked_Deallocation
103 "a-witeio", -- Ada.Wide_Text_IO
104 "a-wtcoio", -- Ada.Wide_Text_IO.Complex_IO
105 "a-wtedit", -- Ada.Wide_Text_IO.Editing
106 "a-wttest", -- Ada.Wide_Text_IO.Text_Streams
108 -------------------------------------------------
109 -- RM Required Additions to Ada for GNAT Types --
110 -------------------------------------------------
112 "a-lfteio", -- Ada.Long_Float_Text_IO
113 "a-lfwtio", -- Ada.Long_Float_Wide_Text_IO
114 "a-liteio", -- Ada.Long_Integer_Text_IO
115 "a-liwtio", -- Ada.Long_Integer_Wide_Text_IO
116 "a-llftio", -- Ada.Long_Long_Float_Text_IO
117 "a-llfwti", -- Ada.Long_Long_Float_Wide_Text_IO
118 "a-llitio", -- Ada.Long_Long_Integer_Text_IO
119 "a-lliwti", -- Ada.Long_Long_Integer_Wide_Text_IO
120 "a-nlcefu", -- Ada.Long_Complex_Elementary_Functions
121 "a-nlcoty", -- Ada.Numerics.Long_Complex_Types
122 "a-nlelfu", -- Ada.Numerics.Long_Elementary_Functions
123 "a-nllcef", -- Ada.Long_Long_Complex_Elementary_Functions
124 "a-nllefu", -- Ada.Numerics.Long_Long_Elementary_Functions
125 "a-nltcty", -- Ada.Numerics.Long_Long_Complex_Types
126 "a-nscefu", -- Ada.Short_Complex_Elementary_Functions
127 "a-nscoty", -- Ada.Numerics.Short_Complex_Types
128 "a-nselfu", -- Ada.Numerics.Short_Elementary_Functions
129 "a-sfteio", -- Ada.Short_Float_Text_IO
130 "a-sfwtio", -- Ada.Short_Float_Wide_Text_IO
131 "a-siteio", -- Ada.Short_Integer_Text_IO
132 "a-siwtio", -- Ada.Short_Integer_Wide_Text_IO
133 "a-ssitio", -- Ada.Short_Short_Integer_Text_IO
134 "a-ssiwti", -- Ada.Short_Short_Integer_Wide_Text_IO
136 -----------------------------------
137 -- GNAT Defined Additions to Ada --
138 -----------------------------------
140 "a-chlat9", -- Ada.Characters.Latin_9
141 "a-colire", -- Ada.Command_Line.Remove
142 "a-cwila1", -- Ada.Characters.Wide_Latin_1
143 "a-cwila9", -- Ada.Characters.Wide_Latin_9
144 "a-diocst", -- Ada.Direct_IO.C_Streams
145 "a-einuoc", -- Ada.Exceptions.Is_Null_Occurrence
146 "a-siocst", -- Ada.Sequential_IO.C_Streams
147 "a-ssicst", -- Ada.Streams.Stream_IO.C_Streams
148 "a-suteio", -- Ada.Strings.Unbounded.Text_IO
149 "a-swuwti", -- Ada.Strings.Wide_Unbounded.Wide_Text_IO
150 "a-taidim", -- Ada.Task_Identification.Image
151 "a-tiocst", -- Ada.Text_IO.C_Streams
152 "a-wtcstr", -- Ada.Wide_Text_IO.C_Streams
154 ---------------------------
155 -- GNAT Special IO Units --
156 ---------------------------
158 -- As further explained elsewhere (see Sem_Ch10), the internal
159 -- packages of Text_IO and Wide_Text_IO are actually implemented
160 -- as separate children, but this fact is intended to be hidden
161 -- from the user completely. Any attempt to WITH one of these
162 -- units will be diagnosed as an error later on, but for now we
163 -- do not consider these internal implementation units (if we did,
164 -- then we would get a junk warning which would be confusing and
165 -- unecessary, given that we generate a clear error message).
167 "a-tideio", -- Ada.Text_IO.Decimal_IO
168 "a-tienio", -- Ada.Text_IO.Enumeration_IO
169 "a-tifiio", -- Ada.Text_IO.Fixed_IO
170 "a-tiflio", -- Ada.Text_IO.Float_IO
171 "a-tiinio", -- Ada.Text_IO.Integer_IO
172 "a-tiinio", -- Ada.Text_IO.Integer_IO
173 "a-timoio", -- Ada.Text_IO.Modular_IO
174 "a-wtdeio", -- Ada.Wide_Text_IO.Decimal_IO
175 "a-wtenio", -- Ada.Wide_Text_IO.Enumeration_IO
176 "a-wtfiio", -- Ada.Wide_Text_IO.Fixed_IO
177 "a-wtflio", -- Ada.Wide_Text_IO.Float_IO
178 "a-wtinio", -- Ada.Wide_Text_IO.Integer_IO
179 "a-wtmoio", -- Ada.Wide_Text_IO.Modular_IO
181 ------------------------
182 -- GNAT Library Units --
183 ------------------------
185 "g-awk ", -- GNAT.AWK
186 "g-busora", -- GNAT.Bubble_Sort_A
187 "g-busorg", -- GNAT.Bubble_Sort_G
188 "g-calend", -- GNAT.Calendar
189 "g-catiio", -- GNAT.Calendar.Time_IO
190 "g-casuti", -- GNAT.Case_Util
191 "g-cgi ", -- GNAT.CGI
192 "g-cgicoo", -- GNAT.CGI.Cookie
193 "g-cgideb", -- GNAT.CGI.Debug
194 "g-comlin", -- GNAT.Command_Line
195 "g-crc32 ", -- GNAT.CRC32
196 "g-curexc", -- GNAT.Current_Exception
197 "g-debpoo", -- GNAT.Debug_Pools
198 "g-debuti", -- GNAT.Debug_Utilities
199 "g-diopit", -- GNAT.Directory_Operations.Iteration
200 "g-dirope", -- GNAT.Directory_Operations
201 "g-dyntab", -- GNAT.Dynamic_Tables
202 "g-exctra", -- GNAT.Exception_Traces
203 "g-expect", -- GNAT.Expect
204 "g-flocon", -- GNAT.Float_Control
205 "g-htable", -- GNAT.Htable
206 "g-hesora", -- GNAT.Heap_Sort_A
207 "g-hesorg", -- GNAT.Heap_Sort_G
208 "g-io ", -- GNAT.IO
209 "g-io_aux", -- GNAT.IO_Aux
210 "g-locfil", -- GNAT.Lock_Files
211 "g-md5 ", -- GNAT.MD5
212 "g-moreex", -- GNAT.Most_Recent_Exception
213 "g-os_lib", -- GNAT.Os_Lib
214 "g-regexp", -- GNAT.Regexp
215 "g-regist", -- GNAT.Registry
216 "g-regpat", -- GNAT.Regpat
217 "g-socket", -- GNAT.Sockets
218 "g-sptabo", -- GNAT.Spitbol.Table_Boolean
219 "g-sptain", -- GNAT.Spitbol.Table_Integer
220 "g-sptavs", -- GNAT.Spitbol.Table_Vstring
221 "g-souinf", -- GNAT.Source_Info
222 "g-speche", -- GNAT.Spell_Checker
223 "g-spitbo", -- GNAT.Spitbol
224 "g-spipat", -- GNAT.Spitbol.Patterns
225 "g-table ", -- GNAT.Table
226 "g-tasloc", -- GNAT.Task_Lock
227 "g-thread", -- GNAT.Threads
228 "g-traceb", -- GNAT.Traceback
229 "g-trasym", -- GNAT.Traceback.Symbolic
231 -----------------------------------------------------
232 -- Interface Hierarchy Units from Reference Manual --
233 -----------------------------------------------------
235 "i-c ", -- Interfaces.C
236 "i-cobol ", -- Interfaces.Cobol
237 "i-cpoint", -- Interfaces.C.Pointers
238 "i-cstrin", -- Interfaces.C.Strings
239 "i-fortra", -- Interfaces.Fortran
241 ------------------------------------------
242 -- GNAT Defined Additions to Interfaces --
243 ------------------------------------------
245 "i-cexten", -- Interfaces.C.Extensions
246 "i-csthre", -- Interfaces.C.Sthreads
247 "i-cstrea", -- Interfaces.C.Streams
248 "i-cpp ", -- Interfaces.CPP
249 "i-java ", -- Interfaces.Java
250 "i-javlan", -- Interfaces.Java.Lang
251 "i-jalaob", -- Interfaces.Java.Lang.Object
252 "i-jalasy", -- Interfaces.Java.Lang.System
253 "i-jalath", -- Interfaces.Java.Lang.Thread
254 "i-os2err", -- Interfaces.Os2lib.Errors
255 "i-os2lib", -- Interfaces.Os2lib
256 "i-os2syn", -- Interfaces.Os2lib.Synchronization
257 "i-os2thr", -- Interfaces.Os2lib.Threads
258 "i-pacdec", -- Interfaces.Packed_Decimal
259 "i-vxwork", -- Interfaces.VxWorks
260 "i-vxwoio", -- Interfaces.VxWorks.IO
262 --------------------------------------------------
263 -- System Hierarchy Units from Reference Manual --
264 --------------------------------------------------
266 "s-atacco", -- System.Address_To_Access_Conversions
267 "s-maccod", -- System.Machine_Code
268 "s-rpc ", -- System.Rpc
269 "s-stoele", -- System.Storage_Elements
270 "s-stopoo", -- System.Storage_Pools
272 --------------------------------------
273 -- GNAT Defined Additions to System --
274 --------------------------------------
276 "s-addima", -- System.Address_Image
277 "s-assert", -- System.Assertions
278 "s-parint", -- System.Partition_Interface
279 "s-tasinf", -- System.Task_Info
280 "s-wchcnv", -- System.Wch_Cnv
281 "s-wchcon"); -- System.Wch_Con
283 -------------------------
284 -- Implementation_Unit --
285 -------------------------
287 function Implementation_Unit (U : Unit_Number_Type) return Boolean is
288 Fname : constant File_Name_Type := Unit_File_Name (U);
290 begin
291 -- All units are OK in GNAT mode
293 if GNAT_Mode then
294 return False;
295 end if;
297 -- If length of file name is greater than 12, definitely OK!
298 -- The value 12 here is an 8 char name with extension .ads.
300 if Length_Of_Name (Fname) > 12 then
301 return False;
302 end if;
304 -- Otherwise test file name
306 Get_Name_String (Fname);
308 -- Definitely OK if file name does not start with a- g- s- i-
310 if Name_Len < 3
311 or else Name_Buffer (2) /= '-'
312 or else (Name_Buffer (1) /= 'a'
313 and then
314 Name_Buffer (1) /= 'g'
315 and then
316 Name_Buffer (1) /= 'i'
317 and then
318 Name_Buffer (1) /= 's')
319 then
320 return False;
321 end if;
323 -- Definitely OK if file name does not end in .ads. This can
324 -- happen when non-standard file names are being used.
326 if Name_Buffer (Name_Len - 3 .. Name_Len) /= ".ads" then
327 return False;
328 end if;
330 -- Otherwise normalize file name to 8 characters
332 Name_Len := Name_Len - 4;
333 while Name_Len < 8 loop
334 Name_Len := Name_Len + 1;
335 Name_Buffer (Name_Len) := ' ';
336 end loop;
338 -- Definitely OK if name is in list
340 for J in Non_Imp_File_Names'Range loop
341 if Name_Buffer (1 .. 8) = Non_Imp_File_Names (J) then
342 return False;
343 end if;
344 end loop;
346 -- Only remaining special possibilities are children of
347 -- System.RPC and System.Garlic and special files of the
348 -- form System.Aux...
350 Get_Name_String (Unit_Name (U));
352 if Name_Len > 12
353 and then Name_Buffer (1 .. 11) = "system.rpc."
354 then
355 return False;
356 end if;
358 if Name_Len > 15
359 and then Name_Buffer (1 .. 14) = "system.garlic."
360 then
361 return False;
362 end if;
364 if Name_Len > 11
365 and then Name_Buffer (1 .. 10) = "system.aux"
366 then
367 return False;
368 end if;
370 -- All tests failed, this is definitely an implementation unit
372 return True;
374 end Implementation_Unit;
376 end Impunit;