* config/rs6000/predicates.md (branch_comparison_operator): Change
[official-gcc.git] / gcc / ada / switch-c.adb
blob391347a0c227d2f618379b8de6622c21e97fd1ec
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-2004 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
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 the --RTS switch. --RTS has been modified by
123 -- gcc and is now of the form -fRTS
125 elsif Ptr + 3 <= Max
126 and then Switch_Chars (Ptr .. Ptr + 3) = "fRTS"
127 then
128 Ptr := Ptr + 1;
130 if Ptr + 4 > Max
131 or else Switch_Chars (Ptr + 3) /= '='
132 then
133 Osint.Fail ("missing path for --RTS");
134 else
135 -- Check that this is the first time --RTS is specified
136 -- or if it is not the first time, the same path has
137 -- been specified.
139 if RTS_Specified = null then
140 RTS_Specified :=
141 new String'(Switch_Chars (Ptr + 4 .. Max));
143 elsif
144 RTS_Specified.all /= Switch_Chars (Ptr + 4 .. Max)
145 then
146 Osint.Fail
147 ("--RTS cannot be specified multiple times");
148 end if;
150 -- Valid --RTS switch
152 Opt.No_Stdinc := True;
153 Opt.RTS_Switch := True;
155 RTS_Src_Path_Name := Get_RTS_Search_Dir
156 (Switch_Chars (Ptr + 4 .. Max),
157 Include);
158 RTS_Lib_Path_Name := Get_RTS_Search_Dir
159 (Switch_Chars (Ptr + 4 .. Max),
160 Objects);
162 if RTS_Src_Path_Name /= null and then
163 RTS_Lib_Path_Name /= null
164 then
165 Ptr := Max + 1;
167 elsif RTS_Src_Path_Name = null and then
168 RTS_Lib_Path_Name = null
169 then
170 Osint.Fail ("RTS path not valid: missing " &
171 "adainclude and adalib directories");
173 elsif RTS_Src_Path_Name = null then
174 Osint.Fail ("RTS path not valid: missing " &
175 "adainclude directory");
177 elsif RTS_Lib_Path_Name = null then
178 Osint.Fail ("RTS path not valid: missing " &
179 "adalib directory");
180 end if;
181 end if;
182 else
183 raise Bad_Switch;
184 end if;
186 when True =>
188 -- Process -gnat* options
190 case C is
192 when 'a' =>
193 Ptr := Ptr + 1;
194 Assertions_Enabled := True;
196 -- Processing for A switch
198 when 'A' =>
199 Ptr := Ptr + 1;
200 Config_File := False;
202 -- Processing for b switch
204 when 'b' =>
205 Ptr := Ptr + 1;
206 Brief_Output := True;
208 -- Processing for c switch
210 when 'c' =>
211 if not First_Switch then
212 Osint.Fail
213 ("-gnatc must be first if combined with other switches");
214 end if;
216 Ptr := Ptr + 1;
217 Operating_Mode := Check_Semantics;
219 if Tree_Output then
220 ASIS_Mode := True;
221 end if;
223 -- Processing for d switch
225 when 'd' =>
226 Store_Switch := False;
227 Storing (First_Stored) := 'd';
228 Dot := False;
230 -- Note: for the debug switch, the remaining characters in this
231 -- switch field must all be debug flags, since all valid switch
232 -- characters are also valid debug characters.
234 -- Loop to scan out debug flags
236 while Ptr < Max loop
237 Ptr := Ptr + 1;
238 C := Switch_Chars (Ptr);
239 exit when C = ASCII.NUL or else C = '/' or else C = '-';
241 if C in '1' .. '9' or else
242 C in 'a' .. 'z' or else
243 C in 'A' .. 'Z'
244 then
245 if Dot then
246 Set_Dotted_Debug_Flag (C);
247 Storing (First_Stored + 1) := '.';
248 Storing (First_Stored + 2) := C;
249 Store_Compilation_Switch
250 (Storing (Storing'First .. First_Stored + 2));
251 Dot := False;
253 else
254 Set_Debug_Flag (C);
255 Storing (First_Stored + 1) := C;
256 Store_Compilation_Switch
257 (Storing (Storing'First .. First_Stored + 1));
258 end if;
260 elsif C = '.' then
261 Dot := True;
263 else
264 raise Bad_Switch;
265 end if;
266 end loop;
268 -- Make sure Zero_Cost_Exceptions is set if gnatdX set. This
269 -- is for backwards compatibility with old versions and usage.
271 if Debug_Flag_XX then
272 Zero_Cost_Exceptions_Set := True;
273 Zero_Cost_Exceptions_Val := True;
274 end if;
276 return;
278 -- Processing for D switch
280 when 'D' =>
281 Ptr := Ptr + 1;
283 -- Note: -gnatD also sets -gnatx (to turn off cross-reference
284 -- generation in the ali file) since otherwise this generation
285 -- gets confused by the "wrong" Sloc values put in the tree.
287 Debug_Generated_Code := True;
288 Xref_Active := False;
289 Set_Debug_Flag ('g');
291 -- -gnate? (extended switches)
293 when 'e' =>
294 Ptr := Ptr + 1;
296 -- The -gnate? switches are all double character switches
297 -- so we must always have a character after the e.
299 if Ptr > Max then
300 raise Bad_Switch;
301 end if;
303 case Switch_Chars (Ptr) is
305 -- -gnatec (configuration pragmas)
307 when 'c' =>
308 Store_Switch := False;
309 Ptr := Ptr + 1;
311 -- There may be an equal sign between -gnatec and
312 -- the path name of the config file.
314 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
315 Ptr := Ptr + 1;
316 end if;
318 if Ptr > Max then
319 raise Bad_Switch;
320 end if;
322 declare
323 Config_File_Name : constant String_Access :=
324 new String'
325 (Switch_Chars (Ptr .. Max));
327 begin
328 if Config_File_Names = null then
329 Config_File_Names :=
330 new String_List'(1 => Config_File_Name);
332 else
333 declare
334 New_Names : constant String_List_Access :=
335 new String_List
336 (1 ..
337 Config_File_Names'Length + 1);
339 begin
340 for Index in Config_File_Names'Range loop
341 New_Names (Index) :=
342 Config_File_Names (Index);
343 Config_File_Names (Index) := null;
344 end loop;
346 New_Names (New_Names'Last) := Config_File_Name;
347 Free (Config_File_Names);
348 Config_File_Names := New_Names;
349 end;
350 end if;
351 end;
353 return;
355 -- -gnateD switch (symbol definition)
357 when 'D' =>
358 Store_Switch := False;
359 Ptr := Ptr + 1;
361 if Ptr > Max then
362 raise Bad_Switch;
363 end if;
365 Add_Symbol_Definition (Switch_Chars (Ptr .. Max));
367 -- Store the switch
369 Storing (First_Stored .. First_Stored + 1) := "eD";
370 Storing
371 (First_Stored + 2 .. First_Stored + Max - Ptr + 2) :=
372 Switch_Chars (Ptr .. Max);
373 Store_Compilation_Switch (Storing
374 (Storing'First .. First_Stored + Max - Ptr + 2));
375 return;
377 -- -gnatef (full source path for brief error messages)
379 when 'f' =>
380 Store_Switch := False;
381 Ptr := Ptr + 1;
382 Full_Path_Name_For_Brief_Errors := True;
383 return;
385 -- -gnateI (index of unit in multi-unit source)
387 when 'I' =>
388 Ptr := Ptr + 1;
389 Scan_Pos (Switch_Chars, Max, Ptr, Multiple_Unit_Index);
391 -- -gnatem (mapping file)
393 when 'm' =>
394 Store_Switch := False;
395 Ptr := Ptr + 1;
397 -- There may be an equal sign between -gnatem and
398 -- the path name of the mapping file.
400 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
401 Ptr := Ptr + 1;
402 end if;
404 if Ptr > Max then
405 raise Bad_Switch;
406 end if;
408 Mapping_File_Name :=
409 new String'(Switch_Chars (Ptr .. Max));
410 return;
412 -- -gnatep (preprocessing data file)
414 when 'p' =>
415 Store_Switch := False;
416 Ptr := Ptr + 1;
418 -- There may be an equal sign between -gnatep and
419 -- the path name of the mapping file.
421 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
422 Ptr := Ptr + 1;
423 end if;
425 if Ptr > Max then
426 raise Bad_Switch;
427 end if;
429 Preprocessing_Data_File :=
430 new String'(Switch_Chars (Ptr .. Max));
432 -- Store the switch.
433 -- Because we may store a longer switch (we normalize
434 -- to -gnatep=), use a local variable.
436 declare
437 To_Store : String
438 (1 .. Preprocessing_Data_File'Length + 8);
440 begin
441 To_Store (1 .. 8) := "-gnatep=";
442 To_Store (9 .. Preprocessing_Data_File'Length + 8) :=
443 Preprocessing_Data_File.all;
444 Store_Compilation_Switch (To_Store);
445 end;
447 return;
449 when 'z' =>
450 Store_Switch := False;
451 Disable_Switch_Storing;
452 Ptr := Ptr + 1;
454 -- All other -gnate? switches are unassigned
456 when others =>
457 raise Bad_Switch;
458 end case;
460 -- -gnatE (dynamic elaboration checks)
462 when 'E' =>
463 Ptr := Ptr + 1;
464 Dynamic_Elaboration_Checks := True;
466 -- -gnatf (full error messages)
468 when 'f' =>
469 Ptr := Ptr + 1;
470 All_Errors_Mode := True;
472 -- Processing for F switch
474 when 'F' =>
475 Ptr := Ptr + 1;
476 External_Name_Exp_Casing := Uppercase;
477 External_Name_Imp_Casing := Uppercase;
479 -- Processing for g switch
481 when 'g' =>
482 Ptr := Ptr + 1;
483 GNAT_Mode := True;
484 Identifier_Character_Set := 'n';
485 System_Extend_Unit := Empty;
486 Warning_Mode := Treat_As_Error;
488 -- Set default warnings (basically -gnatwa)
490 Check_Unreferenced := True;
491 Check_Unreferenced_Formals := True;
492 Check_Withs := True;
493 Constant_Condition_Warnings := True;
494 Implementation_Unit_Warnings := True;
495 Ineffective_Inline_Warnings := True;
496 Warn_On_Constant := True;
497 Warn_On_Export_Import := True;
498 Warn_On_Modified_Unread := True;
499 Warn_On_No_Value_Assigned := True;
500 Warn_On_Obsolescent_Feature := True;
501 Warn_On_Redundant_Constructs := True;
502 Warn_On_Unchecked_Conversion := True;
503 Warn_On_Unrecognized_Pragma := True;
505 Set_Default_Style_Check_Options;
507 -- Processing for G switch
509 when 'G' =>
510 Ptr := Ptr + 1;
511 Print_Generated_Code := True;
513 -- Processing for h switch
515 when 'h' =>
516 Ptr := Ptr + 1;
517 Usage_Requested := True;
519 -- Processing for H switch
521 when 'H' =>
522 Ptr := Ptr + 1;
523 HLO_Active := True;
525 -- Processing for i switch
527 when 'i' =>
528 if Ptr = Max then
529 raise Bad_Switch;
530 end if;
532 Ptr := Ptr + 1;
533 C := Switch_Chars (Ptr);
535 if C in '1' .. '5'
536 or else C = '8'
537 or else C = '9'
538 or else C = 'p'
539 or else C = 'f'
540 or else C = 'n'
541 or else C = 'w'
542 then
543 Identifier_Character_Set := C;
544 Ptr := Ptr + 1;
546 else
547 raise Bad_Switch;
548 end if;
550 -- Processing for k switch
552 when 'k' =>
553 Ptr := Ptr + 1;
554 Scan_Pos (Switch_Chars, Max, Ptr, Maximum_File_Name_Length);
556 -- Processing for l switch
558 when 'l' =>
559 Ptr := Ptr + 1;
560 Full_List := True;
562 -- Processing for L switch
564 when 'L' =>
565 Ptr := Ptr + 1;
566 Zero_Cost_Exceptions_Set := True;
567 Zero_Cost_Exceptions_Val := False;
569 -- Processing for m switch
571 when 'm' =>
572 Ptr := Ptr + 1;
573 Scan_Pos (Switch_Chars, Max, Ptr, Maximum_Errors);
575 -- Processing for n switch
577 when 'n' =>
578 Ptr := Ptr + 1;
579 Inline_Active := True;
581 -- Processing for N switch
583 when 'N' =>
584 Ptr := Ptr + 1;
585 Inline_Active := True;
586 Front_End_Inlining := True;
588 -- Processing for o switch
590 when 'o' =>
591 Ptr := Ptr + 1;
592 Suppress_Options (Overflow_Check) := False;
593 Opt.Enable_Overflow_Checks := True;
595 -- Processing for O switch
597 when 'O' =>
598 Store_Switch := False;
599 Ptr := Ptr + 1;
600 Output_File_Name_Present := True;
602 -- Processing for p switch
604 when 'p' =>
605 Ptr := Ptr + 1;
606 Suppress_Options := (others => True);
607 Validity_Checks_On := False;
608 Opt.Suppress_Checks := True;
609 Opt.Enable_Overflow_Checks := False;
611 -- Processing for P switch
613 when 'P' =>
614 Ptr := Ptr + 1;
615 Polling_Required := True;
617 -- Processing for q switch
619 when 'q' =>
620 Ptr := Ptr + 1;
621 Try_Semantics := True;
623 -- Processing for q switch
625 when 'Q' =>
626 Ptr := Ptr + 1;
627 Force_ALI_Tree_File := True;
628 Try_Semantics := True;
630 -- Processing for R switch
632 when 'R' =>
633 Ptr := Ptr + 1;
634 Back_Annotate_Rep_Info := True;
635 List_Representation_Info := 1;
637 while Ptr <= Max loop
638 C := Switch_Chars (Ptr);
640 if C in '1' .. '3' then
641 List_Representation_Info :=
642 Character'Pos (C) - Character'Pos ('0');
644 elsif Switch_Chars (Ptr) = 's' then
645 List_Representation_Info_To_File := True;
647 elsif Switch_Chars (Ptr) = 'm' then
648 List_Representation_Info_Mechanisms := True;
650 else
651 raise Bad_Switch;
652 end if;
654 Ptr := Ptr + 1;
655 end loop;
657 -- Processing for s switch
659 when 's' =>
660 if not First_Switch then
661 Osint.Fail
662 ("-gnats must be first if combined with other switches");
663 end if;
665 Ptr := Ptr + 1;
666 Operating_Mode := Check_Syntax;
668 -- Processing for S switch
670 when 'S' =>
671 Print_Standard := True;
672 Ptr := Ptr + 1;
674 -- Processing for t switch
676 when 't' =>
677 Ptr := Ptr + 1;
678 Tree_Output := True;
680 if Operating_Mode = Check_Semantics then
681 ASIS_Mode := True;
682 end if;
684 Back_Annotate_Rep_Info := True;
686 -- Processing for T switch
688 when 'T' =>
689 Ptr := Ptr + 1;
690 Scan_Pos (Switch_Chars, Max, Ptr, Table_Factor);
692 -- Processing for u switch
694 when 'u' =>
695 Ptr := Ptr + 1;
696 List_Units := True;
698 -- Processing for U switch
700 when 'U' =>
701 Ptr := Ptr + 1;
702 Unique_Error_Tag := True;
704 -- Processing for v switch
706 when 'v' =>
707 Ptr := Ptr + 1;
708 Verbose_Mode := True;
710 -- Processing for V switch
712 when 'V' =>
713 Store_Switch := False;
714 Storing (First_Stored) := 'V';
715 Ptr := Ptr + 1;
717 if Ptr > Max then
718 raise Bad_Switch;
720 else
721 declare
722 OK : Boolean;
724 begin
725 Set_Validity_Check_Options
726 (Switch_Chars (Ptr .. Max), OK, Ptr);
728 if not OK then
729 raise Bad_Switch;
730 end if;
732 for Index in First_Char + 1 .. Max loop
733 Storing (First_Stored + 1) :=
734 Switch_Chars (Index);
735 Store_Compilation_Switch
736 (Storing (Storing'First .. First_Stored + 1));
737 end loop;
738 end;
739 end if;
741 Ptr := Max + 1;
743 -- Processing for w switch
745 when 'w' =>
746 Store_Switch := False;
747 Storing (First_Stored) := 'w';
748 Ptr := Ptr + 1;
750 if Ptr > Max then
751 raise Bad_Switch;
752 end if;
754 while Ptr <= Max loop
755 C := Switch_Chars (Ptr);
757 case C is
758 when 'a' =>
759 Check_Unreferenced := True;
760 Check_Unreferenced_Formals := True;
761 Check_Withs := True;
762 Constant_Condition_Warnings := True;
763 Implementation_Unit_Warnings := True;
764 Ineffective_Inline_Warnings := True;
765 Warn_On_Constant := True;
766 Warn_On_Export_Import := True;
767 Warn_On_Modified_Unread := True;
768 Warn_On_No_Value_Assigned := True;
769 Warn_On_Obsolescent_Feature := True;
770 Warn_On_Redundant_Constructs := True;
771 Warn_On_Unchecked_Conversion := True;
772 Warn_On_Unrecognized_Pragma := True;
774 when 'A' =>
775 Check_Unreferenced := False;
776 Check_Unreferenced_Formals := False;
777 Check_Withs := False;
778 Constant_Condition_Warnings := False;
779 Elab_Warnings := False;
780 Implementation_Unit_Warnings := False;
781 Ineffective_Inline_Warnings := False;
782 Warn_On_Constant := False;
783 Warn_On_Dereference := False;
784 Warn_On_Export_Import := False;
785 Warn_On_Hiding := False;
786 Warn_On_Modified_Unread := False;
787 Warn_On_No_Value_Assigned := False;
788 Warn_On_Obsolescent_Feature := False;
789 Warn_On_Redundant_Constructs := False;
790 Warn_On_Unchecked_Conversion := False;
791 Warn_On_Unrecognized_Pragma := False;
793 when 'c' =>
794 Constant_Condition_Warnings := True;
796 when 'C' =>
797 Constant_Condition_Warnings := False;
799 when 'd' =>
800 Warn_On_Dereference := True;
802 when 'D' =>
803 Warn_On_Dereference := False;
805 when 'e' =>
806 Warning_Mode := Treat_As_Error;
808 when 'f' =>
809 Check_Unreferenced_Formals := True;
811 when 'F' =>
812 Check_Unreferenced_Formals := False;
814 when 'g' =>
815 Warn_On_Unrecognized_Pragma := True;
817 when 'G' =>
818 Warn_On_Unrecognized_Pragma := False;
820 when 'h' =>
821 Warn_On_Hiding := True;
823 when 'H' =>
824 Warn_On_Hiding := False;
826 when 'i' =>
827 Implementation_Unit_Warnings := True;
829 when 'I' =>
830 Implementation_Unit_Warnings := False;
832 when 'j' =>
833 Warn_On_Obsolescent_Feature := True;
835 when 'J' =>
836 Warn_On_Obsolescent_Feature := False;
838 when 'k' =>
839 Warn_On_Constant := True;
841 when 'K' =>
842 Warn_On_Constant := False;
844 when 'l' =>
845 Elab_Warnings := True;
847 when 'L' =>
848 Elab_Warnings := False;
850 when 'm' =>
851 Warn_On_Modified_Unread := True;
853 when 'M' =>
854 Warn_On_Modified_Unread := False;
856 when 'n' =>
857 Warning_Mode := Normal;
859 when 'o' =>
860 Address_Clause_Overlay_Warnings := True;
862 when 'O' =>
863 Address_Clause_Overlay_Warnings := False;
865 when 'p' =>
866 Ineffective_Inline_Warnings := True;
868 when 'P' =>
869 Ineffective_Inline_Warnings := False;
871 when 'r' =>
872 Warn_On_Redundant_Constructs := True;
874 when 'R' =>
875 Warn_On_Redundant_Constructs := False;
877 when 's' =>
878 Warning_Mode := Suppress;
880 when 'u' =>
881 Check_Unreferenced := True;
882 Check_Withs := True;
883 Check_Unreferenced_Formals := True;
885 when 'U' =>
886 Check_Unreferenced := False;
887 Check_Withs := False;
888 Check_Unreferenced_Formals := False;
890 when 'v' =>
891 Warn_On_No_Value_Assigned := True;
893 when 'V' =>
894 Warn_On_No_Value_Assigned := False;
896 when 'x' =>
897 Warn_On_Export_Import := True;
899 when 'X' =>
900 Warn_On_Export_Import := False;
902 when 'z' =>
903 Warn_On_Unchecked_Conversion := True;
905 when 'Z' =>
906 Warn_On_Unchecked_Conversion := False;
908 -- Allow and ignore 'w' so that the old
909 -- format (e.g. -gnatwuwl) will work.
911 when 'w' =>
912 null;
914 when others =>
915 raise Bad_Switch;
916 end case;
918 if C /= 'w' then
919 Storing (First_Stored + 1) := C;
920 Store_Compilation_Switch
921 (Storing (Storing'First .. First_Stored + 1));
922 end if;
924 Ptr := Ptr + 1;
925 end loop;
927 return;
929 -- Processing for W switch
931 when 'W' =>
932 Ptr := Ptr + 1;
934 if Ptr > Max then
935 raise Bad_Switch;
936 end if;
938 for J in WC_Encoding_Method loop
939 if Switch_Chars (Ptr) = WC_Encoding_Letters (J) then
940 Wide_Character_Encoding_Method := J;
941 exit;
943 elsif J = WC_Encoding_Method'Last then
944 raise Bad_Switch;
945 end if;
946 end loop;
948 Upper_Half_Encoding :=
949 Wide_Character_Encoding_Method in
950 WC_Upper_Half_Encoding_Method;
952 Ptr := Ptr + 1;
954 -- Processing for x switch
956 when 'x' =>
957 Ptr := Ptr + 1;
958 Xref_Active := False;
960 -- Processing for X switch
962 when 'X' =>
963 Ptr := Ptr + 1;
964 Extensions_Allowed := True;
965 Ada_Version := Ada_Version_Type'Last;
967 -- Processing for y switch
969 when 'y' =>
970 Ptr := Ptr + 1;
972 if Ptr > Max then
973 Set_Default_Style_Check_Options;
975 else
976 Store_Switch := False;
977 Storing (First_Stored) := 'y';
979 declare
980 OK : Boolean;
981 Last_Stored : Integer;
983 begin
984 Set_Style_Check_Options
985 (Switch_Chars (Ptr .. Max), OK, Ptr);
987 if not OK then
988 raise Bad_Switch;
989 end if;
991 Ptr := First_Char + 1;
993 while Ptr <= Max loop
994 Last_Stored := First_Stored + 1;
995 Storing (Last_Stored) := Switch_Chars (Ptr);
997 if Switch_Chars (Ptr) = 'M' then
998 loop
999 Ptr := Ptr + 1;
1000 exit when Ptr > Max
1001 or else Switch_Chars (Ptr) not in '0' .. '9';
1002 Last_Stored := Last_Stored + 1;
1003 Storing (Last_Stored) := Switch_Chars (Ptr);
1004 end loop;
1006 else
1007 Ptr := Ptr + 1;
1008 end if;
1010 Store_Compilation_Switch
1011 (Storing (Storing'First .. Last_Stored));
1012 end loop;
1013 end;
1014 end if;
1016 -- Processing for z switch
1018 when 'z' =>
1019 Ptr := Ptr + 1;
1021 -- Allowed for compiler only if this is the only
1022 -- -z switch, we do not allow multiple occurrences
1024 if Distribution_Stub_Mode = No_Stubs then
1025 case Switch_Chars (Ptr) is
1026 when 'r' =>
1027 Distribution_Stub_Mode := Generate_Receiver_Stub_Body;
1029 when 'c' =>
1030 Distribution_Stub_Mode := Generate_Caller_Stub_Body;
1032 when others =>
1033 raise Bad_Switch;
1034 end case;
1036 Ptr := Ptr + 1;
1038 end if;
1040 -- Processing for Z switch
1042 when 'Z' =>
1043 Ptr := Ptr + 1;
1044 Zero_Cost_Exceptions_Set := True;
1045 Zero_Cost_Exceptions_Val := True;
1047 -- Processing for 83 switch
1049 when '8' =>
1050 if Ptr = Max then
1051 raise Bad_Switch;
1052 end if;
1054 Ptr := Ptr + 1;
1056 if Switch_Chars (Ptr) /= '3' then
1057 raise Bad_Switch;
1058 else
1059 Ptr := Ptr + 1;
1060 Ada_Version := Ada_83;
1061 end if;
1063 -- Processing for 95 switch
1065 when '9' =>
1066 if Ptr = Max then
1067 raise Bad_Switch;
1068 end if;
1070 Ptr := Ptr + 1;
1072 if Switch_Chars (Ptr) /= '5' then
1073 raise Bad_Switch;
1074 else
1075 Ptr := Ptr + 1;
1076 Ada_Version := Ada_95;
1077 end if;
1079 -- Processing for 05 switch
1081 when '0' =>
1082 if Ptr = Max then
1083 raise Bad_Switch;
1084 end if;
1086 Ptr := Ptr + 1;
1088 if Switch_Chars (Ptr) /= '5' then
1089 raise Bad_Switch;
1090 else
1091 Ptr := Ptr + 1;
1092 Ada_Version := Ada_05;
1093 end if;
1095 -- Ignore extra switch character
1097 when '/' | '-' =>
1098 Ptr := Ptr + 1;
1100 -- Anything else is an error (illegal switch character)
1102 when others =>
1103 raise Bad_Switch;
1104 end case;
1105 end case;
1107 if Store_Switch then
1108 Storing (First_Stored .. First_Stored + Ptr - First_Char - 1) :=
1109 Switch_Chars (First_Char .. Ptr - 1);
1110 Store_Compilation_Switch
1111 (Storing (Storing'First .. First_Stored + Ptr - First_Char - 1));
1112 end if;
1114 First_Switch := False;
1115 end loop;
1117 exception
1118 when Bad_Switch =>
1119 Osint.Fail ("invalid switch: ", (1 => C));
1121 when Bad_Switch_Value =>
1122 Osint.Fail ("numeric value out of range for switch: ", (1 => C));
1124 when Missing_Switch_Value =>
1125 Osint.Fail ("missing numeric value for switch: ", (1 => C));
1127 end Scan_Front_End_Switches;
1129 end Switch.C;