OSDN Git Service

2003-10-22 Arnaud Charlet <charlet@act-europe.fr>
[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-2003 Free Software Foundation, Inc.          --
10 --                                                                          --
11 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
12 -- terms of the  GNU General Public License as published  by the Free Soft- --
13 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
14 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
17 -- for  more details.  You should have  received  a copy of the GNU General --
18 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
19 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
20 -- MA 02111-1307, USA.                                                      --
21 --                                                                          --
22 -- GNAT was originally developed  by the GNAT team at  New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
24 --                                                                          --
25 ------------------------------------------------------------------------------
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 Types;    use Types;
35 with Validsw;  use Validsw;
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          raise Bad_Switch;
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 only two front-end switches that
100             --  do not start with -gnat, namely -I and --RTS
101
102                if Switch_Chars (Ptr) = 'I' then
103                   Store_Switch := False;
104
105                   Ptr := Ptr + 1;
106
107                   if Ptr > Max then
108                      raise Bad_Switch;
109                   end if;
110
111                   --  Find out whether this is a -I- or regular -Ixxx switch
112
113                   if Ptr = Max and then Switch_Chars (Ptr) = '-' then
114                      Look_In_Primary_Dir := False;
115
116                   else
117                      Add_Src_Search_Dir (Switch_Chars (Ptr .. Max));
118                   end if;
119
120                   Ptr := Max + 1;
121
122                --  Processing of the --RTS switch. --RTS has been modified by
123                --  gcc and is now of the form -fRTS
124
125                elsif Ptr + 3 <= Max
126                  and then Switch_Chars (Ptr .. Ptr + 3) = "fRTS"
127                then
128                   Ptr := Ptr + 1;
129
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.
138
139                      if RTS_Specified = null then
140                         RTS_Specified :=
141                           new String'(Switch_Chars (Ptr + 4 .. Max));
142
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;
149
150                      --  Valid --RTS switch
151
152                      Opt.No_Stdinc := True;
153                      Opt.RTS_Switch := True;
154
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);
161
162                      if RTS_Src_Path_Name /= null and then
163                         RTS_Lib_Path_Name /= null
164                      then
165                         Ptr := Max + 1;
166
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");
172
173                      elsif RTS_Src_Path_Name = null then
174                         Osint.Fail ("RTS path not valid: missing " &
175                                     "adainclude directory");
176
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;
185
186          when True =>
187
188             --  Process -gnat* options
189
190             case C is
191
192             when 'a' =>
193                Ptr := Ptr + 1;
194                Assertions_Enabled := True;
195
196             --  Processing for A switch
197
198             when 'A' =>
199                Ptr := Ptr + 1;
200                Config_File := False;
201
202             --  Processing for b switch
203
204             when 'b' =>
205                Ptr := Ptr + 1;
206                Brief_Output := True;
207
208             --  Processing for c switch
209
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;
215
216                Ptr := Ptr + 1;
217                Operating_Mode := Check_Semantics;
218
219             --  Processing for d switch
220
221             when 'd' =>
222                Store_Switch := False;
223                Storing (First_Stored) := 'd';
224                Dot := False;
225
226                --  Note: for the debug switch, the remaining characters in this
227                --  switch field must all be debug flags, since all valid switch
228                --  characters are also valid debug characters.
229
230                --  Loop to scan out debug flags
231
232                while Ptr < Max loop
233                   Ptr := Ptr + 1;
234                   C := Switch_Chars (Ptr);
235                   exit when C = ASCII.NUL or else C = '/' or else C = '-';
236
237                   if C in '1' .. '9' or else
238                      C in 'a' .. 'z' or else
239                      C in 'A' .. 'Z'
240                   then
241                      if Dot then
242                         Set_Dotted_Debug_Flag (C);
243                         Storing (First_Stored + 1) := '.';
244                         Storing (First_Stored + 2) := C;
245                         Store_Compilation_Switch
246                           (Storing (Storing'First .. First_Stored + 2));
247                         Dot := False;
248
249                      else
250                         Set_Debug_Flag (C);
251                         Storing (First_Stored + 1) := C;
252                         Store_Compilation_Switch
253                           (Storing (Storing'First .. First_Stored + 1));
254                      end if;
255
256                   elsif C = '.' then
257                      Dot := True;
258
259                   else
260                      raise Bad_Switch;
261                   end if;
262                end loop;
263
264                --  Make sure Zero_Cost_Exceptions is set if gnatdX set. This
265                --  is for backwards compatibility with old versions and usage.
266
267                if Debug_Flag_XX then
268                   Zero_Cost_Exceptions_Set := True;
269                   Zero_Cost_Exceptions_Val := True;
270                end if;
271
272                return;
273
274             --  Processing for D switch
275
276             when 'D' =>
277                Ptr := Ptr + 1;
278
279                --  Note: -gnatD also sets -gnatx (to turn off cross-reference
280                --  generation in the ali file) since otherwise this generation
281                --  gets confused by the "wrong" Sloc values put in the tree.
282
283                Debug_Generated_Code := True;
284                Xref_Active := False;
285                Set_Debug_Flag ('g');
286
287             --  Processing for e switch
288
289             when 'e' =>
290                --  Only -gnateD and -gnatep= are stored
291
292                Ptr := Ptr + 1;
293
294                if Ptr > Max then
295                   raise Bad_Switch;
296                end if;
297
298                case Switch_Chars (Ptr) is
299
300                   --  Configuration pragmas
301
302                   when 'c' =>
303                      Store_Switch := False;
304                      Ptr := Ptr + 1;
305
306                      --  There may be an equal sign between -gnatec and
307                      --  the path name of the config file.
308
309                      if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
310                         Ptr := Ptr + 1;
311                      end if;
312
313                      if Ptr > Max then
314                         raise Bad_Switch;
315                      end if;
316
317                      declare
318                         Config_File_Name : constant String_Access :=
319                                              new String'
320                                                   (Switch_Chars (Ptr .. Max));
321
322                      begin
323                         if Config_File_Names = null then
324                            Config_File_Names :=
325                              new String_List'(1 => Config_File_Name);
326
327                         else
328                            declare
329                               New_Names : constant String_List_Access :=
330                                             new String_List
331                                               (1 ..
332                                                Config_File_Names'Length + 1);
333
334                            begin
335                               for Index in Config_File_Names'Range loop
336                                  New_Names (Index) :=
337                                    Config_File_Names (Index);
338                                  Config_File_Names (Index) := null;
339                               end loop;
340
341                               New_Names (New_Names'Last) := Config_File_Name;
342                               Free (Config_File_Names);
343                               Config_File_Names := New_Names;
344                            end;
345                         end if;
346                      end;
347
348                      return;
349
350                   --  Symbol definition
351
352                   when 'D' =>
353                      Store_Switch := False;
354                      Ptr := Ptr + 1;
355
356                      if Ptr > Max then
357                         raise Bad_Switch;
358                      end if;
359
360                      Add_Symbol_Definition (Switch_Chars (Ptr .. Max));
361
362                      --  Store the switch
363
364                      Storing (First_Stored .. First_Stored + 1) := "eD";
365                      Storing
366                        (First_Stored + 2 .. First_Stored + Max - Ptr + 2) :=
367                        Switch_Chars (Ptr .. Max);
368                      Store_Compilation_Switch (Storing
369                               (Storing'First .. First_Stored + Max - Ptr + 2));
370                      return;
371
372                   --  Full source path for brief error messages
373
374                   when 'f' =>
375                      Store_Switch := False;
376                      Ptr := Ptr + 1;
377                      Full_Path_Name_For_Brief_Errors := True;
378                      return;
379
380                   --  Mapping file
381
382                   when 'm' =>
383                      Store_Switch := False;
384                      Ptr := Ptr + 1;
385
386                      --  There may be an equal sign between -gnatem and
387                      --  the path name of the mapping file.
388
389                      if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
390                         Ptr := Ptr + 1;
391                      end if;
392
393                      if Ptr > Max then
394                         raise Bad_Switch;
395                      end if;
396
397                      Mapping_File_Name :=
398                        new String'(Switch_Chars (Ptr .. Max));
399                      return;
400
401                   --  Preprocessing data file
402
403                   when 'p' =>
404                      Store_Switch := False;
405                      Ptr := Ptr + 1;
406
407                      --  There may be an equal sign between -gnatep and
408                      --  the path name of the mapping file.
409
410                      if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
411                         Ptr := Ptr + 1;
412                      end if;
413
414                      if Ptr > Max then
415                         raise Bad_Switch;
416                      end if;
417
418                      Preprocessing_Data_File :=
419                        new String'(Switch_Chars (Ptr .. Max));
420
421                      --  Store the switch.
422                      --  Because we may store a longer switch (we normalize
423                      --  to -gnatep=), use a local variable.
424
425                      declare
426                         To_Store : String
427                           (1 .. Preprocessing_Data_File'Length + 8);
428
429                      begin
430                         To_Store (1 .. 8) := "-gnatep=";
431                         To_Store (9 .. Preprocessing_Data_File'Length + 8) :=
432                           Preprocessing_Data_File.all;
433                         Store_Compilation_Switch (To_Store);
434                      end;
435
436                      return;
437
438                   when others =>
439                      raise Bad_Switch;
440                end case;
441
442             --  Processing for E switch
443
444             when 'E' =>
445                Ptr := Ptr + 1;
446                Dynamic_Elaboration_Checks := True;
447
448             --  Processing for f switch
449
450             when 'f' =>
451                Ptr := Ptr + 1;
452                All_Errors_Mode := True;
453
454             --  Processing for F switch
455
456             when 'F' =>
457                Ptr := Ptr + 1;
458                External_Name_Exp_Casing := Uppercase;
459                External_Name_Imp_Casing := Uppercase;
460
461             --  Processing for g switch
462
463             when 'g' =>
464                Ptr := Ptr + 1;
465                GNAT_Mode                  := True;
466                Identifier_Character_Set   := 'n';
467                Warning_Mode               := Treat_As_Error;
468                Check_Unreferenced         := True;
469                Check_Withs                := True;
470                Check_Unreferenced_Formals := True;
471                System_Extend_Unit         := Empty;
472
473                Set_Default_Style_Check_Options;
474
475             --  Processing for G switch
476
477             when 'G' =>
478                Ptr := Ptr + 1;
479                Print_Generated_Code := True;
480
481             --  Processing for h switch
482
483             when 'h' =>
484                Ptr := Ptr + 1;
485                Usage_Requested := True;
486
487             --  Processing for H switch
488
489             when 'H' =>
490                Ptr := Ptr + 1;
491                HLO_Active := True;
492
493             --  Processing for i switch
494
495             when 'i' =>
496                if Ptr = Max then
497                   raise Bad_Switch;
498                end if;
499
500                Ptr := Ptr + 1;
501                C := Switch_Chars (Ptr);
502
503                if C in '1' .. '5'
504                  or else C = '8'
505                  or else C = '9'
506                  or else C = 'p'
507                  or else C = 'f'
508                  or else C = 'n'
509                  or else C = 'w'
510                then
511                   Identifier_Character_Set := C;
512                   Ptr := Ptr + 1;
513
514                else
515                   raise Bad_Switch;
516                end if;
517
518             --  Processing for k switch
519
520             when 'k' =>
521                Ptr := Ptr + 1;
522                Scan_Pos (Switch_Chars, Max, Ptr, Maximum_File_Name_Length);
523
524             --  Processing for l switch
525
526             when 'l' =>
527                Ptr := Ptr + 1;
528                Full_List := True;
529
530             --  Processing for L switch
531
532             when 'L' =>
533                Ptr := Ptr + 1;
534                Zero_Cost_Exceptions_Set := True;
535                Zero_Cost_Exceptions_Val := False;
536
537             --  Processing for m switch
538
539             when 'm' =>
540                Ptr := Ptr + 1;
541                Scan_Pos (Switch_Chars, Max, Ptr, Maximum_Errors);
542
543             --  Processing for n switch
544
545             when 'n' =>
546                Ptr := Ptr + 1;
547                Inline_Active := True;
548
549             --  Processing for N switch
550
551             when 'N' =>
552                Ptr := Ptr + 1;
553                Inline_Active := True;
554                Front_End_Inlining := True;
555
556             --  Processing for o switch
557
558             when 'o' =>
559                Ptr := Ptr + 1;
560                Suppress_Options (Overflow_Check) := False;
561                Opt.Enable_Overflow_Checks := True;
562
563             --  Processing for O switch
564
565             when 'O' =>
566                Store_Switch := False;
567                Ptr := Ptr + 1;
568                Output_File_Name_Present := True;
569
570             --  Processing for p switch
571
572             when 'p' =>
573                Ptr := Ptr + 1;
574                Suppress_Options           := (others => True);
575                Validity_Checks_On         := False;
576                Opt.Suppress_Checks        := True;
577                Opt.Enable_Overflow_Checks := False;
578
579             --  Processing for P switch
580
581             when 'P' =>
582                Ptr := Ptr + 1;
583                Polling_Required := True;
584
585             --  Processing for q switch
586
587             when 'q' =>
588                Ptr := Ptr + 1;
589                Try_Semantics := True;
590
591             --  Processing for q switch
592
593             when 'Q' =>
594                Ptr := Ptr + 1;
595                Force_ALI_Tree_File := True;
596                Try_Semantics := True;
597
598             --  Processing for R switch
599
600             when 'R' =>
601                Ptr := Ptr + 1;
602                Back_Annotate_Rep_Info := True;
603                List_Representation_Info := 1;
604
605                while Ptr <= Max loop
606                   C := Switch_Chars (Ptr);
607
608                   if C in '1' .. '3' then
609                      List_Representation_Info :=
610                        Character'Pos (C) - Character'Pos ('0');
611
612                   elsif Switch_Chars (Ptr) = 's' then
613                      List_Representation_Info_To_File := True;
614
615                   elsif Switch_Chars (Ptr) = 'm' then
616                      List_Representation_Info_Mechanisms := True;
617
618                   else
619                      raise Bad_Switch;
620                   end if;
621
622                   Ptr := Ptr + 1;
623                end loop;
624
625             --  Processing for s switch
626
627             when 's' =>
628                if not First_Switch then
629                   Osint.Fail
630                     ("-gnats must be first if combined with other switches");
631                end if;
632
633                Ptr := Ptr + 1;
634                Operating_Mode := Check_Syntax;
635
636             --  Processing for t switch
637
638             when 't' =>
639                Ptr := Ptr + 1;
640                Tree_Output := True;
641                ASIS_Mode := True;
642                Back_Annotate_Rep_Info := True;
643
644             --  Processing for T switch
645
646             when 'T' =>
647                Ptr := Ptr + 1;
648                Scan_Pos (Switch_Chars, Max, Ptr, Table_Factor);
649
650             --  Processing for u switch
651
652             when 'u' =>
653                Ptr := Ptr + 1;
654                List_Units := True;
655
656             --  Processing for U switch
657
658             when 'U' =>
659                Ptr := Ptr + 1;
660                Unique_Error_Tag := True;
661
662             --  Processing for v switch
663
664             when 'v' =>
665                Ptr := Ptr + 1;
666                Verbose_Mode := True;
667
668             --  Processing for V switch
669
670             when 'V' =>
671                Store_Switch := False;
672                Storing (First_Stored) := 'V';
673                Ptr := Ptr + 1;
674
675                if Ptr > Max then
676                   raise Bad_Switch;
677
678                else
679                   declare
680                      OK  : Boolean;
681
682                   begin
683                      Set_Validity_Check_Options
684                        (Switch_Chars (Ptr .. Max), OK, Ptr);
685
686                      if not OK then
687                         raise Bad_Switch;
688                      end if;
689
690                      for Index in First_Char + 1 .. Max loop
691                         Storing (First_Stored + 1) :=
692                           Switch_Chars (Index);
693                         Store_Compilation_Switch
694                           (Storing (Storing'First .. First_Stored + 1));
695                      end loop;
696                   end;
697                end if;
698
699                Ptr := Max + 1;
700
701             --  Processing for w switch
702
703             when 'w' =>
704                Store_Switch := False;
705                Storing (First_Stored) := 'w';
706                Ptr := Ptr + 1;
707
708                if Ptr > Max then
709                   raise Bad_Switch;
710                end if;
711
712                while Ptr <= Max loop
713                   C := Switch_Chars (Ptr);
714
715                   case C is
716                      when 'a' =>
717                         Check_Unreferenced              := True;
718                         Check_Unreferenced_Formals      := True;
719                         Check_Withs                     := True;
720                         Constant_Condition_Warnings     := True;
721                         Implementation_Unit_Warnings    := True;
722                         Ineffective_Inline_Warnings     := True;
723                         Warn_On_Constant                := True;
724                         Warn_On_Export_Import           := True;
725                         Warn_On_Modified_Unread         := True;
726                         Warn_On_No_Value_Assigned       := True;
727                         Warn_On_Obsolescent_Feature     := True;
728                         Warn_On_Redundant_Constructs    := True;
729                         Warn_On_Unchecked_Conversion    := True;
730                         Warn_On_Unrecognized_Pragma     := True;
731
732                      when 'A' =>
733                         Check_Unreferenced              := False;
734                         Check_Unreferenced_Formals      := False;
735                         Check_Withs                     := False;
736                         Constant_Condition_Warnings     := False;
737                         Elab_Warnings                   := False;
738                         Implementation_Unit_Warnings    := False;
739                         Ineffective_Inline_Warnings     := False;
740                         Warn_On_Constant                := False;
741                         Warn_On_Dereference             := False;
742                         Warn_On_Export_Import           := False;
743                         Warn_On_Hiding                  := False;
744                         Warn_On_Modified_Unread         := False;
745                         Warn_On_No_Value_Assigned       := False;
746                         Warn_On_Obsolescent_Feature     := False;
747                         Warn_On_Redundant_Constructs    := False;
748                         Warn_On_Unchecked_Conversion    := False;
749                         Warn_On_Unrecognized_Pragma     := False;
750
751                      when 'c' =>
752                         Constant_Condition_Warnings     := True;
753
754                      when 'C' =>
755                         Constant_Condition_Warnings     := False;
756
757                      when 'd' =>
758                         Warn_On_Dereference             := True;
759
760                      when 'D' =>
761                         Warn_On_Dereference             := False;
762
763                      when 'e' =>
764                         Warning_Mode                    := Treat_As_Error;
765
766                      when 'f' =>
767                         Check_Unreferenced_Formals      := True;
768
769                      when 'F' =>
770                         Check_Unreferenced_Formals      := False;
771
772                      when 'g' =>
773                         Warn_On_Unrecognized_Pragma     := True;
774
775                      when 'G' =>
776                         Warn_On_Unrecognized_Pragma     := False;
777
778                      when 'h' =>
779                         Warn_On_Hiding                  := True;
780
781                      when 'H' =>
782                         Warn_On_Hiding                  := False;
783
784                      when 'i' =>
785                         Implementation_Unit_Warnings    := True;
786
787                      when 'I' =>
788                         Implementation_Unit_Warnings    := False;
789
790                      when 'j' =>
791                         Warn_On_Obsolescent_Feature     := True;
792
793                      when 'J' =>
794                         Warn_On_Obsolescent_Feature     := False;
795
796                      when 'k' =>
797                         Warn_On_Constant                := True;
798
799                      when 'K' =>
800                         Warn_On_Constant                := False;
801
802                      when 'l' =>
803                         Elab_Warnings                   := True;
804
805                      when 'L' =>
806                         Elab_Warnings                   := False;
807
808                      when 'm' =>
809                         Warn_On_Modified_Unread         := True;
810
811                      when 'M' =>
812                         Warn_On_Modified_Unread         := False;
813
814                      when 'n' =>
815                         Warning_Mode                    := Normal;
816
817                      when 'o' =>
818                         Address_Clause_Overlay_Warnings := True;
819
820                      when 'O' =>
821                         Address_Clause_Overlay_Warnings := False;
822
823                      when 'p' =>
824                         Ineffective_Inline_Warnings     := True;
825
826                      when 'P' =>
827                         Ineffective_Inline_Warnings     := False;
828
829                      when 'r' =>
830                         Warn_On_Redundant_Constructs    := True;
831
832                      when 'R' =>
833                         Warn_On_Redundant_Constructs    := False;
834
835                      when 's' =>
836                         Warning_Mode                    := Suppress;
837
838                      when 'u' =>
839                         Check_Unreferenced              := True;
840                         Check_Withs                     := True;
841                         Check_Unreferenced_Formals      := True;
842
843                      when 'U' =>
844                         Check_Unreferenced              := False;
845                         Check_Withs                     := False;
846                         Check_Unreferenced_Formals      := False;
847
848                      when 'v' =>
849                         Warn_On_No_Value_Assigned       := True;
850
851                      when 'V' =>
852                         Warn_On_No_Value_Assigned       := False;
853
854                      when 'x' =>
855                         Warn_On_Export_Import           := True;
856
857                      when 'X' =>
858                         Warn_On_Export_Import           := False;
859
860                      when 'z' =>
861                         Warn_On_Unchecked_Conversion    := True;
862
863                      when 'Z' =>
864                         Warn_On_Unchecked_Conversion    := False;
865
866                         --  Allow and ignore 'w' so that the old
867                         --  format (e.g. -gnatwuwl) will work.
868
869                      when 'w' =>
870                         null;
871
872                      when others =>
873                         raise Bad_Switch;
874                   end case;
875
876                   if C /= 'w' then
877                      Storing (First_Stored + 1) := C;
878                      Store_Compilation_Switch
879                        (Storing (Storing'First .. First_Stored + 1));
880                   end if;
881
882                   Ptr := Ptr + 1;
883                end loop;
884
885                return;
886
887             --  Processing for W switch
888
889             when 'W' =>
890                Ptr := Ptr + 1;
891
892                if Ptr > Max then
893                   raise Bad_Switch;
894                end if;
895
896                for J in WC_Encoding_Method loop
897                   if Switch_Chars (Ptr) = WC_Encoding_Letters (J) then
898                      Wide_Character_Encoding_Method := J;
899                      exit;
900
901                   elsif J = WC_Encoding_Method'Last then
902                      raise Bad_Switch;
903                   end if;
904                end loop;
905
906                Upper_Half_Encoding :=
907                  Wide_Character_Encoding_Method in
908                  WC_Upper_Half_Encoding_Method;
909
910                Ptr := Ptr + 1;
911
912             --  Processing for x switch
913
914             when 'x' =>
915                Ptr := Ptr + 1;
916                Xref_Active := False;
917
918             --  Processing for X switch
919
920             when 'X' =>
921                Ptr := Ptr + 1;
922                Extensions_Allowed := True;
923
924             --  Processing for y switch
925
926             when 'y' =>
927                Ptr := Ptr + 1;
928
929                if Ptr > Max then
930                   Set_Default_Style_Check_Options;
931
932                else
933                   Store_Switch := False;
934                   Storing (First_Stored) := 'y';
935
936                   declare
937                      OK  : Boolean;
938                      Last_Stored : Integer;
939
940                   begin
941                      Set_Style_Check_Options
942                        (Switch_Chars (Ptr .. Max), OK, Ptr);
943
944                      if not OK then
945                         raise Bad_Switch;
946                      end if;
947
948                      Ptr := First_Char + 1;
949
950                      while Ptr <= Max loop
951                         Last_Stored := First_Stored + 1;
952                         Storing (Last_Stored) := Switch_Chars (Ptr);
953
954                         if Switch_Chars (Ptr) = 'M' then
955                            loop
956                               Ptr := Ptr + 1;
957                               exit when Ptr > Max
958                                 or else Switch_Chars (Ptr) not in '0' .. '9';
959                               Last_Stored := Last_Stored + 1;
960                               Storing (Last_Stored) := Switch_Chars (Ptr);
961                            end loop;
962
963                         else
964                            Ptr := Ptr + 1;
965                         end if;
966
967                         Store_Compilation_Switch
968                           (Storing (Storing'First .. Last_Stored));
969                      end loop;
970                   end;
971                end if;
972
973             --  Processing for z switch
974
975             when 'z' =>
976                Ptr := Ptr + 1;
977
978                --  Allowed for compiler only if this is the only
979                --  -z switch, we do not allow multiple occurrences
980
981                if Distribution_Stub_Mode = No_Stubs then
982                   case Switch_Chars (Ptr) is
983                      when 'r' =>
984                         Distribution_Stub_Mode := Generate_Receiver_Stub_Body;
985
986                      when 'c' =>
987                         Distribution_Stub_Mode := Generate_Caller_Stub_Body;
988
989                      when others =>
990                         raise Bad_Switch;
991                   end case;
992
993                   Ptr := Ptr + 1;
994
995                end if;
996
997             --  Processing for Z switch
998
999             when 'Z' =>
1000                Ptr := Ptr + 1;
1001                Zero_Cost_Exceptions_Set := True;
1002                Zero_Cost_Exceptions_Val := True;
1003
1004             --  Processing for 83 switch
1005
1006             when '8' =>
1007
1008                if Ptr = Max then
1009                   raise Bad_Switch;
1010                end if;
1011
1012                Ptr := Ptr + 1;
1013
1014                if Switch_Chars (Ptr) /= '3' then
1015                   raise Bad_Switch;
1016                else
1017                   Ptr := Ptr + 1;
1018                   Ada_95 := False;
1019                   Ada_83 := True;
1020                end if;
1021
1022             --  Ignore extra switch character
1023
1024             when '/' | '-' =>
1025                Ptr := Ptr + 1;
1026
1027             --  Anything else is an error (illegal switch character)
1028
1029             when others =>
1030                raise Bad_Switch;
1031             end case;
1032          end case;
1033
1034          if Store_Switch then
1035             Storing (First_Stored .. First_Stored + Ptr - First_Char - 1) :=
1036               Switch_Chars (First_Char .. Ptr - 1);
1037             Store_Compilation_Switch
1038               (Storing (Storing'First .. First_Stored + Ptr - First_Char - 1));
1039          end if;
1040
1041          First_Switch := False;
1042       end loop;
1043
1044    exception
1045       when Bad_Switch =>
1046          Osint.Fail ("invalid switch: ", (1 => C));
1047
1048       when Bad_Switch_Value =>
1049          Osint.Fail ("numeric value out of range for switch: ", (1 => C));
1050
1051       when Missing_Switch_Value =>
1052          Osint.Fail ("missing numeric value for switch: ", (1 => C));
1053
1054    end Scan_Front_End_Switches;
1055
1056 end Switch.C;