switch-c.adb, [...]: Implement new switch -gnatw.g.
[gcc.git] / gcc / ada / switch-c.adb
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- S W I T C H - C --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 2001-2009, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
20 -- --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
23 -- --
24 ------------------------------------------------------------------------------
25
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;
34
35 with System.OS_Lib; use System.OS_Lib;
36
37 with System.WCh_Con; use System.WCh_Con;
38
39 package body Switch.C is
40
41 RTS_Specified : String_Access := null;
42 -- Used to detect multiple use of --RTS= flag
43
44 -----------------------------
45 -- Scan_Front_End_Switches --
46 -----------------------------
47
48 procedure Scan_Front_End_Switches (Switch_Chars : String) is
49 First_Switch : Boolean := True;
50 -- False for all but first switch
51
52 Max : constant Natural := Switch_Chars'Last;
53 Ptr : Natural;
54 C : Character := ' ';
55 Dot : Boolean;
56
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.
65
66 First_Char : Positive;
67 -- Marks start of switch to be stored
68
69 begin
70 Ptr := Switch_Chars'First;
71
72 -- Skip past the initial character (must be the switch character)
73
74 if Ptr = Max then
75 Bad_Switch (C);
76 else
77 Ptr := Ptr + 1;
78 end if;
79
80 -- Handle switches that do not start with -gnat
81
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
87
88 if Switch_Chars (Ptr) = 'I' then
89
90 -- Set flag Search_Directory_Present if switch is "-I" only:
91 -- the directory will be the next argument.
92
93 if Ptr = Max then
94 Search_Directory_Present := True;
95 return;
96 end if;
97
98 Ptr := Ptr + 1;
99
100 -- Find out whether this is a -I- or regular -Ixxx switch
101
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.
105
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;
111
112 -- Processing of the --RTS switch. --RTS may have been modified by
113 -- gcc into -fRTS (for GCC targets).
114
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;
121
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.
129
130 if RTS_Specified = null then
131 RTS_Specified := new String'(Switch_Chars (Ptr + 4 .. Max));
132
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;
138
139 -- Valid --RTS switch
140
141 Opt.No_Stdinc := True;
142 Opt.RTS_Switch := True;
143
144 RTS_Src_Path_Name :=
145 Get_RTS_Search_Dir
146 (Switch_Chars (Ptr + 4 .. Max), Include);
147
148 RTS_Lib_Path_Name :=
149 Get_RTS_Search_Dir
150 (Switch_Chars (Ptr + 4 .. Max), Objects);
151
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).
157
158 Store_Compilation_Switch (Switch_Chars);
159
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");
165
166 elsif RTS_Src_Path_Name = null then
167 Osint.Fail ("RTS path not valid: missing " &
168 "adainclude directory");
169
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;
175
176 -- There are no other switches not starting with -gnat
177
178 else
179 Bad_Switch (Switch_Chars);
180 end if;
181
182 -- Case of switch starting with -gnat
183
184 else
185 Ptr := Ptr + 4;
186
187 -- Loop to scan through switches given in switch string
188
189 while Ptr <= Max loop
190 First_Char := Ptr;
191 Store_Switch := True;
192
193 C := Switch_Chars (Ptr);
194
195 case C is
196
197 when 'a' =>
198 Ptr := Ptr + 1;
199 Assertions_Enabled := True;
200 Debug_Pragmas_Enabled := True;
201
202 -- Processing for A switch
203
204 when 'A' =>
205 Ptr := Ptr + 1;
206 Config_File := False;
207
208 -- Processing for b switch
209
210 when 'b' =>
211 Ptr := Ptr + 1;
212 Brief_Output := True;
213
214 -- Processing for B switch
215
216 when 'B' =>
217 Ptr := Ptr + 1;
218 Assume_No_Invalid_Values := True;
219
220 -- Processing for c switch
221
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;
227
228 Ptr := Ptr + 1;
229 Operating_Mode := Check_Semantics;
230
231 -- Processing for C switch
232
233 when 'C' =>
234 Ptr := Ptr + 1;
235 CodePeer_Mode := True;
236
237 -- Processing for d switch
238
239 when 'd' =>
240 Store_Switch := False;
241 Dot := False;
242
243 -- Note: for the debug switch, the remaining characters in this
244 -- switch field must all be debug flags, since all valid switch
245 -- characters are also valid debug characters.
246
247 -- Loop to scan out debug flags
248
249 while Ptr < Max loop
250 Ptr := Ptr + 1;
251 C := Switch_Chars (Ptr);
252 exit when C = ASCII.NUL or else C = '/' or else C = '-';
253
254 if C in '1' .. '9' or else
255 C in 'a' .. 'z' or else
256 C in 'A' .. 'Z'
257 then
258 if Dot then
259 Set_Dotted_Debug_Flag (C);
260 Store_Compilation_Switch ("-gnatd." & C);
261 else
262 Set_Debug_Flag (C);
263 Store_Compilation_Switch ("-gnatd" & C);
264 end if;
265
266 elsif C = '.' then
267 Dot := True;
268
269 elsif Dot then
270 Bad_Switch ("-gnatd." & Switch_Chars (Ptr .. Max));
271 else
272 Bad_Switch ("-gnatd" & Switch_Chars (Ptr .. Max));
273 end if;
274 end loop;
275
276 return;
277
278 -- Processing for D switch
279
280 when 'D' =>
281 Ptr := Ptr + 1;
282
283 -- Scan optional integer line limit value
284
285 if Nat_Present (Switch_Chars, Max, Ptr) then
286 Scan_Nat (Switch_Chars, Max, Ptr, Sprint_Line_Limit, 'D');
287 Sprint_Line_Limit := Nat'Max (Sprint_Line_Limit, 40);
288 end if;
289
290 -- Note: -gnatD also sets -gnatx (to turn off cross-reference
291 -- generation in the ali file) since otherwise this generation
292 -- gets confused by the "wrong" Sloc values put in the tree.
293
294 Debug_Generated_Code := True;
295 Xref_Active := False;
296 Set_Debug_Flag ('g');
297
298 -- -gnate? (extended switches)
299
300 when 'e' =>
301 Ptr := Ptr + 1;
302
303 -- The -gnate? switches are all double character switches
304 -- so we must always have a character after the e.
305
306 if Ptr > Max then
307 Bad_Switch ("-gnate");
308 end if;
309
310 case Switch_Chars (Ptr) is
311
312 when 'a' =>
313 Store_Switch := False;
314 Enable_Switch_Storing;
315 Ptr := Ptr + 1;
316
317 -- -gnatec (configuration pragmas)
318
319 when 'c' =>
320 Store_Switch := False;
321 Ptr := Ptr + 1;
322
323 -- There may be an equal sign between -gnatec and
324 -- the path name of the config file.
325
326 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
327 Ptr := Ptr + 1;
328 end if;
329
330 if Ptr > Max then
331 Bad_Switch ("-gnatec");
332 end if;
333
334 declare
335 Config_File_Name : constant String_Access :=
336 new String'
337 (Switch_Chars (Ptr .. Max));
338
339 begin
340 if Config_File_Names = null then
341 Config_File_Names :=
342 new String_List'(1 => Config_File_Name);
343
344 else
345 declare
346 New_Names : constant String_List_Access :=
347 new String_List
348 (1 ..
349 Config_File_Names'Length + 1);
350
351 begin
352 for Index in Config_File_Names'Range loop
353 New_Names (Index) :=
354 Config_File_Names (Index);
355 Config_File_Names (Index) := null;
356 end loop;
357
358 New_Names (New_Names'Last) := Config_File_Name;
359 Free (Config_File_Names);
360 Config_File_Names := New_Names;
361 end;
362 end if;
363 end;
364
365 return;
366
367 -- -gnateC switch (CodePeer SCIL generation)
368 -- Not enabled for now, keep it for later???
369 -- use -gnatd.I only for now
370
371 -- when 'C' =>
372 -- Ptr := Ptr + 1;
373 -- Generate_SCIL := True;
374
375 -- -gnateD switch (preprocessing symbol definition)
376
377 when 'D' =>
378 Store_Switch := False;
379 Ptr := Ptr + 1;
380
381 if Ptr > Max then
382 Bad_Switch ("-gnateD");
383 end if;
384
385 Add_Symbol_Definition (Switch_Chars (Ptr .. Max));
386
387 -- Store the switch
388
389 Store_Compilation_Switch
390 ("-gnateD" & Switch_Chars (Ptr .. Max));
391 Ptr := Max + 1;
392
393 -- -gnatef (full source path for brief error messages)
394
395 when 'f' =>
396 Store_Switch := False;
397 Ptr := Ptr + 1;
398 Full_Path_Name_For_Brief_Errors := True;
399 return;
400
401 -- -gnateG (save preprocessor output)
402
403 when 'G' =>
404 if Ptr < Max then
405 Bad_Switch (Switch_Chars);
406 end if;
407
408 Generate_Processed_File := True;
409 Ptr := Ptr + 1;
410
411 -- -gnateI (index of unit in multi-unit source)
412
413 when 'I' =>
414 Ptr := Ptr + 1;
415 Scan_Pos (Switch_Chars, Max, Ptr, Multiple_Unit_Index, C);
416
417 -- -gnatem (mapping file)
418
419 when 'm' =>
420 Store_Switch := False;
421 Ptr := Ptr + 1;
422
423 -- There may be an equal sign between -gnatem and
424 -- the path name of the mapping file.
425
426 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
427 Ptr := Ptr + 1;
428 end if;
429
430 if Ptr > Max then
431 Bad_Switch ("-gnatem");
432 end if;
433
434 Mapping_File_Name :=
435 new String'(Switch_Chars (Ptr .. Max));
436 return;
437
438 -- -gnatep (preprocessing data file)
439
440 when 'p' =>
441 Store_Switch := False;
442 Ptr := Ptr + 1;
443
444 -- There may be an equal sign between -gnatep and
445 -- the path name of the mapping file.
446
447 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
448 Ptr := Ptr + 1;
449 end if;
450
451 if Ptr > Max then
452 Bad_Switch ("-gnatep");
453 end if;
454
455 Preprocessing_Data_File :=
456 new String'(Switch_Chars (Ptr .. Max));
457
458 -- Store the switch, normalizing to -gnatep=
459
460 Store_Compilation_Switch
461 ("-gnatep=" & Preprocessing_Data_File.all);
462
463 Ptr := Max + 1;
464
465 when 'z' =>
466 Store_Switch := False;
467 Disable_Switch_Storing;
468 Ptr := Ptr + 1;
469
470 -- All other -gnate? switches are unassigned
471
472 when others =>
473 Bad_Switch ("-gnate" & Switch_Chars (Ptr .. Max));
474 end case;
475
476 -- -gnatE (dynamic elaboration checks)
477
478 when 'E' =>
479 Ptr := Ptr + 1;
480 Dynamic_Elaboration_Checks := True;
481
482 -- -gnatf (full error messages)
483
484 when 'f' =>
485 Ptr := Ptr + 1;
486 All_Errors_Mode := True;
487
488 -- Processing for F switch
489
490 when 'F' =>
491 Ptr := Ptr + 1;
492 External_Name_Exp_Casing := Uppercase;
493 External_Name_Imp_Casing := Uppercase;
494
495 -- Processing for g switch
496
497 when 'g' =>
498 Ptr := Ptr + 1;
499 GNAT_Mode := True;
500 Identifier_Character_Set := 'n';
501 System_Extend_Unit := Empty;
502 Warning_Mode := Treat_As_Error;
503
504 -- Set Ada 2005 mode explicitly. We don't want to rely on the
505 -- implicit setting here, since for example, we want
506 -- Preelaborate_05 treated as Preelaborate
507
508 Ada_Version := Ada_05;
509 Ada_Version_Explicit := Ada_Version;
510
511 -- Set default warnings and style checks for -gnatg
512
513 Set_GNAT_Mode_Warnings;
514 Set_GNAT_Style_Check_Options;
515
516 -- Processing for G switch
517
518 when 'G' =>
519 Ptr := Ptr + 1;
520 Print_Generated_Code := True;
521
522 -- Scan optional integer line limit value
523
524 if Nat_Present (Switch_Chars, Max, Ptr) then
525 Scan_Nat (Switch_Chars, Max, Ptr, Sprint_Line_Limit, 'G');
526 Sprint_Line_Limit := Nat'Max (Sprint_Line_Limit, 40);
527 end if;
528
529 -- Processing for h switch
530
531 when 'h' =>
532 Ptr := Ptr + 1;
533 Usage_Requested := True;
534
535 -- Processing for H switch
536
537 when 'H' =>
538 Ptr := Ptr + 1;
539 HLO_Active := True;
540
541 -- Processing for i switch
542
543 when 'i' =>
544 if Ptr = Max then
545 Bad_Switch ("-gnati");
546 end if;
547
548 Ptr := Ptr + 1;
549 C := Switch_Chars (Ptr);
550
551 if C in '1' .. '5'
552 or else C = '8'
553 or else C = '9'
554 or else C = 'p'
555 or else C = 'f'
556 or else C = 'n'
557 or else C = 'w'
558 then
559 Identifier_Character_Set := C;
560 Ptr := Ptr + 1;
561
562 else
563 Bad_Switch ("-gnati" & Switch_Chars (Ptr .. Max));
564 end if;
565
566 -- Processing for I switch
567
568 when 'I' =>
569 Ptr := Ptr + 1;
570 Ignore_Rep_Clauses := True;
571
572 -- Processing for j switch
573
574 when 'j' =>
575 Ptr := Ptr + 1;
576 Scan_Nat (Switch_Chars, Max, Ptr, Error_Msg_Line_Length, C);
577
578 -- Processing for k switch
579
580 when 'k' =>
581 Ptr := Ptr + 1;
582 Scan_Pos
583 (Switch_Chars, Max, Ptr, Maximum_File_Name_Length, C);
584
585 -- Processing for l switch
586
587 when 'l' =>
588 Ptr := Ptr + 1;
589 Full_List := True;
590
591 -- There may be an equal sign between -gnatl and a file name
592
593 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
594 if Ptr = Max then
595 Osint.Fail ("file name for -gnatl= is null");
596 else
597 Opt.Full_List_File_Name :=
598 new String'(Switch_Chars (Ptr + 1 .. Max));
599 Ptr := Max + 1;
600 end if;
601 end if;
602
603 -- Processing for L switch
604
605 when 'L' =>
606 Ptr := Ptr + 1;
607 Dump_Source_Text := True;
608
609 -- Processing for m switch
610
611 when 'm' =>
612 Ptr := Ptr + 1;
613 Scan_Nat (Switch_Chars, Max, Ptr, Maximum_Messages, C);
614
615 -- Processing for n switch
616
617 when 'n' =>
618 Ptr := Ptr + 1;
619 Inline_Active := True;
620
621 -- Processing for N switch
622
623 when 'N' =>
624 Ptr := Ptr + 1;
625 Inline_Active := True;
626 Front_End_Inlining := True;
627
628 -- Processing for o switch
629
630 when 'o' =>
631 Ptr := Ptr + 1;
632 Suppress_Options (Overflow_Check) := False;
633 Opt.Enable_Overflow_Checks := True;
634
635 -- Processing for O switch
636
637 when 'O' =>
638 Store_Switch := False;
639 Ptr := Ptr + 1;
640 Output_File_Name_Present := True;
641
642 -- Processing for p switch
643
644 when 'p' =>
645 Ptr := Ptr + 1;
646
647 -- Set all specific options as well as All_Checks in the
648 -- Suppress_Options array, excluding Elaboration_Check, since
649 -- this is treated specially because we do not want -gnatp to
650 -- disable static elaboration processing.
651
652 for J in Suppress_Options'Range loop
653 if J /= Elaboration_Check then
654 Suppress_Options (J) := True;
655 end if;
656 end loop;
657
658 Validity_Checks_On := False;
659 Opt.Suppress_Checks := True;
660 Opt.Enable_Overflow_Checks := False;
661
662 -- Processing for P switch
663
664 when 'P' =>
665 Ptr := Ptr + 1;
666 Polling_Required := True;
667
668 -- Processing for q switch
669
670 when 'q' =>
671 Ptr := Ptr + 1;
672 Try_Semantics := True;
673
674 -- Processing for Q switch
675
676 when 'Q' =>
677 Ptr := Ptr + 1;
678 Force_ALI_Tree_File := True;
679 Try_Semantics := True;
680
681 -- Processing for r switch
682
683 when 'r' =>
684 Ptr := Ptr + 1;
685 Treat_Restrictions_As_Warnings := True;
686
687 -- Processing for R switch
688
689 when 'R' =>
690 Back_Annotate_Rep_Info := True;
691 List_Representation_Info := 1;
692
693 Ptr := Ptr + 1;
694 while Ptr <= Max loop
695 C := Switch_Chars (Ptr);
696
697 if C in '1' .. '3' then
698 List_Representation_Info :=
699 Character'Pos (C) - Character'Pos ('0');
700
701 elsif Switch_Chars (Ptr) = 's' then
702 List_Representation_Info_To_File := True;
703
704 elsif Switch_Chars (Ptr) = 'm' then
705 List_Representation_Info_Mechanisms := True;
706
707 else
708 Bad_Switch ("-gnatR" & Switch_Chars (Ptr .. Max));
709 end if;
710
711 Ptr := Ptr + 1;
712 end loop;
713
714 -- Processing for s switch
715
716 when 's' =>
717 if not First_Switch then
718 Osint.Fail
719 ("-gnats must be first if combined with other switches");
720 end if;
721
722 Ptr := Ptr + 1;
723 Operating_Mode := Check_Syntax;
724
725 -- Processing for S switch
726
727 when 'S' =>
728 Print_Standard := True;
729 Ptr := Ptr + 1;
730
731 -- Processing for t switch
732
733 when 't' =>
734 Ptr := Ptr + 1;
735 Tree_Output := True;
736 Back_Annotate_Rep_Info := True;
737
738 -- Processing for T switch
739
740 when 'T' =>
741 Ptr := Ptr + 1;
742 Scan_Pos (Switch_Chars, Max, Ptr, Table_Factor, C);
743
744 -- Processing for u switch
745
746 when 'u' =>
747 Ptr := Ptr + 1;
748 List_Units := True;
749
750 -- Processing for U switch
751
752 when 'U' =>
753 Ptr := Ptr + 1;
754 Unique_Error_Tag := True;
755
756 -- Processing for v switch
757
758 when 'v' =>
759 Ptr := Ptr + 1;
760 Verbose_Mode := True;
761
762 -- Processing for V switch
763
764 when 'V' =>
765 Store_Switch := False;
766 Ptr := Ptr + 1;
767
768 if Ptr > Max then
769 Bad_Switch ("-gnatV");
770
771 else
772 declare
773 OK : Boolean;
774
775 begin
776 Set_Validity_Check_Options
777 (Switch_Chars (Ptr .. Max), OK, Ptr);
778
779 if not OK then
780 Bad_Switch ("-gnatV" & Switch_Chars (Ptr .. Max));
781 end if;
782
783 for Index in First_Char + 1 .. Max loop
784 Store_Compilation_Switch
785 ("-gnatV" & Switch_Chars (Index));
786 end loop;
787 end;
788 end if;
789
790 Ptr := Max + 1;
791
792 -- Processing for w switch
793
794 when 'w' =>
795 Store_Switch := False;
796 Ptr := Ptr + 1;
797
798 if Ptr > Max then
799 Bad_Switch ("-gnatw");
800 end if;
801
802 while Ptr <= Max loop
803 C := Switch_Chars (Ptr);
804
805 -- Case of dot switch
806
807 if C = '.' and then Ptr < Max then
808 Ptr := Ptr + 1;
809 C := Switch_Chars (Ptr);
810
811 if Set_Dot_Warning_Switch (C) then
812 Store_Compilation_Switch ("-gnatw." & C);
813 else
814 Bad_Switch ("-gnatw." & Switch_Chars (Ptr .. Max));
815 end if;
816
817 -- Normal case, no dot
818
819 else
820 if Set_Warning_Switch (C) then
821 Store_Compilation_Switch ("-gnatw" & C);
822 else
823 Bad_Switch ("-gnatw" & Switch_Chars (Ptr .. Max));
824 end if;
825 end if;
826
827 Ptr := Ptr + 1;
828 end loop;
829
830 return;
831
832 -- Processing for W switch
833
834 when 'W' =>
835 Ptr := Ptr + 1;
836
837 if Ptr > Max then
838 Bad_Switch ("-gnatW");
839 end if;
840
841 begin
842 Wide_Character_Encoding_Method :=
843 Get_WC_Encoding_Method (Switch_Chars (Ptr));
844 exception
845 when Constraint_Error =>
846 Bad_Switch ("-gnatW" & Switch_Chars (Ptr .. Max));
847 end;
848
849 Wide_Character_Encoding_Method_Specified := True;
850
851 Upper_Half_Encoding :=
852 Wide_Character_Encoding_Method in
853 WC_Upper_Half_Encoding_Method;
854
855 Ptr := Ptr + 1;
856
857 -- Processing for x switch
858
859 when 'x' =>
860 Ptr := Ptr + 1;
861 Xref_Active := False;
862
863 -- Processing for X switch
864
865 when 'X' =>
866 Ptr := Ptr + 1;
867 Extensions_Allowed := True;
868
869 -- Processing for y switch
870
871 when 'y' =>
872 Ptr := Ptr + 1;
873
874 if Ptr > Max then
875 Set_Default_Style_Check_Options;
876
877 else
878 Store_Switch := False;
879
880 declare
881 OK : Boolean;
882
883 begin
884 Set_Style_Check_Options
885 (Switch_Chars (Ptr .. Max), OK, Ptr);
886
887 if not OK then
888 Osint.Fail
889 ("bad -gnaty switch (" &
890 Style_Msg_Buf (1 .. Style_Msg_Len) & ')');
891 end if;
892
893 Ptr := First_Char + 1;
894 while Ptr <= Max loop
895 if Switch_Chars (Ptr) = 'M' then
896 First_Char := Ptr;
897 loop
898 Ptr := Ptr + 1;
899 exit when Ptr > Max
900 or else Switch_Chars (Ptr) not in '0' .. '9';
901 end loop;
902
903 Store_Compilation_Switch
904 ("-gnaty" & Switch_Chars (First_Char .. Ptr - 1));
905
906 else
907 Store_Compilation_Switch
908 ("-gnaty" & Switch_Chars (Ptr));
909 Ptr := Ptr + 1;
910 end if;
911 end loop;
912 end;
913 end if;
914
915 -- Processing for z switch
916
917 when 'z' =>
918 Ptr := Ptr + 1;
919
920 -- Allowed for compiler only if this is the only
921 -- -z switch, we do not allow multiple occurrences
922
923 if Distribution_Stub_Mode = No_Stubs then
924 case Switch_Chars (Ptr) is
925 when 'r' =>
926 Distribution_Stub_Mode := Generate_Receiver_Stub_Body;
927
928 when 'c' =>
929 Distribution_Stub_Mode := Generate_Caller_Stub_Body;
930
931 when others =>
932 Bad_Switch ("-gnatz" & Switch_Chars (Ptr .. Max));
933 end case;
934
935 Ptr := Ptr + 1;
936 end if;
937
938 -- Processing for Z switch
939
940 when 'Z' =>
941 Ptr := Ptr + 1;
942 Osint.Fail
943 ("-gnatZ is no longer supported: consider using --RTS=zcx");
944
945 -- Processing for 83 switch
946
947 when '8' =>
948 if Ptr = Max then
949 Bad_Switch ("-gnat8");
950 end if;
951
952 Ptr := Ptr + 1;
953
954 if Switch_Chars (Ptr) /= '3' then
955 Bad_Switch ("-gnat8" & Switch_Chars (Ptr .. Max));
956 else
957 Ptr := Ptr + 1;
958 Ada_Version := Ada_83;
959 Ada_Version_Explicit := Ada_Version;
960 end if;
961
962 -- Processing for 95 switch
963
964 when '9' =>
965 if Ptr = Max then
966 Bad_Switch ("-gnat9");
967 end if;
968
969 Ptr := Ptr + 1;
970
971 if Switch_Chars (Ptr) /= '5' then
972 Bad_Switch ("-gnat9" & Switch_Chars (Ptr .. Max));
973 else
974 Ptr := Ptr + 1;
975 Ada_Version := Ada_95;
976 Ada_Version_Explicit := Ada_Version;
977 end if;
978
979 -- Processing for 05 switch
980
981 when '0' =>
982 if Ptr = Max then
983 Bad_Switch ("-gnat0");
984 end if;
985
986 Ptr := Ptr + 1;
987
988 if Switch_Chars (Ptr) /= '5' then
989 Bad_Switch ("-gnat0" & Switch_Chars (Ptr .. Max));
990 else
991 Ptr := Ptr + 1;
992 Ada_Version := Ada_05;
993 Ada_Version_Explicit := Ada_Version;
994 end if;
995
996 -- Ignore extra switch character
997
998 when '/' | '-' =>
999 Ptr := Ptr + 1;
1000
1001 -- Anything else is an error (illegal switch character)
1002
1003 when others =>
1004 Bad_Switch ("-gnat" & Switch_Chars (Ptr .. Max));
1005 end case;
1006
1007 if Store_Switch then
1008 Store_Compilation_Switch
1009 ("-gnat" & Switch_Chars (First_Char .. Ptr - 1));
1010 end if;
1011
1012 First_Switch := False;
1013 end loop;
1014 end if;
1015 end Scan_Front_End_Switches;
1016
1017 end Switch.C;