1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2012, Free Software Foundation, Inc. --
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. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 -- This package is for switch processing and should not depend on higher level
27 -- packages such as those for the scanner, parser, etc. Doing so may cause
28 -- circularities, especially for back ends using Adabkend.
30 with Debug
; use Debug
;
32 with Osint
; use Osint
;
34 with Validsw
; use Validsw
;
35 with Stylesw
; use Stylesw
;
36 with Ttypes
; use Ttypes
;
37 with Warnsw
; use Warnsw
;
39 with Ada
.Unchecked_Deallocation
;
40 with System
.WCh_Con
; use System
.WCh_Con
;
42 package body Switch
.C
is
44 RTS_Specified
: String_Access
:= null;
45 -- Used to detect multiple use of --RTS= flag
47 procedure Add_Symbol_Definition
(Def
: String);
48 -- Add a symbol definition from the command line
51 new Ada
.Unchecked_Deallocation
(String_List
, String_List_Access
);
52 -- Avoid using System.Strings.Free, which also frees the designated strings
54 function Get_Overflow_Mode
(C
: Character) return Overflow_Mode_Type
;
55 -- Given a digit in the range 0 .. 3, returns the corresponding value of
56 -- Overflow_Mode_Type. Raises Program_Error if C is outside this range.
58 function Switch_Subsequently_Cancelled
61 Arg_Rank
: Positive) return Boolean;
62 -- This function is called from Scan_Front_End_Switches. It determines if
63 -- the switch currently being scanned is followed by a switch of the form
64 -- "-gnat-" & C, where C is the argument. If so, then True is returned,
65 -- and Scan_Front_End_Switches will cancel the effect of the switch. If
66 -- no such switch is found, False is returned.
68 ---------------------------
69 -- Add_Symbol_Definition --
70 ---------------------------
72 procedure Add_Symbol_Definition
(Def
: String) is
74 -- If Preprocessor_Symbol_Defs is not large enough, double its size
76 if Preprocessing_Symbol_Last
= Preprocessing_Symbol_Defs
'Last then
78 New_Symbol_Definitions
: constant String_List_Access
:=
79 new String_List
(1 .. 2 * Preprocessing_Symbol_Last
);
81 New_Symbol_Definitions
(Preprocessing_Symbol_Defs
'Range) :=
82 Preprocessing_Symbol_Defs
.all;
83 Free
(Preprocessing_Symbol_Defs
);
84 Preprocessing_Symbol_Defs
:= New_Symbol_Definitions
;
88 Preprocessing_Symbol_Last
:= Preprocessing_Symbol_Last
+ 1;
89 Preprocessing_Symbol_Defs
(Preprocessing_Symbol_Last
) :=
91 end Add_Symbol_Definition;
93 -----------------------
94 -- Get_Overflow_Mode --
95 -----------------------
97 function Get_Overflow_Mode (C : Character) return Overflow_Mode_Type is
106 -- Eliminated allowed only if Long_Long_Integer is 64 bits (since
107 -- the current implementation of System.Bignums assumes this).
110 if Standard_Long_Long_Integer_Size /= 64 then
111 Bad_Switch ("-gnato3 not implemented for this configuration");
119 end Get_Overflow_Mode;
121 -----------------------------
122 -- Scan_Front_End_Switches --
123 -----------------------------
125 procedure Scan_Front_End_Switches
126 (Switch_Chars : String;
130 First_Switch : Boolean := True;
131 -- False for all but first switch
133 Max : constant Natural := Switch_Chars'Last;
135 C : Character := ' ';
138 Store_Switch : Boolean;
139 -- For -gnatxx switches, the normal processing, signalled by this flag
140 -- being set to True, is to store the switch on exit from the case
141 -- statement, the switch stored is -gnat followed by the characters
142 -- from First_Char to Ptr-1. For cases like -gnaty, where the switch
143 -- is stored in separate pieces, this flag is set to False, and the
144 -- appropriate calls to Store_Compilation_Switch are made from within
147 First_Char : Positive;
148 -- Marks start of switch to be stored
151 Ptr := Switch_Chars'First;
153 -- Skip past the initial character (must be the switch character)
161 -- Handle switches that do not start with -gnat
163 if Ptr + 3 > Max or else Switch_Chars (Ptr .. Ptr + 3) /= "gnat" then
165 -- There are two front-end switches that do not start with -gnat:
168 if Switch_Chars (Ptr) = 'I
' then
170 -- Set flag Search_Directory_Present if switch is "-I" only:
171 -- the directory will be the next argument.
174 Search_Directory_Present := True;
180 -- Find out whether this is a -I- or regular -Ixxx switch
182 -- Note: -I switches are not recorded in the ALI file, since the
183 -- meaning of the program depends on the source files compiled,
184 -- not where they came from.
186 if Ptr = Max and then Switch_Chars (Ptr) = '-' then
187 Look_In_Primary_Dir := False;
189 Add_Src_Search_Dir (Switch_Chars (Ptr .. Max));
192 -- Processing of the --RTS switch. --RTS may have been modified by
193 -- gcc into -fRTS (for GCC targets).
196 and then (Switch_Chars (Ptr .. Ptr + 3) = "fRTS"
198 Switch_Chars (Ptr .. Ptr + 3) = "-RTS")
203 or else Switch_Chars (Ptr + 3) /= '='
205 Osint.Fail ("missing path for --RTS");
207 -- Check that this is the first time --RTS is specified or if
208 -- it is not the first time, the same path has been specified.
210 if RTS_Specified = null then
211 RTS_Specified := new String'(Switch_Chars
(Ptr
+ 4 .. Max
));
214 RTS_Specified
.all /= Switch_Chars
(Ptr
+ 4 .. Max
)
216 Osint
.Fail
("--RTS cannot be specified multiple times");
219 -- Valid --RTS switch
221 Opt
.No_Stdinc
:= True;
222 Opt
.RTS_Switch
:= True;
226 (Switch_Chars
(Ptr
+ 4 .. Max
), Include
);
230 (Switch_Chars
(Ptr
+ 4 .. Max
), Objects
);
232 if RTS_Src_Path_Name
/= null
233 and then RTS_Lib_Path_Name
/= null
235 -- Store the -fRTS switch (Note: Store_Compilation_Switch
236 -- changes -fRTS back into --RTS for the actual output).
238 Store_Compilation_Switch
(Switch_Chars
);
240 elsif RTS_Src_Path_Name
= null
241 and then RTS_Lib_Path_Name
= null
243 Osint
.Fail
("RTS path not valid: missing " &
244 "adainclude and adalib directories");
246 elsif RTS_Src_Path_Name
= null then
247 Osint
.Fail
("RTS path not valid: missing " &
248 "adainclude directory");
250 elsif RTS_Lib_Path_Name
= null then
251 Osint
.Fail
("RTS path not valid: missing " &
256 -- There are no other switches not starting with -gnat
259 Bad_Switch
(Switch_Chars
);
262 -- Case of switch starting with -gnat
267 -- Loop to scan through switches given in switch string
269 while Ptr
<= Max
loop
271 Store_Switch
:= True;
273 C
:= Switch_Chars
(Ptr
);
279 Assertions_Enabled
:= True;
280 Debug_Pragmas_Enabled
:= True;
282 -- Processing for A switch
286 Config_File
:= False;
288 -- Processing for b switch
292 Brief_Output
:= True;
294 -- Processing for B switch
298 Assume_No_Invalid_Values
:= True;
300 -- Processing for c switch
303 if not First_Switch
then
305 ("-gnatc must be first if combined with other switches");
309 Operating_Mode
:= Check_Semantics
;
311 -- Processing for C switch
316 if not CodePeer_Mode
then
317 CodePeer_Mode
:= True;
319 -- Suppress compiler warnings by default, since what we are
320 -- interested in here is what CodePeer can find out. Note
321 -- that if -gnatwxxx is specified after -gnatC on the
322 -- command line, we do not want to override this setting in
323 -- Adjust_Global_Switches, and assume that the user wants to
324 -- get both warnings from GNAT and CodePeer messages.
326 Warning_Mode
:= Suppress
;
329 -- Processing for d switch
332 Store_Switch
:= False;
335 -- Note: for the debug switch, the remaining characters in this
336 -- switch field must all be debug flags, since all valid switch
337 -- characters are also valid debug characters.
339 -- Loop to scan out debug flags
343 C
:= Switch_Chars
(Ptr
);
344 exit when C
= ASCII
.NUL
or else C
= '/' or else C
= '-';
346 if C
in '1' .. '9' or else
347 C
in 'a' .. 'z' or else
351 Set_Dotted_Debug_Flag
(C
);
352 Store_Compilation_Switch
("-gnatd." & C
);
355 Store_Compilation_Switch
("-gnatd" & C
);
362 Bad_Switch
("-gnatd." & Switch_Chars
(Ptr
.. Max
));
364 Bad_Switch
("-gnatd" & Switch_Chars
(Ptr
.. Max
));
370 -- Processing for D switch
375 -- Scan optional integer line limit value
377 if Nat_Present
(Switch_Chars
, Max
, Ptr
) then
378 Scan_Nat
(Switch_Chars
, Max
, Ptr
, Sprint_Line_Limit
, 'D');
379 Sprint_Line_Limit
:= Nat
'Max (Sprint_Line_Limit
, 40);
382 -- Note: -gnatD also sets -gnatx (to turn off cross-reference
383 -- generation in the ali file) since otherwise this generation
384 -- gets confused by the "wrong" Sloc values put in the tree.
386 Debug_Generated_Code
:= True;
387 Xref_Active
:= False;
388 Set_Debug_Flag
('g');
390 -- -gnate? (extended switches)
395 -- The -gnate? switches are all double character switches
396 -- so we must always have a character after the e.
399 Bad_Switch
("-gnate");
402 case Switch_Chars
(Ptr
) is
404 -- -gnatea (initial delimiter of explicit switches)
406 -- All switches that come before -gnatea have been added by
407 -- the GCC driver and are not stored in the ALI file.
408 -- See also -gnatez below.
411 Store_Switch
:= False;
412 Enable_Switch_Storing
;
415 -- -gnateA (aliasing checks on parameters)
419 Check_Aliasing_Of_Parameters
:= True;
421 -- -gnatec (configuration pragmas)
424 Store_Switch
:= False;
427 -- There may be an equal sign between -gnatec and
428 -- the path name of the config file.
430 if Ptr
<= Max
and then Switch_Chars
(Ptr
) = '=' then
435 Bad_Switch
("-gnatec");
439 Config_File_Name
: constant String_Access
:=
441 (Switch_Chars (Ptr .. Max));
444 if Config_File_Names = null then
446 new String_List'(1 => Config_File_Name
);
450 New_Names
: constant String_List_Access
:=
453 Config_File_Names
'Length + 1);
456 for Index
in Config_File_Names
'Range loop
458 Config_File_Names
(Index
);
459 Config_File_Names
(Index
) := null;
462 New_Names
(New_Names
'Last) := Config_File_Name
;
463 Free
(Config_File_Names
);
464 Config_File_Names
:= New_Names
;
471 -- -gnateC switch (CodePeer SCIL generation)
473 -- Not enabled for now, keep it for later???
474 -- use -gnatd.I only for now
478 -- Generate_SCIL := True;
480 -- -gnated switch (disable atomic synchronization)
483 Suppress_Options
.Suppress
(Atomic_Synchronization
) :=
486 -- -gnateD switch (preprocessing symbol definition)
489 Store_Switch
:= False;
493 Bad_Switch
("-gnateD");
496 Add_Symbol_Definition
(Switch_Chars
(Ptr
.. Max
));
500 Store_Compilation_Switch
501 ("-gnateD" & Switch_Chars
(Ptr
.. Max
));
504 -- -gnateE (extra exception information)
507 Exception_Extra_Info
:= True;
510 -- -gnatef (full source path for brief error messages)
513 Store_Switch
:= False;
515 Full_Path_Name_For_Brief_Errors
:= True;
517 -- -gnateF (Check_Float_Overflow)
521 Check_Float_Overflow
:= True;
523 -- -gnateG (save preprocessor output)
526 Generate_Processed_File
:= True;
529 -- -gnatei (max number of instantiations)
534 (Switch_Chars
, Max
, Ptr
, Maximum_Instantiations
, C
);
536 -- -gnateI (index of unit in multi-unit source)
540 Scan_Pos
(Switch_Chars
, Max
, Ptr
, Multiple_Unit_Index
, C
);
542 -- -gnatem (mapping file)
545 Store_Switch
:= False;
548 -- There may be an equal sign between -gnatem and
549 -- the path name of the mapping file.
551 if Ptr
<= Max
and then Switch_Chars
(Ptr
) = '=' then
556 Bad_Switch
("-gnatem");
560 new String'(Switch_Chars (Ptr .. Max));
563 -- -gnateO= (object path file)
566 Store_Switch := False;
571 if Ptr >= Max or else Switch_Chars (Ptr) /= '=' then
572 Bad_Switch ("-gnateO");
575 Object_Path_File_Name :=
576 new String'(Switch_Chars
(Ptr
+ 1 .. Max
));
581 -- -gnatep (preprocessing data file)
584 Store_Switch
:= False;
587 -- There may be an equal sign between -gnatep and
588 -- the path name of the mapping file.
590 if Ptr
<= Max
and then Switch_Chars
(Ptr
) = '=' then
595 Bad_Switch
("-gnatep");
598 Preprocessing_Data_File
:=
599 new String'(Switch_Chars (Ptr .. Max));
601 -- Store the switch, normalizing to -gnatep=
603 Store_Compilation_Switch
604 ("-gnatep=" & Preprocessing_Data_File.all);
608 -- -gnateP (Treat pragma Pure/Preelaborate errs as warnings)
611 Treat_Categorization_Errors_As_Warnings := True;
613 -- -gnateS (generate SCO information)
615 -- Include Source Coverage Obligation information in ALI
616 -- files for the benefit of source coverage analysis tools
620 Generate_SCO := True;
621 Generate_SCO_Instance_Table := True;
624 -- -gnatet (generate target dependent information)
627 Generate_Target_Dependent_Info := True;
630 -- -gnateV (validity checks on parameters)
634 Check_Validity_Of_Parameters := True;
636 -- -gnateY (ignore Style_Checks pragmas)
639 Ignore_Style_Checks_Pragmas := True;
642 -- -gnatez (final delimiter of explicit switches)
644 -- All switches that come after -gnatez have been added by
645 -- the GCC driver and are not stored in the ALI file. See
646 -- also -gnatea above.
649 Store_Switch := False;
650 Disable_Switch_Storing;
653 -- All other -gnate? switches are unassigned
656 Bad_Switch ("-gnate" & Switch_Chars (Ptr .. Max));
659 -- -gnatE (dynamic elaboration checks)
663 Dynamic_Elaboration_Checks := True;
665 -- -gnatf (full error messages)
669 All_Errors_Mode := True;
671 -- Processing for F switch
675 External_Name_Exp_Casing := Uppercase;
676 External_Name_Imp_Casing := Uppercase;
678 -- Processing for g switch
683 Identifier_Character_Set := 'n
';
684 System_Extend_Unit := Empty;
685 Warning_Mode := Treat_As_Error;
687 -- Set Ada 2012 mode explicitly. We don't want to rely on the
688 -- implicit setting here, since for example, we want
689 -- Preelaborate_05 treated as Preelaborate
691 Ada_Version := Ada_2012;
692 Ada_Version_Explicit := Ada_Version;
694 -- Set default warnings and style checks for -gnatg
696 Set_GNAT_Mode_Warnings;
697 Set_GNAT_Style_Check_Options;
699 -- Processing for G switch
703 Print_Generated_Code := True;
705 -- Scan optional integer line limit value
707 if Nat_Present (Switch_Chars, Max, Ptr) then
708 Scan_Nat (Switch_Chars, Max, Ptr, Sprint_Line_Limit, 'G
');
709 Sprint_Line_Limit := Nat'Max (Sprint_Line_Limit, 40);
712 -- Processing for h switch
716 Usage_Requested := True;
718 -- Processing for i switch
722 Bad_Switch ("-gnati");
726 C := Switch_Chars (Ptr);
736 Identifier_Character_Set := C;
740 Bad_Switch ("-gnati" & Switch_Chars (Ptr .. Max));
743 -- Processing for I switch
747 Ignore_Rep_Clauses := True;
749 -- Processing for j switch
753 Scan_Nat (Switch_Chars, Max, Ptr, Error_Msg_Line_Length, C);
755 -- Processing for k switch
760 (Switch_Chars, Max, Ptr, Maximum_File_Name_Length, C);
762 -- Processing for l switch
768 -- There may be an equal sign between -gnatl and a file name
770 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
772 Osint.Fail ("file name for -gnatl= is null");
774 Opt.Full_List_File_Name :=
775 new String'(Switch_Chars
(Ptr
+ 1 .. Max
));
780 -- Processing for L switch
784 Dump_Source_Text
:= True;
786 -- Processing for m switch
790 Scan_Nat
(Switch_Chars
, Max
, Ptr
, Maximum_Messages
, C
);
792 -- Processing for n switch
796 Inline_Active
:= True;
798 -- There may be a digit (1 or 2) appended to the switch
801 C
:= Switch_Chars
(Ptr
);
803 if C
in '1' .. '2' then
805 Inline_Level
:= Character'Pos (C
) - Character'Pos ('0');
809 -- Processing for N switch
813 Inline_Active
:= True;
814 Front_End_Inlining
:= True;
816 -- Processing for o switch
820 Suppress_Options
.Suppress
(Overflow_Check
) := False;
822 -- Case of no digits after the -gnato
824 if Ptr
> Max
or else Switch_Chars
(Ptr
) not in '1' .. '3' then
825 Suppress_Options
.Overflow_Mode_General
:= Strict
;
826 Suppress_Options
.Overflow_Mode_Assertions
:= Strict
;
828 -- At least one digit after the -gnato
831 -- Handle first digit after -gnato
833 Suppress_Options
.Overflow_Mode_General
:=
834 Get_Overflow_Mode
(Switch_Chars
(Ptr
));
837 -- Only one digit after -gnato, set assertions mode to
838 -- be the same as general mode.
841 or else Switch_Chars
(Ptr
) not in '1' .. '3'
843 Suppress_Options
.Overflow_Mode_Assertions
:=
844 Suppress_Options
.Overflow_Mode_General
;
846 -- Process second digit after -gnato
849 Suppress_Options
.Overflow_Mode_Assertions
:=
850 Get_Overflow_Mode
(Switch_Chars
(Ptr
));
855 -- Processing for O switch
858 Store_Switch
:= False;
860 Output_File_Name_Present
:= True;
862 -- Processing for p switch
867 -- Skip processing if cancelled by subsequent -gnat-p
869 if Switch_Subsequently_Cancelled
("p", Args
, Arg_Rank
) then
870 Store_Switch
:= False;
873 -- Set all specific options as well as All_Checks in the
874 -- Suppress_Options array, excluding Elaboration_Check,
875 -- since this is treated specially because we do not want
876 -- -gnatp to disable static elaboration processing. Also
877 -- exclude Atomic_Synchronization, since this is not a real
880 for J
in Suppress_Options
.Suppress
'Range loop
881 if J
/= Elaboration_Check
883 J
/= Atomic_Synchronization
885 Suppress_Options
.Suppress
(J
) := True;
889 Validity_Checks_On
:= False;
890 Opt
.Suppress_Checks
:= True;
893 -- Processing for P switch
897 Polling_Required
:= True;
899 -- Processing for q switch
903 Try_Semantics
:= True;
905 -- Processing for Q switch
909 Force_ALI_Tree_File
:= True;
910 Try_Semantics
:= True;
912 -- Processing for r switch
916 Treat_Restrictions_As_Warnings
:= True;
918 -- Processing for R switch
921 Back_Annotate_Rep_Info
:= True;
922 List_Representation_Info
:= 1;
925 while Ptr
<= Max
loop
926 C
:= Switch_Chars
(Ptr
);
928 if C
in '1' .. '3' then
929 List_Representation_Info
:=
930 Character'Pos (C
) - Character'Pos ('0');
932 elsif Switch_Chars
(Ptr
) = 's' then
933 List_Representation_Info_To_File
:= True;
935 elsif Switch_Chars
(Ptr
) = 'm' then
936 List_Representation_Info_Mechanisms
:= True;
939 Bad_Switch
("-gnatR" & Switch_Chars
(Ptr
.. Max
));
945 -- Processing for s switch
948 if not First_Switch
then
950 ("-gnats must be first if combined with other switches");
954 Operating_Mode
:= Check_Syntax
;
956 -- Processing for S switch
959 Print_Standard
:= True;
962 -- Processing for t switch
967 Back_Annotate_Rep_Info
:= True;
969 -- Processing for T switch
973 Scan_Pos
(Switch_Chars
, Max
, Ptr
, Table_Factor
, C
);
975 -- Processing for u switch
981 -- Processing for U switch
985 Unique_Error_Tag
:= True;
987 -- Processing for v switch
991 Verbose_Mode
:= True;
993 -- Processing for V switch
996 Store_Switch
:= False;
1000 Bad_Switch
("-gnatV");
1007 Set_Validity_Check_Options
1008 (Switch_Chars
(Ptr
.. Max
), OK
, Ptr
);
1011 Bad_Switch
("-gnatV" & Switch_Chars
(Ptr
.. Max
));
1014 for Index
in First_Char
+ 1 .. Max
loop
1015 Store_Compilation_Switch
1016 ("-gnatV" & Switch_Chars
(Index
));
1023 -- Processing for w switch
1026 Store_Switch
:= False;
1030 Bad_Switch
("-gnatw");
1033 while Ptr
<= Max
loop
1034 C
:= Switch_Chars
(Ptr
);
1036 -- Case of dot switch
1038 if C
= '.' and then Ptr
< Max
then
1040 C
:= Switch_Chars
(Ptr
);
1042 if Set_Dot_Warning_Switch
(C
) then
1043 Store_Compilation_Switch
("-gnatw." & C
);
1045 Bad_Switch
("-gnatw." & Switch_Chars
(Ptr
.. Max
));
1048 -- Normal case, no dot
1051 if Set_Warning_Switch
(C
) then
1052 Store_Compilation_Switch
("-gnatw" & C
);
1054 Bad_Switch
("-gnatw" & Switch_Chars
(Ptr
.. Max
));
1063 -- Processing for W switch
1069 Bad_Switch
("-gnatW");
1073 Wide_Character_Encoding_Method
:=
1074 Get_WC_Encoding_Method
(Switch_Chars
(Ptr
));
1076 when Constraint_Error
=>
1077 Bad_Switch
("-gnatW" & Switch_Chars
(Ptr
.. Max
));
1080 Wide_Character_Encoding_Method_Specified
:= True;
1082 Upper_Half_Encoding
:=
1083 Wide_Character_Encoding_Method
in
1084 WC_Upper_Half_Encoding_Method
;
1088 -- Processing for x switch
1092 Xref_Active
:= False;
1094 -- Processing for X switch
1098 Extensions_Allowed
:= True;
1099 Ada_Version
:= Ada_Version_Type
'Last;
1100 Ada_Version_Explicit
:= Ada_Version_Type
'Last;
1102 -- Processing for y switch
1108 Set_Default_Style_Check_Options
;
1111 Store_Switch
:= False;
1117 Set_Style_Check_Options
1118 (Switch_Chars
(Ptr
.. Max
), OK
, Ptr
);
1122 ("bad -gnaty switch (" &
1123 Style_Msg_Buf
(1 .. Style_Msg_Len
) & ')');
1126 Ptr
:= First_Char
+ 1;
1127 while Ptr
<= Max
loop
1128 if Switch_Chars
(Ptr
) = 'M' then
1133 or else Switch_Chars
(Ptr
) not in '0' .. '9';
1136 Store_Compilation_Switch
1137 ("-gnaty" & Switch_Chars
(First_Char
.. Ptr
- 1));
1140 Store_Compilation_Switch
1141 ("-gnaty" & Switch_Chars
(Ptr
));
1148 -- Processing for z switch
1152 -- -gnatz must be the first and only switch in Switch_Chars,
1153 -- and is a two-letter switch.
1155 if Ptr
/= Switch_Chars
'First + 5
1156 or else (Max
- Ptr
+ 1) > 2
1159 ("-gnatz* may not be combined with other switches");
1163 Bad_Switch
("-gnatz");
1168 -- Only one occurrence of -gnat* is permitted
1170 if Distribution_Stub_Mode
= No_Stubs
then
1171 case Switch_Chars
(Ptr
) is
1173 Distribution_Stub_Mode
:= Generate_Receiver_Stub_Body
;
1176 Distribution_Stub_Mode
:= Generate_Caller_Stub_Body
;
1179 Bad_Switch
("-gnatz" & Switch_Chars
(Ptr
.. Max
));
1185 Osint
.Fail
("only one -gnatz* switch allowed");
1188 -- Processing for Z switch
1193 ("-gnatZ is no longer supported: consider using --RTS=zcx");
1195 -- Note on language version switches: whenever a new language
1196 -- version switch is added, Switch.M.Normalize_Compiler_Switches
1199 -- Processing for 83 switch
1203 Bad_Switch
("-gnat8");
1208 if Switch_Chars
(Ptr
) /= '3' then
1209 Bad_Switch
("-gnat8" & Switch_Chars
(Ptr
.. Max
));
1212 Ada_Version
:= Ada_83
;
1213 Ada_Version_Explicit
:= Ada_Version
;
1216 -- Processing for 95 switch
1220 Bad_Switch
("-gnat9");
1225 if Switch_Chars
(Ptr
) /= '5' then
1226 Bad_Switch
("-gnat9" & Switch_Chars
(Ptr
.. Max
));
1229 Ada_Version
:= Ada_95
;
1230 Ada_Version_Explicit
:= Ada_Version
;
1233 -- Processing for 05 switch
1237 Bad_Switch
("-gnat0");
1242 if Switch_Chars
(Ptr
) /= '5' then
1243 Bad_Switch
("-gnat0" & Switch_Chars
(Ptr
.. Max
));
1246 Ada_Version
:= Ada_2005
;
1247 Ada_Version_Explicit
:= Ada_Version
;
1250 -- Processing for 12 switch
1254 Bad_Switch
("-gnat1");
1259 if Switch_Chars
(Ptr
) /= '2' then
1260 Bad_Switch
("-gnat1" & Switch_Chars
(Ptr
.. Max
));
1263 Ada_Version
:= Ada_2012
;
1264 Ada_Version_Explicit
:= Ada_Version
;
1267 -- Processing for 2005 and 2012 switches
1270 if Ptr
> Max
- 3 then
1271 Bad_Switch
("-gnat" & Switch_Chars
(Ptr
.. Max
));
1273 elsif Switch_Chars
(Ptr
.. Ptr
+ 3) = "2005" then
1274 Ada_Version
:= Ada_2005
;
1276 elsif Switch_Chars
(Ptr
.. Ptr
+ 3) = "2012" then
1277 Ada_Version
:= Ada_2012
;
1280 Bad_Switch
("-gnat" & Switch_Chars
(Ptr
.. Ptr
+ 3));
1283 Ada_Version_Explicit
:= Ada_Version
;
1286 -- Switch cancellation, currently only -gnat-p is allowed.
1287 -- All we do here is the error checking, since the actual
1288 -- processing for switch cancellation is done by calls to
1289 -- Switch_Subsequently_Cancelled at the appropriate point.
1293 -- Simple ignore -gnat-p
1295 if Switch_Chars
= "-gnat-p" then
1298 -- Any other occurrence of minus is ignored. This is for
1299 -- maximum compatibility with previous version which ignored
1300 -- all occurrences of minus.
1303 Store_Switch
:= False;
1307 -- We ignore '/' in switches, this is historical, still needed???
1310 Store_Switch
:= False;
1312 -- Anything else is an error (illegal switch character)
1315 Bad_Switch
("-gnat" & Switch_Chars
(Ptr
.. Max
));
1318 if Store_Switch
then
1319 Store_Compilation_Switch
1320 ("-gnat" & Switch_Chars
(First_Char
.. Ptr
- 1));
1323 First_Switch
:= False;
1326 end Scan_Front_End_Switches
;
1328 -----------------------------------
1329 -- Switch_Subsequently_Cancelled --
1330 -----------------------------------
1332 function Switch_Subsequently_Cancelled
1335 Arg_Rank
: Positive) return Boolean
1338 -- Loop through arguments following the current one
1340 for Arg
in Arg_Rank
+ 1 .. Args
'Last loop
1341 if Args
(Arg
).all = "-gnat-" & C
then
1346 -- No match found, not cancelled
1349 end Switch_Subsequently_Cancelled
;