OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [gcc/] [ada/] [switch-c.adb] - Blame information for rev 20

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 jlechner
------------------------------------------------------------------------------
2
--                                                                          --
3
--                         GNAT COMPILER COMPONENTS                         --
4
--                                                                          --
5
--                             S W I T C H - C                              --
6
--                                                                          --
7
--                                 B o d y                                  --
8
--                                                                          --
9
--          Copyright (C) 2001-2005, Free Software Foundation, Inc.         --
10
--                                                                          --
11
-- GNAT is free software;  you can  redistribute it  and/or modify it under --
12
-- terms of the  GNU General Public License as published  by the Free Soft- --
13
-- ware  Foundation;  either version 2,  or (at your option) any later ver- --
14
-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
15
-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
16
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
17
-- for  more details.  You should have  received  a copy of the GNU General --
18
-- Public License  distributed with GNAT;  see file COPYING.  If not, write --
19
-- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
20
-- Boston, MA 02110-1301, USA.                                              --
21
--                                                                          --
22
-- GNAT was originally developed  by the GNAT team at  New York University. --
23
-- Extensive contributions were provided by Ada Core Technologies Inc.      --
24
--                                                                          --
25
------------------------------------------------------------------------------
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
                  Ptr := Ptr + 1;
106
 
107
                  if Ptr > Max then
108
                     Bad_Switch (C);
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
                  Bad_Switch (C);
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
               Debug_Pragmas_Enabled := True;
196
 
197
            --  Processing for A switch
198
 
199
            when 'A' =>
200
               Ptr := Ptr + 1;
201
               Config_File := False;
202
 
203
            --  Processing for b switch
204
 
205
            when 'b' =>
206
               Ptr := Ptr + 1;
207
               Brief_Output := True;
208
 
209
            --  Processing for c switch
210
 
211
            when 'c' =>
212
               if not First_Switch then
213
                  Osint.Fail
214
                    ("-gnatc must be first if combined with other switches");
215
               end if;
216
 
217
               Ptr := Ptr + 1;
218
               Operating_Mode := Check_Semantics;
219
 
220
               if Tree_Output then
221
                  ASIS_Mode := True;
222
               end if;
223
 
224
            --  Processing for d switch
225
 
226
            when 'd' =>
227
               Store_Switch := False;
228
               Storing (First_Stored) := 'd';
229
               Dot := False;
230
 
231
               --  Note: for the debug switch, the remaining characters in this
232
               --  switch field must all be debug flags, since all valid switch
233
               --  characters are also valid debug characters.
234
 
235
               --  Loop to scan out debug flags
236
 
237
               while Ptr < Max loop
238
                  Ptr := Ptr + 1;
239
                  C := Switch_Chars (Ptr);
240
                  exit when C = ASCII.NUL or else C = '/' or else C = '-';
241
 
242
                  if C in '1' .. '9' or else
243
                     C in 'a' .. 'z' or else
244
                     C in 'A' .. 'Z'
245
                  then
246
                     if Dot then
247
                        Set_Dotted_Debug_Flag (C);
248
                        Storing (First_Stored + 1) := '.';
249
                        Storing (First_Stored + 2) := C;
250
                        Store_Compilation_Switch
