fixing pr42337
[official-gcc.git] / gcc / ada / switch-c.adb
blob9ccba42377db849f732d474d94f9e724a4752d0e
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-2009, 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 ("--RTS cannot be specified multiple times");
137 end if;
139 -- Valid --RTS switch
141 Opt.No_Stdinc := True;
142 Opt.RTS_Switch := True;
144 RTS_Src_Path_Name :=
145 Get_RTS_Search_Dir
146 (Switch_Chars (Ptr + 4 .. Max), Include);
148 RTS_Lib_Path_Name :=
149 Get_RTS_Search_Dir
150 (Switch_Chars (Ptr + 4 .. Max), Objects);
152 if RTS_Src_Path_Name /= null
153 and then RTS_Lib_Path_Name /= null
154 then
155 -- Store the -fRTS switch (Note: Store_Compilation_Switch
156 -- changes -fRTS back into --RTS for the actual output).
158 Store_Compilation_Switch (Switch_Chars);
160 elsif RTS_Src_Path_Name = null
161 and then RTS_Lib_Path_Name = null
162 then
163 Osint.Fail ("RTS path not valid: missing " &
164 "adainclude and adalib directories");
166 elsif RTS_Src_Path_Name = null then
167 Osint.Fail ("RTS path not valid: missing " &
168 "adainclude directory");
170 elsif RTS_Lib_Path_Name = null then
171 Osint.Fail ("RTS path not valid: missing " &
172 "adalib directory");
173 end if;
174 end if;
176 -- There are no other switches not starting with -gnat
178 else
179 Bad_Switch (Switch_Chars);
180 end if;
182 -- Case of switch starting with -gnat
184 else
185 Ptr := Ptr + 4;
187 -- Loop to scan through switches given in switch string
189 while Ptr <= Max loop
190 First_Char := Ptr;
191 Store_Switch := True;
193 C := Switch_Chars (Ptr);
195 case C is
197 when 'a' =>
198 Ptr := Ptr + 1;
199 Assertions_Enabled := True;
200 Debug_Pragmas_Enabled := True;
202 -- Processing for A switch
204 when 'A' =>
205 Ptr := Ptr + 1;
206 Config_File := False;
208 -- Processing for b switch
210 when 'b' =>
211 Ptr := Ptr + 1;
212 Brief_Output := True;
214 -- Processing for B switch
216 when 'B' =>
217 Ptr := Ptr + 1;
218 Assume_No_Invalid_Values := True;
220 -- Processing for c switch
222 when 'c' =>
223 if not First_Switch then
224 Osint.Fail
225 ("-gnatc must be first if combined with other switches");
226 end if;
228 Ptr := Ptr + 1;
229 Operating_Mode := Check_Semantics;
231 -- Processing for C switch
233 when 'C' =>
234 Ptr := Ptr + 1;
235 CodePeer_Mode := True;
237 -- Processing for d switch
239 when 'd' =>
240 Store_Switch := False;
241 Dot := False;
243 -- Note: for the debug switch, the remaining characters in this
244 -- switch field must all be debug flags, since all valid switch
245 -- characters are also valid debug characters.
247 -- Loop to scan out debug flags
249 while Ptr < Max loop
250 Ptr := Ptr + 1;
251 C := Switch_Chars (Ptr);
252 exit when C = ASCII.NUL or else C = '/' or else C = '-';
254 if C in '1' .. '9' or else
255 C in 'a' .. 'z' or else
256 C in 'A' .. 'Z'
257 then
258 if Dot then
259 Set_Dotted_Debug_Flag (C);
260 Store_Compilation_Switch ("-gnatd." & C);
261 else
262 Set_Debug_Flag (C);
263 Store_Compilation_Switch ("-gnatd" & C);
264 end if;
266 elsif C = '.' then
267 Dot := True;
269 elsif Dot then
270 Bad_Switch ("-gnatd." & Switch_Chars (Ptr .. Max));
271 else
272 Bad_Switch ("-gnatd" & Switch_Chars (Ptr .. Max));
273 end if;
274 end loop;
276 return;
278 -- Processing for D switch
280 when 'D' =>
281 Ptr := Ptr + 1;
283 -- Scan optional integer line limit value
285 if Nat_Present (Switch_Chars, Max, Ptr) then
286 Scan_Nat (Switch_Chars, Max, Ptr, Sprint_Line_Limit, 'D');
287 Sprint_Line_Limit := Nat'Max (Sprint_Line_Limit, 40);
288 end if;
290 -- Note: -gnatD also sets -gnatx (to turn off cross-reference
291 -- generation in the ali file) since otherwise this generation
292 -- gets confused by the "wrong" Sloc values put in the tree.
294 Debug_Generated_Code := True;
295 Xref_Active := False;
296 Set_Debug_Flag ('g');
298 -- -gnate? (extended switches)
300 when 'e' =>
301 Ptr := Ptr + 1;
303 -- The -gnate? switches are all double character switches
304 -- so we must always have a character after the e.
306 if Ptr > Max then
307 Bad_Switch ("-gnate");
308 end if;
310 case Switch_Chars (Ptr) is
312 -- -gnatea (initial delimiter of explicit switches)
314 -- All switches that come before -gnatea have been added by
315 -- the GCC driver and are not stored in the ALI file.
316 -- See also -gnatez below.
318 when 'a' =>
319 Store_Switch := False;
320 Enable_Switch_Storing;
321 Ptr := Ptr + 1;
323 -- -gnatec (configuration pragmas)
325 when 'c' =>
326 Store_Switch := False;
327 Ptr := Ptr + 1;
329 -- There may be an equal sign between -gnatec and
330 -- the path name of the config file.
332 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
333 Ptr := Ptr + 1;
334 end if;
336 if Ptr > Max then
337 Bad_Switch ("-gnatec");
338 end if;
340 declare
341 Config_File_Name : constant String_Access :=
342 new String'
343 (Switch_Chars (Ptr .. Max));
345 begin
346 if Config_File_Names = null then
347 Config_File_Names :=
348 new String_List'(1 => Config_File_Name);
350 else
351 declare
352 New_Names : constant String_List_Access :=
353 new String_List
354 (1 ..
355 Config_File_Names'Length + 1);
357 begin
358 for Index in Config_File_Names'Range loop
359 New_Names (Index) :=
360 Config_File_Names (Index);
361 Config_File_Names (Index) := null;
362 end loop;
364 New_Names (New_Names'Last) := Config_File_Name;
365 Free (Config_File_Names);
366 Config_File_Names := New_Names;
367 end;
368 end if;
369 end;
371 return;
373 -- -gnateC switch (CodePeer SCIL generation)
375 -- Not enabled for now, keep it for later???
376 -- use -gnatd.I only for now
378 -- when 'C' =>
379 -- Ptr := Ptr + 1;
380 -- Generate_SCIL := True;
382 -- -gnateD switch (preprocessing symbol definition)
384 when 'D' =>
385 Store_Switch := False;
386 Ptr := Ptr + 1;
388 if Ptr > Max then
389 Bad_Switch ("-gnateD");
390 end if;
392 Add_Symbol_Definition (Switch_Chars (Ptr .. Max));
394 -- Store the switch
396 Store_Compilation_Switch
397 ("-gnateD" & Switch_Chars (Ptr .. Max));
398 Ptr := Max + 1;
400 -- -gnatef (full source path for brief error messages)
402 when 'f' =>
403 Store_Switch := False;
404 Ptr := Ptr + 1;
405 Full_Path_Name_For_Brief_Errors := True;
406 return;
408 -- -gnateG (save preprocessor output)
410 when 'G' =>
411 if Ptr < Max then
412 Bad_Switch (Switch_Chars);
413 end if;
415 Generate_Processed_File := True;
416 Ptr := Ptr + 1;
418 -- -gnateI (index of unit in multi-unit source)
420 when 'I' =>
421 Ptr := Ptr + 1;
422 Scan_Pos (Switch_Chars, Max, Ptr, Multiple_Unit_Index, C);
424 -- -gnatem (mapping file)
426 when 'm' =>
427 Store_Switch := False;
428 Ptr := Ptr + 1;
430 -- There may be an equal sign between -gnatem and
431 -- the path name of the mapping file.
433 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
434 Ptr := Ptr + 1;
435 end if;
437 if Ptr > Max then
438 Bad_Switch ("-gnatem");
439 end if;
441 Mapping_File_Name :=
442 new String'(Switch_Chars (Ptr .. Max));
443 return;
445 -- -gnatep (preprocessing data file)
447 when 'p' =>
448 Store_Switch := False;
449 Ptr := Ptr + 1;
451 -- There may be an equal sign between -gnatep and
452 -- the path name of the mapping file.
454 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
455 Ptr := Ptr + 1;
456 end if;
458 if Ptr > Max then
459 Bad_Switch ("-gnatep");
460 end if;
462 Preprocessing_Data_File :=
463 new String'(Switch_Chars (Ptr .. Max));
465 -- Store the switch, normalizing to -gnatep=
467 Store_Compilation_Switch
468 ("-gnatep=" & Preprocessing_Data_File.all);
470 Ptr := Max + 1;
472 -- -gnatez (final delimiter of explicit switches)
474 -- All switches that come after -gnatez have been added by
475 -- the GCC driver and are not stored in the ALI file. See
476 -- also -gnatea above.
478 when 'z' =>
479 Store_Switch := False;
480 Disable_Switch_Storing;
481 Ptr := Ptr + 1;
483 -- -gnateS (generate SCO information)
485 -- Include Source Coverage Obligation information in ALI
486 -- files for the benefit of source coverage analysis tools
487 -- (xcov).
489 when 'S' =>
490 Generate_SCO := True;
491 Ptr := Ptr + 1;
493 -- All other -gnate? switches are unassigned
495 when others =>
496 Bad_Switch ("-gnate" & Switch_Chars (Ptr .. Max));
497 end case;
499 -- -gnatE (dynamic elaboration checks)
501 when 'E' =>
502 Ptr := Ptr + 1;
503 Dynamic_Elaboration_Checks := True;
505 -- -gnatf (full error messages)
507 when 'f' =>
508 Ptr := Ptr + 1;
509 All_Errors_Mode := True;
511 -- Processing for F switch
513 when 'F' =>
514 Ptr := Ptr + 1;
515 External_Name_Exp_Casing := Uppercase;
516 External_Name_Imp_Casing := Uppercase;
518 -- Processing for g switch
520 when 'g' =>
521 Ptr := Ptr + 1;
522 GNAT_Mode := True;
523 Identifier_Character_Set := 'n';
524 System_Extend_Unit := Empty;
525 Warning_Mode := Treat_As_Error;
527 -- Set Ada 2005 mode explicitly. We don't want to rely on the
528 -- implicit setting here, since for example, we want
529 -- Preelaborate_05 treated as Preelaborate
531 Ada_Version := Ada_05;
532 Ada_Version_Explicit := Ada_Version;
534 -- Set default warnings and style checks for -gnatg
536 Set_GNAT_Mode_Warnings;
537 Set_GNAT_Style_Check_Options;
539 -- Processing for G switch
541 when 'G' =>
542 Ptr := Ptr + 1;
543 Print_Generated_Code := True;
545 -- Scan optional integer line limit value
547 if Nat_Present (Switch_Chars, Max, Ptr) then
548 Scan_Nat (Switch_Chars, Max, Ptr, Sprint_Line_Limit, 'G');
549 Sprint_Line_Limit := Nat'Max (Sprint_Line_Limit, 40);
550 end if;
552 -- Processing for h switch
554 when 'h' =>
555 Ptr := Ptr + 1;
556 Usage_Requested := True;
558 -- Processing for H switch
560 when 'H' =>
561 Ptr := Ptr + 1;
562 HLO_Active := True;
564 -- Processing for i switch
566 when 'i' =>
567 if Ptr = Max then
568 Bad_Switch ("-gnati");
569 end if;
571 Ptr := Ptr + 1;
572 C := Switch_Chars (Ptr);
574 if C in '1' .. '5'
575 or else C = '8'
576 or else C = '9'
577 or else C = 'p'
578 or else C = 'f'
579 or else C = 'n'
580 or else C = 'w'
581 then
582 Identifier_Character_Set := C;
583 Ptr := Ptr + 1;
585 else
586 Bad_Switch ("-gnati" & Switch_Chars (Ptr .. Max));
587 end if;
589 -- Processing for I switch
591 when 'I' =>
592 Ptr := Ptr + 1;
593 Ignore_Rep_Clauses := True;
595 -- Processing for j switch
597 when 'j' =>
598 Ptr := Ptr + 1;
599 Scan_Nat (Switch_Chars, Max, Ptr, Error_Msg_Line_Length, C);
601 -- Processing for k switch
603 when 'k' =>
604 Ptr := Ptr + 1;
605 Scan_Pos
606 (Switch_Chars, Max, Ptr, Maximum_File_Name_Length, C);
608 -- Processing for l switch
610 when 'l' =>
611 Ptr := Ptr + 1;
612 Full_List := True;
614 -- There may be an equal sign between -gnatl and a file name
616 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
617 if Ptr = Max then
618 Osint.Fail ("file name for -gnatl= is null");
619 else
620 Opt.Full_List_File_Name :=
621 new String'(Switch_Chars (Ptr + 1 .. Max));
622 Ptr := Max + 1;
623 end if;
624 end if;
626 -- Processing for L switch
628 when 'L' =>
629 Ptr := Ptr + 1;
630 Dump_Source_Text := True;
632 -- Processing for m switch
634 when 'm' =>
635 Ptr := Ptr + 1;
636 Scan_Nat (Switch_Chars, Max, Ptr, Maximum_Messages, C);
638 -- Processing for n switch
640 when 'n' =>
641 Ptr := Ptr + 1;
642 Inline_Active := True;
644 -- Processing for N switch
646 when 'N' =>
647 Ptr := Ptr + 1;
648 Inline_Active := True;
649 Front_End_Inlining := True;
651 -- Processing for o switch
653 when 'o' =>
654 Ptr := Ptr + 1;
655 Suppress_Options (Overflow_Check) := False;
656 Opt.Enable_Overflow_Checks := True;
658 -- Processing for O switch
660 when 'O' =>
661 Store_Switch := False;
662 Ptr := Ptr + 1;
663 Output_File_Name_Present := True;
665 -- Processing for p switch
667 when 'p' =>
668 Ptr := Ptr + 1;
670 -- Set all specific options as well as All_Checks in the
671 -- Suppress_Options array, excluding Elaboration_Check, since
672 -- this is treated specially because we do not want -gnatp to
673 -- disable static elaboration processing.
675 for J in Suppress_Options'Range loop
676 if J /= Elaboration_Check then
677 Suppress_Options (J) := True;
678 end if;
679 end loop;
681 Validity_Checks_On := False;
682 Opt.Suppress_Checks := True;
683 Opt.Enable_Overflow_Checks := False;
685 -- Processing for P switch
687 when 'P' =>
688 Ptr := Ptr + 1;
689 Polling_Required := True;
691 -- Processing for q switch
693 when 'q' =>
694 Ptr := Ptr + 1;
695 Try_Semantics := True;
697 -- Processing for Q switch
699 when 'Q' =>
700 Ptr := Ptr + 1;
701 Force_ALI_Tree_File := True;
702 Try_Semantics := True;
704 -- Processing for r switch
706 when 'r' =>
707 Ptr := Ptr + 1;
708 Treat_Restrictions_As_Warnings := True;
710 -- Processing for R switch
712 when 'R' =>
713 Back_Annotate_Rep_Info := True;
714 List_Representation_Info := 1;
716 Ptr := Ptr + 1;
717 while Ptr <= Max loop
718 C := Switch_Chars (Ptr);
720 if C in '1' .. '3' then
721 List_Representation_Info :=
722 Character'Pos (C) - Character'Pos ('0');
724 elsif Switch_Chars (Ptr) = 's' then
725 List_Representation_Info_To_File := True;
727 elsif Switch_Chars (Ptr) = 'm' then
728 List_Representation_Info_Mechanisms := True;
730 else
731 Bad_Switch ("-gnatR" & Switch_Chars (Ptr .. Max));
732 end if;
734 Ptr := Ptr + 1;
735 end loop;
737 -- Processing for s switch
739 when 's' =>
740 if not First_Switch then
741 Osint.Fail
742 ("-gnats must be first if combined with other switches");
743 end if;
745 Ptr := Ptr + 1;
746 Operating_Mode := Check_Syntax;
748 -- Processing for S switch
750 when 'S' =>
751 Print_Standard := True;
752 Ptr := Ptr + 1;
754 -- Processing for t switch
756 when 't' =>
757 Ptr := Ptr + 1;
758 Tree_Output := True;
759 Back_Annotate_Rep_Info := True;
761 -- Processing for T switch
763 when 'T' =>
764 Ptr := Ptr + 1;
765 Scan_Pos (Switch_Chars, Max, Ptr, Table_Factor, C);
767 -- Processing for u switch
769 when 'u' =>
770 Ptr := Ptr + 1;
771 List_Units := True;
773 -- Processing for U switch
775 when 'U' =>
776 Ptr := Ptr + 1;
777 Unique_Error_Tag := True;
779 -- Processing for v switch
781 when 'v' =>
782 Ptr := Ptr + 1;
783 Verbose_Mode := True;
785 -- Processing for V switch
787 when 'V' =>
788 Store_Switch := False;
789 Ptr := Ptr + 1;
791 if Ptr > Max then
792 Bad_Switch ("-gnatV");
794 else
795 declare
796 OK : Boolean;
798 begin
799 Set_Validity_Check_Options
800 (Switch_Chars (Ptr .. Max), OK, Ptr);
802 if not OK then
803 Bad_Switch ("-gnatV" & Switch_Chars (Ptr .. Max));
804 end if;
806 for Index in First_Char + 1 .. Max loop
807 Store_Compilation_Switch
808 ("-gnatV" & Switch_Chars (Index));
809 end loop;
810 end;
811 end if;
813 Ptr := Max + 1;
815 -- Processing for w switch
817 when 'w' =>
818 Store_Switch := False;
819 Ptr := Ptr + 1;
821 if Ptr > Max then
822 Bad_Switch ("-gnatw");
823 end if;
825 while Ptr <= Max loop
826 C := Switch_Chars (Ptr);
828 -- Case of dot switch
830 if C = '.' and then Ptr < Max then
831 Ptr := Ptr + 1;
832 C := Switch_Chars (Ptr);
834 if Set_Dot_Warning_Switch (C) then
835 Store_Compilation_Switch ("-gnatw." & C);
836 else
837 Bad_Switch ("-gnatw." & Switch_Chars (Ptr .. Max));
838 end if;
840 -- Normal case, no dot
842 else
843 if Set_Warning_Switch (C) then
844 Store_Compilation_Switch ("-gnatw" & C);
845 else
846 Bad_Switch ("-gnatw" & Switch_Chars (Ptr .. Max));
847 end if;
848 end if;
850 Ptr := Ptr + 1;
851 end loop;
853 return;
855 -- Processing for W switch
857 when 'W' =>
858 Ptr := Ptr + 1;
860 if Ptr > Max then
861 Bad_Switch ("-gnatW");
862 end if;
864 begin
865 Wide_Character_Encoding_Method :=
866 Get_WC_Encoding_Method (Switch_Chars (Ptr));
867 exception
868 when Constraint_Error =>
869 Bad_Switch ("-gnatW" & Switch_Chars (Ptr .. Max));
870 end;
872 Wide_Character_Encoding_Method_Specified := True;
874 Upper_Half_Encoding :=
875 Wide_Character_Encoding_Method in
876 WC_Upper_Half_Encoding_Method;
878 Ptr := Ptr + 1;
880 -- Processing for x switch
882 when 'x' =>
883 Ptr := Ptr + 1;
884 Xref_Active := False;
886 -- Processing for X switch
888 when 'X' =>
889 Ptr := Ptr + 1;
890 Extensions_Allowed := True;
892 -- Processing for y switch
894 when 'y' =>
895 Ptr := Ptr + 1;
897 if Ptr > Max then
898 Set_Default_Style_Check_Options;
900 else
901 Store_Switch := False;
903 declare
904 OK : Boolean;
906 begin
907 Set_Style_Check_Options
908 (Switch_Chars (Ptr .. Max), OK, Ptr);
910 if not OK then
911 Osint.Fail
912 ("bad -gnaty switch (" &
913 Style_Msg_Buf (1 .. Style_Msg_Len) & ')');
914 end if;
916 Ptr := First_Char + 1;
917 while Ptr <= Max loop
918 if Switch_Chars (Ptr) = 'M' then
919 First_Char := Ptr;
920 loop
921 Ptr := Ptr + 1;
922 exit when Ptr > Max
923 or else Switch_Chars (Ptr) not in '0' .. '9';
924 end loop;
926 Store_Compilation_Switch
927 ("-gnaty" & Switch_Chars (First_Char .. Ptr - 1));
929 else
930 Store_Compilation_Switch
931 ("-gnaty" & Switch_Chars (Ptr));
932 Ptr := Ptr + 1;
933 end if;
934 end loop;
935 end;
936 end if;
938 -- Processing for z switch
940 when 'z' =>
941 Ptr := Ptr + 1;
943 -- Allowed for compiler only if this is the only
944 -- -z switch, we do not allow multiple occurrences
946 if Distribution_Stub_Mode = No_Stubs then
947 case Switch_Chars (Ptr) is
948 when 'r' =>
949 Distribution_Stub_Mode := Generate_Receiver_Stub_Body;
951 when 'c' =>
952 Distribution_Stub_Mode := Generate_Caller_Stub_Body;
954 when others =>
955 Bad_Switch ("-gnatz" & Switch_Chars (Ptr .. Max));
956 end case;
958 Ptr := Ptr + 1;
959 end if;
961 -- Processing for Z switch
963 when 'Z' =>
964 Ptr := Ptr + 1;
965 Osint.Fail
966 ("-gnatZ is no longer supported: consider using --RTS=zcx");
968 -- Processing for 83 switch
970 when '8' =>
971 if Ptr = Max then
972 Bad_Switch ("-gnat8");
973 end if;
975 Ptr := Ptr + 1;
977 if Switch_Chars (Ptr) /= '3' then
978 Bad_Switch ("-gnat8" & Switch_Chars (Ptr .. Max));
979 else
980 Ptr := Ptr + 1;
981 Ada_Version := Ada_83;
982 Ada_Version_Explicit := Ada_Version;
983 end if;
985 -- Processing for 95 switch
987 when '9' =>
988 if Ptr = Max then
989 Bad_Switch ("-gnat9");
990 end if;
992 Ptr := Ptr + 1;
994 if Switch_Chars (Ptr) /= '5' then
995 Bad_Switch ("-gnat9" & Switch_Chars (Ptr .. Max));
996 else
997 Ptr := Ptr + 1;
998 Ada_Version := Ada_95;
999 Ada_Version_Explicit := Ada_Version;
1000 end if;
1002 -- Processing for 05 switch
1004 when '0' =>
1005 if Ptr = Max then
1006 Bad_Switch ("-gnat0");
1007 end if;
1009 Ptr := Ptr + 1;
1011 if Switch_Chars (Ptr) /= '5' then
1012 Bad_Switch ("-gnat0" & Switch_Chars (Ptr .. Max));
1013 else
1014 Ptr := Ptr + 1;
1015 Ada_Version := Ada_05;
1016 Ada_Version_Explicit := Ada_Version;
1017 end if;
1019 -- Ignore extra switch character
1021 when '/' | '-' =>
1022 Ptr := Ptr + 1;
1024 -- Anything else is an error (illegal switch character)
1026 when others =>
1027 Bad_Switch ("-gnat" & Switch_Chars (Ptr .. Max));
1028 end case;
1030 if Store_Switch then
1031 Store_Compilation_Switch
1032 ("-gnat" & Switch_Chars (First_Char .. Ptr - 1));
1033 end if;
1035 First_Switch := False;
1036 end loop;
1037 end if;
1038 end Scan_Front_End_Switches;
1040 end Switch.C;