2003-11-27 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / ada / switch-c.adb
blob5f4e6cabadcee03b498ce373ee5b86578dd58e4d
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-2003 Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
21 -- --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 -- --
25 ------------------------------------------------------------------------------
27 with GNAT.OS_Lib; use GNAT.OS_Lib;
29 with Debug; use Debug;
30 with Lib; use Lib;
31 with Osint; use Osint;
32 with Opt; use Opt;
33 with Prepcomp; use Prepcomp;
34 with Types; use Types;
35 with Validsw; use Validsw;
36 with Stylesw; use Stylesw;
38 with System.WCh_Con; use System.WCh_Con;
40 package body Switch.C is
42 RTS_Specified : String_Access := null;
43 -- Used to detect multiple use of --RTS= flag
45 -----------------------------
46 -- Scan_Front_End_Switches --
47 -----------------------------
49 procedure Scan_Front_End_Switches (Switch_Chars : String) is
50 Switch_Starts_With_Gnat : Boolean;
51 -- True if first four switch characters are "gnat"
53 First_Switch : Boolean := True;
54 -- False for all but first switch
56 Ptr : Integer := Switch_Chars'First;
57 Max : constant Integer := Switch_Chars'Last;
58 C : Character := ' ';
59 Dot : Boolean;
61 Store_Switch : Boolean := True;
62 First_Char : Integer := Ptr;
63 Storing : String := Switch_Chars;
64 First_Stored : Positive := Ptr + 1;
65 -- The above need comments ???
67 begin
68 -- Skip past the initial character (must be the switch character)
70 if Ptr = Max then
71 raise Bad_Switch;
72 else
73 Ptr := Ptr + 1;
74 end if;
76 -- Remove "gnat" from the switch, if present
78 Switch_Starts_With_Gnat :=
79 Ptr + 3 <= Max and then Switch_Chars (Ptr .. Ptr + 3) = "gnat";
81 if Switch_Starts_With_Gnat then
82 Ptr := Ptr + 4;
83 First_Stored := Ptr;
84 end if;
86 -- Loop to scan through switches given in switch string
88 while Ptr <= Max loop
89 Store_Switch := True;
90 First_Char := Ptr;
91 C := Switch_Chars (Ptr);
93 -- Processing for a switch
95 case Switch_Starts_With_Gnat is
97 when False =>
99 -- There are few front-end switches that
100 -- do not start with -gnat: -I, --RTS, -nostdlib
102 if Switch_Chars (Ptr) = 'I' then
103 Store_Switch := False;
105 Ptr := Ptr + 1;
107 if Ptr > Max then
108 raise Bad_Switch;
109 end if;
111 -- Find out whether this is a -I- or regular -Ixxx switch
113 if Ptr = Max and then Switch_Chars (Ptr) = '-' then
114 Look_In_Primary_Dir := False;
116 else
117 Add_Src_Search_Dir (Switch_Chars (Ptr .. Max));
118 end if;
120 Ptr := Max + 1;
122 -- Processing of -nostdlib
124 elsif Ptr + 7 = Max
125 and then Switch_Chars (Ptr .. Ptr + 7) = "nostdlib"
126 then
127 Opt.No_Stdlib := True;
128 Ptr := Max + 1;
130 -- Processing of the --RTS switch. --RTS has been modified by
131 -- gcc and is now of the form -fRTS
133 elsif Ptr + 3 <= Max
134 and then Switch_Chars (Ptr .. Ptr + 3) = "fRTS"
135 then
136 Ptr := Ptr + 1;
138 if Ptr + 4 > Max
139 or else Switch_Chars (Ptr + 3) /= '='
140 then
141 Osint.Fail ("missing path for --RTS");
142 else
143 -- Check that this is the first time --RTS is specified
144 -- or if it is not the first time, the same path has
145 -- been specified.
147 if RTS_Specified = null then
148 RTS_Specified :=
149 new String'(Switch_Chars (Ptr + 4 .. Max));
151 elsif
152 RTS_Specified.all /= Switch_Chars (Ptr + 4 .. Max)
153 then
154 Osint.Fail
155 ("--RTS cannot be specified multiple times");
156 end if;
158 -- Valid --RTS switch
160 Opt.No_Stdinc := True;
161 Opt.RTS_Switch := True;
163 RTS_Src_Path_Name := Get_RTS_Search_Dir
164 (Switch_Chars (Ptr + 4 .. Max),
165 Include);
166 RTS_Lib_Path_Name := Get_RTS_Search_Dir
167 (Switch_Chars (Ptr + 4 .. Max),
168 Objects);
170 if RTS_Src_Path_Name /= null and then
171 RTS_Lib_Path_Name /= null
172 then
173 Ptr := Max + 1;
175 elsif RTS_Src_Path_Name = null and then
176 RTS_Lib_Path_Name = null
177 then
178 Osint.Fail ("RTS path not valid: missing " &
179 "adainclude and adalib directories");
181 elsif RTS_Src_Path_Name = null then
182 Osint.Fail ("RTS path not valid: missing " &
183 "adainclude directory");
185 elsif RTS_Lib_Path_Name = null then
186 Osint.Fail ("RTS path not valid: missing " &
187 "adalib directory");
188 end if;
189 end if;
190 else
191 raise Bad_Switch;
192 end if;
194 when True =>
196 -- Process -gnat* options
198 case C is
200 when 'a' =>
201 Ptr := Ptr + 1;
202 Assertions_Enabled := True;
204 -- Processing for A switch
206 when 'A' =>
207 Ptr := Ptr + 1;
208 Config_File := False;
210 -- Processing for b switch
212 when 'b' =>
213 Ptr := Ptr + 1;
214 Brief_Output := True;
216 -- Processing for c switch
218 when 'c' =>
219 if not First_Switch then
220 Osint.Fail
221 ("-gnatc must be first if combined with other switches");
222 end if;
224 Ptr := Ptr + 1;
225 Operating_Mode := Check_Semantics;
227 if Tree_Output then
228 ASIS_Mode := True;
229 end if;
231 -- Processing for d switch
233 when 'd' =>
234 Store_Switch := False;
235 Storing (First_Stored) := 'd';
236 Dot := False;
238 -- Note: for the debug switch, the remaining characters in this
239 -- switch field must all be debug flags, since all valid switch
240 -- characters are also valid debug characters.
242 -- Loop to scan out debug flags
244 while Ptr < Max loop
245 Ptr := Ptr + 1;
246 C := Switch_Chars (Ptr);
247 exit when C = ASCII.NUL or else C = '/' or else C = '-';
249 if C in '1' .. '9' or else
250 C in 'a' .. 'z' or else
251 C in 'A' .. 'Z'
252 then
253 if Dot then
254 Set_Dotted_Debug_Flag (C);
255 Storing (First_Stored + 1) := '.';
256 Storing (First_Stored + 2) := C;
257 Store_Compilation_Switch
258 (Storing (Storing'First .. First_Stored + 2));
259 Dot := False;
261 else
262 Set_Debug_Flag (C);
263 Storing (First_Stored + 1) := C;
264 Store_Compilation_Switch
265 (Storing (Storing'First .. First_Stored + 1));
266 end if;
268 elsif C = '.' then
269 Dot := True;
271 else
272 raise Bad_Switch;
273 end if;
274 end loop;
276 -- Make sure Zero_Cost_Exceptions is set if gnatdX set. This
277 -- is for backwards compatibility with old versions and usage.
279 if Debug_Flag_XX then
280 Zero_Cost_Exceptions_Set := True;
281 Zero_Cost_Exceptions_Val := True;
282 end if;
284 return;
286 -- Processing for D switch
288 when 'D' =>
289 Ptr := Ptr + 1;
291 -- Note: -gnatD also sets -gnatx (to turn off cross-reference
292 -- generation in the ali file) since otherwise this generation
293 -- gets confused by the "wrong" Sloc values put in the tree.
295 Debug_Generated_Code := True;
296 Xref_Active := False;
297 Set_Debug_Flag ('g');
299 -- Processing for e switch
301 when 'e' =>
302 -- Only -gnateD and -gnatep= are stored
304 Ptr := Ptr + 1;
306 if Ptr > Max then
307 raise Bad_Switch;
308 end if;
310 case Switch_Chars (Ptr) is
312 -- Configuration pragmas
314 when 'c' =>
315 Store_Switch := False;
316 Ptr := Ptr + 1;
318 -- There may be an equal sign between -gnatec and
319 -- the path name of the config file.
321 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
322 Ptr := Ptr + 1;
323 end if;
325 if Ptr > Max then
326 raise Bad_Switch;
327 end if;
329 declare
330 Config_File_Name : constant String_Access :=
331 new String'
332 (Switch_Chars (Ptr .. Max));
334 begin
335 if Config_File_Names = null then
336 Config_File_Names :=
337 new String_List'(1 => Config_File_Name);
339 else
340 declare
341 New_Names : constant String_List_Access :=
342 new String_List
343 (1 ..
344 Config_File_Names'Length + 1);
346 begin
347 for Index in Config_File_Names'Range loop
348 New_Names (Index) :=
349 Config_File_Names (Index);
350 Config_File_Names (Index) := null;
351 end loop;
353 New_Names (New_Names'Last) := Config_File_Name;
354 Free (Config_File_Names);
355 Config_File_Names := New_Names;
356 end;
357 end if;
358 end;
360 return;
362 -- Symbol definition
364 when 'D' =>
365 Store_Switch := False;
366 Ptr := Ptr + 1;
368 if Ptr > Max then
369 raise Bad_Switch;
370 end if;
372 Add_Symbol_Definition (Switch_Chars (Ptr .. Max));
374 -- Store the switch
376 Storing (First_Stored .. First_Stored + 1) := "eD";
377 Storing
378 (First_Stored + 2 .. First_Stored + Max - Ptr + 2) :=
379 Switch_Chars (Ptr .. Max);
380 Store_Compilation_Switch (Storing
381 (Storing'First .. First_Stored + Max - Ptr + 2));
382 return;
384 -- Full source path for brief error messages
386 when 'f' =>
387 Store_Switch := False;
388 Ptr := Ptr + 1;
389 Full_Path_Name_For_Brief_Errors := True;
390 return;
392 -- Mapping file
394 when 'm' =>
395 Store_Switch := False;
396 Ptr := Ptr + 1;
398 -- There may be an equal sign between -gnatem and
399 -- the path name of the mapping file.
401 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
402 Ptr := Ptr + 1;
403 end if;
405 if Ptr > Max then
406 raise Bad_Switch;
407 end if;
409 Mapping_File_Name :=
410 new String'(Switch_Chars (Ptr .. Max));
411 return;
413 -- Preprocessing data file
415 when 'p' =>
416 Store_Switch := False;
417 Ptr := Ptr + 1;
419 -- There may be an equal sign between -gnatep and
420 -- the path name of the mapping file.
422 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
423 Ptr := Ptr + 1;
424 end if;
426 if Ptr > Max then
427 raise Bad_Switch;
428 end if;
430 Preprocessing_Data_File :=
431 new String'(Switch_Chars (Ptr .. Max));
433 -- Store the switch.
434 -- Because we may store a longer switch (we normalize
435 -- to -gnatep=), use a local variable.
437 declare
438 To_Store : String
439 (1 .. Preprocessing_Data_File'Length + 8);
441 begin
442 To_Store (1 .. 8) := "-gnatep=";
443 To_Store (9 .. Preprocessing_Data_File'Length + 8) :=
444 Preprocessing_Data_File.all;
445 Store_Compilation_Switch (To_Store);
446 end;
448 return;
450 when others =>
451 raise Bad_Switch;
452 end case;
454 -- Processing for E switch
456 when 'E' =>
457 Ptr := Ptr + 1;
458 Dynamic_Elaboration_Checks := True;
460 -- Processing for f switch
462 when 'f' =>
463 Ptr := Ptr + 1;
464 All_Errors_Mode := True;
466 -- Processing for F switch
468 when 'F' =>
469 Ptr := Ptr + 1;
470 External_Name_Exp_Casing := Uppercase;
471 External_Name_Imp_Casing := Uppercase;
473 -- Processing for g switch
475 when 'g' =>
476 Ptr := Ptr + 1;
477 GNAT_Mode := True;
478 Identifier_Character_Set := 'n';
479 Warning_Mode := Treat_As_Error;
480 Check_Unreferenced := True;
481 Check_Withs := True;
482 Check_Unreferenced_Formals := True;
483 System_Extend_Unit := Empty;
485 Set_Default_Style_Check_Options;
487 -- Processing for G switch
489 when 'G' =>
490 Ptr := Ptr + 1;
491 Print_Generated_Code := True;
493 -- Processing for h switch
495 when 'h' =>
496 Ptr := Ptr + 1;
497 Usage_Requested := True;
499 -- Processing for H switch
501 when 'H' =>
502 Ptr := Ptr + 1;
503 HLO_Active := True;
505 -- Processing for i switch
507 when 'i' =>
508 if Ptr = Max then
509 raise Bad_Switch;
510 end if;
512 Ptr := Ptr + 1;
513 C := Switch_Chars (Ptr);
515 if C in '1' .. '5'
516 or else C = '8'
517 or else C = '9'
518 or else C = 'p'
519 or else C = 'f'
520 or else C = 'n'
521 or else C = 'w'
522 then
523 Identifier_Character_Set := C;
524 Ptr := Ptr + 1;
526 else
527 raise Bad_Switch;
528 end if;
530 -- Processing for k switch
532 when 'k' =>
533 Ptr := Ptr + 1;
534 Scan_Pos (Switch_Chars, Max, Ptr, Maximum_File_Name_Length);
536 -- Processing for l switch
538 when 'l' =>
539 Ptr := Ptr + 1;
540 Full_List := True;
542 -- Processing for L switch
544 when 'L' =>
545 Ptr := Ptr + 1;
546 Zero_Cost_Exceptions_Set := True;
547 Zero_Cost_Exceptions_Val := False;
549 -- Processing for m switch
551 when 'm' =>
552 Ptr := Ptr + 1;
553 Scan_Pos (Switch_Chars, Max, Ptr, Maximum_Errors);
555 -- Processing for n switch
557 when 'n' =>
558 Ptr := Ptr + 1;
559 Inline_Active := True;
561 -- Processing for N switch
563 when 'N' =>
564 Ptr := Ptr + 1;
565 Inline_Active := True;
566 Front_End_Inlining := True;
568 -- Processing for o switch
570 when 'o' =>
571 Ptr := Ptr + 1;
572 Suppress_Options (Overflow_Check) := False;
573 Opt.Enable_Overflow_Checks := True;
575 -- Processing for O switch
577 when 'O' =>
578 Store_Switch := False;
579 Ptr := Ptr + 1;
580 Output_File_Name_Present := True;
582 -- Processing for p switch
584 when 'p' =>
585 Ptr := Ptr + 1;
586 Suppress_Options := (others => True);
587 Validity_Checks_On := False;
588 Opt.Suppress_Checks := True;
589 Opt.Enable_Overflow_Checks := False;
591 -- Processing for P switch
593 when 'P' =>
594 Ptr := Ptr + 1;
595 Polling_Required := True;
597 -- Processing for q switch
599 when 'q' =>
600 Ptr := Ptr + 1;
601 Try_Semantics := True;
603 -- Processing for q switch
605 when 'Q' =>
606 Ptr := Ptr + 1;
607 Force_ALI_Tree_File := True;
608 Try_Semantics := True;
610 -- Processing for R switch
612 when 'R' =>
613 Ptr := Ptr + 1;
614 Back_Annotate_Rep_Info := True;
615 List_Representation_Info := 1;
617 while Ptr <= Max loop
618 C := Switch_Chars (Ptr);
620 if C in '1' .. '3' then
621 List_Representation_Info :=
622 Character'Pos (C) - Character'Pos ('0');
624 elsif Switch_Chars (Ptr) = 's' then
625 List_Representation_Info_To_File := True;
627 elsif Switch_Chars (Ptr) = 'm' then
628 List_Representation_Info_Mechanisms := True;
630 else
631 raise Bad_Switch;
632 end if;
634 Ptr := Ptr + 1;
635 end loop;
637 -- Processing for s switch
639 when 's' =>
640 if not First_Switch then
641 Osint.Fail
642 ("-gnats must be first if combined with other switches");
643 end if;
645 Ptr := Ptr + 1;
646 Operating_Mode := Check_Syntax;
648 -- Processing for S switch
650 when 'S' =>
651 Print_Standard := True;
652 Ptr := Ptr + 1;
654 -- Processing for t switch
656 when 't' =>
657 Ptr := Ptr + 1;
658 Tree_Output := True;
660 if Operating_Mode = Check_Semantics then
661 ASIS_Mode := True;
662 end if;
664 Back_Annotate_Rep_Info := True;
666 -- Processing for T switch
668 when 'T' =>
669 Ptr := Ptr + 1;
670 Scan_Pos (Switch_Chars, Max, Ptr, Table_Factor);
672 -- Processing for u switch
674 when 'u' =>
675 Ptr := Ptr + 1;
676 List_Units := True;
678 -- Processing for U switch
680 when 'U' =>
681 Ptr := Ptr + 1;
682 Unique_Error_Tag := True;
684 -- Processing for v switch
686 when 'v' =>
687 Ptr := Ptr + 1;
688 Verbose_Mode := True;
690 -- Processing for V switch
692 when 'V' =>
693 Store_Switch := False;
694 Storing (First_Stored) := 'V';
695 Ptr := Ptr + 1;
697 if Ptr > Max then
698 raise Bad_Switch;
700 else
701 declare
702 OK : Boolean;
704 begin
705 Set_Validity_Check_Options
706 (Switch_Chars (Ptr .. Max), OK, Ptr);
708 if not OK then
709 raise Bad_Switch;
710 end if;
712 for Index in First_Char + 1 .. Max loop
713 Storing (First_Stored + 1) :=
714 Switch_Chars (Index);
715 Store_Compilation_Switch
716 (Storing (Storing'First .. First_Stored + 1));
717 end loop;
718 end;
719 end if;
721 Ptr := Max + 1;
723 -- Processing for w switch
725 when 'w' =>
726 Store_Switch := False;
727 Storing (First_Stored) := 'w';
728 Ptr := Ptr + 1;
730 if Ptr > Max then
731 raise Bad_Switch;
732 end if;
734 while Ptr <= Max loop
735 C := Switch_Chars (Ptr);
737 case C is
738 when 'a' =>
739 Check_Unreferenced := True;
740 Check_Unreferenced_Formals := True;
741 Check_Withs := True;
742 Constant_Condition_Warnings := True;
743 Implementation_Unit_Warnings := True;
744 Ineffective_Inline_Warnings := True;
745 Warn_On_Constant := True;
746 Warn_On_Export_Import := True;
747 Warn_On_Modified_Unread := True;
748 Warn_On_No_Value_Assigned := True;
749 Warn_On_Obsolescent_Feature := True;
750 Warn_On_Redundant_Constructs := True;
751 Warn_On_Unchecked_Conversion := True;
752 Warn_On_Unrecognized_Pragma := True;
754 when 'A' =>
755 Check_Unreferenced := False;
756 Check_Unreferenced_Formals := False;
757 Check_Withs := False;
758 Constant_Condition_Warnings := False;
759 Elab_Warnings := False;
760 Implementation_Unit_Warnings := False;
761 Ineffective_Inline_Warnings := False;
762 Warn_On_Constant := False;
763 Warn_On_Dereference := False;
764 Warn_On_Export_Import := False;
765 Warn_On_Hiding := False;
766 Warn_On_Modified_Unread := False;
767 Warn_On_No_Value_Assigned := False;
768 Warn_On_Obsolescent_Feature := False;
769 Warn_On_Redundant_Constructs := False;
770 Warn_On_Unchecked_Conversion := False;
771 Warn_On_Unrecognized_Pragma := False;
773 when 'c' =>
774 Constant_Condition_Warnings := True;
776 when 'C' =>
777 Constant_Condition_Warnings := False;
779 when 'd' =>
780 Warn_On_Dereference := True;
782 when 'D' =>
783 Warn_On_Dereference := False;
785 when 'e' =>
786 Warning_Mode := Treat_As_Error;
788 when 'f' =>
789 Check_Unreferenced_Formals := True;
791 when 'F' =>
792 Check_Unreferenced_Formals := False;
794 when 'g' =>
795 Warn_On_Unrecognized_Pragma := True;
797 when 'G' =>
798 Warn_On_Unrecognized_Pragma := False;
800 when 'h' =>
801 Warn_On_Hiding := True;
803 when 'H' =>
804 Warn_On_Hiding := False;
806 when 'i' =>
807 Implementation_Unit_Warnings := True;
809 when 'I' =>
810 Implementation_Unit_Warnings := False;
812 when 'j' =>
813 Warn_On_Obsolescent_Feature := True;
815 when 'J' =>
816 Warn_On_Obsolescent_Feature := False;
818 when 'k' =>
819 Warn_On_Constant := True;
821 when 'K' =>
822 Warn_On_Constant := False;
824 when 'l' =>
825 Elab_Warnings := True;
827 when 'L' =>
828 Elab_Warnings := False;
830 when 'm' =>
831 Warn_On_Modified_Unread := True;
833 when 'M' =>
834 Warn_On_Modified_Unread := False;
836 when 'n' =>
837 Warning_Mode := Normal;
839 when 'o' =>
840 Address_Clause_Overlay_Warnings := True;
842 when 'O' =>
843 Address_Clause_Overlay_Warnings := False;
845 when 'p' =>
846 Ineffective_Inline_Warnings := True;
848 when 'P' =>
849 Ineffective_Inline_Warnings := False;
851 when 'r' =>
852 Warn_On_Redundant_Constructs := True;
854 when 'R' =>
855 Warn_On_Redundant_Constructs := False;
857 when 's' =>
858 Warning_Mode := Suppress;
860 when 'u' =>
861 Check_Unreferenced := True;
862 Check_Withs := True;
863 Check_Unreferenced_Formals := True;
865 when 'U' =>
866 Check_Unreferenced := False;
867 Check_Withs := False;
868 Check_Unreferenced_Formals := False;
870 when 'v' =>
871 Warn_On_No_Value_Assigned := True;
873 when 'V' =>
874 Warn_On_No_Value_Assigned := False;
876 when 'x' =>
877 Warn_On_Export_Import := True;
879 when 'X' =>
880 Warn_On_Export_Import := False;
882 when 'z' =>
883 Warn_On_Unchecked_Conversion := True;
885 when 'Z' =>
886 Warn_On_Unchecked_Conversion := False;
888 -- Allow and ignore 'w' so that the old
889 -- format (e.g. -gnatwuwl) will work.
891 when 'w' =>
892 null;
894 when others =>
895 raise Bad_Switch;
896 end case;
898 if C /= 'w' then
899 Storing (First_Stored + 1) := C;
900 Store_Compilation_Switch
901 (Storing (Storing'First .. First_Stored + 1));
902 end if;
904 Ptr := Ptr + 1;
905 end loop;
907 return;
909 -- Processing for W switch
911 when 'W' =>
912 Ptr := Ptr + 1;
914 if Ptr > Max then
915 raise Bad_Switch;
916 end if;
918 for J in WC_Encoding_Method loop
919 if Switch_Chars (Ptr) = WC_Encoding_Letters (J) then
920 Wide_Character_Encoding_Method := J;
921 exit;
923 elsif J = WC_Encoding_Method'Last then
924 raise Bad_Switch;
925 end if;
926 end loop;
928 Upper_Half_Encoding :=
929 Wide_Character_Encoding_Method in
930 WC_Upper_Half_Encoding_Method;
932 Ptr := Ptr + 1;
934 -- Processing for x switch
936 when 'x' =>
937 Ptr := Ptr + 1;
938 Xref_Active := False;
940 -- Processing for X switch
942 when 'X' =>
943 Ptr := Ptr + 1;
944 Extensions_Allowed := True;
946 -- Processing for y switch
948 when 'y' =>
949 Ptr := Ptr + 1;
951 if Ptr > Max then
952 Set_Default_Style_Check_Options;
954 else
955 Store_Switch := False;
956 Storing (First_Stored) := 'y';
958 declare
959 OK : Boolean;
960 Last_Stored : Integer;
962 begin
963 Set_Style_Check_Options
964 (Switch_Chars (Ptr .. Max), OK, Ptr);
966 if not OK then
967 raise Bad_Switch;
968 end if;
970 Ptr := First_Char + 1;
972 while Ptr <= Max loop
973 Last_Stored := First_Stored + 1;
974 Storing (Last_Stored) := Switch_Chars (Ptr);
976 if Switch_Chars (Ptr) = 'M' then
977 loop
978 Ptr := Ptr + 1;
979 exit when Ptr > Max
980 or else Switch_Chars (Ptr) not in '0' .. '9';
981 Last_Stored := Last_Stored + 1;
982 Storing (Last_Stored) := Switch_Chars (Ptr);
983 end loop;
985 else
986 Ptr := Ptr + 1;
987 end if;
989 Store_Compilation_Switch
990 (Storing (Storing'First .. Last_Stored));
991 end loop;
992 end;
993 end if;
995 -- Processing for z switch
997 when 'z' =>
998 Ptr := Ptr + 1;
1000 -- Allowed for compiler only if this is the only
1001 -- -z switch, we do not allow multiple occurrences
1003 if Distribution_Stub_Mode = No_Stubs then
1004 case Switch_Chars (Ptr) is
1005 when 'r' =>
1006 Distribution_Stub_Mode := Generate_Receiver_Stub_Body;
1008 when 'c' =>
1009 Distribution_Stub_Mode := Generate_Caller_Stub_Body;
1011 when others =>
1012 raise Bad_Switch;
1013 end case;
1015 Ptr := Ptr + 1;
1017 end if;
1019 -- Processing for Z switch
1021 when 'Z' =>
1022 Ptr := Ptr + 1;
1023 Zero_Cost_Exceptions_Set := True;
1024 Zero_Cost_Exceptions_Val := True;
1026 -- Processing for 83 switch
1028 when '8' =>
1030 if Ptr = Max then
1031 raise Bad_Switch;
1032 end if;
1034 Ptr := Ptr + 1;
1036 if Switch_Chars (Ptr) /= '3' then
1037 raise Bad_Switch;
1038 else
1039 Ptr := Ptr + 1;
1040 Ada_95 := False;
1041 Ada_83 := True;
1042 end if;
1044 -- Ignore extra switch character
1046 when '/' | '-' =>
1047 Ptr := Ptr + 1;
1049 -- Anything else is an error (illegal switch character)
1051 when others =>
1052 raise Bad_Switch;
1053 end case;
1054 end case;
1056 if Store_Switch then
1057 Storing (First_Stored .. First_Stored + Ptr - First_Char - 1) :=
1058 Switch_Chars (First_Char .. Ptr - 1);
1059 Store_Compilation_Switch
1060 (Storing (Storing'First .. First_Stored + Ptr - First_Char - 1));
1061 end if;
1063 First_Switch := False;
1064 end loop;
1066 exception
1067 when Bad_Switch =>
1068 Osint.Fail ("invalid switch: ", (1 => C));
1070 when Bad_Switch_Value =>
1071 Osint.Fail ("numeric value out of range for switch: ", (1 => C));
1073 when Missing_Switch_Value =>
1074 Osint.Fail ("missing numeric value for switch: ", (1 => C));
1076 end Scan_Front_End_Switches;
1078 end Switch.C;