251
                          (Storing (Storing'First .. First_Stored + 2));
252
                        Dot := False;
253
 
254
                     else
255
                        Set_Debug_Flag (C);
256
                        Storing (First_Stored + 1) := C;
257
                        Store_Compilation_Switch
258
                          (Storing (Storing'First .. First_Stored + 1));
259
                     end if;
260
 
261
                  elsif C = '.' then
262
                     Dot := True;
263
 
264
                  else
265
                     Bad_Switch (C);
266
                  end if;
267
               end loop;
268
 
269
               return;
270
 
271
            --  Processing for D switch
272
 
273
            when 'D' =>
274
               Ptr := Ptr + 1;
275
 
276
               --  Note: -gnatD also sets -gnatx (to turn off cross-reference
277
               --  generation in the ali file) since otherwise this generation
278
               --  gets confused by the "wrong" Sloc values put in the tree.
279
 
280
               Debug_Generated_Code := True;
281
               Xref_Active := False;
282
               Set_Debug_Flag ('g');
283
 
284
            --  -gnate? (extended switches)
285
 
286
            when 'e' =>
287
               Ptr := Ptr + 1;
288
 
289
               --  The -gnate? switches are all double character switches
290
               --  so we must always have a character after the e.
291
 
292
               if Ptr > Max then
293
                  Bad_Switch (C);
294
               end if;
295
 
296
               case Switch_Chars (Ptr) is
297
 
298
                  --  -gnatec (configuration pragmas)
299
 
300
                  when 'c' =>
301
                     Store_Switch := False;
302
                     Ptr := Ptr + 1;
303
 
304
                     --  There may be an equal sign between -gnatec and
305
                     --  the path name of the config file.
306
 
307
                     if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
308
                        Ptr := Ptr + 1;
309
                     end if;
310
 
311
                     if Ptr > Max then
312
                        Bad_Switch (C);
313
                     end if;
314
 
315
                     declare
316
                        Config_File_Name : constant String_Access :=
317
                                             new String'
318
                                                  (Switch_Chars (Ptr .. Max));
319
 
320
                     begin
321
                        if Config_File_Names = null then
322
                           Config_File_Names :=
323
                             new String_List'(1 => Config_File_Name);
324
 
325
                        else
326
                           declare
327
                              New_Names : constant String_List_Access :=
328
                                            new String_List
329
                                              (1 ..
330
                                               Config_File_Names'Length + 1);
331
 
332
                           begin
333
                              for Index in Config_File_Names'Range loop
334
                                 New_Names (Index) :=
335
                                   Config_File_Names (Index);
336
                                 Config_File_Names (Index) := null;
337
                              end loop;
338
 
339
                              New_Names (New_Names'Last) := Config_File_Name;
340
                              Free (Config_File_Names);
341
                              Config_File_Names := New_Names;
342
                           end;
343
                        end if;
344
                     end;
345
 
346
                     return;
347
 
348
                  --  -gnateD switch (symbol definition)
349
 
350
                  when 'D' =>
351
                     Store_Switch := False;
352
                     Ptr := Ptr + 1;
353
 
354
                     if Ptr > Max then
355
                        Bad_Switch (C);
356
                     end if;
357
 
358
                     Add_Symbol_Definition (Switch_Chars (Ptr .. Max));
359
 
360
                     --  Store the switch
361
 
362
                     Storing (First_Stored .. First_Stored + 1) := "eD";
363
                     Storing
364
                       (First_Stored + 2 .. First_Stored + Max - Ptr + 2) :=
365
                       Switch_Chars (Ptr .. Max);
366
                     Store_Compilation_Switch (Storing
367
                              (Storing'First .. First_Stored + Max - Ptr + 2));
368
                     return;
369
 
370
                  --  -gnatef (full source path for brief error messages)
371
 
372
                  when 'f' =>
373
                     Store_Switch := False;
374
                     Ptr := Ptr + 1;
375
                     Full_Path_Name_For_Brief_Errors := True;
376
                     return;
377
 
378
                  --  -gnateI (index of unit in multi-unit source)
379
 
380
                  when 'I' =>
381
                     Ptr := Ptr + 1;
382
                     Scan_Pos
383
                       (Switch_Chars, Max, Ptr, Multiple_Unit_Index, C);
384
 
385
                  --  -gnatem (mapping file)
386
 
387
                  when 'm' =>
388
                     Store_Switch := False;
389
                     Ptr := Ptr + 1;
390
 
391
                     --  There may be an equal sign between -gnatem and
392
                     --  the path name of the mapping file.
393
 
394
                     if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
395
                        Ptr := Ptr + 1;
396
                     end if;
397
 
398
                     if Ptr > Max then
399
                        Bad_Switch (C);
400
                     end if;
401
 
402
                     Mapping_File_Name :=
403
                       new String'(Switch_Chars (Ptr .. Max));
404
                     return;
405
 
406
                  --  -gnatep (preprocessing data file)
407
 
408
                  when 'p' =>
409
                     Store_Switch := False;
410
                     Ptr := Ptr + 1;
411
 
412
                     --  There may be an equal sign between -gnatep and
413
                     --  the path name of the mapping file.
414
 
415
                     if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
416
                        Ptr := Ptr + 1;
417
                     end if;
418
 
419
                     if Ptr > Max then
420
                        Bad_Switch (C);
421
                     end if;
422
 
423
                     Preprocessing_Data_File :=
424
                       new String'(Switch_Chars (Ptr .. Max));
425
 
426
                     --  Store the switch.
427
                     --  Because we may store a longer switch (we normalize
428
                     --  to -gnatep=), use a local variable.
429
 
430
                     declare
431
                        To_Store : String
432
                          (1 .. Preprocessing_Data_File'Length + 8);
433
 
434
                     begin
435
                        To_Store (1 .. 8) := "-gnatep=";
436
                        To_Store (9 .. Preprocessing_Data_File'Length + 8) :=
437
                          Preprocessing_Data_File.all;
438
                        Store_Compilation_Switch (To_Store);
439
                     end;
440
 
441
                  return;
442
 
443
                  when 'z' =>
444
                     Store_Switch := False;
445
                     Disable_Switch_Storing;
446
                     Ptr := Ptr + 1;
447
 
448
                  --  All other -gnate? switches are unassigned
449
 
450
                  when others =>
451
                     Bad_Switch (C);
452
               end case;
453
 
454
            --  -gnatE (dynamic elaboration checks)
455
 
456
            when 'E' =>
457
               Ptr := Ptr + 1;
458
               Dynamic_Elaboration_Checks := True;
459
 
460
            --  -gnatf (full error messages)
461
 
462
            when 'f' =>
463
               Ptr := Ptr + 1;
464
               All_Errors_Mode := True;
465
 
466
            --  Processing for F switch
467
 
468
            when 'F' =>
469
               Ptr := Ptr + 1;
470
               External_Name_Exp_Casing := Uppercase;
471
               External_Name_Imp_Casing := Uppercase;
472
 
473
            --  Processing for g switch
474
 
475
            when 'g' =>
476
               Ptr := Ptr + 1;
477
               GNAT_Mode := True;
478
               Identifier_Character_Set := 'n';
479
               System_Extend_Unit := Empty;
480
               Warning_Mode := Treat_As_Error;
481
 
482
               --  Set Ada 2005 mode explicitly. We don't want to rely on the
483
               --  implicit setting here, since for example, we want
484
               --  Preelaborate_05 treated as Preelaborate
485
 
486
               Ada_Version := Ada_05;
487
               Ada_Version_Explicit := Ada_Version;
488
 
489
               --  Set default warnings for -gnatg (same set as -gnatwa)
490
 
491
               Check_Unreferenced           := True;
492
               Check_Unreferenced_Formals   := True;
493
               Check_Withs                  := True;
494
               Constant_Condition_Warnings  := True;
495
               Implementation_Unit_Warnings := True;
496
               Ineffective_Inline_Warnings  := True;
497
               Warn_On_Bad_Fixed_Value      := True;
498
               Warn_On_Constant             := True;
499
               Warn_On_Export_Import        := True;
500
               Warn_On_Modified_Unread      := True;
501
               Warn_On_No_Value_Assigned    := True;
502
               Warn_On_Obsolescent_Feature  := True;
503
               Warn_On_Redundant_Constructs := True;
504
               Warn_On_Unchecked_Conversion := True;
505
               Warn_On_Unrecognized_Pragma  := True;
506
 
507
               Set_Style_Check_Options ("3abcdefhiklmnprstux");
508
 
509
            --  Processing for G switch
510
 
511
            when 'G' =>
512
               Ptr := Ptr + 1;
513
               Print_Generated_Code := True;
514
 
515
            --  Processing for h switch
516
 
517
            when 'h' =>
518
               Ptr := Ptr + 1;
519
               Usage_Requested := True;
520
 
521
            --  Processing for H switch
522
 
523
            when 'H' =>
524
               Ptr := Ptr + 1;
525
               HLO_Active := True;
526
 
527
            --  Processing for i switch
528
 
529
            when 'i' =>
530
               if Ptr = Max then
531
                  Bad_Switch (C);
532
               end if;
533
 
534
               Ptr := Ptr + 1;
535
               C := Switch_Chars (Ptr);
536
 
537
               if C in '1' .. '5'
538
                 or else C = '8'
539
                 or else C = '9'
540
                 or else C = 'p'
541
                 or else C = 'f'
542
                 or else C = 'n'
543
                 or else C = 'w'
544
               then
545
                  Identifier_Character_Set := C;
546
                  Ptr := Ptr + 1;
547
 
548
               else
549
                  Bad_Switch (C);
550
               end if;
551
 
552
            --  Processing for k switch
553
 
554
            when 'k' =>
555
               Ptr := Ptr + 1;
556
                  Scan_Pos
557
                    (Switch_Chars, Max, Ptr, Maximum_File_Name_Length, C);
558
 
559
            --  Processing for l switch
560
 
561
            when 'l' =>
562
               Ptr := Ptr + 1;
563
               Full_List := True;
564
 
565
            --  Processing for L switch
566
 
567
            when 'L' =>
568
               Ptr := Ptr + 1;
569
               Osint.Fail
570
                 ("-gnatL is no longer supported: consider using --RTS=sjlj");
571
 
572
            --  Processing for m switch
573
 
574
            when 'm' =>
575
               Ptr := Ptr + 1;
576
 
577
               --  There may be an equal sign between -gnatm and the value
578
 
579
               if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
580
                  Ptr := Ptr + 1;
581
               end if;
582
 
583
               Scan_Pos (Switch_Chars, Max, Ptr, Maximum_Errors, C);
584
 
585
            --  Processing for n switch
586
 
587
            when 'n' =>
588
               Ptr := Ptr + 1;
589
               Inline_Active := True;
590
 
591
            --  Processing for N switch
592
 
593
            when 'N' =>
594
               Ptr := Ptr + 1;
595
               Inline_Active := True;
596
               Front_End_Inlining := True;
597
 
598
            --  Processing for o switch
599
 
600
            when 'o' =>
601
               Ptr := Ptr + 1;
602
               Suppress_Options (Overflow_Check) := False;
603
               Opt.Enable_Overflow_Checks := True;
604
 
605
            --  Processing for O switch
606
 
607
            when 'O' =>
608
               Store_Switch := False;
609
               Ptr := Ptr + 1;
610
               Output_File_Name_Present := True;
611
 
612
            --  Processing for p switch
613
 
614
            when 'p' =>
615
               Ptr := Ptr + 1;
616
 
617
               --  Set all specific options as well as All_Checks in the
618
               --  Suppress_Options array, excluding Elaboration_Check, since
619
               --  this is treated specially because we do not want -gnatp to
620
               --  disable static elaboration processing.
621
 
622
               for J in Suppress_Options'Range loop
623
                  if J /= Elaboration_Check then
624
                     Suppress_Options (J) := True;
625
                  end if;
626
               end loop;
627
 
628
               Validity_Checks_On         := False;
629
               Opt.Suppress_Checks        := True;
630
               Opt.Enable_Overflow_Checks := False;
631
 
632
            --  Processing for P switch
633
 
634
            when 'P' =>
635
               Ptr := Ptr + 1;
636
               Polling_Required := True;
637
 
638
            --  Processing for q switch
639
 
640
            when 'q' =>
641
               Ptr := Ptr + 1;
642
               Try_Semantics := True;
643
 
644
            --  Processing for q switch
645
 
646
            when 'Q' =>
647
               Ptr := Ptr + 1;
648
               Force_ALI_Tree_File := True;
649
               Try_Semantics := True;
650
 
651
            --  Processing for R switch
652
 
653
            when 'R' =>
654
               Ptr := Ptr + 1;
655
               Back_Annotate_Rep_Info := True;
656
               List_Representation_Info := 1;
657
 
658
               while Ptr <= Max loop
659
                  C := Switch_Chars (Ptr);
660
 
661
                  if C in '1' .. '3' then
662
                     List_Representation_Info :=
663
                       Character'Pos (C) - Character'Pos ('0');
664
 
665
                  elsif Switch_Chars (Ptr) = 's' then
666
                     List_Representation_Info_To_File := True;
667
 
668
                  elsif Switch_Chars (Ptr) = 'm' then
669
                     List_Representation_Info_Mechanisms := True;
670
 
671
                  else
672
                     Bad_Switch (C);
673
                  end if;
674
 
675
                  Ptr := Ptr + 1;
676
               end loop;
677
 
678
            --  Processing for s switch
679
 
680
            when 's' =>
681
               if not First_Switch then
682
                  Osint.Fail
683
                    ("-gnats must be first if combined with other switches");
684
               end if;
685
 
686
               Ptr := Ptr + 1;
687
               Operating_Mode := Check_Syntax;
688
 
689
            --  Processing for S switch
690
 
691
            when 'S' =>
692
               Print_Standard := True;
693
               Ptr := Ptr + 1;
694
 
695
            --  Processing for t switch
696
 
697
            when 't' =>
698
               Ptr := Ptr + 1;
699
               Tree_Output := True;
700
 
701
               if Operating_Mode = Check_Semantics then
702
                  ASIS_Mode := True;
703
               end if;
704
 
705
               Back_Annotate_Rep_Info := True;
706
 
707
            --  Processing for T switch
708
 
709
            when 'T' =>
710
               Ptr := Ptr + 1;
711
               Scan_Pos (Switch_Chars, Max, Ptr, Table_Factor, C);
712
 
713
            --  Processing for u switch
714
 
715
            when 'u' =>
716
               Ptr := Ptr + 1;
717
               List_Units := True;
718
 
719
            --  Processing for U switch
720
 
721
            when 'U' =>
722
               Ptr := Ptr + 1;
723
               Unique_Error_Tag := True;
724
 
725
            --  Processing for v switch
726
 
727
            when 'v' =>
728
               Ptr := Ptr + 1;
729
               Verbose_Mode := True;
730
 
731
            --  Processing for V switch
732
 
733
            when 'V' =>
734
               Store_Switch := False;
735
               Storing (First_Stored) := 'V';
736
               Ptr := Ptr + 1;
737
 
738
               if Ptr > Max then
739
                  Bad_Switch (C);
740
 
741
               else
742
                  declare
743
                     OK  : Boolean;
744
 
745
                  begin
746
                     Set_Validity_Check_Options
747
                       (Switch_Chars (Ptr .. Max), OK, Ptr);
748
 
749
                     if not OK then
750
                        Bad_Switch (C);
751
                     end if;
752
 
753
                     for Index in First_Char + 1 .. Max loop
754
                        Storing (First_Stored + 1) :=
755
                          Switch_Chars (Index);
756
                        Store_Compilation_Switch
757
                          (Storing (Storing'First .. First_Stored + 1));
758
                     end loop;
759
                  end;
760
               end if;
761
 
762
               Ptr := Max + 1;
763
 
764
            --  Processing for w switch
765
 
766
            when 'w' =>
767
               Store_Switch := False;
768
               Storing (First_Stored) := 'w';
769
               Ptr := Ptr + 1;
770
 
771
               if Ptr > Max then
772
                  Bad_Switch (C);
773
               end if;
774
 
775
               while Ptr <= Max loop
776
                  C := Switch_Chars (Ptr);
777
 
778
                  if Set_Warning_Switch (C) then
779
                     null;
780
                  else
781
                     Bad_Switch (C);
782
                  end if;
783
 
784
                  if C /= 'w' then
785
                     Storing (First_Stored + 1) := C;
786
                     Store_Compilation_Switch
787
                       (Storing (Storing'First .. First_Stored + 1));
788
                  end if;
789
 
790
                  Ptr := Ptr + 1;
791
               end loop;
792
 
793
               return;
794
 
795
            --  Processing for W switch
796
 
797
            when 'W' =>
798
               Ptr := Ptr + 1;
799
 
800
               if Ptr > Max then
801
                  Bad_Switch (C);
802
               end if;
803
 
804
               for J in WC_Encoding_Method loop
805
                  if Switch_Chars (Ptr) = WC_Encoding_Letters (J) then
806
                     Wide_Character_Encoding_Method := J;
807
                     exit;
808
 
809
                  elsif J = WC_Encoding_Method'Last then
810
                     Bad_Switch (C);
811
                  end if;
812
               end loop;
813
 
814
               Upper_Half_Encoding :=
815
                 Wide_Character_Encoding_Method in
816
                 WC_Upper_Half_Encoding_Method;
817
 
818
               Ptr := Ptr + 1;
819
 
820
            --  Processing for x switch
821
 
822
            when 'x' =>
823
               Ptr := Ptr + 1;
824
               Xref_Active := False;
825
 
826
            --  Processing for X switch
827
 
828
            when 'X' =>
829
               Ptr := Ptr + 1;
830
               Extensions_Allowed := True;
831
               Ada_Version := Ada_Version_Type'Last;
832
               Ada_Version_Explicit := Ada_Version;
833
 
834
            --  Processing for y switch
835
 
836
            when 'y' =>
837
               Ptr := Ptr + 1;
838
 
839
               if Ptr > Max then
840
                  Set_Default_Style_Check_Options;
841
 
842
               else
843
                  Store_Switch := False;
844
                  Storing (First_Stored) := 'y';
845
 
846
                  declare
847
                     OK  : Boolean;
848
                     Last_Stored : Integer;
849
 
850
                  begin
851
                     Set_Style_Check_Options
852
                       (Switch_Chars (Ptr .. Max), OK, Ptr);
853
 
854
                     if not OK then
855
                        Bad_Switch (C);
856
                     end if;
857
 
858
                     Ptr := First_Char + 1;
859
 
860
                     while Ptr <= Max loop
861
                        Last_Stored := First_Stored + 1;
862
                        Storing (Last_Stored) := Switch_Chars (Ptr);
863
 
864
                        if Switch_Chars (Ptr) = 'M' then
865
                           loop
866
                              Ptr := Ptr + 1;
867
                              exit when Ptr > Max
868
                                or else Switch_Chars (Ptr) not in '0' .. '9';
869
                              Last_Stored := Last_Stored + 1;
870
                              Storing (Last_Stored) := Switch_Chars (Ptr);
871
                           end loop;
872
 
873
                        else
874
                           Ptr := Ptr + 1;
875
                        end if;
876
 
877
                        Store_Compilation_Switch
878
                          (Storing (Storing'First .. Last_Stored));
879
                     end loop;
880
                  end;
881
               end if;
882
 
883
            --  Processing for z switch
884
 
885
            when 'z' =>
886
               Ptr := Ptr + 1;
887
 
888
               --  Allowed for compiler only if this is the only
889
               --  -z switch, we do not allow multiple occurrences
890
 
891
               if Distribution_Stub_Mode = No_Stubs then
892
                  case Switch_Chars (Ptr) is
893
                     when 'r' =>
894
                        Distribution_Stub_Mode := Generate_Receiver_Stub_Body;
895
 
896
                     when 'c' =>
897
                        Distribution_Stub_Mode := Generate_Caller_Stub_Body;
898
 
899
                     when others =>
900
                        Bad_Switch (C);
901
                  end case;
902
 
903
                  Ptr := Ptr + 1;
904
 
905
               end if;
906
 
907
            --  Processing for Z switch
908
 
909
            when 'Z' =>
910
               Ptr := Ptr + 1;
911
               Osint.Fail
912
                 ("-gnatZ is no longer supported: consider using --RTS=zcx");
913
 
914
            --  Processing for 83 switch
915
 
916
            when '8' =>
917
               if Ptr = Max then
918
                  Bad_Switch (C);
919
               end if;
920
 
921
               Ptr := Ptr + 1;
922
 
923
               if Switch_Chars (Ptr) /= '3' then
924
                  Bad_Switch (C);
925
               else
926
                  Ptr := Ptr + 1;
927
                  Ada_Version := Ada_83;
928
                  Ada_Version_Explicit := Ada_Version;
929
               end if;
930
 
931
            --  Processing for 95 switch
932
 
933
            when '9' =>
934
               if Ptr = Max then
935
                  Bad_Switch (C);
936
               end if;
937
 
938
               Ptr := Ptr + 1;
939
 
940
               if Switch_Chars (Ptr) /= '5' then
941
                  Bad_Switch (C);
942
               else
943
                  Ptr := Ptr + 1;
944
                  Ada_Version := Ada_95;
945
                  Ada_Version_Explicit := Ada_Version;
946
               end if;
947
 
948
            --  Processing for 05 switch
949
 
950
            when '0' =>
951
               if Ptr = Max then
952
                  Bad_Switch (C);
953
               end if;
954
 
955
               Ptr := Ptr + 1;
956
 
957
               if Switch_Chars (Ptr) /= '5' then
958
                  Bad_Switch (C);
959
               else
960
                  Ptr := Ptr + 1;
961
                  Ada_Version := Ada_05;
962
                  Ada_Version_Explicit := Ada_Version;
963
               end if;
964
 
965
            --  Ignore extra switch character
966
 
967
            when '/' | '-' =>
968
               Ptr := Ptr + 1;
969
 
970
            --  Anything else is an error (illegal switch character)
971
 
972
            when others =>
973
               Bad_Switch (C);
974
            end case;
975
         end case;
976
 
977
         if Store_Switch then
978
            Storing (First_Stored .. First_Stored + Ptr - First_Char - 1) :=
979
              Switch_Chars (First_Char .. Ptr - 1);
980
            Store_Compilation_Switch
981
              (Storing (Storing'First .. First_Stored + Ptr - First_Char - 1));
982
         end if;
983
 
984
         First_Switch := False;
985
      end loop;
986
   end Scan_Front_End_Switches;
987
 
988
end Switch.C;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.