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_Check_Type
;
55 -- Given a digit in the range 0 .. 3, returns the corresponding value of
56 -- Overflow_Check_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_Check_Type is
109 -- Eliminated allowed only if Long_Long_Integer is 64 bits (since
110 -- the current implementation of System.Bignums assumes this).
113 if Standard_Long_Long_Integer_Size /= 64 then
114 Bad_Switch ("-gnato3 not implemented for this configuration");
122 end Get_Overflow_Mode;
124 -----------------------------
125 -- Scan_Front_End_Switches --
126 -----------------------------
128 procedure Scan_Front_End_Switches
129 (Switch_Chars : String;
133 First_Switch : Boolean := True;
134 -- False for all but first switch
136 Max : constant Natural := Switch_Chars'Last;
138 C : Character := ' ';
141 Store_Switch : Boolean;
142 -- For -gnatxx switches, the normal processing, signalled by this flag
143 -- being set to True, is to store the switch on exit from the case
144 -- statement, the switch stored is -gnat followed by the characters
145 -- from First_Char to Ptr-1. For cases like -gnaty, where the switch
146 -- is stored in separate pieces, this flag is set to False, and the
147 -- appropriate calls to Store_Compilation_Switch are made from within
150 First_Char : Positive;
151 -- Marks start of switch to be stored
154 Ptr := Switch_Chars'First;
156 -- Skip past the initial character (must be the switch character)
164 -- Handle switches that do not start with -gnat
166 if Ptr + 3 > Max or else Switch_Chars (Ptr .. Ptr + 3) /= "gnat" then
168 -- There are two front-end switches that do not start with -gnat:
171 if Switch_Chars (Ptr) = 'I
' then
173 -- Set flag Search_Directory_Present if switch is "-I" only:
174 -- the directory will be the next argument.
177 Search_Directory_Present := True;
183 -- Find out whether this is a -I- or regular -Ixxx switch
185 -- Note: -I switches are not recorded in the ALI file, since the
186 -- meaning of the program depends on the source files compiled,
187 -- not where they came from.
189 if Ptr = Max and then Switch_Chars (Ptr) = '-' then
190 Look_In_Primary_Dir := False;
192 Add_Src_Search_Dir (Switch_Chars (Ptr .. Max));
195 -- Processing of the --RTS switch. --RTS may have been modified by
196 -- gcc into -fRTS (for GCC targets).
199 and then (Switch_Chars (Ptr .. Ptr + 3) = "fRTS"
201 Switch_Chars (Ptr .. Ptr + 3) = "-RTS")
206 or else Switch_Chars (Ptr + 3) /= '='
208 Osint.Fail ("missing path for --RTS");
210 -- Check that this is the first time --RTS is specified or if
211 -- it is not the first time, the same path has been specified.
213 if RTS_Specified = null then
214 RTS_Specified := new String'(Switch_Chars
(Ptr
+ 4 .. Max
));
217 RTS_Specified
.all /= Switch_Chars
(Ptr
+ 4 .. Max
)
219 Osint
.Fail
("--RTS cannot be specified multiple times");
222 -- Valid --RTS switch
224 Opt
.No_Stdinc
:= True;
225 Opt
.RTS_Switch
:= True;
229 (Switch_Chars
(Ptr
+ 4 .. Max
), Include
);
233 (Switch_Chars
(Ptr
+ 4 .. Max
), Objects
);
235 if RTS_Src_Path_Name
/= null
236 and then RTS_Lib_Path_Name
/= null
238 -- Store the -fRTS switch (Note: Store_Compilation_Switch
239 -- changes -fRTS back into --RTS for the actual output).
241 Store_Compilation_Switch
(Switch_Chars
);
243 elsif RTS_Src_Path_Name
= null
244 and then RTS_Lib_Path_Name
= null
246 Osint
.Fail
("RTS path not valid: missing " &
247 "adainclude and adalib directories");
249 elsif RTS_Src_Path_Name
= null then
250 Osint
.Fail
("RTS path not valid: missing " &
251 "adainclude directory");
253 elsif RTS_Lib_Path_Name
= null then
254 Osint
.Fail
("RTS path not valid: missing " &
259 -- There are no other switches not starting with -gnat
262 Bad_Switch
(Switch_Chars
);
265 -- Case of switch starting with -gnat
270 -- Loop to scan through switches given in switch string
272 while Ptr
<= Max
loop
274 Store_Switch
:= True;
276 C
:= Switch_Chars
(Ptr
);
282 Assertions_Enabled
:= True;
283 Debug_Pragmas_Enabled
:= True;
285 -- Processing for A switch
289 Config_File
:= False;
291 -- Processing for b switch
295 Brief_Output
:= True;
297 -- Processing for B switch
301 Assume_No_Invalid_Values
:= True;
303 -- Processing for c switch
306 if not First_Switch
then
308 ("-gnatc must be first if combined with other switches");
312 Operating_Mode
:= Check_Semantics
;
314 -- Processing for C switch
319 if not CodePeer_Mode
then
320 CodePeer_Mode
:= True;
322 -- Suppress compiler warnings by default, since what we are
323 -- interested in here is what CodePeer can find out. Note
324 -- that if -gnatwxxx is specified after -gnatC on the
325 -- command line, we do not want to override this setting in
326 -- Adjust_Global_Switches, and assume that the user wants to
327 -- get both warnings from GNAT and CodePeer messages.
329 Warning_Mode
:= Suppress
;
332 -- Processing for d switch
335 Store_Switch
:= False;
338 -- Note: for the debug switch, the remaining characters in this
339 -- switch field must all be debug flags, since all valid switch
340 -- characters are also valid debug characters.
342 -- Loop to scan out debug flags
346 C
:= Switch_Chars
(Ptr
);
347 exit when C
= ASCII
.NUL
or else C
= '/' or else C
= '-';
349 if C
in '1' .. '9' or else
350 C
in 'a' .. 'z' or else
354 Set_Dotted_Debug_Flag
(C
);
355 Store_Compilation_Switch
("-gnatd." & C
);
358 Store_Compilation_Switch
("-gnatd" & C
);
365 Bad_Switch
("-gnatd." & Switch_Chars
(Ptr
.. Max
));
367 Bad_Switch
("-gnatd" & Switch_Chars
(Ptr
.. Max
));
373 -- Processing for D switch
378 -- Scan optional integer line limit value
380 if Nat_Present
(Switch_Chars
, Max
, Ptr
) then
381 Scan_Nat
(Switch_Chars
, Max
, Ptr
, Sprint_Line_Limit
, 'D');
382 Sprint_Line_Limit
:= Nat
'Max (Sprint_Line_Limit
, 40);
385 -- Note: -gnatD also sets -gnatx (to turn off cross-reference
386 -- generation in the ali file) since otherwise this generation
387 -- gets confused by the "wrong" Sloc values put in the tree.
389 Debug_Generated_Code
:= True;
390 Xref_Active
:= False;
391 Set_Debug_Flag
('g');
393 -- -gnate? (extended switches)
398 -- The -gnate? switches are all double character switches
399 -- so we must always have a character after the e.
402 Bad_Switch
("-gnate");
405 case Switch_Chars
(Ptr
) is
407 -- -gnatea (initial delimiter of explicit switches)
409 -- All switches that come before -gnatea have been added by
410 -- the GCC driver and are not stored in the ALI file.
411 -- See also -gnatez below.
414 Store_Switch
:= False;
415 Enable_Switch_Storing
;
418 -- -gnateA (aliasing checks on parameters)
422 Check_Aliasing_Of_Parameters
:= True;
424 -- -gnatec (configuration pragmas)
427 Store_Switch
:= False;
430 -- There may be an equal sign between -gnatec and
431 -- the path name of the config file.
433 if Ptr
<= Max
and then Switch_Chars
(Ptr
) = '=' then
438 Bad_Switch
("-gnatec");
442 Config_File_Name
: constant String_Access
:=
444 (Switch_Chars (Ptr .. Max));
447 if Config_File_Names = null then
449 new String_List'(1 => Config_File_Name
);
453 New_Names
: constant String_List_Access
:=
456 Config_File_Names
'Length + 1);
459 for Index
in Config_File_Names
'Range loop
461 Config_File_Names
(Index
);
462 Config_File_Names
(Index
) := null;
465 New_Names
(New_Names
'Last) := Config_File_Name
;
466 Free
(Config_File_Names
);
467 Config_File_Names
:= New_Names
;
474 -- -gnateC switch (CodePeer SCIL generation)
476 -- Not enabled for now, keep it for later???
477 -- use -gnatd.I only for now
481 -- Generate_SCIL := True;
483 -- -gnated switch (disable atomic synchronization)
486 Suppress_Options
.Suppress
(Atomic_Synchronization
) :=
489 -- -gnateD switch (preprocessing symbol definition)
492 Store_Switch
:= False;
496 Bad_Switch
("-gnateD");
499 Add_Symbol_Definition
(Switch_Chars
(Ptr
.. Max
));
503 Store_Compilation_Switch
504 ("-gnateD" & Switch_Chars
(Ptr
.. Max
));
507 -- -gnateE (extra exception information)
510 Exception_Extra_Info
:= True;
513 -- -gnatef (full source path for brief error messages)
516 Store_Switch
:= False;
518 Full_Path_Name_For_Brief_Errors
:= True;
520 -- -gnateG (save preprocessor output)
523 Generate_Processed_File
:= True;
526 -- -gnatei (max number of instantiations)
531 (Switch_Chars
, Max
, Ptr
, Maximum_Instantiations
, C
);
533 -- -gnateI (index of unit in multi-unit source)
537 Scan_Pos
(Switch_Chars
, Max
, Ptr
, Multiple_Unit_Index
, C
);
539 -- -gnatem (mapping file)
542 Store_Switch
:= False;
545 -- There may be an equal sign between -gnatem and
546 -- the path name of the mapping file.
548 if Ptr
<= Max
and then Switch_Chars
(Ptr
) = '=' then
553 Bad_Switch
("-gnatem");
557 new String'(Switch_Chars (Ptr .. Max));
560 -- -gnateO= (object path file)
563 Store_Switch := False;
568 if Ptr >= Max or else Switch_Chars (Ptr) /= '=' then
569 Bad_Switch ("-gnateO");
572 Object_Path_File_Name :=
573 new String'(Switch_Chars
(Ptr
+ 1 .. Max
));
578 -- -gnatep (preprocessing data file)
581 Store_Switch
:= False;
584 -- There may be an equal sign between -gnatep and
585 -- the path name of the mapping file.
587 if Ptr
<= Max
and then Switch_Chars
(Ptr
) = '=' then
592 Bad_Switch
("-gnatep");
595 Preprocessing_Data_File
:=
596 new String'(Switch_Chars (Ptr .. Max));
598 -- Store the switch, normalizing to -gnatep=
600 Store_Compilation_Switch
601 ("-gnatep=" & Preprocessing_Data_File.all);
605 -- -gnateP (Treat pragma Pure/Preelaborate errs as warnings)
608 Treat_Categorization_Errors_As_Warnings := True;
610 -- -gnateS (generate SCO information)
612 -- Include Source Coverage Obligation information in ALI
613 -- files for the benefit of source coverage analysis tools
617 Generate_SCO := True;
620 -- -gnateV (validity checks on parameters)
624 Check_Validity_Of_Parameters := True;
626 -- -gnatez (final delimiter of explicit switches)
628 -- All switches that come after -gnatez have been added by
629 -- the GCC driver and are not stored in the ALI file. See
630 -- also -gnatea above.
633 Store_Switch := False;
634 Disable_Switch_Storing;
637 -- All other -gnate? switches are unassigned
640 Bad_Switch ("-gnate" & Switch_Chars (Ptr .. Max));
643 -- -gnatE (dynamic elaboration checks)
647 Dynamic_Elaboration_Checks := True;
649 -- -gnatf (full error messages)
653 All_Errors_Mode := True;
655 -- Processing for F switch
659 External_Name_Exp_Casing := Uppercase;
660 External_Name_Imp_Casing := Uppercase;
662 -- Processing for g switch
667 Identifier_Character_Set := 'n
';
668 System_Extend_Unit := Empty;
669 Warning_Mode := Treat_As_Error;
671 -- Set Ada 2012 mode explicitly. We don't want to rely on the
672 -- implicit setting here, since for example, we want
673 -- Preelaborate_05 treated as Preelaborate
675 Ada_Version := Ada_2012;
676 Ada_Version_Explicit := Ada_Version;
678 -- Set default warnings and style checks for -gnatg
680 Set_GNAT_Mode_Warnings;
681 Set_GNAT_Style_Check_Options;
683 -- Processing for G switch
687 Print_Generated_Code := True;
689 -- Scan optional integer line limit value
691 if Nat_Present (Switch_Chars, Max, Ptr) then
692 Scan_Nat (Switch_Chars, Max, Ptr, Sprint_Line_Limit, 'G
');
693 Sprint_Line_Limit := Nat'Max (Sprint_Line_Limit, 40);
696 -- Processing for h switch
700 Usage_Requested := True;
702 -- Processing for i switch
706 Bad_Switch ("-gnati");
710 C := Switch_Chars (Ptr);
720 Identifier_Character_Set := C;
724 Bad_Switch ("-gnati" & Switch_Chars (Ptr .. Max));
727 -- Processing for I switch
731 Ignore_Rep_Clauses := True;
733 -- Processing for j switch
737 Scan_Nat (Switch_Chars, Max, Ptr, Error_Msg_Line_Length, C);
739 -- Processing for k switch
744 (Switch_Chars, Max, Ptr, Maximum_File_Name_Length, C);
746 -- Processing for l switch
752 -- There may be an equal sign between -gnatl and a file name
754 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
756 Osint.Fail ("file name for -gnatl= is null");
758 Opt.Full_List_File_Name :=
759 new String'(Switch_Chars
(Ptr
+ 1 .. Max
));
764 -- Processing for L switch
768 Dump_Source_Text
:= True;
770 -- Processing for m switch
774 Scan_Nat
(Switch_Chars
, Max
, Ptr
, Maximum_Messages
, C
);
776 -- Processing for n switch
780 Inline_Active
:= True;
782 -- There may be a digit (1 or 2) appended to the switch
785 C
:= Switch_Chars
(Ptr
);
787 if C
in '1' .. '2' then
789 Inline_Level
:= Character'Pos (C
) - Character'Pos ('0');
793 -- Processing for N switch
797 Inline_Active
:= True;
798 Front_End_Inlining
:= True;
800 -- Processing for o switch
805 -- Case of no digits after the -gnato
807 if Ptr
> Max
or else Switch_Chars
(Ptr
) not in '0' .. '3' then
808 Suppress_Options
.Overflow_Checks_General
:= Checked
;
809 Suppress_Options
.Overflow_Checks_Assertions
:= Checked
;
811 -- At least one digit after the -gnato
814 -- Handle first digit after -gnato
816 Suppress_Options
.Overflow_Checks_General
:=
817 Get_Overflow_Mode
(Switch_Chars
(Ptr
));
820 -- Only one digit after -gnato, set assertions mode to
821 -- be the same as general mode.
824 or else Switch_Chars
(Ptr
) not in '0' .. '3'
826 Suppress_Options
.Overflow_Checks_Assertions
:=
827 Suppress_Options
.Overflow_Checks_General
;
829 -- Process second digit after -gnato
832 Suppress_Options
.Overflow_Checks_Assertions
:=
833 Get_Overflow_Mode
(Switch_Chars
(Ptr
));
838 -- Processing for O switch
841 Store_Switch
:= False;
843 Output_File_Name_Present
:= True;
845 -- Processing for p switch
850 -- Skip processing if cancelled by subsequent -gnat-p
852 if Switch_Subsequently_Cancelled
("p", Args
, Arg_Rank
) then
853 Store_Switch
:= False;
856 -- Set all specific options as well as All_Checks in the
857 -- Suppress_Options array, excluding Elaboration_Check,
858 -- since this is treated specially because we do not want
859 -- -gnatp to disable static elaboration processing. Also
860 -- exclude Atomic_Synchronization, since this is not a real
863 for J
in Suppress_Options
.Suppress
'Range loop
864 if J
/= Elaboration_Check
866 J
/= Atomic_Synchronization
868 Suppress_Options
.Suppress
(J
) := True;
871 Suppress_Options
.Overflow_Checks_General
:= Suppressed
;
872 Suppress_Options
.Overflow_Checks_Assertions
:= Suppressed
;
875 Validity_Checks_On
:= False;
876 Opt
.Suppress_Checks
:= True;
879 -- Processing for P switch
883 Polling_Required
:= True;
885 -- Processing for q switch
889 Try_Semantics
:= True;
891 -- Processing for Q switch
895 Force_ALI_Tree_File
:= True;
896 Try_Semantics
:= True;
898 -- Processing for r switch
902 Treat_Restrictions_As_Warnings
:= True;
904 -- Processing for R switch
907 Back_Annotate_Rep_Info
:= True;
908 List_Representation_Info
:= 1;
911 while Ptr
<= Max
loop
912 C
:= Switch_Chars
(Ptr
);
914 if C
in '1' .. '3' then
915 List_Representation_Info
:=
916 Character'Pos (C
) - Character'Pos ('0');
918 elsif Switch_Chars
(Ptr
) = 's' then
919 List_Representation_Info_To_File
:= True;
921 elsif Switch_Chars
(Ptr
) = 'm' then
922 List_Representation_Info_Mechanisms
:= True;
925 Bad_Switch
("-gnatR" & Switch_Chars
(Ptr
.. Max
));
931 -- Processing for s switch
934 if not First_Switch
then
936 ("-gnats must be first if combined with other switches");
940 Operating_Mode
:= Check_Syntax
;
942 -- Processing for S switch
945 Print_Standard
:= True;
948 -- Processing for t switch
953 Back_Annotate_Rep_Info
:= True;
955 -- Processing for T switch
959 Scan_Pos
(Switch_Chars
, Max
, Ptr
, Table_Factor
, C
);
961 -- Processing for u switch
967 -- Processing for U switch
971 Unique_Error_Tag
:= True;
973 -- Processing for v switch
977 Verbose_Mode
:= True;
979 -- Processing for V switch
982 Store_Switch
:= False;
986 Bad_Switch
("-gnatV");
993 Set_Validity_Check_Options
994 (Switch_Chars
(Ptr
.. Max
), OK
, Ptr
);
997 Bad_Switch
("-gnatV" & Switch_Chars
(Ptr
.. Max
));
1000 for Index
in First_Char
+ 1 .. Max
loop
1001 Store_Compilation_Switch
1002 ("-gnatV" & Switch_Chars
(Index
));
1009 -- Processing for w switch
1012 Store_Switch
:= False;
1016 Bad_Switch
("-gnatw");
1019 while Ptr
<= Max
loop
1020 C
:= Switch_Chars
(Ptr
);
1022 -- Case of dot switch
1024 if C
= '.' and then Ptr
< Max
then
1026 C
:= Switch_Chars
(Ptr
);
1028 if Set_Dot_Warning_Switch
(C
) then
1029 Store_Compilation_Switch
("-gnatw." & C
);
1031 Bad_Switch
("-gnatw." & Switch_Chars
(Ptr
.. Max
));
1034 -- Normal case, no dot
1037 if Set_Warning_Switch
(C
) then
1038 Store_Compilation_Switch
("-gnatw" & C
);
1040 Bad_Switch
("-gnatw" & Switch_Chars
(Ptr
.. Max
));
1049 -- Processing for W switch
1055 Bad_Switch
("-gnatW");
1059 Wide_Character_Encoding_Method
:=
1060 Get_WC_Encoding_Method
(Switch_Chars
(Ptr
));
1062 when Constraint_Error
=>
1063 Bad_Switch
("-gnatW" & Switch_Chars
(Ptr
.. Max
));
1066 Wide_Character_Encoding_Method_Specified
:= True;
1068 Upper_Half_Encoding
:=
1069 Wide_Character_Encoding_Method
in
1070 WC_Upper_Half_Encoding_Method
;
1074 -- Processing for x switch
1078 Xref_Active
:= False;
1080 -- Processing for X switch
1084 Extensions_Allowed
:= True;
1085 Ada_Version
:= Ada_Version_Type
'Last;
1086 Ada_Version_Explicit
:= Ada_Version_Type
'Last;
1088 -- Processing for y switch
1094 Set_Default_Style_Check_Options
;
1097 Store_Switch
:= False;
1103 Set_Style_Check_Options
1104 (Switch_Chars
(Ptr
.. Max
), OK
, Ptr
);
1108 ("bad -gnaty switch (" &
1109 Style_Msg_Buf
(1 .. Style_Msg_Len
) & ')');
1112 Ptr
:= First_Char
+ 1;
1113 while Ptr
<= Max
loop
1114 if Switch_Chars
(Ptr
) = 'M' then
1119 or else Switch_Chars
(Ptr
) not in '0' .. '9';
1122 Store_Compilation_Switch
1123 ("-gnaty" & Switch_Chars
(First_Char
.. Ptr
- 1));
1126 Store_Compilation_Switch
1127 ("-gnaty" & Switch_Chars
(Ptr
));
1134 -- Processing for z switch
1138 -- -gnatz must be the first and only switch in Switch_Chars,
1139 -- and is a two-letter switch.
1141 if Ptr
/= Switch_Chars
'First + 5
1142 or else (Max
- Ptr
+ 1) > 2
1145 ("-gnatz* may not be combined with other switches");
1149 Bad_Switch
("-gnatz");
1154 -- Only one occurrence of -gnat* is permitted
1156 if Distribution_Stub_Mode
= No_Stubs
then
1157 case Switch_Chars
(Ptr
) is
1159 Distribution_Stub_Mode
:= Generate_Receiver_Stub_Body
;
1162 Distribution_Stub_Mode
:= Generate_Caller_Stub_Body
;
1165 Bad_Switch
("-gnatz" & Switch_Chars
(Ptr
.. Max
));
1171 Osint
.Fail
("only one -gnatz* switch allowed");
1174 -- Processing for Z switch
1179 ("-gnatZ is no longer supported: consider using --RTS=zcx");
1181 -- Note on language version switches: whenever a new language
1182 -- version switch is added, Switch.M.Normalize_Compiler_Switches
1185 -- Processing for 83 switch
1189 Bad_Switch
("-gnat8");
1194 if Switch_Chars
(Ptr
) /= '3' then
1195 Bad_Switch
("-gnat8" & Switch_Chars
(Ptr
.. Max
));
1198 Ada_Version
:= Ada_83
;
1199 Ada_Version_Explicit
:= Ada_Version
;
1202 -- Processing for 95 switch
1206 Bad_Switch
("-gnat9");
1211 if Switch_Chars
(Ptr
) /= '5' then
1212 Bad_Switch
("-gnat9" & Switch_Chars
(Ptr
.. Max
));
1215 Ada_Version
:= Ada_95
;
1216 Ada_Version_Explicit
:= Ada_Version
;
1219 -- Processing for 05 switch
1223 Bad_Switch
("-gnat0");
1228 if Switch_Chars
(Ptr
) /= '5' then
1229 Bad_Switch
("-gnat0" & Switch_Chars
(Ptr
.. Max
));
1232 Ada_Version
:= Ada_2005
;
1233 Ada_Version_Explicit
:= Ada_Version
;
1236 -- Processing for 12 switch
1240 Bad_Switch
("-gnat1");
1245 if Switch_Chars
(Ptr
) /= '2' then
1246 Bad_Switch
("-gnat1" & Switch_Chars
(Ptr
.. Max
));
1249 Ada_Version
:= Ada_2012
;
1250 Ada_Version_Explicit
:= Ada_Version
;
1253 -- Processing for 2005 and 2012 switches
1256 if Ptr
> Max
- 3 then
1257 Bad_Switch
("-gnat" & Switch_Chars
(Ptr
.. Max
));
1259 elsif Switch_Chars
(Ptr
.. Ptr
+ 3) = "2005" then
1260 Ada_Version
:= Ada_2005
;
1262 elsif Switch_Chars
(Ptr
.. Ptr
+ 3) = "2012" then
1263 Ada_Version
:= Ada_2012
;
1266 Bad_Switch
("-gnat" & Switch_Chars
(Ptr
.. Ptr
+ 3));
1269 Ada_Version_Explicit
:= Ada_Version
;
1272 -- Switch cancellation, currently only -gnat-p is allowed.
1273 -- All we do here is the error checking, since the actual
1274 -- processing for switch cancellation is done by calls to
1275 -- Switch_Subsequently_Cancelled at the appropriate point.
1279 -- Simple ignore -gnat-p
1281 if Switch_Chars
= "-gnat-p" then
1284 -- Any other occurrence of minus is ignored. This is for
1285 -- maximum compatibility with previous version which ignored
1286 -- all occurrences of minus.
1289 Store_Switch
:= False;
1293 -- We ignore '/' in switches, this is historical, still needed???
1296 Store_Switch
:= False;
1298 -- Anything else is an error (illegal switch character)
1301 Bad_Switch
("-gnat" & Switch_Chars
(Ptr
.. Max
));
1304 if Store_Switch
then
1305 Store_Compilation_Switch
1306 ("-gnat" & Switch_Chars
(First_Char
.. Ptr
- 1));
1309 First_Switch
:= False;
1312 end Scan_Front_End_Switches
;
1314 -----------------------------------
1315 -- Switch_Subsequently_Cancelled --
1316 -----------------------------------
1318 function Switch_Subsequently_Cancelled
1321 Arg_Rank
: Positive) return Boolean
1324 -- Loop through arguments following the current one
1326 for Arg
in Arg_Rank
+ 1 .. Args
'Last loop
1327 if Args
(Arg
).all = "-gnat-" & C
then
1332 -- No match found, not cancelled
1335 end Switch_Subsequently_Cancelled
;