1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2013, 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
150 First_Ptr : Positive;
151 -- Save position of first character after -gnatd (for checking that
152 -- debug flags that must come first are first, in particular -gnatd.b),
155 Ptr := Switch_Chars'First;
157 -- Skip past the initial character (must be the switch character)
165 -- Handle switches that do not start with -gnat
167 if Ptr + 3 > Max or else Switch_Chars (Ptr .. Ptr + 3) /= "gnat" then
169 -- There are two front-end switches that do not start with -gnat:
172 if Switch_Chars (Ptr) = 'I' then
174 -- Set flag Search_Directory_Present if switch is "-I" only:
175 -- the directory will be the next argument.
178 Search_Directory_Present := True;
184 -- Find out whether this is a -I- or regular -Ixxx switch
186 -- Note: -I switches are not recorded in the ALI file, since the
187 -- meaning of the program depends on the source files compiled,
188 -- not where they came from.
190 if Ptr = Max and then Switch_Chars (Ptr) = '-' then
191 Look_In_Primary_Dir := False;
193 Add_Src_Search_Dir (Switch_Chars (Ptr .. Max));
196 -- Processing of the --RTS switch. --RTS may have been modified by
197 -- gcc into -fRTS (for GCC targets).
200 and then (Switch_Chars (Ptr .. Ptr + 3) = "fRTS"
202 Switch_Chars (Ptr .. Ptr + 3) = "-RTS")
207 or else Switch_Chars (Ptr + 3) /= '='
209 Osint.Fail ("missing path for --RTS");
211 -- Check that this is the first time --RTS is specified or if
212 -- it is not the first time, the same path has been specified.
214 if RTS_Specified = null then
215 RTS_Specified := new String'(Switch_Chars (Ptr + 4 .. Max));
218 RTS_Specified.all /= Switch_Chars (Ptr + 4 .. Max)
220 Osint.Fail ("--RTS cannot be specified multiple times");
223 -- Valid --RTS switch
225 Opt.No_Stdinc := True;
226 Opt.RTS_Switch := True;
230 (Switch_Chars (Ptr + 4 .. Max), Include);
234 (Switch_Chars (Ptr + 4 .. Max), Objects);
236 if RTS_Src_Path_Name /= null
237 and then RTS_Lib_Path_Name /= null
239 -- Store the -fRTS switch (Note: Store_Compilation_Switch
240 -- changes -fRTS back into --RTS for the actual output).
242 Store_Compilation_Switch (Switch_Chars);
244 elsif RTS_Src_Path_Name = null
245 and then RTS_Lib_Path_Name = null
247 Osint.Fail ("RTS path not valid: missing " &
248 "adainclude and adalib directories");
250 elsif RTS_Src_Path_Name = null then
251 Osint.Fail ("RTS path not valid: missing " &
252 "adainclude directory");
254 elsif RTS_Lib_Path_Name = null then
255 Osint.Fail ("RTS path not valid: missing " &
260 -- There are no other switches not starting with -gnat
263 Bad_Switch (Switch_Chars);
266 -- Case of switch starting with -gnat
271 -- Loop to scan through switches given in switch string
273 while Ptr <= Max loop
275 Store_Switch := True;
277 C := Switch_Chars (Ptr);
281 -- -gnata (assertions enabled)
285 Assertions_Enabled := True;
286 Debug_Pragmas_Enabled := True;
288 -- -gnatA (disregard gnat.adc)
292 Config_File := False;
294 -- -gnatb (brief messages to stderr)
298 Brief_Output := True;
300 -- -gnatB (assume no invalid values)
304 Assume_No_Invalid_Values := True;
306 -- -gnatc (check syntax and semantics only)
309 if not First_Switch then
311 ("-gnatc must be first if combined with other switches");
315 Operating_Mode := Check_Semantics;
317 -- -gnatC (Generate CodePeer information)
322 if not CodePeer_Mode then
323 CodePeer_Mode := True;
325 -- Suppress compiler warnings by default, since what we are
326 -- interested in here is what CodePeer can find out. Note
327 -- that if -gnatwxxx is specified after -gnatC on the
328 -- command line, we do not want to override this setting in
329 -- Adjust_Global_Switches, and assume that the user wants to
330 -- get both warnings from GNAT and CodePeer messages.
332 Warning_Mode := Suppress;
335 -- -gnatd (compiler debug options)
338 Store_Switch := False;
340 First_Ptr := Ptr + 1;
342 -- Note: for the debug switch, the remaining characters in this
343 -- switch field must all be debug flags, since all valid switch
344 -- characters are also valid debug characters.
346 -- Loop to scan out debug flags
350 C := Switch_Chars (Ptr);
351 exit when C = ASCII.NUL or else C = '/' or else C = '-';
353 if C in '1' .. '9' or else
354 C in 'a' .. 'z' or else
357 -- Case of dotted flag
360 Set_Dotted_Debug_Flag (C);
361 Store_Compilation_Switch ("-gnatd." & C);
363 -- Special check, -gnatd.b must come first
366 and then (Ptr /= First_Ptr + 1
367 or else not First_Switch)
370 ("-gnatd.b must be first if combined "
371 & "with other switches");
378 Store_Compilation_Switch ("-gnatd" & C);
385 Bad_Switch ("-gnatd." & Switch_Chars (Ptr .. Max));
387 Bad_Switch ("-gnatd" & Switch_Chars (Ptr .. Max));
393 -- -gnatD (debug expanded code)
398 -- Scan optional integer line limit value
400 if Nat_Present (Switch_Chars, Max, Ptr) then
401 Scan_Nat (Switch_Chars, Max, Ptr, Sprint_Line_Limit, 'D');
402 Sprint_Line_Limit := Nat'Max (Sprint_Line_Limit, 40);
405 -- Note: -gnatD also sets -gnatx (to turn off cross-reference
406 -- generation in the ali file) since otherwise this generation
407 -- gets confused by the "wrong" Sloc values put in the tree.
409 Debug_Generated_Code := True;
410 Xref_Active := False;
411 Set_Debug_Flag ('g');
413 -- -gnate? (extended switches)
418 -- The -gnate? switches are all double character switches
419 -- so we must always have a character after the e.
422 Bad_Switch ("-gnate");
425 case Switch_Chars (Ptr) is
427 -- -gnatea (initial delimiter of explicit switches)
429 -- This is an internal switch
431 -- All switches that come before -gnatea have been added by
432 -- the GCC driver and are not stored in the ALI file.
433 -- See also -gnatez below.
436 Store_Switch := False;
437 Enable_Switch_Storing;
440 -- -gnateA (aliasing checks on parameters)
444 Check_Aliasing_Of_Parameters := True;
446 -- -gnatec (configuration pragmas)
449 Store_Switch := False;
452 -- There may be an equal sign between -gnatec and
453 -- the path name of the config file.
455 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
460 Bad_Switch ("-gnatec");
464 Config_File_Name : constant String_Access :=
466 (Switch_Chars (Ptr .. Max));
469 if Config_File_Names = null then
471 new String_List'(1 => Config_File_Name);
475 New_Names : constant String_List_Access :=
478 Config_File_Names'Length + 1);
481 for Index in Config_File_Names'Range loop
483 Config_File_Names (Index);
484 Config_File_Names (Index) := null;
487 New_Names (New_Names'Last) := Config_File_Name;
488 Free (Config_File_Names);
489 Config_File_Names := New_Names;
496 -- -gnateC switch (CodePeer SCIL generation)
498 -- Not enabled for now, keep it for later???
499 -- use -gnatd.I only for now
503 -- Generate_SCIL := True;
505 -- -gnated switch (disable atomic synchronization)
508 Suppress_Options.Suppress (Atomic_Synchronization) :=
511 -- -gnateD switch (preprocessing symbol definition)
514 Store_Switch := False;
518 Bad_Switch ("-gnateD");
521 Add_Symbol_Definition (Switch_Chars (Ptr .. Max));
525 Store_Compilation_Switch
526 ("-gnateD" & Switch_Chars (Ptr .. Max));
529 -- -gnateE (extra exception information)
532 Exception_Extra_Info := True;
535 -- -gnatef (full source path for brief error messages)
538 Store_Switch := False;
540 Full_Path_Name_For_Brief_Errors := True;
542 -- -gnateF (Check_Float_Overflow)
546 Check_Float_Overflow := True;
548 -- -gnateG (save preprocessor output)
551 Generate_Processed_File := True;
554 -- -gnatei (max number of instantiations)
559 (Switch_Chars, Max, Ptr, Maximum_Instantiations, C);
561 -- -gnateI (index of unit in multi-unit source)
565 Scan_Pos (Switch_Chars, Max, Ptr, Multiple_Unit_Index, C);
567 -- -gnatem (mapping file)
570 Store_Switch := False;
573 -- There may be an equal sign between -gnatem and
574 -- the path name of the mapping file.
576 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
581 Bad_Switch ("-gnatem");
585 new String'(Switch_Chars (Ptr .. Max));
588 -- -gnateO= (object path file)
590 -- This is an internal switch
593 Store_Switch := False;
598 if Ptr >= Max or else Switch_Chars (Ptr) /= '=' then
599 Bad_Switch ("-gnateO");
601 Object_Path_File_Name :=
602 new String'(Switch_Chars (Ptr + 1 .. Max));
607 -- -gnatep (preprocessing data file)
610 Store_Switch := False;
613 -- There may be an equal sign between -gnatep and
614 -- the path name of the mapping file.
616 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
621 Bad_Switch ("-gnatep");
624 Preprocessing_Data_File :=
625 new String'(Switch_Chars (Ptr .. Max));
627 -- Store the switch, normalizing to -gnatep=
629 Store_Compilation_Switch
630 ("-gnatep=" & Preprocessing_Data_File.all);
634 -- -gnateP (Treat pragma Pure/Preelaborate errs as warnings)
637 Treat_Categorization_Errors_As_Warnings := True;
639 -- -gnateS (generate SCO information)
641 -- Include Source Coverage Obligation information in ALI
642 -- files for the benefit of source coverage analysis tools
646 Generate_SCO := True;
647 Generate_SCO_Instance_Table := True;
650 -- -gnatet (write target dependent information)
653 if not First_Switch then
655 ("-gnatet must be first if combined with "
663 if Ptr >= Max or else Switch_Chars (Ptr) /= '=' then
664 Bad_Switch ("-gnatet");
666 Target_Dependent_Info_Write_Name :=
667 new String'(Switch_Chars (Ptr + 1 .. Max));
672 -- -gnateT (read target dependent information)
675 if not First_Switch then
677 ("-gnateT must be first if combined with "
685 if Ptr >= Max or else Switch_Chars (Ptr) /= '=' then
686 Bad_Switch ("-gnateT");
688 -- This parameter was stored by Set_Targ earlier
691 (Target_Dependent_Info_Read_Name.all =
692 Switch_Chars (Ptr + 1 .. Max));
698 -- -gnateV (validity checks on parameters)
702 Check_Validity_Of_Parameters := True;
704 -- -gnateY (ignore Style_Checks pragmas)
707 Ignore_Style_Checks_Pragmas := True;
710 -- -gnatez (final delimiter of explicit switches)
712 -- This is an internal switch
714 -- All switches that come after -gnatez have been added by
715 -- the GCC driver and are not stored in the ALI file. See
716 -- also -gnatea above.
719 Store_Switch := False;
720 Disable_Switch_Storing;
723 -- All other -gnate? switches are unassigned
726 Bad_Switch ("-gnate" & Switch_Chars (Ptr .. Max));
729 -- -gnatE (dynamic elaboration checks)
733 Dynamic_Elaboration_Checks := True;
735 -- -gnatf (full error messages)
739 All_Errors_Mode := True;
741 -- -gnatF (overflow of predefined float types)
745 External_Name_Exp_Casing := Uppercase;
746 External_Name_Imp_Casing := Uppercase;
748 -- -gnatg (GNAT implementation mode)
753 Identifier_Character_Set := 'n';
754 System_Extend_Unit := Empty;
755 Warning_Mode := Treat_As_Error;
757 -- Set Ada 2012 mode explicitly. We don't want to rely on the
758 -- implicit setting here, since for example, we want
759 -- Preelaborate_05 treated as Preelaborate
761 Ada_Version := Ada_2012;
762 Ada_Version_Explicit := Ada_Version;
764 -- Set default warnings and style checks for -gnatg
766 Set_GNAT_Mode_Warnings;
767 Set_GNAT_Style_Check_Options;
769 -- -gnatG (output generated code)
773 Print_Generated_Code := True;
775 -- Scan optional integer line limit value
777 if Nat_Present (Switch_Chars, Max, Ptr) then
778 Scan_Nat (Switch_Chars, Max, Ptr, Sprint_Line_Limit, 'G');
779 Sprint_Line_Limit := Nat'Max (Sprint_Line_Limit, 40);
782 -- -gnath (help information)
786 Usage_Requested := True;
788 -- -gnati (character set)
792 Bad_Switch ("-gnati");
796 C := Switch_Chars (Ptr);
806 Identifier_Character_Set := C;
810 Bad_Switch ("-gnati" & Switch_Chars (Ptr .. Max));
813 -- -gnatI (ignore representation clauses)
817 Ignore_Rep_Clauses := True;
819 -- -gnatj (messages in limited length lines)
823 Scan_Nat (Switch_Chars, Max, Ptr, Error_Msg_Line_Length, C);
825 -- -gnatk (limit file name length)
830 (Switch_Chars, Max, Ptr, Maximum_File_Name_Length, C);
832 -- -gnatl (output full source)
838 -- There may be an equal sign between -gnatl and a file name
840 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
842 Osint.Fail ("file name for -gnatl= is null");
844 Opt.Full_List_File_Name :=
845 new String'(Switch_Chars (Ptr + 1 .. Max));
850 -- -gnatL (corresponding source text)
854 Dump_Source_Text := True;
856 -- -gnatm (max number or errors/warnings)
860 Scan_Nat (Switch_Chars, Max, Ptr, Maximum_Messages, C);
862 -- -gnatn (enable pragma Inline)
866 Inline_Active := True;
868 -- There may be a digit (1 or 2) appended to the switch
871 C := Switch_Chars (Ptr);
873 if C in '1' .. '2' then
875 Inline_Level := Character'Pos (C) - Character'Pos ('0');
879 -- -gnatN (obsolescent)
883 Inline_Active := True;
884 Front_End_Inlining := True;
886 -- -gnato (overflow checks)
890 Suppress_Options.Suppress (Overflow_Check) := False;
892 -- Case of no digits after the -gnato
894 if Ptr > Max or else Switch_Chars (Ptr) not in '1' .. '3' then
895 Suppress_Options.Overflow_Mode_General := Strict;
896 Suppress_Options.Overflow_Mode_Assertions := Strict;
898 -- At least one digit after the -gnato
901 -- Handle first digit after -gnato
903 Suppress_Options.Overflow_Mode_General :=
904 Get_Overflow_Mode (Switch_Chars (Ptr));
907 -- Only one digit after -gnato, set assertions mode to
908 -- be the same as general mode.
911 or else Switch_Chars (Ptr) not in '1' .. '3'
913 Suppress_Options.Overflow_Mode_Assertions :=
914 Suppress_Options.Overflow_Mode_General;
916 -- Process second digit after -gnato
919 Suppress_Options.Overflow_Mode_Assertions :=
920 Get_Overflow_Mode (Switch_Chars (Ptr));
925 -- -gnatO (specify name of the object file)
927 -- This is an internal switch
930 Store_Switch := False;
932 Output_File_Name_Present := True;
934 -- -gnatp (suppress all checks)
939 -- Skip processing if cancelled by subsequent -gnat-p
941 if Switch_Subsequently_Cancelled ("p", Args, Arg_Rank) then
942 Store_Switch := False;
945 -- Set all specific options as well as All_Checks in the
946 -- Suppress_Options array, excluding Elaboration_Check,
947 -- since this is treated specially because we do not want
948 -- -gnatp to disable static elaboration processing. Also
949 -- exclude Atomic_Synchronization, since this is not a real
952 for J in Suppress_Options.Suppress'Range loop
953 if J /= Elaboration_Check
955 J /= Atomic_Synchronization
957 Suppress_Options.Suppress (J) := True;
961 Validity_Checks_On := False;
962 Opt.Suppress_Checks := True;
965 -- -gnatP (periodic poll)
969 Polling_Required := True;
971 -- -gnatq (don't quit)
975 Try_Semantics := True;
977 -- -gnatQ (always write ALI file)
981 Force_ALI_Tree_File := True;
982 Try_Semantics := True;
984 -- -gnatr (restrictions as warnings)
988 Treat_Restrictions_As_Warnings := True;
990 -- -gnatR (list rep. info)
993 Back_Annotate_Rep_Info := True;
994 List_Representation_Info := 1;
997 while Ptr <= Max loop
998 C := Switch_Chars (Ptr);
1000 if C in '1' .. '3' then
1001 List_Representation_Info :=
1002 Character'Pos (C) - Character'Pos ('0');
1004 elsif Switch_Chars (Ptr) = 's' then
1005 List_Representation_Info_To_File := True;
1007 elsif Switch_Chars (Ptr) = 'm' then
1008 List_Representation_Info_Mechanisms := True;
1011 Bad_Switch ("-gnatR" & Switch_Chars (Ptr .. Max));
1017 -- -gnats (syntax check only)
1020 if not First_Switch then
1022 ("-gnats must be first if combined with other switches");
1026 Operating_Mode := Check_Syntax;
1028 -- -gnatS (print package Standard)
1031 Print_Standard := True;
1034 -- -gnatt (output tree)
1038 Tree_Output := True;
1039 Back_Annotate_Rep_Info := True;
1041 -- -gnatT (change start of internal table sizes)
1045 Scan_Pos (Switch_Chars, Max, Ptr, Table_Factor, C);
1047 -- -gnatu (list units for compilation)
1053 -- -gnatU (unique tags)
1057 Unique_Error_Tag := True;
1059 -- -gnatv (verbose mode)
1063 Verbose_Mode := True;
1065 -- -gnatV (validity checks)
1068 Store_Switch := False;
1072 Bad_Switch ("-gnatV");
1079 Set_Validity_Check_Options
1080 (Switch_Chars (Ptr .. Max), OK, Ptr);
1083 Bad_Switch ("-gnatV" & Switch_Chars (Ptr .. Max));
1086 for Index in First_Char + 1 .. Max loop
1087 Store_Compilation_Switch
1088 ("-gnatV" & Switch_Chars (Index));
1095 -- -gnatw (warning modes)
1098 Store_Switch := False;
1102 Bad_Switch ("-gnatw");
1105 while Ptr <= Max loop
1106 C := Switch_Chars (Ptr);
1108 -- Case of dot switch
1110 if C = '.' and then Ptr < Max then
1112 C := Switch_Chars (Ptr);
1114 if Set_Dot_Warning_Switch (C) then
1115 Store_Compilation_Switch ("-gnatw." & C);
1117 Bad_Switch ("-gnatw." & Switch_Chars (Ptr .. Max));
1120 -- Normal case, no dot
1123 if Set_Warning_Switch (C) then
1124 Store_Compilation_Switch ("-gnatw" & C);
1126 Bad_Switch ("-gnatw" & Switch_Chars (Ptr .. Max));
1135 -- -gnatW (wide character encoding method)
1141 Bad_Switch ("-gnatW");
1145 Wide_Character_Encoding_Method :=
1146 Get_WC_Encoding_Method (Switch_Chars (Ptr));
1148 when Constraint_Error =>
1149 Bad_Switch ("-gnatW" & Switch_Chars (Ptr .. Max));
1152 Wide_Character_Encoding_Method_Specified := True;
1154 Upper_Half_Encoding :=
1155 Wide_Character_Encoding_Method in
1156 WC_Upper_Half_Encoding_Method;
1160 -- -gnatx (suppress cross-ref information)
1164 Xref_Active := False;
1166 -- -gnatX (language extensions)
1170 Extensions_Allowed := True;
1171 Ada_Version := Ada_Version_Type'Last;
1172 Ada_Version_Explicit := Ada_Version_Type'Last;
1174 -- -gnaty (style checks)
1180 Set_Default_Style_Check_Options;
1183 Store_Switch := False;
1189 Set_Style_Check_Options
1190 (Switch_Chars (Ptr .. Max), OK, Ptr);
1194 ("bad -gnaty switch (" &
1195 Style_Msg_Buf (1 .. Style_Msg_Len) & ')');
1198 Ptr := First_Char + 1;
1199 while Ptr <= Max loop
1200 if Switch_Chars (Ptr) = 'M' then
1205 or else Switch_Chars (Ptr) not in '0' .. '9';
1208 Store_Compilation_Switch
1209 ("-gnaty" & Switch_Chars (First_Char .. Ptr - 1));
1212 Store_Compilation_Switch
1213 ("-gnaty" & Switch_Chars (Ptr));
1220 -- -gnatz (stub generation)
1224 -- -gnatz must be the first and only switch in Switch_Chars,
1225 -- and is a two-letter switch.
1227 if Ptr /= Switch_Chars'First + 5
1228 or else (Max - Ptr + 1) > 2
1231 ("-gnatz* may not be combined with other switches");
1235 Bad_Switch ("-gnatz");
1240 -- Only one occurrence of -gnat* is permitted
1242 if Distribution_Stub_Mode = No_Stubs then
1243 case Switch_Chars (Ptr) is
1245 Distribution_Stub_Mode := Generate_Receiver_Stub_Body;
1248 Distribution_Stub_Mode := Generate_Caller_Stub_Body;
1251 Bad_Switch ("-gnatz" & Switch_Chars (Ptr .. Max));
1257 Osint.Fail ("only one -gnatz* switch allowed");
1260 -- -gnatZ (obsolescent)
1265 ("-gnatZ is no longer supported: consider using --RTS=zcx");
1267 -- Note on language version switches: whenever a new language
1268 -- version switch is added, Switch.M.Normalize_Compiler_Switches
1275 Bad_Switch ("-gnat8");
1280 if Switch_Chars (Ptr) /= '3' then
1281 Bad_Switch ("-gnat8" & Switch_Chars (Ptr .. Max));
1284 Ada_Version := Ada_83;
1285 Ada_Version_Explicit := Ada_Version;
1292 Bad_Switch ("-gnat9");
1297 if Switch_Chars (Ptr) /= '5' then
1298 Bad_Switch ("-gnat9" & Switch_Chars (Ptr .. Max));
1301 Ada_Version := Ada_95;
1302 Ada_Version_Explicit := Ada_Version;
1309 Bad_Switch ("-gnat0");
1314 if Switch_Chars (Ptr) /= '5' then
1315 Bad_Switch ("-gnat0" & Switch_Chars (Ptr .. Max));
1318 Ada_Version := Ada_2005;
1319 Ada_Version_Explicit := Ada_Version;
1326 Bad_Switch ("-gnat1");
1331 if Switch_Chars (Ptr) /= '2' then
1332 Bad_Switch ("-gnat1" & Switch_Chars (Ptr .. Max));
1335 Ada_Version := Ada_2012;
1336 Ada_Version_Explicit := Ada_Version;
1339 -- -gnat2005 and -gnat2012
1342 if Ptr > Max - 3 then
1343 Bad_Switch ("-gnat" & Switch_Chars (Ptr .. Max));
1345 elsif Switch_Chars (Ptr .. Ptr + 3) = "2005" then
1346 Ada_Version := Ada_2005;
1348 elsif Switch_Chars (Ptr .. Ptr + 3) = "2012" then
1349 Ada_Version := Ada_2012;
1352 Bad_Switch ("-gnat" & Switch_Chars (Ptr .. Ptr + 3));
1355 Ada_Version_Explicit := Ada_Version;
1358 -- Switch cancellation, currently only -gnat-p is allowed.
1359 -- All we do here is the error checking, since the actual
1360 -- processing for switch cancellation is done by calls to
1361 -- Switch_Subsequently_Cancelled at the appropriate point.
1365 -- Simple ignore -gnat-p
1367 if Switch_Chars = "-gnat-p" then
1370 -- Any other occurrence of minus is ignored. This is for
1371 -- maximum compatibility with previous version which ignored
1372 -- all occurrences of minus.
1375 Store_Switch := False;
1379 -- We ignore '/' in switches, this is historical, still needed???
1382 Store_Switch := False;
1384 -- Anything else is an error (illegal switch character)
1387 Bad_Switch ("-gnat" & Switch_Chars (Ptr .. Max));
1390 if Store_Switch then
1391 Store_Compilation_Switch
1392 ("-gnat" & Switch_Chars (First_Char .. Ptr - 1));
1395 First_Switch := False;
1398 end Scan_Front_End_Switches;
1400 -----------------------------------
1401 -- Switch_Subsequently_Cancelled --
1402 -----------------------------------
1404 function Switch_Subsequently_Cancelled
1407 Arg_Rank : Positive) return Boolean
1410 -- Loop through arguments following the current one
1412 for Arg in Arg_Rank + 1 .. Args'Last loop
1413 if Args (Arg).all = "-gnat-" & C then
1418 -- No match found, not cancelled
1421 end Switch_Subsequently_Cancelled;