* gcc.dg/vect/vect-22.c: Require vect_float.
[official-gcc.git] / gcc / ada / switch-b.adb
blobde69081a104221c63a78246c3e645887291e2891
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- S W I T C H - B --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 2001-2005 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 2, 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 COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
21 -- --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 -- --
25 ------------------------------------------------------------------------------
27 with Debug; use Debug;
28 with Osint; use Osint;
29 with Opt; use Opt;
31 with System.WCh_Con; use System.WCh_Con;
33 package body Switch.B is
35 --------------------------
36 -- Scan_Binder_Switches --
37 --------------------------
39 procedure Scan_Binder_Switches (Switch_Chars : String) is
40 Max : constant Integer := Switch_Chars'Last;
41 Ptr : Integer := Switch_Chars'First;
42 C : Character := ' ';
44 begin
45 -- Skip past the initial character (must be the switch character)
47 if Ptr = Max then
48 raise Bad_Switch;
49 else
50 Ptr := Ptr + 1;
51 end if;
53 -- A little check, "gnat" at the start of a switch is not allowed
54 -- except for the compiler
56 if Switch_Chars'Last >= Ptr + 3
57 and then Switch_Chars (Ptr .. Ptr + 3) = "gnat"
58 then
59 Osint.Fail ("invalid switch: """, Switch_Chars, """"
60 & " (gnat not needed here)");
61 end if;
63 -- Loop to scan through switches given in switch string
65 while Ptr <= Max loop
66 C := Switch_Chars (Ptr);
68 case C is
70 -- Processing for a switch
72 when 'a' =>
73 Ptr := Ptr + 1;
74 Use_Pragma_Linker_Constructor := True;
76 -- Processing for A switch
78 when 'A' =>
79 Ptr := Ptr + 1;
80 Ada_Bind_File := True;
82 -- Processing for b switch
84 when 'b' =>
85 Ptr := Ptr + 1;
86 Brief_Output := True;
88 -- Processing for c switch
90 when 'c' =>
91 Ptr := Ptr + 1;
93 Check_Only := True;
95 -- Processing for C switch
97 when 'C' =>
98 Ptr := Ptr + 1;
100 Ada_Bind_File := False;
102 -- Processing for d switch
104 when 'd' =>
106 -- Note: for the debug switch, the remaining characters in this
107 -- switch field must all be debug flags, since all valid switch
108 -- characters are also valid debug characters. This switch is not
109 -- documented on purpose because it is only used by the
110 -- implementors.
112 -- Loop to scan out debug flags
114 while Ptr < Max loop
115 Ptr := Ptr + 1;
116 C := Switch_Chars (Ptr);
117 exit when C = ASCII.NUL or else C = '/' or else C = '-';
119 if C in '1' .. '9' or else
120 C in 'a' .. 'z' or else
121 C in 'A' .. 'Z'
122 then
123 Set_Debug_Flag (C);
124 else
125 raise Bad_Switch;
126 end if;
127 end loop;
129 return;
131 -- Processing for D switch
133 when 'D' =>
134 Ptr := Ptr + 1;
135 Scan_Pos (Switch_Chars, Max, Ptr, Default_Sec_Stack_Size);
137 -- Processing for e switch
139 when 'e' =>
140 Ptr := Ptr + 1;
141 Elab_Dependency_Output := True;
143 -- Processing for E switch
145 when 'E' =>
146 Ptr := Ptr + 1;
147 Exception_Tracebacks := True;
149 -- Processing for F switch
151 when 'F' =>
152 Ptr := Ptr + 1;
153 Force_Checking_Of_Elaboration_Flags := True;
155 -- Processing for g switch
157 when 'g' =>
158 Ptr := Ptr + 1;
160 if Ptr <= Max then
161 C := Switch_Chars (Ptr);
163 if C in '0' .. '3' then
164 Debugger_Level :=
165 Character'Pos
166 (Switch_Chars (Ptr)) - Character'Pos ('0');
167 Ptr := Ptr + 1;
168 end if;
170 else
171 Debugger_Level := 2;
172 end if;
174 -- Processing for h switch
176 when 'h' =>
177 Ptr := Ptr + 1;
178 Usage_Requested := True;
180 -- Processing for i switch
182 when 'i' =>
183 if Ptr = Max then
184 raise Bad_Switch;
185 end if;
187 Ptr := Ptr + 1;
188 C := Switch_Chars (Ptr);
190 if C in '1' .. '5'
191 or else C = '8'
192 or else C = 'p'
193 or else C = 'f'
194 or else C = 'n'
195 or else C = 'w'
196 then
197 Identifier_Character_Set := C;
198 Ptr := Ptr + 1;
199 else
200 raise Bad_Switch;
201 end if;
203 -- Processing for K switch
205 when 'K' =>
206 Ptr := Ptr + 1;
207 Output_Linker_Option_List := True;
209 -- Processing for l switch
211 when 'l' =>
212 Ptr := Ptr + 1;
213 Elab_Order_Output := True;
215 -- Processing for m switch
217 when 'm' =>
218 Ptr := Ptr + 1;
219 Scan_Pos (Switch_Chars, Max, Ptr, Maximum_Errors);
221 -- Processing for n switch
223 when 'n' =>
224 Ptr := Ptr + 1;
225 Bind_Main_Program := False;
227 -- Note: The -L option of the binder also implies -n, so
228 -- any change here must also be reflected in the processing
229 -- for -L that is found in Gnatbind.Scan_Bind_Arg.
231 -- Processing for o switch
233 when 'o' =>
234 Ptr := Ptr + 1;
236 if Output_File_Name_Present then
237 raise Too_Many_Output_Files;
239 else
240 Output_File_Name_Present := True;
241 end if;
243 -- Processing for O switch
245 when 'O' =>
246 Ptr := Ptr + 1;
247 Output_Object_List := True;
249 -- Processing for p switch
251 when 'p' =>
252 Ptr := Ptr + 1;
253 Pessimistic_Elab_Order := True;
255 -- Processing for q switch
257 when 'q' =>
258 Ptr := Ptr + 1;
259 Quiet_Output := True;
261 -- Processing for r switch
263 when 'r' =>
264 Ptr := Ptr + 1;
265 List_Restrictions := True;
267 -- Processing for s switch
269 when 's' =>
270 Ptr := Ptr + 1;
271 All_Sources := True;
272 Check_Source_Files := True;
274 -- Processing for t switch
276 when 't' =>
277 Ptr := Ptr + 1;
278 Tolerate_Consistency_Errors := True;
280 -- Processing for T switch
282 when 'T' =>
283 Ptr := Ptr + 1;
284 Time_Slice_Set := True;
285 Scan_Nat (Switch_Chars, Max, Ptr, Time_Slice_Value);
286 Time_Slice_Value := Time_Slice_Value * 1_000;
288 -- Processing for v switch
290 when 'v' =>
291 Ptr := Ptr + 1;
292 Verbose_Mode := True;
294 -- Processing for w switch
296 when 'w' =>
298 -- For the binder we only allow suppress/error cases
300 Ptr := Ptr + 1;
302 case Switch_Chars (Ptr) is
304 when 'e' =>
305 Warning_Mode := Treat_As_Error;
307 when 's' =>
308 Warning_Mode := Suppress;
310 when others =>
311 raise Bad_Switch;
312 end case;
314 Ptr := Ptr + 1;
316 -- Processing for W switch
318 when 'W' =>
319 Ptr := Ptr + 1;
321 for J in WC_Encoding_Method loop
322 if Switch_Chars (Ptr) = WC_Encoding_Letters (J) then
323 Wide_Character_Encoding_Method := J;
324 exit;
326 elsif J = WC_Encoding_Method'Last then
327 raise Bad_Switch;
328 end if;
329 end loop;
331 Upper_Half_Encoding :=
332 Wide_Character_Encoding_Method in
333 WC_Upper_Half_Encoding_Method;
335 Ptr := Ptr + 1;
337 -- Processing for x switch
339 when 'x' =>
340 Ptr := Ptr + 1;
341 All_Sources := False;
342 Check_Source_Files := False;
344 -- Processing for X switch
346 when 'X' =>
347 Ptr := Ptr + 1;
348 Scan_Pos (Switch_Chars, Max, Ptr, Default_Exit_Status);
350 -- Processing for z switch
352 when 'z' =>
353 Ptr := Ptr + 1;
354 No_Main_Subprogram := True;
356 -- Ignore extra switch character
358 when '/' =>
359 Ptr := Ptr + 1;
361 -- Ignore '-' extra switch caracter, only if it isn't followed by
362 -- 'RTS'. If it is, then we must process the 'RTS' switch
364 when '-' =>
366 if Ptr + 3 <= Max and then
367 Switch_Chars (Ptr + 1 .. Ptr + 3) = "RTS"
368 then
369 Ptr := Ptr + 1;
371 if Switch_Chars (Ptr + 3) /= '=' or else
372 (Switch_Chars (Ptr + 3) = '='
373 and then Ptr + 4 > Max)
374 then
375 Osint.Fail ("missing path for --RTS");
376 else
378 -- valid --RTS switch
379 Opt.No_Stdinc := True;
380 Opt.RTS_Switch := True;
382 declare
383 Src_Path_Name : constant String_Ptr :=
384 Get_RTS_Search_Dir
385 (Switch_Chars
386 (Ptr + 4 .. Switch_Chars'Last),
387 Include);
388 Lib_Path_Name : constant String_Ptr :=
389 Get_RTS_Search_Dir
390 (Switch_Chars
391 (Ptr + 4 .. Switch_Chars'Last),
392 Objects);
394 begin
395 if Src_Path_Name /= null and then
396 Lib_Path_Name /= null
397 then
398 -- Set the RTS_*_Path_Name variables, so that the
399 -- correct directories will be set when
400 -- Osint.Add_Default_Search_Dirs will be called later.
402 RTS_Src_Path_Name := Src_Path_Name;
403 RTS_Lib_Path_Name := Lib_Path_Name;
405 -- We can exit as there can not be another switch
406 -- after --RTS
408 exit;
410 elsif Src_Path_Name = null
411 and then Lib_Path_Name = null
412 then
413 Osint.Fail ("RTS path not valid: missing " &
414 "adainclude and adalib directories");
415 elsif Src_Path_Name = null then
416 Osint.Fail ("RTS path not valid: missing " &
417 "adainclude directory");
418 elsif Lib_Path_Name = null then
419 Osint.Fail ("RTS path not valid: missing " &
420 "adalib directory");
421 end if;
422 end;
423 end if;
425 else
426 Ptr := Ptr + 1;
427 end if;
429 -- Anything else is an error (illegal switch character)
431 when others =>
432 raise Bad_Switch;
433 end case;
434 end loop;
436 exception
437 when Bad_Switch =>
438 Osint.Fail ("invalid switch: ", (1 => C));
440 when Bad_Switch_Value =>
441 Osint.Fail ("numeric value out of range for switch: ", (1 => C));
443 when Missing_Switch_Value =>
444 Osint.Fail ("missing numeric value for switch: ", (1 => C));
446 when Too_Many_Output_Files =>
447 Osint.Fail ("duplicate -o switch");
448 end Scan_Binder_Switches;
450 end Switch.B;