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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [ada/] [switch-c.adb] - Blame information for rev 513

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

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

powered by: WebSVN 2.1.0

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