* dwarf2out.c, fold-const.c, ipa-type-escape.c,
[official-gcc.git] / gcc / ada / switch-c.adb
blob95eabe04650b8524468421692adcb08ec1bb15e8
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-2005 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, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, 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 for -gnatg (same set as -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_Bad_Fixed_Value := True;
497 Warn_On_Constant := True;
498 Warn_On_Export_Import := True;
499 Warn_On_Modified_Unread := True;
500 Warn_On_No_Value_Assigned := True;
501 Warn_On_Obsolescent_Feature := True;
502 Warn_On_Redundant_Constructs := True;
503 Warn_On_Unchecked_Conversion := True;
504 Warn_On_Unrecognized_Pragma := True;
506 Set_Style_Check_Options ("3abcdefhiklmnprstu");
508 -- Processing for G switch
510 when 'G' =>
511 Ptr := Ptr + 1;
512 Print_Generated_Code := True;
514 -- Processing for h switch
516 when 'h' =>
517 Ptr := Ptr + 1;
518 Usage_Requested := True;
520 -- Processing for H switch
522 when 'H' =>
523 Ptr := Ptr + 1;
524 HLO_Active := True;
526 -- Processing for i switch
528 when 'i' =>
529 if Ptr = Max then
530 raise Bad_Switch;
531 end if;
533 Ptr := Ptr + 1;
534 C := Switch_Chars (Ptr);
536 if C in '1' .. '5'
537 or else C = '8'
538 or else C = '9'
539 or else C = 'p'
540 or else C = 'f'
541 or else C = 'n'
542 or else C = 'w'
543 then
544 Identifier_Character_Set := C;
545 Ptr := Ptr + 1;
547 else
548 raise Bad_Switch;
549 end if;
551 -- Processing for k switch
553 when 'k' =>
554 Ptr := Ptr + 1;
555 Scan_Pos (Switch_Chars, Max, Ptr, Maximum_File_Name_Length);
557 -- Processing for l switch
559 when 'l' =>
560 Ptr := Ptr + 1;
561 Full_List := True;
563 -- Processing for L switch
565 when 'L' =>
566 Ptr := Ptr + 1;
567 Zero_Cost_Exceptions_Set := True;
568 Zero_Cost_Exceptions_Val := False;
570 -- Processing for m switch
572 when 'm' =>
573 Ptr := Ptr + 1;
574 Scan_Pos (Switch_Chars, Max, Ptr, Maximum_Errors);
576 -- Processing for n switch
578 when 'n' =>
579 Ptr := Ptr + 1;
580 Inline_Active := True;
582 -- Processing for N switch
584 when 'N' =>
585 Ptr := Ptr + 1;
586 Inline_Active := True;
587 Front_End_Inlining := True;
589 -- Processing for o switch
591 when 'o' =>
592 Ptr := Ptr + 1;
593 Suppress_Options (Overflow_Check) := False;
594 Opt.Enable_Overflow_Checks := True;
596 -- Processing for O switch
598 when 'O' =>
599 Store_Switch := False;
600 Ptr := Ptr + 1;
601 Output_File_Name_Present := True;
603 -- Processing for p switch
605 when 'p' =>
606 Ptr := Ptr + 1;
607 Suppress_Options := (others => True);
608 Validity_Checks_On := False;
609 Opt.Suppress_Checks := True;
610 Opt.Enable_Overflow_Checks := False;
612 -- Processing for P switch
614 when 'P' =>
615 Ptr := Ptr + 1;
616 Polling_Required := True;
618 -- Processing for q switch
620 when 'q' =>
621 Ptr := Ptr + 1;
622 Try_Semantics := True;
624 -- Processing for q switch
626 when 'Q' =>
627 Ptr := Ptr + 1;
628 Force_ALI_Tree_File := True;
629 Try_Semantics := True;
631 -- Processing for R switch
633 when 'R' =>
634 Ptr := Ptr + 1;
635 Back_Annotate_Rep_Info := True;
636 List_Representation_Info := 1;
638 while Ptr <= Max loop
639 C := Switch_Chars (Ptr);
641 if C in '1' .. '3' then
642 List_Representation_Info :=
643 Character'Pos (C) - Character'Pos ('0');
645 elsif Switch_Chars (Ptr) = 's' then
646 List_Representation_Info_To_File := True;
648 elsif Switch_Chars (Ptr) = 'm' then
649 List_Representation_Info_Mechanisms := True;
651 else
652 raise Bad_Switch;
653 end if;
655 Ptr := Ptr + 1;
656 end loop;
658 -- Processing for s switch
660 when 's' =>
661 if not First_Switch then
662 Osint.Fail
663 ("-gnats must be first if combined with other switches");
664 end if;
666 Ptr := Ptr + 1;
667 Operating_Mode := Check_Syntax;
669 -- Processing for S switch
671 when 'S' =>
672 Print_Standard := True;
673 Ptr := Ptr + 1;
675 -- Processing for t switch
677 when 't' =>
678 Ptr := Ptr + 1;
679 Tree_Output := True;
681 if Operating_Mode = Check_Semantics then
682 ASIS_Mode := True;
683 end if;
685 Back_Annotate_Rep_Info := True;
687 -- Processing for T switch
689 when 'T' =>
690 Ptr := Ptr + 1;
691 Scan_Pos (Switch_Chars, Max, Ptr, Table_Factor);
693 -- Processing for u switch
695 when 'u' =>
696 Ptr := Ptr + 1;
697 List_Units := True;
699 -- Processing for U switch
701 when 'U' =>
702 Ptr := Ptr + 1;
703 Unique_Error_Tag := True;
705 -- Processing for v switch
707 when 'v' =>
708 Ptr := Ptr + 1;
709 Verbose_Mode := True;
711 -- Processing for V switch
713 when 'V' =>
714 Store_Switch := False;
715 Storing (First_Stored) := 'V';
716 Ptr := Ptr + 1;
718 if Ptr > Max then
719 raise Bad_Switch;
721 else
722 declare
723 OK : Boolean;
725 begin
726 Set_Validity_Check_Options
727 (Switch_Chars (Ptr .. Max), OK, Ptr);
729 if not OK then
730 raise Bad_Switch;
731 end if;
733 for Index in First_Char + 1 .. Max loop
734 Storing (First_Stored + 1) :=
735 Switch_Chars (Index);
736 Store_Compilation_Switch
737 (Storing (Storing'First .. First_Stored + 1));
738 end loop;
739 end;
740 end if;
742 Ptr := Max + 1;
744 -- Processing for w switch
746 when 'w' =>
747 Store_Switch := False;
748 Storing (First_Stored) := 'w';
749 Ptr := Ptr + 1;
751 if Ptr > Max then
752 raise Bad_Switch;
753 end if;
755 while Ptr <= Max loop
756 C := Switch_Chars (Ptr);
758 case C is
759 when 'a' =>
760 Check_Unreferenced := True;
761 Check_Unreferenced_Formals := True;
762 Check_Withs := True;
763 Constant_Condition_Warnings := True;
764 Implementation_Unit_Warnings := True;
765 Ineffective_Inline_Warnings := True;
766 Warn_On_Ada_2005_Compatibility := True;
767 Warn_On_Bad_Fixed_Value := True;
768 Warn_On_Constant := True;
769 Warn_On_Export_Import := True;
770 Warn_On_Modified_Unread := True;
771 Warn_On_No_Value_Assigned := True;
772 Warn_On_Obsolescent_Feature := True;
773 Warn_On_Redundant_Constructs := True;
774 Warn_On_Unchecked_Conversion := True;
775 Warn_On_Unrecognized_Pragma := True;
777 when 'A' =>
778 Check_Unreferenced := False;
779 Check_Unreferenced_Formals := False;
780 Check_Withs := False;
781 Constant_Condition_Warnings := False;
782 Elab_Warnings := False;
783 Implementation_Unit_Warnings := False;
784 Ineffective_Inline_Warnings := False;
785 Warn_On_Ada_2005_Compatibility := False;
786 Warn_On_Bad_Fixed_Value := False;
787 Warn_On_Constant := False;
788 Warn_On_Dereference := False;
789 Warn_On_Export_Import := False;
790 Warn_On_Hiding := False;
791 Warn_On_Modified_Unread := False;
792 Warn_On_No_Value_Assigned := False;
793 Warn_On_Obsolescent_Feature := False;
794 Warn_On_Redundant_Constructs := False;
795 Warn_On_Unchecked_Conversion := False;
796 Warn_On_Unrecognized_Pragma := False;
798 when 'b' =>
799 Warn_On_Bad_Fixed_Value := True;
801 when 'B' =>
802 Warn_On_Bad_Fixed_Value := False;
804 when 'c' =>
805 Constant_Condition_Warnings := True;
807 when 'C' =>
808 Constant_Condition_Warnings := False;
810 when 'd' =>
811 Warn_On_Dereference := True;
813 when 'D' =>
814 Warn_On_Dereference := False;
816 when 'e' =>
817 Warning_Mode := Treat_As_Error;
819 when 'f' =>
820 Check_Unreferenced_Formals := True;
822 when 'F' =>
823 Check_Unreferenced_Formals := False;
825 when 'g' =>
826 Warn_On_Unrecognized_Pragma := True;
828 when 'G' =>
829 Warn_On_Unrecognized_Pragma := False;
831 when 'h' =>
832 Warn_On_Hiding := True;
834 when 'H' =>
835 Warn_On_Hiding := False;
837 when 'i' =>
838 Implementation_Unit_Warnings := True;
840 when 'I' =>
841 Implementation_Unit_Warnings := False;
843 when 'j' =>
844 Warn_On_Obsolescent_Feature := True;
846 when 'J' =>
847 Warn_On_Obsolescent_Feature := False;
849 when 'k' =>
850 Warn_On_Constant := True;
852 when 'K' =>
853 Warn_On_Constant := False;
855 when 'l' =>
856 Elab_Warnings := True;
858 when 'L' =>
859 Elab_Warnings := False;
861 when 'm' =>
862 Warn_On_Modified_Unread := True;
864 when 'M' =>
865 Warn_On_Modified_Unread := False;
867 when 'n' =>
868 Warning_Mode := Normal;
870 when 'o' =>
871 Address_Clause_Overlay_Warnings := True;
873 when 'O' =>
874 Address_Clause_Overlay_Warnings := False;
876 when 'p' =>
877 Ineffective_Inline_Warnings := True;
879 when 'P' =>
880 Ineffective_Inline_Warnings := False;
882 when 'r' =>
883 Warn_On_Redundant_Constructs := True;
885 when 'R' =>
886 Warn_On_Redundant_Constructs := False;
888 when 's' =>
889 Warning_Mode := Suppress;
891 when 'u' =>
892 Check_Unreferenced := True;
893 Check_Withs := True;
894 Check_Unreferenced_Formals := True;
896 when 'U' =>
897 Check_Unreferenced := False;
898 Check_Withs := False;
899 Check_Unreferenced_Formals := False;
901 when 'v' =>
902 Warn_On_No_Value_Assigned := True;
904 when 'V' =>
905 Warn_On_No_Value_Assigned := False;
907 when 'x' =>
908 Warn_On_Export_Import := True;
910 when 'X' =>
911 Warn_On_Export_Import := False;
913 when 'y' =>
914 Warn_On_Ada_2005_Compatibility := True;
916 when 'Y' =>
917 Warn_On_Ada_2005_Compatibility := False;
919 when 'z' =>
920 Warn_On_Unchecked_Conversion := True;
922 when 'Z' =>
923 Warn_On_Unchecked_Conversion := False;
925 -- Allow and ignore 'w' so that the old
926 -- format (e.g. -gnatwuwl) will work.
928 when 'w' =>
929 null;
931 when others =>
932 raise Bad_Switch;
933 end case;
935 if C /= 'w' then
936 Storing (First_Stored + 1) := C;
937 Store_Compilation_Switch
938 (Storing (Storing'First .. First_Stored + 1));
939 end if;
941 Ptr := Ptr + 1;
942 end loop;
944 return;
946 -- Processing for W switch
948 when 'W' =>
949 Ptr := Ptr + 1;
951 if Ptr > Max then
952 raise Bad_Switch;
953 end if;
955 for J in WC_Encoding_Method loop
956 if Switch_Chars (Ptr) = WC_Encoding_Letters (J) then
957 Wide_Character_Encoding_Method := J;
958 exit;
960 elsif J = WC_Encoding_Method'Last then
961 raise Bad_Switch;
962 end if;
963 end loop;
965 Upper_Half_Encoding :=
966 Wide_Character_Encoding_Method in
967 WC_Upper_Half_Encoding_Method;
969 Ptr := Ptr + 1;
971 -- Processing for x switch
973 when 'x' =>
974 Ptr := Ptr + 1;
975 Xref_Active := False;
977 -- Processing for X switch
979 when 'X' =>
980 Ptr := Ptr + 1;
981 Extensions_Allowed := True;
982 Ada_Version := Ada_Version_Type'Last;
983 Ada_Version_Explicit := Ada_Version;
985 -- Processing for y switch
987 when 'y' =>
988 Ptr := Ptr + 1;
990 if Ptr > Max then
991 Set_Default_Style_Check_Options;
993 else
994 Store_Switch := False;
995 Storing (First_Stored) := 'y';
997 declare
998 OK : Boolean;
999 Last_Stored : Integer;
1001 begin
1002 Set_Style_Check_Options
1003 (Switch_Chars (Ptr .. Max), OK, Ptr);
1005 if not OK then
1006 raise Bad_Switch;
1007 end if;
1009 Ptr := First_Char + 1;
1011 while Ptr <= Max loop
1012 Last_Stored := First_Stored + 1;
1013 Storing (Last_Stored) := Switch_Chars (Ptr);
1015 if Switch_Chars (Ptr) = 'M' then
1016 loop
1017 Ptr := Ptr + 1;
1018 exit when Ptr > Max
1019 or else Switch_Chars (Ptr) not in '0' .. '9';
1020 Last_Stored := Last_Stored + 1;
1021 Storing (Last_Stored) := Switch_Chars (Ptr);
1022 end loop;
1024 else
1025 Ptr := Ptr + 1;
1026 end if;
1028 Store_Compilation_Switch
1029 (Storing (Storing'First .. Last_Stored));
1030 end loop;
1031 end;
1032 end if;
1034 -- Processing for z switch
1036 when 'z' =>
1037 Ptr := Ptr + 1;
1039 -- Allowed for compiler only if this is the only
1040 -- -z switch, we do not allow multiple occurrences
1042 if Distribution_Stub_Mode = No_Stubs then
1043 case Switch_Chars (Ptr) is
1044 when 'r' =>
1045 Distribution_Stub_Mode := Generate_Receiver_Stub_Body;
1047 when 'c' =>
1048 Distribution_Stub_Mode := Generate_Caller_Stub_Body;
1050 when others =>
1051 raise Bad_Switch;
1052 end case;
1054 Ptr := Ptr + 1;
1056 end if;
1058 -- Processing for Z switch
1060 when 'Z' =>
1061 Ptr := Ptr + 1;
1062 Zero_Cost_Exceptions_Set := True;
1063 Zero_Cost_Exceptions_Val := True;
1065 -- Processing for 83 switch
1067 when '8' =>
1068 if Ptr = Max then
1069 raise Bad_Switch;
1070 end if;
1072 Ptr := Ptr + 1;
1074 if Switch_Chars (Ptr) /= '3' then
1075 raise Bad_Switch;
1076 else
1077 Ptr := Ptr + 1;
1078 Ada_Version := Ada_83;
1079 Ada_Version_Explicit := Ada_Version;
1080 end if;
1082 -- Processing for 95 switch
1084 when '9' =>
1085 if Ptr = Max then
1086 raise Bad_Switch;
1087 end if;
1089 Ptr := Ptr + 1;
1091 if Switch_Chars (Ptr) /= '5' then
1092 raise Bad_Switch;
1093 else
1094 Ptr := Ptr + 1;
1095 Ada_Version := Ada_95;
1096 Ada_Version_Explicit := Ada_Version;
1097 end if;
1099 -- Processing for 05 switch
1101 when '0' =>
1102 if Ptr = Max then
1103 raise Bad_Switch;
1104 end if;
1106 Ptr := Ptr + 1;
1108 if Switch_Chars (Ptr) /= '5' then
1109 raise Bad_Switch;
1110 else
1111 Ptr := Ptr + 1;
1112 Ada_Version := Ada_05;
1113 Ada_Version_Explicit := Ada_Version;
1114 end if;
1116 -- Ignore extra switch character
1118 when '/' | '-' =>
1119 Ptr := Ptr + 1;
1121 -- Anything else is an error (illegal switch character)
1123 when others =>
1124 raise Bad_Switch;
1125 end case;
1126 end case;
1128 if Store_Switch then
1129 Storing (First_Stored .. First_Stored + Ptr - First_Char - 1) :=
1130 Switch_Chars (First_Char .. Ptr - 1);
1131 Store_Compilation_Switch
1132 (Storing (Storing'First .. First_Stored + Ptr - First_Char - 1));
1133 end if;
1135 First_Switch := False;
1136 end loop;
1138 exception
1139 when Bad_Switch =>
1140 Osint.Fail ("invalid switch: ", (1 => C));
1142 when Bad_Switch_Value =>
1143 Osint.Fail ("numeric value out of range for switch: ", (1 => C));
1145 when Missing_Switch_Value =>
1146 Osint.Fail ("missing numeric value for switch: ", (1 => C));
1148 end Scan_Front_End_Switches;
1150 end Switch.C;