2008-05-30 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / ada / switch-c.adb
blobcf59c8198cdcf4f615402d3b68e08d16604d805c
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- S W I T C H - C --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 2001-2008, 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 ------------------------------------------------------------------------------
26 with Debug; use Debug;
27 with Lib; use Lib;
28 with Osint; use Osint;
29 with Opt; use Opt;
30 with Prepcomp; use Prepcomp;
31 with Validsw; use Validsw;
32 with Sem_Warn; use Sem_Warn;
33 with Stylesw; use Stylesw;
35 with System.OS_Lib; use System.OS_Lib;
37 with System.WCh_Con; use System.WCh_Con;
39 package body Switch.C is
41 RTS_Specified : String_Access := null;
42 -- Used to detect multiple use of --RTS= flag
44 -----------------------------
45 -- Scan_Front_End_Switches --
46 -----------------------------
48 procedure Scan_Front_End_Switches (Switch_Chars : String) is
49 First_Switch : Boolean := True;
50 -- False for all but first switch
52 Max : constant Natural := Switch_Chars'Last;
53 Ptr : Natural;
54 C : Character := ' ';
55 Dot : Boolean;
57 Store_Switch : Boolean;
58 -- For -gnatxx switches, the normal processing, signalled by this flag
59 -- being set to True, is to store the switch on exit from the case
60 -- statement, the switch stored is -gnat followed by the characters
61 -- from First_Char to Ptr-1. For cases like -gnaty, where the switch
62 -- is stored in separate pieces, this flag is set to False, and the
63 -- appropriate calls to Store_Compilation_Switch are made from within
64 -- the case branch.
66 First_Char : Positive;
67 -- Marks start of switch to be stored
69 begin
70 Ptr := Switch_Chars'First;
72 -- Skip past the initial character (must be the switch character)
74 if Ptr = Max then
75 Bad_Switch (C);
76 else
77 Ptr := Ptr + 1;
78 end if;
80 -- Handle switches that do not start with -gnat
82 if Ptr + 3 > Max
83 or else Switch_Chars (Ptr .. Ptr + 3) /= "gnat"
84 then
85 -- There are two front-end switches that do not start with -gnat:
86 -- -I, --RTS
88 if Switch_Chars (Ptr) = 'I' then
90 -- Set flag Search_Directory_Present if switch is "-I" only:
91 -- the directory will be the next argument.
93 if Ptr = Max then
94 Search_Directory_Present := True;
95 return;
96 end if;
98 Ptr := Ptr + 1;
100 -- Find out whether this is a -I- or regular -Ixxx switch
102 -- Note: -I switches are not recorded in the ALI file, since the
103 -- meaning of the program depends on the source files compiled,
104 -- not where they came from.
106 if Ptr = Max and then Switch_Chars (Ptr) = '-' then
107 Look_In_Primary_Dir := False;
108 else
109 Add_Src_Search_Dir (Switch_Chars (Ptr .. Max));
110 end if;
112 -- Processing of the --RTS switch. --RTS may have been modified by
113 -- gcc into -fRTS (for GCC targets).
115 elsif Ptr + 3 <= Max
116 and then (Switch_Chars (Ptr .. Ptr + 3) = "fRTS"
117 or else
118 Switch_Chars (Ptr .. Ptr + 3) = "-RTS")
119 then
120 Ptr := Ptr + 1;
122 if Ptr + 4 > Max
123 or else Switch_Chars (Ptr + 3) /= '='
124 then
125 Osint.Fail ("missing path for --RTS");
126 else
127 -- Check that this is the first time --RTS is specified or if
128 -- it is not the first time, the same path has been specified.
130 if RTS_Specified = null then
131 RTS_Specified := new String'(Switch_Chars (Ptr + 4 .. Max));
133 elsif
134 RTS_Specified.all /= Switch_Chars (Ptr + 4 .. Max)
135 then
136 Osint.Fail
137 ("--RTS cannot be specified multiple times");
138 end if;
140 -- Valid --RTS switch
142 Opt.No_Stdinc := True;
143 Opt.RTS_Switch := True;
145 RTS_Src_Path_Name :=
146 Get_RTS_Search_Dir
147 (Switch_Chars (Ptr + 4 .. Max), Include);
149 RTS_Lib_Path_Name :=
150 Get_RTS_Search_Dir
151 (Switch_Chars (Ptr + 4 .. Max), Objects);
153 if RTS_Src_Path_Name /= null
154 and then RTS_Lib_Path_Name /= null
155 then
156 -- Store the -fRTS switch (Note: Store_Compilation_Switch
157 -- changes -fRTS back into --RTS for the actual output).
159 Store_Compilation_Switch (Switch_Chars);
161 elsif RTS_Src_Path_Name = null
162 and then RTS_Lib_Path_Name = null
163 then
164 Osint.Fail ("RTS path not valid: missing " &
165 "adainclude and adalib directories");
167 elsif RTS_Src_Path_Name = null then
168 Osint.Fail ("RTS path not valid: missing " &
169 "adainclude directory");
171 elsif RTS_Lib_Path_Name = null then
172 Osint.Fail ("RTS path not valid: missing " &
173 "adalib directory");
174 end if;
175 end if;
177 -- There are no other switches not starting with -gnat
179 else
180 Bad_Switch (Switch_Chars);
181 end if;
183 -- Case of switch starting with -gnat
185 else
186 Ptr := Ptr + 4;
188 -- Loop to scan through switches given in switch string
190 while Ptr <= Max loop
191 First_Char := Ptr;
192 Store_Switch := True;
194 C := Switch_Chars (Ptr);
196 case C is
198 when 'a' =>
199 Ptr := Ptr + 1;
200 Assertions_Enabled := True;
201 Debug_Pragmas_Enabled := True;
203 -- Processing for A switch
205 when 'A' =>
206 Ptr := Ptr + 1;
207 Config_File := False;
209 -- Processing for b switch
211 when 'b' =>
212 Ptr := Ptr + 1;
213 Brief_Output := True;
215 -- Processing for c switch
217 when 'c' =>
218 if not First_Switch then
219 Osint.Fail
220 ("-gnatc must be first if combined with other switches");
221 end if;
223 Ptr := Ptr + 1;
224 Operating_Mode := Check_Semantics;
226 if Tree_Output then
227 ASIS_Mode := True;
228 end if;
230 -- Processing for d switch
232 when 'd' =>
233 Store_Switch := False;
234 Dot := False;
236 -- Note: for the debug switch, the remaining characters in this
237 -- switch field must all be debug flags, since all valid switch
238 -- characters are also valid debug characters.
240 -- Loop to scan out debug flags
242 while Ptr < Max loop
243 Ptr := Ptr + 1;
244 C := Switch_Chars (Ptr);
245 exit when C = ASCII.NUL or else C = '/' or else C = '-';
247 if C in '1' .. '9' or else
248 C in 'a' .. 'z' or else
249 C in 'A' .. 'Z'
250 then
251 if Dot then
252 Set_Dotted_Debug_Flag (C);
253 Store_Compilation_Switch ("-gnatd." & C);
254 else
255 Set_Debug_Flag (C);
256 Store_Compilation_Switch ("-gnatd" & C);
257 end if;
259 elsif C = '.' then
260 Dot := True;
262 elsif Dot then
263 Bad_Switch ("-gnatd." & Switch_Chars (Ptr .. Max));
264 else
265 Bad_Switch ("-gnatd" & Switch_Chars (Ptr .. Max));
266 end if;
267 end loop;
269 return;
271 -- Processing for D switch
273 when 'D' =>
274 Ptr := Ptr + 1;
276 -- Note: -gnatD also sets -gnatx (to turn off cross-reference
277 -- generation in the ali file) since otherwise this generation
278 -- gets confused by the "wrong" Sloc values put in the tree.
280 Debug_Generated_Code := True;
281 Xref_Active := False;
282 Set_Debug_Flag ('g');
284 -- -gnate? (extended switches)
286 when 'e' =>
287 Ptr := Ptr + 1;
289 -- The -gnate? switches are all double character switches
290 -- so we must always have a character after the e.
292 if Ptr > Max then
293 Bad_Switch ("-gnate");
294 end if;
296 case Switch_Chars (Ptr) is
298 -- -gnatec (configuration pragmas)
300 when 'c' =>
301 Store_Switch := False;
302 Ptr := Ptr + 1;
304 -- There may be an equal sign between -gnatec and
305 -- the path name of the config file.
307 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
308 Ptr := Ptr + 1;
309 end if;
311 if Ptr > Max then
312 Bad_Switch ("-gnatec");
313 end if;
315 declare
316 Config_File_Name : constant String_Access :=
317 new String'
318 (Switch_Chars (Ptr .. Max));
320 begin
321 if Config_File_Names = null then
322 Config_File_Names :=
323 new String_List'(1 => Config_File_Name);
325 else
326 declare
327 New_Names : constant String_List_Access :=
328 new String_List
329 (1 ..
330 Config_File_Names'Length + 1);
332 begin
333 for Index in Config_File_Names'Range loop
334 New_Names (Index) :=
335 Config_File_Names (Index);
336 Config_File_Names (Index) := null;
337 end loop;
339 New_Names (New_Names'Last) := Config_File_Name;
340 Free (Config_File_Names);
341 Config_File_Names := New_Names;
342 end;
343 end if;
344 end;
346 return;
348 -- -gnateD switch (preprocessing symbol definition)
350 when 'D' =>
351 Store_Switch := False;
352 Ptr := Ptr + 1;
354 if Ptr > Max then
355 Bad_Switch ("-gnateD");
356 end if;
358 Add_Symbol_Definition (Switch_Chars (Ptr .. Max));
360 -- Store the switch
362 Store_Compilation_Switch
363 ("-gnateD" & Switch_Chars (Ptr .. Max));
364 Ptr := Max + 1;
366 -- -gnatef (full source path for brief error messages)
368 when 'f' =>
369 Store_Switch := False;
370 Ptr := Ptr + 1;
371 Full_Path_Name_For_Brief_Errors := True;
372 return;
374 -- -gnateI (index of unit in multi-unit source)
376 when 'I' =>
377 Ptr := Ptr + 1;
378 Scan_Pos (Switch_Chars, Max, Ptr, Multiple_Unit_Index, C);
380 -- -gnatem (mapping file)
382 when 'm' =>
383 Store_Switch := False;
384 Ptr := Ptr + 1;
386 -- There may be an equal sign between -gnatem and
387 -- the path name of the mapping file.
389 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
390 Ptr := Ptr + 1;
391 end if;
393 if Ptr > Max then
394 Bad_Switch ("-gnatem");
395 end if;
397 Mapping_File_Name :=
398 new String'(Switch_Chars (Ptr .. Max));
399 return;
401 -- -gnatep (preprocessing data file)
403 when 'p' =>
404 Store_Switch := False;
405 Ptr := Ptr + 1;
407 -- There may be an equal sign between -gnatep and
408 -- the path name of the mapping file.
410 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
411 Ptr := Ptr + 1;
412 end if;
414 if Ptr > Max then
415 Bad_Switch ("-gnatep");
416 end if;
418 Preprocessing_Data_File :=
419 new String'(Switch_Chars (Ptr .. Max));
421 -- Store the switch, normalizing to -gnatep=
423 Store_Compilation_Switch
424 ("-gnatep=" & Preprocessing_Data_File.all);
426 Ptr := Max + 1;
428 when 'z' =>
429 Store_Switch := False;
430 Disable_Switch_Storing;
431 Ptr := Ptr + 1;
433 -- All other -gnate? switches are unassigned
435 when others =>
436 Bad_Switch ("-gnate" & Switch_Chars (Ptr .. Max));
437 end case;
439 -- -gnatE (dynamic elaboration checks)
441 when 'E' =>
442 Ptr := Ptr + 1;
443 Dynamic_Elaboration_Checks := True;
445 -- -gnatf (full error messages)
447 when 'f' =>
448 Ptr := Ptr + 1;
449 All_Errors_Mode := True;
451 -- Processing for F switch
453 when 'F' =>
454 Ptr := Ptr + 1;
455 External_Name_Exp_Casing := Uppercase;
456 External_Name_Imp_Casing := Uppercase;
458 -- Processing for g switch
460 when 'g' =>
461 Ptr := Ptr + 1;
462 GNAT_Mode := True;
463 Identifier_Character_Set := 'n';
464 System_Extend_Unit := Empty;
465 Warning_Mode := Treat_As_Error;
467 -- Set Ada 2005 mode explicitly. We don't want to rely on the
468 -- implicit setting here, since for example, we want
469 -- Preelaborate_05 treated as Preelaborate
471 Ada_Version := Ada_05;
472 Ada_Version_Explicit := Ada_Version;
474 -- Set default warnings for -gnatg
476 Check_Unreferenced := True;
477 Check_Unreferenced_Formals := True;
478 Check_Withs := True;
479 Constant_Condition_Warnings := True;
480 Implementation_Unit_Warnings := True;
481 Ineffective_Inline_Warnings := True;
482 Warn_On_Assertion_Failure := True;
483 Warn_On_Assumed_Low_Bound := True;
484 Warn_On_Bad_Fixed_Value := True;
485 Warn_On_Constant := True;
486 Warn_On_Export_Import := True;
487 Warn_On_Modified_Unread := True;
488 Warn_On_No_Value_Assigned := True;
489 Warn_On_Non_Local_Exception := False;
490 Warn_On_Obsolescent_Feature := True;
491 Warn_On_Redundant_Constructs := True;
492 Warn_On_Object_Renames_Function := True;
493 Warn_On_Unchecked_Conversion := True;
494 Warn_On_Unrecognized_Pragma := True;
496 Set_GNAT_Style_Check_Options;
498 -- Processing for G switch
500 when 'G' =>
501 Ptr := Ptr + 1;
502 Print_Generated_Code := True;
504 -- Processing for h switch
506 when 'h' =>
507 Ptr := Ptr + 1;
508 Usage_Requested := True;
510 -- Processing for H switch
512 when 'H' =>
513 Ptr := Ptr + 1;
514 HLO_Active := True;
516 -- Processing for i switch
518 when 'i' =>
519 if Ptr = Max then
520 Bad_Switch ("-gnati");
521 end if;
523 Ptr := Ptr + 1;
524 C := Switch_Chars (Ptr);
526 if C in '1' .. '5'
527 or else C = '8'
528 or else C = '9'
529 or else C = 'p'
530 or else C = 'f'
531 or else C = 'n'
532 or else C = 'w'
533 then
534 Identifier_Character_Set := C;
535 Ptr := Ptr + 1;
537 else
538 Bad_Switch ("-gnati" & Switch_Chars (Ptr .. Max));
539 end if;
541 -- Processing for I switch
543 when 'I' =>
544 Ptr := Ptr + 1;
545 Ignore_Rep_Clauses := True;
547 -- Processing for j switch
549 when 'j' =>
550 Ptr := Ptr + 1;
552 -- There may be an equal sign between -gnatj and the value
554 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
555 Ptr := Ptr + 1;
556 end if;
558 Scan_Nat (Switch_Chars, Max, Ptr, Error_Msg_Line_Length, C);
560 -- Processing for k switch
562 when 'k' =>
563 Ptr := Ptr + 1;
564 Scan_Pos
565 (Switch_Chars, Max, Ptr, Maximum_File_Name_Length, C);
567 -- Processing for l switch
569 when 'l' =>
570 Ptr := Ptr + 1;
571 Full_List := True;
573 -- There may be an equal sign between -gnatl and a file name
575 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
576 if Ptr = Max then
577 Osint.Fail ("file name for -gnatl= is null");
578 else
579 Opt.Full_List_File_Name :=
580 new String'(Switch_Chars (Ptr + 1 .. Max));
581 Ptr := Max + 1;
582 end if;
583 end if;
585 -- Processing for L switch
587 when 'L' =>
588 Ptr := Ptr + 1;
589 Dump_Source_Text := True;
591 -- Processing for m switch
593 when 'm' =>
594 Ptr := Ptr + 1;
596 -- There may be an equal sign between -gnatm and the value
598 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
599 Ptr := Ptr + 1;
600 end if;
602 Scan_Nat (Switch_Chars, Max, Ptr, Maximum_Errors, C);
604 -- Processing for n switch
606 when 'n' =>
607 Ptr := Ptr + 1;
608 Inline_Active := True;
610 -- Processing for N switch
612 when 'N' =>
613 Ptr := Ptr + 1;
614 Inline_Active := True;
615 Front_End_Inlining := True;
617 -- Processing for o switch
619 when 'o' =>
620 Ptr := Ptr + 1;
621 Suppress_Options (Overflow_Check) := False;
622 Opt.Enable_Overflow_Checks := True;
624 -- Processing for O switch
626 when 'O' =>
627 Store_Switch := False;
628 Ptr := Ptr + 1;
629 Output_File_Name_Present := True;
631 -- Processing for p switch
633 when 'p' =>
634 Ptr := Ptr + 1;
636 -- Set all specific options as well as All_Checks in the
637 -- Suppress_Options array, excluding Elaboration_Check, since
638 -- this is treated specially because we do not want -gnatp to
639 -- disable static elaboration processing.
641 for J in Suppress_Options'Range loop
642 if J /= Elaboration_Check then
643 Suppress_Options (J) := True;
644 end if;
645 end loop;
647 Validity_Checks_On := False;
648 Opt.Suppress_Checks := True;
649 Opt.Enable_Overflow_Checks := False;
651 -- Processing for P switch
653 when 'P' =>
654 Ptr := Ptr + 1;
655 Polling_Required := True;
657 -- Processing for q switch
659 when 'q' =>
660 Ptr := Ptr + 1;
661 Try_Semantics := True;
663 -- Processing for Q switch
665 when 'Q' =>
666 Ptr := Ptr + 1;
667 Force_ALI_Tree_File := True;
668 Try_Semantics := True;
670 -- Processing for r switch
672 when 'r' =>
673 Ptr := Ptr + 1;
674 Treat_Restrictions_As_Warnings := True;
676 -- Processing for R switch
678 when 'R' =>
679 Back_Annotate_Rep_Info := True;
680 List_Representation_Info := 1;
682 Ptr := Ptr + 1;
683 while Ptr <= Max loop
684 C := Switch_Chars (Ptr);
686 if C in '1' .. '3' then
687 List_Representation_Info :=
688 Character'Pos (C) - Character'Pos ('0');
690 elsif Switch_Chars (Ptr) = 's' then
691 List_Representation_Info_To_File := True;
693 elsif Switch_Chars (Ptr) = 'm' then
694 List_Representation_Info_Mechanisms := True;
696 else
697 Bad_Switch ("-gnatR" & Switch_Chars (Ptr .. Max));
698 end if;
700 Ptr := Ptr + 1;
701 end loop;
703 -- Processing for s switch
705 when 's' =>
706 if not First_Switch then
707 Osint.Fail
708 ("-gnats must be first if combined with other switches");
709 end if;
711 Ptr := Ptr + 1;
712 Operating_Mode := Check_Syntax;
714 -- Processing for S switch
716 when 'S' =>
717 Print_Standard := True;
718 Ptr := Ptr + 1;
720 -- Processing for t switch
722 when 't' =>
723 Ptr := Ptr + 1;
724 Tree_Output := True;
726 if Operating_Mode = Check_Semantics then
727 ASIS_Mode := True;
728 end if;
730 Back_Annotate_Rep_Info := True;
732 -- Processing for T switch
734 when 'T' =>
735 Ptr := Ptr + 1;
736 Scan_Pos (Switch_Chars, Max, Ptr, Table_Factor, C);
738 -- Processing for u switch
740 when 'u' =>
741 Ptr := Ptr + 1;
742 List_Units := True;
744 -- Processing for U switch
746 when 'U' =>
747 Ptr := Ptr + 1;
748 Unique_Error_Tag := True;
750 -- Processing for v switch
752 when 'v' =>
753 Ptr := Ptr + 1;
754 Verbose_Mode := True;
756 -- Processing for V switch
758 when 'V' =>
759 Store_Switch := False;
760 Ptr := Ptr + 1;
762 if Ptr > Max then
763 Bad_Switch ("-gnatV");
765 else
766 declare
767 OK : Boolean;
769 begin
770 Set_Validity_Check_Options
771 (Switch_Chars (Ptr .. Max), OK, Ptr);
773 if not OK then
774 Bad_Switch ("-gnatV" & Switch_Chars (Ptr .. Max));
775 end if;
777 for Index in First_Char + 1 .. Max loop
778 Store_Compilation_Switch
779 ("-gnatV" & Switch_Chars (Index));
780 end loop;
781 end;
782 end if;
784 Ptr := Max + 1;
786 -- Processing for w switch
788 when 'w' =>
789 Store_Switch := False;
790 Ptr := Ptr + 1;
792 if Ptr > Max then
793 Bad_Switch ("-gnatw");
794 end if;
796 while Ptr <= Max loop
797 C := Switch_Chars (Ptr);
799 -- Case of dot switch
801 if C = '.' and then Ptr < Max then
802 Ptr := Ptr + 1;
803 C := Switch_Chars (Ptr);
805 if Set_Dot_Warning_Switch (C) then
806 Store_Compilation_Switch ("-gnatw." & C);
807 else
808 Bad_Switch ("-gnatw." & Switch_Chars (Ptr .. Max));
809 end if;
811 -- Normal case, no dot
813 else
814 if Set_Warning_Switch (C) then
815 Store_Compilation_Switch ("-gnatw" & C);
816 else
817 Bad_Switch ("-gnatw" & Switch_Chars (Ptr .. Max));
818 end if;
819 end if;
821 Ptr := Ptr + 1;
822 end loop;
824 return;
826 -- Processing for W switch
828 when 'W' =>
829 Ptr := Ptr + 1;
831 if Ptr > Max then
832 Bad_Switch ("-gnatW");
833 end if;
835 begin
836 Wide_Character_Encoding_Method :=
837 Get_WC_Encoding_Method (Switch_Chars (Ptr));
838 exception
839 when Constraint_Error =>
840 Bad_Switch ("-gnatW" & Switch_Chars (Ptr .. Max));
841 end;
843 Wide_Character_Encoding_Method_Specified := True;
845 Upper_Half_Encoding :=
846 Wide_Character_Encoding_Method in
847 WC_Upper_Half_Encoding_Method;
849 Ptr := Ptr + 1;
851 -- Processing for x switch
853 when 'x' =>
854 Ptr := Ptr + 1;
855 Xref_Active := False;
857 -- Processing for X switch
859 when 'X' =>
860 Ptr := Ptr + 1;
861 Extensions_Allowed := True;
863 -- Processing for y switch
865 when 'y' =>
866 Ptr := Ptr + 1;
868 if Ptr > Max then
869 Set_Default_Style_Check_Options;
871 else
872 Store_Switch := False;
874 declare
875 OK : Boolean;
877 begin
878 Set_Style_Check_Options
879 (Switch_Chars (Ptr .. Max), OK, Ptr);
881 if not OK then
882 Osint.Fail
883 ("bad -gnaty switch (" &
884 Style_Msg_Buf (1 .. Style_Msg_Len) & ')');
885 end if;
887 Ptr := First_Char + 1;
888 while Ptr <= Max loop
889 if Switch_Chars (Ptr) = 'M' then
890 First_Char := Ptr;
891 loop
892 Ptr := Ptr + 1;
893 exit when Ptr > Max
894 or else Switch_Chars (Ptr) not in '0' .. '9';
895 end loop;
897 Store_Compilation_Switch
898 ("-gnaty" & Switch_Chars (First_Char .. Ptr - 1));
900 else
901 Store_Compilation_Switch
902 ("-gnaty" & Switch_Chars (Ptr));
903 Ptr := Ptr + 1;
904 end if;
905 end loop;
906 end;
907 end if;
909 -- Processing for z switch
911 when 'z' =>
912 Ptr := Ptr + 1;
914 -- Allowed for compiler only if this is the only
915 -- -z switch, we do not allow multiple occurrences
917 if Distribution_Stub_Mode = No_Stubs then
918 case Switch_Chars (Ptr) is
919 when 'r' =>
920 Distribution_Stub_Mode := Generate_Receiver_Stub_Body;
922 when 'c' =>
923 Distribution_Stub_Mode := Generate_Caller_Stub_Body;
925 when others =>
926 Bad_Switch ("-gnatz" & Switch_Chars (Ptr .. Max));
927 end case;
929 Ptr := Ptr + 1;
930 end if;
932 -- Processing for Z switch
934 when 'Z' =>
935 Ptr := Ptr + 1;
936 Osint.Fail
937 ("-gnatZ is no longer supported: consider using --RTS=zcx");
939 -- Processing for 83 switch
941 when '8' =>
942 if Ptr = Max then
943 Bad_Switch ("-gnat8");
944 end if;
946 Ptr := Ptr + 1;
948 if Switch_Chars (Ptr) /= '3' then
949 Bad_Switch ("-gnat8" & Switch_Chars (Ptr .. Max));
950 else
951 Ptr := Ptr + 1;
952 Ada_Version := Ada_83;
953 Ada_Version_Explicit := Ada_Version;
954 end if;
956 -- Processing for 95 switch
958 when '9' =>
959 if Ptr = Max then
960 Bad_Switch ("-gnat9");
961 end if;
963 Ptr := Ptr + 1;
965 if Switch_Chars (Ptr) /= '5' then
966 Bad_Switch ("-gnat9" & Switch_Chars (Ptr .. Max));
967 else
968 Ptr := Ptr + 1;
969 Ada_Version := Ada_95;
970 Ada_Version_Explicit := Ada_Version;
971 end if;
973 -- Processing for 05 switch
975 when '0' =>
976 if Ptr = Max then
977 Bad_Switch ("-gnat0");
978 end if;
980 Ptr := Ptr + 1;
982 if Switch_Chars (Ptr) /= '5' then
983 Bad_Switch ("-gnat0" & Switch_Chars (Ptr .. Max));
984 else
985 Ptr := Ptr + 1;
986 Ada_Version := Ada_05;
987 Ada_Version_Explicit := Ada_Version;
988 end if;
990 -- Ignore extra switch character
992 when '/' | '-' =>
993 Ptr := Ptr + 1;
995 -- Anything else is an error (illegal switch character)
997 when others =>
998 Bad_Switch ("-gnat" & Switch_Chars (Ptr .. Max));
999 end case;
1001 if Store_Switch then
1002 Store_Compilation_Switch
1003 ("-gnat" & Switch_Chars (First_Char .. Ptr - 1));
1004 end if;
1006 First_Switch := False;
1007 end loop;
1008 end if;
1009 end Scan_Front_End_Switches;
1011 end Switch.C;