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 -- -gnateG (save preprocessor output)
520 Generate_Processed_File := True;
523 -- -gnatei (max number of instantiations)
528 (Switch_Chars, Max, Ptr, Maximum_Instantiations, C);
530 -- -gnateI (index of unit in multi-unit source)
534 Scan_Pos (Switch_Chars, Max, Ptr, Multiple_Unit_Index, C);
536 -- -gnatem (mapping file)
539 Store_Switch := False;
542 -- There may be an equal sign between -gnatem and
543 -- the path name of the mapping file.
545 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
550 Bad_Switch ("-gnatem");
554 new String'(Switch_Chars (Ptr .. Max));
557 -- -gnateO= (object path file)
560 Store_Switch := False;
565 if Ptr >= Max or else Switch_Chars (Ptr) /= '=' then
566 Bad_Switch ("-gnateO");
569 Object_Path_File_Name :=
570 new String'(Switch_Chars (Ptr + 1 .. Max));
575 -- -gnatep (preprocessing data file)
578 Store_Switch := False;
581 -- There may be an equal sign between -gnatep and
582 -- the path name of the mapping file.
584 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
589 Bad_Switch ("-gnatep");
592 Preprocessing_Data_File :=
593 new String'(Switch_Chars (Ptr .. Max));
595 -- Store the switch, normalizing to -gnatep=
597 Store_Compilation_Switch
598 ("-gnatep=" & Preprocessing_Data_File.all);
602 -- -gnateP (Treat pragma Pure/Preelaborate errs as warnings)
605 Treat_Categorization_Errors_As_Warnings := True;
607 -- -gnateS (generate SCO information)
609 -- Include Source Coverage Obligation information in ALI
610 -- files for the benefit of source coverage analysis tools
614 Generate_SCO := True;
617 -- -gnatet (generate target dependent information)
620 Generate_Target_Dependent_Info := True;
623 -- -gnateV (validity checks on parameters)
627 Check_Validity_Of_Parameters := True;
629 -- -gnatez (final delimiter of explicit switches)
631 -- All switches that come after -gnatez have been added by
632 -- the GCC driver and are not stored in the ALI file. See
633 -- also -gnatea above.
636 Store_Switch := False;
637 Disable_Switch_Storing;
640 -- All other -gnate? switches are unassigned
643 Bad_Switch ("-gnate" & Switch_Chars (Ptr .. Max));
646 -- -gnatE (dynamic elaboration checks)
650 Dynamic_Elaboration_Checks := True;
652 -- -gnatf (full error messages)
656 All_Errors_Mode := True;
658 -- Processing for F switch
662 External_Name_Exp_Casing := Uppercase;
663 External_Name_Imp_Casing := Uppercase;
665 -- Processing for g switch
670 Identifier_Character_Set := 'n';
671 System_Extend_Unit := Empty;
672 Warning_Mode := Treat_As_Error;
674 -- Set Ada 2012 mode explicitly. We don't want to rely on the
675 -- implicit setting here, since for example, we want
676 -- Preelaborate_05 treated as Preelaborate
678 Ada_Version := Ada_2012;
679 Ada_Version_Explicit := Ada_Version;
681 -- Set default warnings and style checks for -gnatg
683 Set_GNAT_Mode_Warnings;
684 Set_GNAT_Style_Check_Options;
686 -- Processing for G switch
690 Print_Generated_Code := True;
692 -- Scan optional integer line limit value
694 if Nat_Present (Switch_Chars, Max, Ptr) then
695 Scan_Nat (Switch_Chars, Max, Ptr, Sprint_Line_Limit, 'G');
696 Sprint_Line_Limit := Nat'Max (Sprint_Line_Limit, 40);
699 -- Processing for h switch
703 Usage_Requested := True;
705 -- Processing for i switch
709 Bad_Switch ("-gnati");
713 C := Switch_Chars (Ptr);
723 Identifier_Character_Set := C;
727 Bad_Switch ("-gnati" & Switch_Chars (Ptr .. Max));
730 -- Processing for I switch
734 Ignore_Rep_Clauses := True;
736 -- Processing for j switch
740 Scan_Nat (Switch_Chars, Max, Ptr, Error_Msg_Line_Length, C);
742 -- Processing for k switch
747 (Switch_Chars, Max, Ptr, Maximum_File_Name_Length, C);
749 -- Processing for l switch
755 -- There may be an equal sign between -gnatl and a file name
757 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
759 Osint.Fail ("file name for -gnatl= is null");
761 Opt.Full_List_File_Name :=
762 new String'(Switch_Chars (Ptr + 1 .. Max));
767 -- Processing for L switch
771 Dump_Source_Text := True;
773 -- Processing for m switch
777 Scan_Nat (Switch_Chars, Max, Ptr, Maximum_Messages, C);
779 -- Processing for n switch
783 Inline_Active := True;
785 -- There may be a digit (1 or 2) appended to the switch
788 C := Switch_Chars (Ptr);
790 if C in '1' .. '2' then
792 Inline_Level := Character'Pos (C) - Character'Pos ('0');
796 -- Processing for N switch
800 Inline_Active := True;
801 Front_End_Inlining := True;
803 -- Processing for o switch
807 Suppress_Options.Suppress (Overflow_Check) := False;
809 -- Case of no digits after the -gnato
811 if Ptr > Max or else Switch_Chars (Ptr) not in '1' .. '3' then
812 Suppress_Options.Overflow_Mode_General := Strict;
813 Suppress_Options.Overflow_Mode_Assertions := Strict;
815 -- At least one digit after the -gnato
818 -- Handle first digit after -gnato
820 Suppress_Options.Overflow_Mode_General :=
821 Get_Overflow_Mode (Switch_Chars (Ptr));
824 -- Only one digit after -gnato, set assertions mode to
825 -- be the same as general mode.
828 or else Switch_Chars (Ptr) not in '1' .. '3'
830 Suppress_Options.Overflow_Mode_Assertions :=
831 Suppress_Options.Overflow_Mode_General;
833 -- Process second digit after -gnato
836 Suppress_Options.Overflow_Mode_Assertions :=
837 Get_Overflow_Mode (Switch_Chars (Ptr));
842 -- Processing for O switch
845 Store_Switch := False;
847 Output_File_Name_Present := True;
849 -- Processing for p switch
854 -- Skip processing if cancelled by subsequent -gnat-p
856 if Switch_Subsequently_Cancelled ("p", Args, Arg_Rank) then
857 Store_Switch := False;
860 -- Set all specific options as well as All_Checks in the
861 -- Suppress_Options array, excluding Elaboration_Check,
862 -- since this is treated specially because we do not want
863 -- -gnatp to disable static elaboration processing. Also
864 -- exclude Atomic_Synchronization, since this is not a real
867 for J in Suppress_Options.Suppress'Range loop
868 if J /= Elaboration_Check
870 J /= Atomic_Synchronization
872 Suppress_Options.Suppress (J) := True;
876 Validity_Checks_On := False;
877 Opt.Suppress_Checks := True;
880 -- Processing for P switch
884 Polling_Required := True;
886 -- Processing for q switch
890 Try_Semantics := True;
892 -- Processing for Q switch
896 Force_ALI_Tree_File := True;
897 Try_Semantics := True;
899 -- Processing for r switch
903 Treat_Restrictions_As_Warnings := True;
905 -- Processing for R switch
908 Back_Annotate_Rep_Info := True;
909 List_Representation_Info := 1;
912 while Ptr <= Max loop
913 C := Switch_Chars (Ptr);
915 if C in '1' .. '3' then
916 List_Representation_Info :=
917 Character'Pos (C) - Character'Pos ('0');
919 elsif Switch_Chars (Ptr) = 's' then
920 List_Representation_Info_To_File := True;
922 elsif Switch_Chars (Ptr) = 'm' then
923 List_Representation_Info_Mechanisms := True;
926 Bad_Switch ("-gnatR" & Switch_Chars (Ptr .. Max));
932 -- Processing for s switch
935 if not First_Switch then
937 ("-gnats must be first if combined with other switches");
941 Operating_Mode := Check_Syntax;
943 -- Processing for S switch
946 Print_Standard := True;
949 -- Processing for t switch
954 Back_Annotate_Rep_Info := True;
956 -- Processing for T switch
960 Scan_Pos (Switch_Chars, Max, Ptr, Table_Factor, C);
962 -- Processing for u switch
968 -- Processing for U switch
972 Unique_Error_Tag := True;
974 -- Processing for v switch
978 Verbose_Mode := True;
980 -- Processing for V switch
983 Store_Switch := False;
987 Bad_Switch ("-gnatV");
994 Set_Validity_Check_Options
995 (Switch_Chars (Ptr .. Max), OK, Ptr);
998 Bad_Switch ("-gnatV" & Switch_Chars (Ptr .. Max));
1001 for Index in First_Char + 1 .. Max loop
1002 Store_Compilation_Switch
1003 ("-gnatV" & Switch_Chars (Index));
1010 -- Processing for w switch
1013 Store_Switch := False;
1017 Bad_Switch ("-gnatw");
1020 while Ptr <= Max loop
1021 C := Switch_Chars (Ptr);
1023 -- Case of dot switch
1025 if C = '.' and then Ptr < Max then
1027 C := Switch_Chars (Ptr);
1029 if Set_Dot_Warning_Switch (C) then
1030 Store_Compilation_Switch ("-gnatw." & C);
1032 Bad_Switch ("-gnatw." & Switch_Chars (Ptr .. Max));
1035 -- Normal case, no dot
1038 if Set_Warning_Switch (C) then
1039 Store_Compilation_Switch ("-gnatw" & C);
1041 Bad_Switch ("-gnatw" & Switch_Chars (Ptr .. Max));
1050 -- Processing for W switch
1056 Bad_Switch ("-gnatW");
1060 Wide_Character_Encoding_Method :=
1061 Get_WC_Encoding_Method (Switch_Chars (Ptr));
1063 when Constraint_Error =>
1064 Bad_Switch ("-gnatW" & Switch_Chars (Ptr .. Max));
1067 Wide_Character_Encoding_Method_Specified := True;
1069 Upper_Half_Encoding :=
1070 Wide_Character_Encoding_Method in
1071 WC_Upper_Half_Encoding_Method;
1075 -- Processing for x switch
1079 Xref_Active := False;
1081 -- Processing for X switch
1085 Extensions_Allowed := True;
1086 Ada_Version := Ada_Version_Type'Last;
1087 Ada_Version_Explicit := Ada_Version_Type'Last;
1089 -- Processing for y switch
1095 Set_Default_Style_Check_Options;
1098 Store_Switch := False;
1104 Set_Style_Check_Options
1105 (Switch_Chars (Ptr .. Max), OK, Ptr);
1109 ("bad -gnaty switch (" &
1110 Style_Msg_Buf (1 .. Style_Msg_Len) & ')');
1113 Ptr := First_Char + 1;
1114 while Ptr <= Max loop
1115 if Switch_Chars (Ptr) = 'M' then
1120 or else Switch_Chars (Ptr) not in '0' .. '9';
1123 Store_Compilation_Switch
1124 ("-gnaty" & Switch_Chars (First_Char .. Ptr - 1));
1127 Store_Compilation_Switch
1128 ("-gnaty" & Switch_Chars (Ptr));
1135 -- Processing for z switch
1139 -- -gnatz must be the first and only switch in Switch_Chars,
1140 -- and is a two-letter switch.
1142 if Ptr /= Switch_Chars'First + 5
1143 or else (Max - Ptr + 1) > 2
1146 ("-gnatz* may not be combined with other switches");
1150 Bad_Switch ("-gnatz");
1155 -- Only one occurrence of -gnat* is permitted
1157 if Distribution_Stub_Mode = No_Stubs then
1158 case Switch_Chars (Ptr) is
1160 Distribution_Stub_Mode := Generate_Receiver_Stub_Body;
1163 Distribution_Stub_Mode := Generate_Caller_Stub_Body;
1166 Bad_Switch ("-gnatz" & Switch_Chars (Ptr .. Max));
1172 Osint.Fail ("only one -gnatz* switch allowed");
1175 -- Processing for Z switch
1180 ("-gnatZ is no longer supported: consider using --RTS=zcx");
1182 -- Note on language version switches: whenever a new language
1183 -- version switch is added, Switch.M.Normalize_Compiler_Switches
1186 -- Processing for 83 switch
1190 Bad_Switch ("-gnat8");
1195 if Switch_Chars (Ptr) /= '3' then
1196 Bad_Switch ("-gnat8" & Switch_Chars (Ptr .. Max));
1199 Ada_Version := Ada_83;
1200 Ada_Version_Explicit := Ada_Version;
1203 -- Processing for 95 switch
1207 Bad_Switch ("-gnat9");
1212 if Switch_Chars (Ptr) /= '5' then
1213 Bad_Switch ("-gnat9" & Switch_Chars (Ptr .. Max));
1216 Ada_Version := Ada_95;
1217 Ada_Version_Explicit := Ada_Version;
1220 -- Processing for 05 switch
1224 Bad_Switch ("-gnat0");
1229 if Switch_Chars (Ptr) /= '5' then
1230 Bad_Switch ("-gnat0" & Switch_Chars (Ptr .. Max));
1233 Ada_Version := Ada_2005;
1234 Ada_Version_Explicit := Ada_Version;
1237 -- Processing for 12 switch
1241 Bad_Switch ("-gnat1");
1246 if Switch_Chars (Ptr) /= '2' then
1247 Bad_Switch ("-gnat1" & Switch_Chars (Ptr .. Max));
1250 Ada_Version := Ada_2012;
1251 Ada_Version_Explicit := Ada_Version;
1254 -- Processing for 2005 and 2012 switches
1257 if Ptr > Max - 3 then
1258 Bad_Switch ("-gnat" & Switch_Chars (Ptr .. Max));
1260 elsif Switch_Chars (Ptr .. Ptr + 3) = "2005" then
1261 Ada_Version := Ada_2005;
1263 elsif Switch_Chars (Ptr .. Ptr + 3) = "2012" then
1264 Ada_Version := Ada_2012;
1267 Bad_Switch ("-gnat" & Switch_Chars (Ptr .. Ptr + 3));
1270 Ada_Version_Explicit := Ada_Version;
1273 -- Switch cancellation, currently only -gnat-p is allowed.
1274 -- All we do here is the error checking, since the actual
1275 -- processing for switch cancellation is done by calls to
1276 -- Switch_Subsequently_Cancelled at the appropriate point.
1280 -- Simple ignore -gnat-p
1282 if Switch_Chars = "-gnat-p" then
1285 -- Any other occurrence of minus is ignored. This is for
1286 -- maximum compatibility with previous version which ignored
1287 -- all occurrences of minus.
1290 Store_Switch := False;
1294 -- We ignore '/' in switches, this is historical, still needed???
1297 Store_Switch := False;
1299 -- Anything else is an error (illegal switch character)
1302 Bad_Switch ("-gnat" & Switch_Chars (Ptr .. Max));
1305 if Store_Switch then
1306 Store_Compilation_Switch
1307 ("-gnat" & Switch_Chars (First_Char .. Ptr - 1));
1310 First_Switch := False;
1313 end Scan_Front_End_Switches;
1315 -----------------------------------
1316 -- Switch_Subsequently_Cancelled --
1317 -----------------------------------
1319 function Switch_Subsequently_Cancelled
1322 Arg_Rank : Positive) return Boolean
1325 -- Loop through arguments following the current one
1327 for Arg in Arg_Rank + 1 .. Args'Last loop
1328 if Args (Arg).all = "-gnat-" & C then
1333 -- No match found, not cancelled
1336 end Switch_Subsequently_Cancelled;