Merged revision 156805 into branch.
[official-gcc.git] / gcc / ada / switch-c.adb
blob7b194107ff619569d25e13ae70aee1e78b0a7c0d
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;
407 -- -gnateG (save preprocessor output)
409 when 'G' =>
410 Generate_Processed_File := True;
411 Ptr := Ptr + 1;
413 -- -gnateI (index of unit in multi-unit source)
415 when 'I' =>
416 Ptr := Ptr + 1;
417 Scan_Pos (Switch_Chars, Max, Ptr, Multiple_Unit_Index, C);
419 -- -gnatem (mapping file)
421 when 'm' =>
422 Store_Switch := False;
423 Ptr := Ptr + 1;
425 -- There may be an equal sign between -gnatem and
426 -- the path name of the mapping file.
428 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
429 Ptr := Ptr + 1;
430 end if;
432 if Ptr > Max then
433 Bad_Switch ("-gnatem");
434 end if;
436 Mapping_File_Name :=
437 new String'(Switch_Chars (Ptr .. Max));
438 return;
440 -- -gnatep (preprocessing data file)
442 when 'p' =>
443 Store_Switch := False;
444 Ptr := Ptr + 1;
446 -- There may be an equal sign between -gnatep and
447 -- the path name of the mapping file.
449 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
450 Ptr := Ptr + 1;
451 end if;
453 if Ptr > Max then
454 Bad_Switch ("-gnatep");
455 end if;
457 Preprocessing_Data_File :=
458 new String'(Switch_Chars (Ptr .. Max));
460 -- Store the switch, normalizing to -gnatep=
462 Store_Compilation_Switch
463 ("-gnatep=" & Preprocessing_Data_File.all);
465 Ptr := Max + 1;
467 -- -gnatez (final delimiter of explicit switches)
469 -- All switches that come after -gnatez have been added by
470 -- the GCC driver and are not stored in the ALI file. See
471 -- also -gnatea above.
473 when 'z' =>
474 Store_Switch := False;
475 Disable_Switch_Storing;
476 Ptr := Ptr + 1;
478 -- -gnateS (generate SCO information)
480 -- Include Source Coverage Obligation information in ALI
481 -- files for the benefit of source coverage analysis tools
482 -- (xcov).
484 when 'S' =>
485 Generate_SCO := True;
486 Ptr := Ptr + 1;
488 -- All other -gnate? switches are unassigned
490 when others =>
491 Bad_Switch ("-gnate" & Switch_Chars (Ptr .. Max));
492 end case;
494 -- -gnatE (dynamic elaboration checks)
496 when 'E' =>
497 Ptr := Ptr + 1;
498 Dynamic_Elaboration_Checks := True;
500 -- -gnatf (full error messages)
502 when 'f' =>
503 Ptr := Ptr + 1;
504 All_Errors_Mode := True;
506 -- Processing for F switch
508 when 'F' =>
509 Ptr := Ptr + 1;
510 External_Name_Exp_Casing := Uppercase;
511 External_Name_Imp_Casing := Uppercase;
513 -- Processing for g switch
515 when 'g' =>
516 Ptr := Ptr + 1;
517 GNAT_Mode := True;
518 Identifier_Character_Set := 'n';
519 System_Extend_Unit := Empty;
520 Warning_Mode := Treat_As_Error;
522 -- Set Ada 2005 mode explicitly. We don't want to rely on the
523 -- implicit setting here, since for example, we want
524 -- Preelaborate_05 treated as Preelaborate
526 Ada_Version := Ada_05;
527 Ada_Version_Explicit := Ada_Version;
529 -- Set default warnings and style checks for -gnatg
531 Set_GNAT_Mode_Warnings;
532 Set_GNAT_Style_Check_Options;
534 -- Processing for G switch
536 when 'G' =>
537 Ptr := Ptr + 1;
538 Print_Generated_Code := True;
540 -- Scan optional integer line limit value
542 if Nat_Present (Switch_Chars, Max, Ptr) then
543 Scan_Nat (Switch_Chars, Max, Ptr, Sprint_Line_Limit, 'G');
544 Sprint_Line_Limit := Nat'Max (Sprint_Line_Limit, 40);
545 end if;
547 -- Processing for h switch
549 when 'h' =>
550 Ptr := Ptr + 1;
551 Usage_Requested := True;
553 -- Processing for H switch
555 when 'H' =>
556 Ptr := Ptr + 1;
557 HLO_Active := True;
559 -- Processing for i switch
561 when 'i' =>
562 if Ptr = Max then
563 Bad_Switch ("-gnati");
564 end if;
566 Ptr := Ptr + 1;
567 C := Switch_Chars (Ptr);
569 if C in '1' .. '5'
570 or else C = '8'
571 or else C = '9'
572 or else C = 'p'
573 or else C = 'f'
574 or else C = 'n'
575 or else C = 'w'
576 then
577 Identifier_Character_Set := C;
578 Ptr := Ptr + 1;
580 else
581 Bad_Switch ("-gnati" & Switch_Chars (Ptr .. Max));
582 end if;
584 -- Processing for I switch
586 when 'I' =>
587 Ptr := Ptr + 1;
588 Ignore_Rep_Clauses := True;
590 -- Processing for j switch
592 when 'j' =>
593 Ptr := Ptr + 1;
594 Scan_Nat (Switch_Chars, Max, Ptr, Error_Msg_Line_Length, C);
596 -- Processing for k switch
598 when 'k' =>
599 Ptr := Ptr + 1;
600 Scan_Pos
601 (Switch_Chars, Max, Ptr, Maximum_File_Name_Length, C);
603 -- Processing for l switch
605 when 'l' =>
606 Ptr := Ptr + 1;
607 Full_List := True;
609 -- There may be an equal sign between -gnatl and a file name
611 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
612 if Ptr = Max then
613 Osint.Fail ("file name for -gnatl= is null");
614 else
615 Opt.Full_List_File_Name :=
616 new String'(Switch_Chars (Ptr + 1 .. Max));
617 Ptr := Max + 1;
618 end if;
619 end if;
621 -- Processing for L switch
623 when 'L' =>
624 Ptr := Ptr + 1;
625 Dump_Source_Text := True;
627 -- Processing for m switch
629 when 'm' =>
630 Ptr := Ptr + 1;
631 Scan_Nat (Switch_Chars, Max, Ptr, Maximum_Messages, C);
633 -- Processing for n switch
635 when 'n' =>
636 Ptr := Ptr + 1;
637 Inline_Active := True;
639 -- Processing for N switch
641 when 'N' =>
642 Ptr := Ptr + 1;
643 Inline_Active := True;
644 Front_End_Inlining := True;
646 -- Processing for o switch
648 when 'o' =>
649 Ptr := Ptr + 1;
650 Suppress_Options (Overflow_Check) := False;
651 Opt.Enable_Overflow_Checks := True;
653 -- Processing for O switch
655 when 'O' =>
656 Store_Switch := False;
657 Ptr := Ptr + 1;
658 Output_File_Name_Present := True;
660 -- Processing for p switch
662 when 'p' =>
663 Ptr := Ptr + 1;
665 -- Set all specific options as well as All_Checks in the
666 -- Suppress_Options array, excluding Elaboration_Check, since
667 -- this is treated specially because we do not want -gnatp to
668 -- disable static elaboration processing.
670 for J in Suppress_Options'Range loop
671 if J /= Elaboration_Check then
672 Suppress_Options (J) := True;
673 end if;
674 end loop;
676 Validity_Checks_On := False;
677 Opt.Suppress_Checks := True;
678 Opt.Enable_Overflow_Checks := False;
680 -- Processing for P switch
682 when 'P' =>
683 Ptr := Ptr + 1;
684 Polling_Required := True;
686 -- Processing for q switch
688 when 'q' =>
689 Ptr := Ptr + 1;
690 Try_Semantics := True;
692 -- Processing for Q switch
694 when 'Q' =>
695 Ptr := Ptr + 1;
696 Force_ALI_Tree_File := True;
697 Try_Semantics := True;
699 -- Processing for r switch
701 when 'r' =>
702 Ptr := Ptr + 1;
703 Treat_Restrictions_As_Warnings := True;
705 -- Processing for R switch
707 when 'R' =>
708 Back_Annotate_Rep_Info := True;
709 List_Representation_Info := 1;
711 Ptr := Ptr + 1;
712 while Ptr <= Max loop
713 C := Switch_Chars (Ptr);
715 if C in '1' .. '3' then
716 List_Representation_Info :=
717 Character'Pos (C) - Character'Pos ('0');
719 elsif Switch_Chars (Ptr) = 's' then
720 List_Representation_Info_To_File := True;
722 elsif Switch_Chars (Ptr) = 'm' then
723 List_Representation_Info_Mechanisms := True;
725 else
726 Bad_Switch ("-gnatR" & Switch_Chars (Ptr .. Max));
727 end if;
729 Ptr := Ptr + 1;
730 end loop;
732 -- Processing for s switch
734 when 's' =>
735 if not First_Switch then
736 Osint.Fail
737 ("-gnats must be first if combined with other switches");
738 end if;
740 Ptr := Ptr + 1;
741 Operating_Mode := Check_Syntax;
743 -- Processing for S switch
745 when 'S' =>
746 Print_Standard := True;
747 Ptr := Ptr + 1;
749 -- Processing for t switch
751 when 't' =>
752 Ptr := Ptr + 1;
753 Tree_Output := True;
754 Back_Annotate_Rep_Info := True;
756 -- Processing for T switch
758 when 'T' =>
759 Ptr := Ptr + 1;
760 Scan_Pos (Switch_Chars, Max, Ptr, Table_Factor, C);
762 -- Processing for u switch
764 when 'u' =>
765 Ptr := Ptr + 1;
766 List_Units := True;
768 -- Processing for U switch
770 when 'U' =>
771 Ptr := Ptr + 1;
772 Unique_Error_Tag := True;
774 -- Processing for v switch
776 when 'v' =>
777 Ptr := Ptr + 1;
778 Verbose_Mode := True;
780 -- Processing for V switch
782 when 'V' =>
783 Store_Switch := False;
784 Ptr := Ptr + 1;
786 if Ptr > Max then
787 Bad_Switch ("-gnatV");
789 else
790 declare
791 OK : Boolean;
793 begin
794 Set_Validity_Check_Options
795 (Switch_Chars (Ptr .. Max), OK, Ptr);
797 if not OK then
798 Bad_Switch ("-gnatV" & Switch_Chars (Ptr .. Max));
799 end if;
801 for Index in First_Char + 1 .. Max loop
802 Store_Compilation_Switch
803 ("-gnatV" & Switch_Chars (Index));
804 end loop;
805 end;
806 end if;
808 Ptr := Max + 1;
810 -- Processing for w switch
812 when 'w' =>
813 Store_Switch := False;
814 Ptr := Ptr + 1;
816 if Ptr > Max then
817 Bad_Switch ("-gnatw");
818 end if;
820 while Ptr <= Max loop
821 C := Switch_Chars (Ptr);
823 -- Case of dot switch
825 if C = '.' and then Ptr < Max then
826 Ptr := Ptr + 1;
827 C := Switch_Chars (Ptr);
829 if Set_Dot_Warning_Switch (C) then
830 Store_Compilation_Switch ("-gnatw." & C);
831 else
832 Bad_Switch ("-gnatw." & Switch_Chars (Ptr .. Max));
833 end if;
835 -- Normal case, no dot
837 else
838 if Set_Warning_Switch (C) then
839 Store_Compilation_Switch ("-gnatw" & C);
840 else
841 Bad_Switch ("-gnatw" & Switch_Chars (Ptr .. Max));
842 end if;
843 end if;
845 Ptr := Ptr + 1;
846 end loop;
848 return;
850 -- Processing for W switch
852 when 'W' =>
853 Ptr := Ptr + 1;
855 if Ptr > Max then
856 Bad_Switch ("-gnatW");
857 end if;
859 begin
860 Wide_Character_Encoding_Method :=
861 Get_WC_Encoding_Method (Switch_Chars (Ptr));
862 exception
863 when Constraint_Error =>
864 Bad_Switch ("-gnatW" & Switch_Chars (Ptr .. Max));
865 end;
867 Wide_Character_Encoding_Method_Specified := True;
869 Upper_Half_Encoding :=
870 Wide_Character_Encoding_Method in
871 WC_Upper_Half_Encoding_Method;
873 Ptr := Ptr + 1;
875 -- Processing for x switch
877 when 'x' =>
878 Ptr := Ptr + 1;
879 Xref_Active := False;
881 -- Processing for X switch
883 when 'X' =>
884 Ptr := Ptr + 1;
885 Extensions_Allowed := True;
887 -- Processing for y switch
889 when 'y' =>
890 Ptr := Ptr + 1;
892 if Ptr > Max then
893 Set_Default_Style_Check_Options;
895 else
896 Store_Switch := False;
898 declare
899 OK : Boolean;
901 begin
902 Set_Style_Check_Options
903 (Switch_Chars (Ptr .. Max), OK, Ptr);
905 if not OK then
906 Osint.Fail
907 ("bad -gnaty switch (" &
908 Style_Msg_Buf (1 .. Style_Msg_Len) & ')');
909 end if;
911 Ptr := First_Char + 1;
912 while Ptr <= Max loop
913 if Switch_Chars (Ptr) = 'M' then
914 First_Char := Ptr;
915 loop
916 Ptr := Ptr + 1;
917 exit when Ptr > Max
918 or else Switch_Chars (Ptr) not in '0' .. '9';
919 end loop;
921 Store_Compilation_Switch
922 ("-gnaty" & Switch_Chars (First_Char .. Ptr - 1));
924 else
925 Store_Compilation_Switch
926 ("-gnaty" & Switch_Chars (Ptr));
927 Ptr := Ptr + 1;
928 end if;
929 end loop;
930 end;
931 end if;
933 -- Processing for z switch
935 when 'z' =>
936 -- -gnatz must be the first and only switch in Switch_Chars,
937 -- and is a two-letter switch.
939 if Ptr /= Switch_Chars'First + 5
940 or else (Max - Ptr + 1) > 2
941 then
942 Osint.Fail
943 ("-gnatz* may not be combined with other switches");
944 end if;
946 if Ptr = Max then
947 Bad_Switch ("-gnatz");
948 end if;
950 Ptr := Ptr + 1;
952 -- Only one occurrence of -gnat* is permitted
954 if Distribution_Stub_Mode = No_Stubs then
955 case Switch_Chars (Ptr) is
956 when 'r' =>
957 Distribution_Stub_Mode := Generate_Receiver_Stub_Body;
959 when 'c' =>
960 Distribution_Stub_Mode := Generate_Caller_Stub_Body;
962 when others =>
963 Bad_Switch ("-gnatz" & Switch_Chars (Ptr .. Max));
964 end case;
966 Ptr := Ptr + 1;
968 else
969 Osint.Fail ("only one -gnatz* switch allowed");
970 end if;
972 -- Processing for Z switch
974 when 'Z' =>
975 Ptr := Ptr + 1;
976 Osint.Fail
977 ("-gnatZ is no longer supported: consider using --RTS=zcx");
979 -- Processing for 83 switch
981 when '8' =>
982 if Ptr = Max then
983 Bad_Switch ("-gnat8");
984 end if;
986 Ptr := Ptr + 1;
988 if Switch_Chars (Ptr) /= '3' then
989 Bad_Switch ("-gnat8" & Switch_Chars (Ptr .. Max));
990 else
991 Ptr := Ptr + 1;
992 Ada_Version := Ada_83;
993 Ada_Version_Explicit := Ada_Version;
994 end if;
996 -- Processing for 95 switch
998 when '9' =>
999 if Ptr = Max then
1000 Bad_Switch ("-gnat9");
1001 end if;
1003 Ptr := Ptr + 1;
1005 if Switch_Chars (Ptr) /= '5' then
1006 Bad_Switch ("-gnat9" & Switch_Chars (Ptr .. Max));
1007 else
1008 Ptr := Ptr + 1;
1009 Ada_Version := Ada_95;
1010 Ada_Version_Explicit := Ada_Version;
1011 end if;
1013 -- Processing for 05 switch
1015 when '0' =>
1016 if Ptr = Max then
1017 Bad_Switch ("-gnat0");
1018 end if;
1020 Ptr := Ptr + 1;
1022 if Switch_Chars (Ptr) /= '5' then
1023 Bad_Switch ("-gnat0" & Switch_Chars (Ptr .. Max));
1024 else
1025 Ptr := Ptr + 1;
1026 Ada_Version := Ada_05;
1027 Ada_Version_Explicit := Ada_Version;
1028 end if;
1030 -- Ignore extra switch character
1032 when '/' | '-' =>
1033 Ptr := Ptr + 1;
1035 -- Anything else is an error (illegal switch character)
1037 when others =>
1038 Bad_Switch ("-gnat" & Switch_Chars (Ptr .. Max));
1039 end case;
1041 if Store_Switch then
1042 Store_Compilation_Switch
1043 ("-gnat" & Switch_Chars (First_Char .. Ptr - 1));
1044 end if;
1046 First_Switch := False;
1047 end loop;
1048 end if;
1049 end Scan_Front_End_Switches;
1051 end Switch.C;