PR testsuite/39776
[official-gcc.git] / gcc / ada / switch-c.adb
blob28ed6c50c45f788edce9838a7681bd30b9558060
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 ("--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 if Tree_Output then
232 ASIS_Mode := True;
233 Inspector_Mode := False;
234 end if;
236 -- Processing for d switch
238 when 'd' =>
239 Store_Switch := False;
240 Dot := False;
242 -- Note: for the debug switch, the remaining characters in this
243 -- switch field must all be debug flags, since all valid switch
244 -- characters are also valid debug characters.
246 -- Loop to scan out debug flags
248 while Ptr < Max loop
249 Ptr := Ptr + 1;
250 C := Switch_Chars (Ptr);
251 exit when C = ASCII.NUL or else C = '/' or else C = '-';
253 if C in '1' .. '9' or else
254 C in 'a' .. 'z' or else
255 C in 'A' .. 'Z'
256 then
257 if Dot then
258 Set_Dotted_Debug_Flag (C);
259 Store_Compilation_Switch ("-gnatd." & C);
261 -- ??? Change this when we use a non debug flag to
262 -- enable inspector mode.
264 if C = 'I' then
265 if ASIS_Mode then
266 -- Do not enable inspector mode in ASIS mode,
267 -- since the two switches are incompatible.
269 Inspector_Mode := False;
271 else
272 -- In inspector mode, we need back-end rep info
273 -- annotations and disable front-end inlining.
275 Back_Annotate_Rep_Info := True;
276 Front_End_Inlining := False;
277 end if;
278 end if;
279 else
280 Set_Debug_Flag (C);
281 Store_Compilation_Switch ("-gnatd" & C);
282 end if;
284 elsif C = '.' then
285 Dot := True;
287 elsif Dot then
288 Bad_Switch ("-gnatd." & Switch_Chars (Ptr .. Max));
289 else
290 Bad_Switch ("-gnatd" & Switch_Chars (Ptr .. Max));
291 end if;
292 end loop;
294 return;
296 -- Processing for D switch
298 when 'D' =>
299 Ptr := Ptr + 1;
301 -- Scan optional integer line limit value
303 if Nat_Present (Switch_Chars, Max, Ptr) then
304 Scan_Nat (Switch_Chars, Max, Ptr, Sprint_Line_Limit, 'D');
305 Sprint_Line_Limit := Nat'Max (Sprint_Line_Limit, 40);
306 end if;
308 -- Note: -gnatD also sets -gnatx (to turn off cross-reference
309 -- generation in the ali file) since otherwise this generation
310 -- gets confused by the "wrong" Sloc values put in the tree.
312 Debug_Generated_Code := True;
313 Xref_Active := False;
314 Set_Debug_Flag ('g');
316 -- -gnate? (extended switches)
318 when 'e' =>
319 Ptr := Ptr + 1;
321 -- The -gnate? switches are all double character switches
322 -- so we must always have a character after the e.
324 if Ptr > Max then
325 Bad_Switch ("-gnate");
326 end if;
328 case Switch_Chars (Ptr) is
330 when 'a' =>
331 Store_Switch := False;
332 Enable_Switch_Storing;
333 Ptr := Ptr + 1;
335 -- -gnatec (configuration pragmas)
337 when 'c' =>
338 Store_Switch := False;
339 Ptr := Ptr + 1;
341 -- There may be an equal sign between -gnatec and
342 -- the path name of the config file.
344 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
345 Ptr := Ptr + 1;
346 end if;
348 if Ptr > Max then
349 Bad_Switch ("-gnatec");
350 end if;
352 declare
353 Config_File_Name : constant String_Access :=
354 new String'
355 (Switch_Chars (Ptr .. Max));
357 begin
358 if Config_File_Names = null then
359 Config_File_Names :=
360 new String_List'(1 => Config_File_Name);
362 else
363 declare
364 New_Names : constant String_List_Access :=
365 new String_List
366 (1 ..
367 Config_File_Names'Length + 1);
369 begin
370 for Index in Config_File_Names'Range loop
371 New_Names (Index) :=
372 Config_File_Names (Index);
373 Config_File_Names (Index) := null;
374 end loop;
376 New_Names (New_Names'Last) := Config_File_Name;
377 Free (Config_File_Names);
378 Config_File_Names := New_Names;
379 end;
380 end if;
381 end;
383 return;
385 -- -gnateD switch (preprocessing symbol definition)
387 when 'D' =>
388 Store_Switch := False;
389 Ptr := Ptr + 1;
391 if Ptr > Max then
392 Bad_Switch ("-gnateD");
393 end if;
395 Add_Symbol_Definition (Switch_Chars (Ptr .. Max));
397 -- Store the switch
399 Store_Compilation_Switch
400 ("-gnateD" & Switch_Chars (Ptr .. Max));
401 Ptr := Max + 1;
403 -- -gnatef (full source path for brief error messages)
405 when 'f' =>
406 Store_Switch := False;
407 Ptr := Ptr + 1;
408 Full_Path_Name_For_Brief_Errors := True;
409 return;
411 -- -gnateG (save preprocessor output)
413 when 'G' =>
414 if Ptr < Max then
415 Bad_Switch (Switch_Chars);
416 end if;
418 Generate_Processed_File := True;
419 Ptr := Ptr + 1;
421 -- -gnateI (index of unit in multi-unit source)
423 when 'I' =>
424 Ptr := Ptr + 1;
425 Scan_Pos (Switch_Chars, Max, Ptr, Multiple_Unit_Index, C);
427 -- -gnatem (mapping file)
429 when 'm' =>
430 Store_Switch := False;
431 Ptr := Ptr + 1;
433 -- There may be an equal sign between -gnatem and
434 -- the path name of the mapping file.
436 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
437 Ptr := Ptr + 1;
438 end if;
440 if Ptr > Max then
441 Bad_Switch ("-gnatem");
442 end if;
444 Mapping_File_Name :=
445 new String'(Switch_Chars (Ptr .. Max));
446 return;
448 -- -gnatep (preprocessing data file)
450 when 'p' =>
451 Store_Switch := False;
452 Ptr := Ptr + 1;
454 -- There may be an equal sign between -gnatep and
455 -- the path name of the mapping file.
457 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
458 Ptr := Ptr + 1;
459 end if;
461 if Ptr > Max then
462 Bad_Switch ("-gnatep");
463 end if;
465 Preprocessing_Data_File :=
466 new String'(Switch_Chars (Ptr .. Max));
468 -- Store the switch, normalizing to -gnatep=
470 Store_Compilation_Switch
471 ("-gnatep=" & Preprocessing_Data_File.all);
473 Ptr := Max + 1;
475 when 'z' =>
476 Store_Switch := False;
477 Disable_Switch_Storing;
478 Ptr := Ptr + 1;
480 -- All other -gnate? switches are unassigned
482 when others =>
483 Bad_Switch ("-gnate" & Switch_Chars (Ptr .. Max));
484 end case;
486 -- -gnatE (dynamic elaboration checks)
488 when 'E' =>
489 Ptr := Ptr + 1;
490 Dynamic_Elaboration_Checks := True;
492 -- -gnatf (full error messages)
494 when 'f' =>
495 Ptr := Ptr + 1;
496 All_Errors_Mode := True;
498 -- Processing for F switch
500 when 'F' =>
501 Ptr := Ptr + 1;
502 External_Name_Exp_Casing := Uppercase;
503 External_Name_Imp_Casing := Uppercase;
505 -- Processing for g switch
507 when 'g' =>
508 Ptr := Ptr + 1;
509 GNAT_Mode := True;
510 Identifier_Character_Set := 'n';
511 System_Extend_Unit := Empty;
512 Warning_Mode := Treat_As_Error;
514 -- Set Ada 2005 mode explicitly. We don't want to rely on the
515 -- implicit setting here, since for example, we want
516 -- Preelaborate_05 treated as Preelaborate
518 Ada_Version := Ada_05;
519 Ada_Version_Explicit := Ada_Version;
521 -- Set default warnings for -gnatg
523 Check_Unreferenced := True;
524 Check_Unreferenced_Formals := True;
525 Check_Withs := True;
526 Constant_Condition_Warnings := True;
527 Implementation_Unit_Warnings := True;
528 Ineffective_Inline_Warnings := True;
529 Warn_On_Assertion_Failure := True;
530 Warn_On_Assumed_Low_Bound := True;
531 Warn_On_Bad_Fixed_Value := True;
532 Warn_On_Constant := True;
533 Warn_On_Export_Import := True;
534 Warn_On_Modified_Unread := True;
535 Warn_On_No_Value_Assigned := True;
536 Warn_On_Non_Local_Exception := False;
537 Warn_On_Obsolescent_Feature := True;
538 Warn_On_Redundant_Constructs := True;
539 Warn_On_Object_Renames_Function := True;
540 Warn_On_Unchecked_Conversion := True;
541 Warn_On_Unrecognized_Pragma := True;
543 Set_GNAT_Style_Check_Options;
545 -- Processing for G switch
547 when 'G' =>
548 Ptr := Ptr + 1;
549 Print_Generated_Code := True;
551 -- Scan optional integer line limit value
553 if Nat_Present (Switch_Chars, Max, Ptr) then
554 Scan_Nat (Switch_Chars, Max, Ptr, Sprint_Line_Limit, 'G');
555 Sprint_Line_Limit := Nat'Max (Sprint_Line_Limit, 40);
556 end if;
558 -- Processing for h switch
560 when 'h' =>
561 Ptr := Ptr + 1;
562 Usage_Requested := True;
564 -- Processing for H switch
566 when 'H' =>
567 Ptr := Ptr + 1;
568 HLO_Active := True;
570 -- Processing for i switch
572 when 'i' =>
573 if Ptr = Max then
574 Bad_Switch ("-gnati");
575 end if;
577 Ptr := Ptr + 1;
578 C := Switch_Chars (Ptr);
580 if C in '1' .. '5'
581 or else C = '8'
582 or else C = '9'
583 or else C = 'p'
584 or else C = 'f'
585 or else C = 'n'
586 or else C = 'w'
587 then
588 Identifier_Character_Set := C;
589 Ptr := Ptr + 1;
591 else
592 Bad_Switch ("-gnati" & Switch_Chars (Ptr .. Max));
593 end if;
595 -- Processing for I switch
597 when 'I' =>
598 Ptr := Ptr + 1;
599 Ignore_Rep_Clauses := True;
601 -- Processing for j switch
603 when 'j' =>
604 Ptr := Ptr + 1;
605 Scan_Nat (Switch_Chars, Max, Ptr, Error_Msg_Line_Length, C);
607 -- Processing for k switch
609 when 'k' =>
610 Ptr := Ptr + 1;
611 Scan_Pos
612 (Switch_Chars, Max, Ptr, Maximum_File_Name_Length, C);
614 -- Processing for l switch
616 when 'l' =>
617 Ptr := Ptr + 1;
618 Full_List := True;
620 -- There may be an equal sign between -gnatl and a file name
622 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
623 if Ptr = Max then
624 Osint.Fail ("file name for -gnatl= is null");
625 else
626 Opt.Full_List_File_Name :=
627 new String'(Switch_Chars (Ptr + 1 .. Max));
628 Ptr := Max + 1;
629 end if;
630 end if;
632 -- Processing for L switch
634 when 'L' =>
635 Ptr := Ptr + 1;
636 Dump_Source_Text := True;
638 -- Processing for m switch
640 when 'm' =>
641 Ptr := Ptr + 1;
642 Scan_Nat (Switch_Chars, Max, Ptr, Maximum_Messages, C);
644 -- Processing for n switch
646 when 'n' =>
647 Ptr := Ptr + 1;
648 Inline_Active := True;
650 -- Processing for N switch
652 when 'N' =>
653 Ptr := Ptr + 1;
654 Inline_Active := True;
656 -- Do not enable front-end inlining in inspector mode, to
657 -- generate trees that can be converted to SCIL. We still
658 -- enable back-end inlining which is fine.
660 if not Inspector_Mode then
661 Front_End_Inlining := True;
662 end if;
664 -- Processing for o switch
666 when 'o' =>
667 Ptr := Ptr + 1;
668 Suppress_Options (Overflow_Check) := False;
669 Opt.Enable_Overflow_Checks := True;
671 -- Processing for O switch
673 when 'O' =>
674 Store_Switch := False;
675 Ptr := Ptr + 1;
676 Output_File_Name_Present := True;
678 -- Processing for p switch
680 when 'p' =>
681 Ptr := Ptr + 1;
683 -- Set all specific options as well as All_Checks in the
684 -- Suppress_Options array, excluding Elaboration_Check, since
685 -- this is treated specially because we do not want -gnatp to
686 -- disable static elaboration processing.
688 for J in Suppress_Options'Range loop
689 if J /= Elaboration_Check then
690 Suppress_Options (J) := True;
691 end if;
692 end loop;
694 Validity_Checks_On := False;
695 Opt.Suppress_Checks := True;
696 Opt.Enable_Overflow_Checks := False;
698 -- Processing for P switch
700 when 'P' =>
701 Ptr := Ptr + 1;
702 Polling_Required := True;
704 -- Processing for q switch
706 when 'q' =>
707 Ptr := Ptr + 1;
708 Try_Semantics := True;
710 -- Processing for Q switch
712 when 'Q' =>
713 Ptr := Ptr + 1;
714 Force_ALI_Tree_File := True;
715 Try_Semantics := True;
717 -- Processing for r switch
719 when 'r' =>
720 Ptr := Ptr + 1;
721 Treat_Restrictions_As_Warnings := True;
723 -- Processing for R switch
725 when 'R' =>
726 Back_Annotate_Rep_Info := True;
727 List_Representation_Info := 1;
729 Ptr := Ptr + 1;
730 while Ptr <= Max loop
731 C := Switch_Chars (Ptr);
733 if C in '1' .. '3' then
734 List_Representation_Info :=
735 Character'Pos (C) - Character'Pos ('0');
737 elsif Switch_Chars (Ptr) = 's' then
738 List_Representation_Info_To_File := True;
740 elsif Switch_Chars (Ptr) = 'm' then
741 List_Representation_Info_Mechanisms := True;
743 else
744 Bad_Switch ("-gnatR" & Switch_Chars (Ptr .. Max));
745 end if;
747 Ptr := Ptr + 1;
748 end loop;
750 -- Processing for s switch
752 when 's' =>
753 if not First_Switch then
754 Osint.Fail
755 ("-gnats must be first if combined with other switches");
756 end if;
758 Ptr := Ptr + 1;
759 Operating_Mode := Check_Syntax;
761 -- Processing for S switch
763 when 'S' =>
764 Print_Standard := True;
765 Ptr := Ptr + 1;
767 -- Processing for t switch
769 when 't' =>
770 Ptr := Ptr + 1;
771 Tree_Output := True;
773 if Operating_Mode = Check_Semantics then
774 ASIS_Mode := True;
775 Inspector_Mode := False;
776 end if;
778 Back_Annotate_Rep_Info := True;
780 -- Processing for T switch
782 when 'T' =>
783 Ptr := Ptr + 1;
784 Scan_Pos (Switch_Chars, Max, Ptr, Table_Factor, C);
786 -- Processing for u switch
788 when 'u' =>
789 Ptr := Ptr + 1;
790 List_Units := True;
792 -- Processing for U switch
794 when 'U' =>
795 Ptr := Ptr + 1;
796 Unique_Error_Tag := True;
798 -- Processing for v switch
800 when 'v' =>
801 Ptr := Ptr + 1;
802 Verbose_Mode := True;
804 -- Processing for V switch
806 when 'V' =>
807 Store_Switch := False;
808 Ptr := Ptr + 1;
810 if Ptr > Max then
811 Bad_Switch ("-gnatV");
813 else
814 declare
815 OK : Boolean;
817 begin
818 Set_Validity_Check_Options
819 (Switch_Chars (Ptr .. Max), OK, Ptr);
821 if not OK then
822 Bad_Switch ("-gnatV" & Switch_Chars (Ptr .. Max));
823 end if;
825 for Index in First_Char + 1 .. Max loop
826 Store_Compilation_Switch
827 ("-gnatV" & Switch_Chars (Index));
828 end loop;
829 end;
830 end if;
832 Ptr := Max + 1;
834 -- Processing for w switch
836 when 'w' =>
837 Store_Switch := False;
838 Ptr := Ptr + 1;
840 if Ptr > Max then
841 Bad_Switch ("-gnatw");
842 end if;
844 while Ptr <= Max loop
845 C := Switch_Chars (Ptr);
847 -- Case of dot switch
849 if C = '.' and then Ptr < Max then
850 Ptr := Ptr + 1;
851 C := Switch_Chars (Ptr);
853 if Set_Dot_Warning_Switch (C) then
854 Store_Compilation_Switch ("-gnatw." & C);
855 else
856 Bad_Switch ("-gnatw." & Switch_Chars (Ptr .. Max));
857 end if;
859 -- Normal case, no dot
861 else
862 if Set_Warning_Switch (C) then
863 Store_Compilation_Switch ("-gnatw" & C);
864 else
865 Bad_Switch ("-gnatw" & Switch_Chars (Ptr .. Max));
866 end if;
867 end if;
869 Ptr := Ptr + 1;
870 end loop;
872 return;
874 -- Processing for W switch
876 when 'W' =>
877 Ptr := Ptr + 1;
879 if Ptr > Max then
880 Bad_Switch ("-gnatW");
881 end if;
883 begin
884 Wide_Character_Encoding_Method :=
885 Get_WC_Encoding_Method (Switch_Chars (Ptr));
886 exception
887 when Constraint_Error =>
888 Bad_Switch ("-gnatW" & Switch_Chars (Ptr .. Max));
889 end;
891 Wide_Character_Encoding_Method_Specified := True;
893 Upper_Half_Encoding :=
894 Wide_Character_Encoding_Method in
895 WC_Upper_Half_Encoding_Method;
897 Ptr := Ptr + 1;
899 -- Processing for x switch
901 when 'x' =>
902 Ptr := Ptr + 1;
903 Xref_Active := False;
905 -- Processing for X switch
907 when 'X' =>
908 Ptr := Ptr + 1;
909 Extensions_Allowed := True;
911 -- Processing for y switch
913 when 'y' =>
914 Ptr := Ptr + 1;
916 if Ptr > Max then
917 Set_Default_Style_Check_Options;
919 else
920 Store_Switch := False;
922 declare
923 OK : Boolean;
925 begin
926 Set_Style_Check_Options
927 (Switch_Chars (Ptr .. Max), OK, Ptr);
929 if not OK then
930 Osint.Fail
931 ("bad -gnaty switch (" &
932 Style_Msg_Buf (1 .. Style_Msg_Len) & ')');
933 end if;
935 Ptr := First_Char + 1;
936 while Ptr <= Max loop
937 if Switch_Chars (Ptr) = 'M' then
938 First_Char := Ptr;
939 loop
940 Ptr := Ptr + 1;
941 exit when Ptr > Max
942 or else Switch_Chars (Ptr) not in '0' .. '9';
943 end loop;
945 Store_Compilation_Switch
946 ("-gnaty" & Switch_Chars (First_Char .. Ptr - 1));
948 else
949 Store_Compilation_Switch
950 ("-gnaty" & Switch_Chars (Ptr));
951 Ptr := Ptr + 1;
952 end if;
953 end loop;
954 end;
955 end if;
957 -- Processing for z switch
959 when 'z' =>
960 Ptr := Ptr + 1;
962 -- Allowed for compiler only if this is the only
963 -- -z switch, we do not allow multiple occurrences
965 if Distribution_Stub_Mode = No_Stubs then
966 case Switch_Chars (Ptr) is
967 when 'r' =>
968 Distribution_Stub_Mode := Generate_Receiver_Stub_Body;
970 when 'c' =>
971 Distribution_Stub_Mode := Generate_Caller_Stub_Body;
973 when others =>
974 Bad_Switch ("-gnatz" & Switch_Chars (Ptr .. Max));
975 end case;
977 Ptr := Ptr + 1;
978 end if;
980 -- Processing for Z switch
982 when 'Z' =>
983 Ptr := Ptr + 1;
984 Osint.Fail
985 ("-gnatZ is no longer supported: consider using --RTS=zcx");
987 -- Processing for 83 switch
989 when '8' =>
990 if Ptr = Max then
991 Bad_Switch ("-gnat8");
992 end if;
994 Ptr := Ptr + 1;
996 if Switch_Chars (Ptr) /= '3' then
997 Bad_Switch ("-gnat8" & Switch_Chars (Ptr .. Max));
998 else
999 Ptr := Ptr + 1;
1000 Ada_Version := Ada_83;
1001 Ada_Version_Explicit := Ada_Version;
1002 end if;
1004 -- Processing for 95 switch
1006 when '9' =>
1007 if Ptr = Max then
1008 Bad_Switch ("-gnat9");
1009 end if;
1011 Ptr := Ptr + 1;
1013 if Switch_Chars (Ptr) /= '5' then
1014 Bad_Switch ("-gnat9" & Switch_Chars (Ptr .. Max));
1015 else
1016 Ptr := Ptr + 1;
1017 Ada_Version := Ada_95;
1018 Ada_Version_Explicit := Ada_Version;
1019 end if;
1021 -- Processing for 05 switch
1023 when '0' =>
1024 if Ptr = Max then
1025 Bad_Switch ("-gnat0");
1026 end if;
1028 Ptr := Ptr + 1;
1030 if Switch_Chars (Ptr) /= '5' then
1031 Bad_Switch ("-gnat0" & Switch_Chars (Ptr .. Max));
1032 else
1033 Ptr := Ptr + 1;
1034 Ada_Version := Ada_05;
1035 Ada_Version_Explicit := Ada_Version;
1036 end if;
1038 -- Ignore extra switch character
1040 when '/' | '-' =>
1041 Ptr := Ptr + 1;
1043 -- Anything else is an error (illegal switch character)
1045 when others =>
1046 Bad_Switch ("-gnat" & Switch_Chars (Ptr .. Max));
1047 end case;
1049 if Store_Switch then
1050 Store_Compilation_Switch
1051 ("-gnat" & Switch_Chars (First_Char .. Ptr - 1));
1052 end if;
1054 First_Switch := False;
1055 end loop;
1056 end if;
1057 end Scan_Front_End_Switches;
1059 end Switch.C;