1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2014, 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 Stylesw
; use Stylesw
;
35 with Ttypes
; use Ttypes
;
36 with Validsw
; use Validsw
;
37 with Warnsw
; use Warnsw
;
39 with Ada
.Unchecked_Deallocation
;
40 with System
.WCh_Con
; use System
.WCh_Con
;
43 package body Switch
.C
is
45 RTS_Specified
: String_Access
:= null;
46 -- Used to detect multiple use of --RTS= flag
48 procedure Add_Symbol_Definition
(Def
: String);
49 -- Add a symbol definition from the command line
52 new Ada
.Unchecked_Deallocation
(String_List
, String_List_Access
);
53 -- Avoid using System.Strings.Free, which also frees the designated strings
55 function Get_Overflow_Mode
(C
: Character) return Overflow_Mode_Type
;
56 -- Given a digit in the range 0 .. 3, returns the corresponding value of
57 -- Overflow_Mode_Type. Raises Program_Error if C is outside this range.
59 function Switch_Subsequently_Cancelled
62 Arg_Rank
: Positive) return Boolean;
63 -- This function is called from Scan_Front_End_Switches. It determines if
64 -- the switch currently being scanned is followed by a switch of the form
65 -- "-gnat-" & C, where C is the argument. If so, then True is returned,
66 -- and Scan_Front_End_Switches will cancel the effect of the switch. If
67 -- no such switch is found, False is returned.
69 ---------------------------
70 -- Add_Symbol_Definition --
71 ---------------------------
73 procedure Add_Symbol_Definition
(Def
: String) is
75 -- If Preprocessor_Symbol_Defs is not large enough, double its size
77 if Preprocessing_Symbol_Last
= Preprocessing_Symbol_Defs
'Last then
79 New_Symbol_Definitions
: constant String_List_Access
:=
80 new String_List
(1 .. 2 * Preprocessing_Symbol_Last
);
82 New_Symbol_Definitions
(Preprocessing_Symbol_Defs
'Range) :=
83 Preprocessing_Symbol_Defs
.all;
84 Free
(Preprocessing_Symbol_Defs
);
85 Preprocessing_Symbol_Defs
:= New_Symbol_Definitions
;
89 Preprocessing_Symbol_Last
:= Preprocessing_Symbol_Last
+ 1;
90 Preprocessing_Symbol_Defs
(Preprocessing_Symbol_Last
) :=
92 end Add_Symbol_Definition;
94 -----------------------
95 -- Get_Overflow_Mode --
96 -----------------------
98 function Get_Overflow_Mode (C : Character) return Overflow_Mode_Type is
107 -- Eliminated allowed only if Long_Long_Integer is 64 bits (since
108 -- the current implementation of System.Bignums assumes this).
111 if Standard_Long_Long_Integer_Size /= 64 then
112 Bad_Switch ("-gnato3 not implemented for this configuration");
120 end Get_Overflow_Mode;
122 -----------------------------
123 -- Scan_Front_End_Switches --
124 -----------------------------
126 procedure Scan_Front_End_Switches
127 (Switch_Chars : String;
131 First_Switch : Boolean := True;
132 -- False for all but first switch
134 Max : constant Natural := Switch_Chars'Last;
136 C : Character := ' ';
139 Store_Switch : Boolean;
140 -- For -gnatxx switches, the normal processing, signalled by this flag
141 -- being set to True, is to store the switch on exit from the case
142 -- statement, the switch stored is -gnat followed by the characters
143 -- from First_Char to Ptr-1. For cases like -gnaty, where the switch
144 -- is stored in separate pieces, this flag is set to False, and the
145 -- appropriate calls to Store_Compilation_Switch are made from within
148 First_Char : Positive;
149 -- Marks start of switch to be stored
151 First_Ptr : Positive;
152 -- Save position of first character after -gnatd (for checking that
153 -- debug flags that must come first are first, in particular -gnatd.b),
156 Ptr := Switch_Chars'First;
158 -- Skip past the initial character (must be the switch character)
166 -- Handle switches that do not start with -gnat
168 if Ptr + 3 > Max or else Switch_Chars (Ptr .. Ptr + 3) /= "gnat" then
170 -- There are two front-end switches that do not start with -gnat:
173 if Switch_Chars (Ptr) = 'I
' then
175 -- Set flag Search_Directory_Present if switch is "-I" only:
176 -- the directory will be the next argument.
179 Search_Directory_Present := True;
185 -- Find out whether this is a -I- or regular -Ixxx switch
187 -- Note: -I switches are not recorded in the ALI file, since the
188 -- meaning of the program depends on the source files compiled,
189 -- not where they came from.
191 if Ptr = Max and then Switch_Chars (Ptr) = '-' then
192 Look_In_Primary_Dir := False;
194 Add_Src_Search_Dir (Switch_Chars (Ptr .. Max));
197 -- Processing of the --RTS switch. --RTS may have been modified by
198 -- gcc into -fRTS (for GCC targets).
201 and then (Switch_Chars (Ptr .. Ptr + 3) = "fRTS"
203 Switch_Chars (Ptr .. Ptr + 3) = "-RTS")
208 or else Switch_Chars (Ptr + 3) /= '='
210 Osint.Fail ("missing path for --RTS");
214 Runtime_Dir : String_Access;
217 if System.OS_Lib.Is_Absolute_Path
218 (Switch_Chars (Ptr + 4 .. Max))
222 (System
.OS_Lib
.Normalize_Pathname
223 (Switch_Chars
(Ptr
+ 4 .. Max
)));
227 new String'(Switch_Chars (Ptr + 4 .. Max));
230 -- Check that this is the first time --RTS is specified
231 -- or if it is not the first time, the same path has been
234 if RTS_Specified = null then
235 RTS_Specified := Runtime_Dir;
237 elsif RTS_Specified.all /= Runtime_Dir.all then
238 Osint.Fail ("--RTS cannot be specified multiple times");
241 -- Valid --RTS switch
243 Opt.No_Stdinc := True;
244 Opt.RTS_Switch := True;
247 Get_RTS_Search_Dir (Runtime_Dir.all, Include);
250 Get_RTS_Search_Dir (Runtime_Dir.all, Objects);
252 if RTS_Src_Path_Name /= null
253 and then RTS_Lib_Path_Name /= null
255 -- Store the -fRTS switch (Note: Store_Compilation_Switch
256 -- changes -fRTS back into --RTS for the actual output).
258 Store_Compilation_Switch (Switch_Chars);
260 elsif RTS_Src_Path_Name = null
261 and then RTS_Lib_Path_Name = null
263 Osint.Fail ("RTS path not valid: missing "
264 & "adainclude and adalib directories");
266 elsif RTS_Src_Path_Name = null then
267 Osint.Fail ("RTS path not valid: missing "
268 & "adainclude directory");
270 elsif RTS_Lib_Path_Name = null then
271 Osint.Fail ("RTS path not valid: missing "
272 & "adalib directory");
277 -- There are no other switches not starting with -gnat
280 Bad_Switch (Switch_Chars);
283 -- Case of switch starting with -gnat
288 -- Loop to scan through switches given in switch string
290 while Ptr <= Max loop
292 Store_Switch := True;
294 C := Switch_Chars (Ptr);
298 -- -gnata (assertions enabled)
302 Assertions_Enabled := True;
304 -- -gnatA (disregard gnat.adc)
308 Config_File := False;
310 -- -gnatb (brief messages to stderr)
314 Brief_Output := True;
316 -- -gnatB (assume no invalid values)
320 Assume_No_Invalid_Values := True;
322 -- -gnatc (check syntax and semantics only)
325 if not First_Switch then
327 ("-gnatc must be first if combined with other switches");
331 Operating_Mode := Check_Semantics;
333 -- -gnatC (Generate CodePeer information)
338 if not CodePeer_Mode then
339 CodePeer_Mode := True;
341 -- Suppress compiler warnings by default, since what we are
342 -- interested in here is what CodePeer can find out. Note
343 -- that if -gnatwxxx is specified after -gnatC on the
344 -- command line, we do not want to override this setting in
345 -- Adjust_Global_Switches, and assume that the user wants to
346 -- get both warnings from GNAT and CodePeer messages.
348 Warning_Mode := Suppress;
351 -- -gnatd (compiler debug options)
354 Store_Switch := False;
356 First_Ptr := Ptr + 1;
358 -- Note: for the debug switch, the remaining characters in this
359 -- switch field must all be debug flags, since all valid switch
360 -- characters are also valid debug characters.
362 -- Loop to scan out debug flags
366 C := Switch_Chars (Ptr);
367 exit when C = ASCII.NUL or else C = '/' or else C = '-';
369 if C in '1' .. '9' or else
370 C in 'a
' .. 'z
' or else
373 -- Case of dotted flag
376 Set_Dotted_Debug_Flag (C);
377 Store_Compilation_Switch ("-gnatd." & C);
379 -- Special check, -gnatd.b must come first
382 and then (Ptr /= First_Ptr + 1
383 or else not First_Switch)
386 ("-gnatd.b must be first if combined "
387 & "with other switches");
394 Store_Compilation_Switch ("-gnatd" & C);
401 Bad_Switch ("-gnatd." & Switch_Chars (Ptr .. Max));
403 Bad_Switch ("-gnatd" & Switch_Chars (Ptr .. Max));
409 -- -gnatD (debug expanded code)
414 -- Not allowed if previous -gnatR given
416 -- The reason for this prohibition is that the rewriting of
417 -- Sloc values causes strange malfunctions in the tests of
418 -- whether units belong to the main source. This is really a
419 -- bug, but too hard to fix for a marginal capability ???
421 -- The proper fix is to completely redo -gnatD processing so
422 -- that the tree is not messed with, and instead a separate
423 -- table is built on the side for debug information generation.
425 if List_Representation_Info /= 0 then
427 ("-gnatD not permitted since -gnatR given previously");
430 -- Scan optional integer line limit value
432 if Nat_Present (Switch_Chars, Max, Ptr) then
433 Scan_Nat (Switch_Chars, Max, Ptr, Sprint_Line_Limit, 'D
');
434 Sprint_Line_Limit := Nat'Max (Sprint_Line_Limit, 40);
437 -- Note: -gnatD also sets -gnatx (to turn off cross-reference
438 -- generation in the ali file) since otherwise this generation
439 -- gets confused by the "wrong" Sloc values put in the tree.
441 Debug_Generated_Code := True;
442 Xref_Active := False;
443 Set_Debug_Flag ('g
');
445 -- -gnate? (extended switches)
450 -- The -gnate? switches are all double character switches
451 -- so we must always have a character after the e.
454 Bad_Switch ("-gnate");
457 case Switch_Chars (Ptr) is
459 -- -gnatea (initial delimiter of explicit switches)
461 -- This is an internal switch
463 -- All switches that come before -gnatea have been added by
464 -- the GCC driver and are not stored in the ALI file.
465 -- See also -gnatez below.
468 Store_Switch := False;
469 Enable_Switch_Storing;
472 -- -gnateA (aliasing checks on parameters)
476 Check_Aliasing_Of_Parameters := True;
478 -- -gnatec (configuration pragmas)
481 Store_Switch := False;
484 -- There may be an equal sign between -gnatec and
485 -- the path name of the config file.
487 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
492 Bad_Switch ("-gnatec");
496 Config_File_Name : constant String_Access :=
498 (Switch_Chars
(Ptr
.. Max
));
501 if Config_File_Names
= null then
503 new String_List
'(1 => Config_File_Name);
507 New_Names : constant String_List_Access :=
510 Config_File_Names'Length + 1);
513 for Index in Config_File_Names'Range loop
515 Config_File_Names (Index);
516 Config_File_Names (Index) := null;
519 New_Names (New_Names'Last) := Config_File_Name;
520 Free (Config_File_Names);
521 Config_File_Names := New_Names;
528 -- -gnateC switch (generate CodePeer messages)
532 Generate_CodePeer_Messages := True;
534 -- -gnated switch (disable atomic synchronization)
537 Suppress_Options.Suppress (Atomic_Synchronization) :=
540 -- -gnateD switch (preprocessing symbol definition)
543 Store_Switch := False;
547 Bad_Switch ("-gnateD");
550 Add_Symbol_Definition (Switch_Chars (Ptr .. Max));
554 Store_Compilation_Switch
555 ("-gnateD" & Switch_Chars (Ptr .. Max));
558 -- -gnateE (extra exception information)
561 Exception_Extra_Info := True;
564 -- -gnatef (full source path for brief error messages)
567 Store_Switch := False;
569 Full_Path_Name_For_Brief_Errors := True;
571 -- -gnateF (Check_Float_Overflow)
575 Check_Float_Overflow := True;
577 -- -gnateG (save preprocessor output)
580 Generate_Processed_File := True;
583 -- -gnatei (max number of instantiations)
588 (Switch_Chars, Max, Ptr, Maximum_Instantiations, C);
590 -- -gnateI (index of unit in multi-unit source)
594 Scan_Pos (Switch_Chars, Max, Ptr, Multiple_Unit_Index, C);
600 Elab_Info_Messages := True;
606 Elab_Info_Messages := False;
608 -- -gnatem (mapping file)
611 Store_Switch := False;
614 -- There may be an equal sign between -gnatem and
615 -- the path name of the mapping file.
617 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
622 Bad_Switch ("-gnatem");
626 new String'(Switch_Chars
(Ptr
.. Max
));
629 -- -gnateO= (object path file)
631 -- This is an internal switch
634 Store_Switch
:= False;
639 if Ptr
>= Max
or else Switch_Chars
(Ptr
) /= '=' then
640 Bad_Switch
("-gnateO");
642 Object_Path_File_Name
:=
643 new String'(Switch_Chars (Ptr + 1 .. Max));
648 -- -gnatep (preprocessing data file)
651 Store_Switch := False;
654 -- There may be an equal sign between -gnatep and
655 -- the path name of the mapping file.
657 if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
662 Bad_Switch ("-gnatep");
665 Preprocessing_Data_File :=
666 new String'(Switch_Chars
(Ptr
.. Max
));
668 -- Store the switch, normalizing to -gnatep=
670 Store_Compilation_Switch
671 ("-gnatep=" & Preprocessing_Data_File
.all);
675 -- -gnateP (Treat pragma Pure/Preelaborate errs as warnings)
678 Treat_Categorization_Errors_As_Warnings
:= True;
680 -- -gnates=file (specify extra file switches for gnat2why)
682 -- This is an internal switch
685 if not First_Switch
then
687 ("-gnates must not be combined with other switches");
694 if Ptr
>= Max
or else Switch_Chars
(Ptr
) /= '=' then
695 Bad_Switch
("-gnates");
697 SPARK_Switches_File_Name
:=
698 new String'(Switch_Chars (Ptr + 1 .. Max));
703 -- -gnateS (generate SCO information)
705 -- Include Source Coverage Obligation information in ALI
706 -- files for use by source coverage analysis tools
707 -- (gnatcov) (equivalent to -fdump-scos, provided for
708 -- backwards compatibility).
711 Generate_SCO := True;
712 Generate_SCO_Instance_Table := True;
715 -- -gnatet (write target dependent information)
718 if not First_Switch then
720 ("-gnatet must not be combined with other switches");
727 if Ptr >= Max or else Switch_Chars (Ptr) /= '=' then
728 Bad_Switch ("-gnatet");
730 Target_Dependent_Info_Write_Name :=
731 new String'(Switch_Chars
(Ptr
+ 1 .. Max
));
736 -- -gnateT (read target dependent information)
739 if not First_Switch
then
741 ("-gnateT must not be combined with other switches");
748 if Ptr
>= Max
or else Switch_Chars
(Ptr
) /= '=' then
749 Bad_Switch
("-gnateT");
751 -- This parameter was stored by Set_Targ earlier
754 (Target_Dependent_Info_Read_Name
.all =
755 Switch_Chars
(Ptr
+ 1 .. Max
));
761 -- -gnateu (unrecognized y,V,w switches)
765 Ignore_Unrecognized_VWY_Switches
:= True;
767 -- -gnateV (validity checks on parameters)
771 Check_Validity_Of_Parameters
:= True;
773 -- -gnateY (ignore Style_Checks pragmas)
776 Ignore_Style_Checks_Pragmas
:= True;
779 -- -gnatez (final delimiter of explicit switches)
781 -- This is an internal switch
783 -- All switches that come after -gnatez have been added by
784 -- the GCC driver and are not stored in the ALI file. See
785 -- also -gnatea above.
788 Store_Switch
:= False;
789 Disable_Switch_Storing
;
792 -- All other -gnate? switches are unassigned
795 Bad_Switch
("-gnate" & Switch_Chars
(Ptr
.. Max
));
798 -- -gnatE (dynamic elaboration checks)
802 Dynamic_Elaboration_Checks
:= True;
804 -- -gnatf (full error messages)
808 All_Errors_Mode
:= True;
810 -- -gnatF (overflow of predefined float types)
814 External_Name_Exp_Casing
:= Uppercase
;
815 External_Name_Imp_Casing
:= Uppercase
;
817 -- -gnatg (GNAT implementation mode)
822 Identifier_Character_Set
:= 'n';
823 System_Extend_Unit
:= Empty
;
824 Warning_Mode
:= Treat_As_Error
;
825 Style_Check_Main
:= True;
826 Ada_Version
:= Ada_2012
;
827 Ada_Version_Explicit
:= Ada_2012
;
828 Ada_Version_Pragma
:= Empty
;
830 -- Set default warnings and style checks for -gnatg
832 Set_GNAT_Mode_Warnings
;
833 Set_GNAT_Style_Check_Options
;
835 -- -gnatG (output generated code)
839 Print_Generated_Code
:= True;
841 -- Scan optional integer line limit value
843 if Nat_Present
(Switch_Chars
, Max
, Ptr
) then
844 Scan_Nat
(Switch_Chars
, Max
, Ptr
, Sprint_Line_Limit
, 'G');
845 Sprint_Line_Limit
:= Nat
'Max (Sprint_Line_Limit
, 40);
848 -- -gnath (help information)
852 Usage_Requested
:= True;
854 -- -gnati (character set)
858 Bad_Switch
("-gnati");
862 C
:= Switch_Chars
(Ptr
);
872 Identifier_Character_Set
:= C
;
876 Bad_Switch
("-gnati" & Switch_Chars
(Ptr
.. Max
));
879 -- -gnatI (ignore representation clauses)
883 Ignore_Rep_Clauses
:= True;
885 -- -gnatj (messages in limited length lines)
889 Scan_Nat
(Switch_Chars
, Max
, Ptr
, Error_Msg_Line_Length
, C
);
891 -- -gnatk (limit file name length)
896 (Switch_Chars
, Max
, Ptr
, Maximum_File_Name_Length
, C
);
898 -- -gnatl (output full source)
904 -- There may be an equal sign between -gnatl and a file name
906 if Ptr
<= Max
and then Switch_Chars
(Ptr
) = '=' then
908 Osint
.Fail
("file name for -gnatl= is null");
910 Opt
.Full_List_File_Name
:=
911 new String'(Switch_Chars (Ptr + 1 .. Max));
916 -- -gnatL (corresponding source text)
920 Dump_Source_Text := True;
922 -- -gnatm (max number or errors/warnings)
926 Scan_Nat (Switch_Chars, Max, Ptr, Maximum_Messages, C);
928 -- -gnatn (enable pragma Inline)
932 Inline_Active := True;
934 -- There may be a digit (1 or 2) appended to the switch
937 C := Switch_Chars (Ptr);
939 if C in '1' .. '2' then
941 Inline_Level := Character'Pos (C) - Character'Pos ('0');
945 -- -gnatN (obsolescent)
949 Inline_Active := True;
950 Front_End_Inlining := True;
952 -- -gnato (overflow checks)
957 -- Case of -gnato0 (overflow checking turned off)
959 if Ptr <= Max and then Switch_Chars (Ptr) = '0' then
961 Suppress_Options.Suppress (Overflow_Check) := True;
963 -- We set strict mode in case overflow checking is turned
964 -- on locally (also records that we had a -gnato switch).
966 Suppress_Options.Overflow_Mode_General := Strict;
967 Suppress_Options.Overflow_Mode_Assertions := Strict;
969 -- All cases other than -gnato0 (overflow checking turned on)
972 Suppress_Options.Suppress (Overflow_Check) := False;
974 -- Case of no digits after the -gnato
977 or else Switch_Chars (Ptr) not in '1' .. '3'
979 Suppress_Options.Overflow_Mode_General := Strict;
980 Suppress_Options.Overflow_Mode_Assertions := Strict;
982 -- At least one digit after the -gnato
985 -- Handle first digit after -gnato
987 Suppress_Options.Overflow_Mode_General :=
988 Get_Overflow_Mode (Switch_Chars (Ptr));
991 -- Only one digit after -gnato, set assertions mode to be
992 -- the same as general mode.
995 or else Switch_Chars (Ptr) not in '1' .. '3'
997 Suppress_Options.Overflow_Mode_Assertions :=
998 Suppress_Options.Overflow_Mode_General;
1000 -- Process second digit after -gnato
1003 Suppress_Options.Overflow_Mode_Assertions :=
1004 Get_Overflow_Mode (Switch_Chars (Ptr));
1010 -- -gnatO (specify name of the object file)
1012 -- This is an internal switch
1015 Store_Switch := False;
1017 Output_File_Name_Present := True;
1019 -- -gnatp (suppress all checks)
1024 -- Skip processing if cancelled by subsequent -gnat-p
1026 if Switch_Subsequently_Cancelled ("p", Args, Arg_Rank) then
1027 Store_Switch := False;
1030 -- Set all specific options as well as All_Checks in the
1031 -- Suppress_Options array, excluding Elaboration_Check,
1032 -- since this is treated specially because we do not want
1033 -- -gnatp to disable static elaboration processing. Also
1034 -- exclude Atomic_Synchronization, since this is not a real
1037 for J in Suppress_Options.Suppress'Range loop
1038 if J /= Elaboration_Check
1040 J /= Atomic_Synchronization
1042 Suppress_Options.Suppress (J) := True;
1046 Validity_Checks_On := False;
1047 Opt.Suppress_Checks := True;
1049 -- Set overflow mode checking to strict in case it gets
1050 -- turned on locally (also signals that overflow checking
1051 -- has been specifically turned off).
1053 Suppress_Options.Overflow_Mode_General := Strict;
1054 Suppress_Options.Overflow_Mode_Assertions := Strict;
1057 -- -gnatP (periodic poll)
1061 Polling_Required := True;
1063 -- -gnatq (don't quit)
1067 Try_Semantics := True;
1069 -- -gnatQ (always write ALI file)
1073 Force_ALI_Tree_File := True;
1074 Try_Semantics := True;
1076 -- -gnatr (restrictions as warnings)
1080 Treat_Restrictions_As_Warnings := True;
1082 -- -gnatR (list rep. info)
1086 -- Not allowed if previous -gnatD given. See more extensive
1087 -- comments in the 'D
' section for the inverse test.
1089 if Debug_Generated_Code then
1091 ("-gnatR not permitted since -gnatD given previously");
1094 -- Set to annotate rep info, and set default -gnatR mode
1096 Back_Annotate_Rep_Info := True;
1097 List_Representation_Info := 1;
1099 -- Scan possible parameter
1102 while Ptr <= Max loop
1103 C := Switch_Chars (Ptr);
1105 if C in '1' .. '3' then
1106 List_Representation_Info :=
1107 Character'Pos (C) - Character'Pos ('0');
1109 elsif Switch_Chars (Ptr) = 's
' then
1110 List_Representation_Info_To_File := True;
1112 elsif Switch_Chars (Ptr) = 'm
' then
1113 List_Representation_Info_Mechanisms := True;
1116 Bad_Switch ("-gnatR" & Switch_Chars (Ptr .. Max));
1122 -- -gnats (syntax check only)
1125 if not First_Switch then
1127 ("-gnats must be first if combined with other switches");
1131 Operating_Mode := Check_Syntax;
1133 -- -gnatS (print package Standard)
1136 Print_Standard := True;
1139 -- -gnatt (output tree)
1143 Tree_Output := True;
1144 Back_Annotate_Rep_Info := True;
1146 -- -gnatT (change start of internal table sizes)
1150 Scan_Pos (Switch_Chars, Max, Ptr, Table_Factor, C);
1152 -- -gnatu (list units for compilation)
1158 -- -gnatU (unique tags)
1162 Unique_Error_Tag := True;
1164 -- -gnatv (verbose mode)
1168 Verbose_Mode := True;
1170 -- -gnatV (validity checks)
1173 Store_Switch := False;
1177 Bad_Switch ("-gnatV");
1184 Set_Validity_Check_Options
1185 (Switch_Chars (Ptr .. Max), OK, Ptr);
1188 Bad_Switch ("-gnatV" & Switch_Chars (Ptr .. Max));
1191 for Index in First_Char + 1 .. Max loop
1192 Store_Compilation_Switch
1193 ("-gnatV" & Switch_Chars (Index));
1200 -- -gnatw (warning modes)
1203 Store_Switch := False;
1207 Bad_Switch ("-gnatw");
1210 while Ptr <= Max loop
1211 C := Switch_Chars (Ptr);
1213 -- Case of dot switch
1215 if C = '.' and then Ptr < Max then
1217 C := Switch_Chars (Ptr);
1219 if Set_Dot_Warning_Switch (C) then
1220 Store_Compilation_Switch ("-gnatw." & C);
1222 Bad_Switch ("-gnatw." & Switch_Chars (Ptr .. Max));
1225 -- Normal case, no dot
1228 if Set_Warning_Switch (C) then
1229 Store_Compilation_Switch ("-gnatw" & C);
1231 Bad_Switch ("-gnatw" & Switch_Chars (Ptr .. Max));
1240 -- -gnatW (wide character encoding method)
1246 Bad_Switch ("-gnatW");
1250 Wide_Character_Encoding_Method :=
1251 Get_WC_Encoding_Method (Switch_Chars (Ptr));
1253 when Constraint_Error =>
1254 Bad_Switch ("-gnatW" & Switch_Chars (Ptr .. Max));
1257 Wide_Character_Encoding_Method_Specified := True;
1259 Upper_Half_Encoding :=
1260 Wide_Character_Encoding_Method in
1261 WC_Upper_Half_Encoding_Method;
1265 -- -gnatx (suppress cross-ref information)
1269 Xref_Active := False;
1271 -- -gnatX (language extensions)
1275 Extensions_Allowed := True;
1276 Ada_Version := Ada_Version_Type'Last;
1277 Ada_Version_Explicit := Ada_Version_Type'Last;
1278 Ada_Version_Pragma := Empty;
1280 -- -gnaty (style checks)
1284 Style_Check_Main := True;
1287 Set_Default_Style_Check_Options;
1290 Store_Switch := False;
1296 Set_Style_Check_Options
1297 (Switch_Chars (Ptr .. Max), OK, Ptr);
1301 ("bad -gnaty switch (" &
1302 Style_Msg_Buf (1 .. Style_Msg_Len) & ')');
1305 Ptr := First_Char + 1;
1306 while Ptr <= Max loop
1307 if Switch_Chars (Ptr) = 'M
' then
1312 or else Switch_Chars (Ptr) not in '0' .. '9';
1315 Store_Compilation_Switch
1316 ("-gnaty" & Switch_Chars (First_Char .. Ptr - 1));
1319 Store_Compilation_Switch
1320 ("-gnaty" & Switch_Chars (Ptr));
1327 -- -gnatz (stub generation)
1331 -- -gnatz must be the first and only switch in Switch_Chars,
1332 -- and is a two-letter switch.
1334 if Ptr /= Switch_Chars'First + 5
1335 or else (Max - Ptr + 1) > 2
1338 ("-gnatz* may not be combined with other switches");
1342 Bad_Switch ("-gnatz");
1347 -- Only one occurrence of -gnat* is permitted
1349 if Distribution_Stub_Mode = No_Stubs then
1350 case Switch_Chars (Ptr) is
1352 Distribution_Stub_Mode := Generate_Receiver_Stub_Body;
1355 Distribution_Stub_Mode := Generate_Caller_Stub_Body;
1358 Bad_Switch ("-gnatz" & Switch_Chars (Ptr .. Max));
1364 Osint.Fail ("only one -gnatz* switch allowed");
1367 -- -gnatZ (obsolescent)
1372 ("-gnatZ is no longer supported: consider using --RTS=zcx");
1374 -- Note on language version switches: whenever a new language
1375 -- version switch is added, Switch.M.Normalize_Compiler_Switches
1382 Bad_Switch ("-gnat8");
1387 if Switch_Chars (Ptr) /= '3' then
1388 Bad_Switch ("-gnat8" & Switch_Chars (Ptr .. Max));
1391 Ada_Version := Ada_83;
1392 Ada_Version_Explicit := Ada_83;
1393 Ada_Version_Pragma := Empty;
1400 Bad_Switch ("-gnat9");
1405 if Switch_Chars (Ptr) /= '5' then
1406 Bad_Switch ("-gnat9" & Switch_Chars (Ptr .. Max));
1409 Ada_Version := Ada_95;
1410 Ada_Version_Explicit := Ada_95;
1411 Ada_Version_Pragma := Empty;
1418 Bad_Switch ("-gnat0");
1423 if Switch_Chars (Ptr) /= '5' then
1424 Bad_Switch ("-gnat0" & Switch_Chars (Ptr .. Max));
1427 Ada_Version := Ada_2005;
1428 Ada_Version_Explicit := Ada_2005;
1429 Ada_Version_Pragma := Empty;
1436 Bad_Switch ("-gnat1");
1441 if Switch_Chars (Ptr) /= '2' then
1442 Bad_Switch ("-gnat1" & Switch_Chars (Ptr .. Max));
1445 Ada_Version := Ada_2012;
1446 Ada_Version_Explicit := Ada_2012;
1447 Ada_Version_Pragma := Empty;
1450 -- -gnat2005 and -gnat2012
1453 if Ptr > Max - 3 then
1454 Bad_Switch ("-gnat" & Switch_Chars (Ptr .. Max));
1456 elsif Switch_Chars (Ptr .. Ptr + 3) = "2005" then
1457 Ada_Version := Ada_2005;
1459 elsif Switch_Chars (Ptr .. Ptr + 3) = "2012" then
1460 Ada_Version := Ada_2012;
1463 Bad_Switch ("-gnat" & Switch_Chars (Ptr .. Ptr + 3));
1466 Ada_Version_Explicit := Ada_Version;
1467 Ada_Version_Pragma := Empty;
1470 -- Switch cancellation, currently only -gnat-p is allowed.
1471 -- All we do here is the error checking, since the actual
1472 -- processing for switch cancellation is done by calls to
1473 -- Switch_Subsequently_Cancelled at the appropriate point.
1477 -- Simple ignore -gnat-p
1479 if Switch_Chars = "-gnat-p" then
1482 -- Any other occurrence of minus is ignored. This is for
1483 -- maximum compatibility with previous version which ignored
1484 -- all occurrences of minus.
1487 Store_Switch := False;
1491 -- We ignore '/' in switches, this is historical, still needed???
1494 Store_Switch := False;
1496 -- Anything else is an error (illegal switch character)
1499 Bad_Switch ("-gnat" & Switch_Chars (Ptr .. Max));
1502 if Store_Switch then
1503 Store_Compilation_Switch
1504 ("-gnat" & Switch_Chars (First_Char .. Ptr - 1));
1507 First_Switch := False;
1510 end Scan_Front_End_Switches;
1512 -----------------------------------
1513 -- Switch_Subsequently_Cancelled --
1514 -----------------------------------
1516 function Switch_Subsequently_Cancelled
1519 Arg_Rank : Positive) return Boolean
1522 -- Loop through arguments following the current one
1524 for Arg in Arg_Rank + 1 .. Args'Last loop
1525 if Args (Arg).all = "-gnat-" & C then
1530 -- No match found, not cancelled
1533 end Switch_Subsequently_Cancelled;