OSDN Git Service

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