-- --
-- B o d y --
-- --
--- Copyright (C) 2001-2006, Free Software Foundation, Inc. --
+-- Copyright (C) 2001-2009, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
--- ware Foundation; either version 2, or (at your option) any later ver- --
+-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
--- Public License distributed with GNAT; see file COPYING. If not, write --
--- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
--- Boston, MA 02110-1301, USA. --
+-- Public License distributed with GNAT; see file COPYING3. If not, go to --
+-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
with Sem_Warn; use Sem_Warn;
with Stylesw; use Stylesw;
-with GNAT.OS_Lib; use GNAT.OS_Lib;
+with System.OS_Lib; use System.OS_Lib;
with System.WCh_Con; use System.WCh_Con;
Add_Src_Search_Dir (Switch_Chars (Ptr .. Max));
end if;
- -- Processing of the --RTS switch. --RTS has been modified by
- -- gcc and is now of the form -fRTS.
+ -- Processing of the --RTS switch. --RTS may have been modified by
+ -- gcc into -fRTS (for GCC targets).
elsif Ptr + 3 <= Max
- and then Switch_Chars (Ptr .. Ptr + 3) = "fRTS"
+ and then (Switch_Chars (Ptr .. Ptr + 3) = "fRTS"
+ or else
+ Switch_Chars (Ptr .. Ptr + 3) = "-RTS")
then
Ptr := Ptr + 1;
-- it is not the first time, the same path has been specified.
if RTS_Specified = null then
- RTS_Specified :=
- new String'(Switch_Chars (Ptr + 4 .. Max));
+ RTS_Specified := new String'(Switch_Chars (Ptr + 4 .. Max));
elsif
RTS_Specified.all /= Switch_Chars (Ptr + 4 .. Max)
then
- Osint.Fail
- ("--RTS cannot be specified multiple times");
+ Osint.Fail ("--RTS cannot be specified multiple times");
end if;
-- Valid --RTS switch
-- There are no other switches not starting with -gnat
else
- Bad_Switch (C);
+ Bad_Switch (Switch_Chars);
end if;
-- Case of switch starting with -gnat
Ptr := Ptr + 1;
Brief_Output := True;
+ -- Processing for B switch
+
+ when 'B' =>
+ Ptr := Ptr + 1;
+ Assume_No_Invalid_Values := True;
+
-- Processing for c switch
when 'c' =>
Ptr := Ptr + 1;
Operating_Mode := Check_Semantics;
- if Tree_Output then
- ASIS_Mode := True;
- end if;
+ -- Processing for C switch
+
+ when 'C' =>
+ Ptr := Ptr + 1;
+ CodePeer_Mode := True;
-- Processing for d switch
elsif C = '.' then
Dot := True;
+ elsif Dot then
+ Bad_Switch ("-gnatd." & Switch_Chars (Ptr .. Max));
else
- Bad_Switch (C);
+ Bad_Switch ("-gnatd" & Switch_Chars (Ptr .. Max));
end if;
end loop;
when 'D' =>
Ptr := Ptr + 1;
+ -- Scan optional integer line limit value
+
+ if Nat_Present (Switch_Chars, Max, Ptr) then
+ Scan_Nat (Switch_Chars, Max, Ptr, Sprint_Line_Limit, 'D');
+ Sprint_Line_Limit := Nat'Max (Sprint_Line_Limit, 40);
+ end if;
+
-- Note: -gnatD also sets -gnatx (to turn off cross-reference
-- generation in the ali file) since otherwise this generation
-- gets confused by the "wrong" Sloc values put in the tree.
-- so we must always have a character after the e.
if Ptr > Max then
- Bad_Switch (C);
+ Bad_Switch ("-gnate");
end if;
case Switch_Chars (Ptr) is
+ -- -gnatea (initial delimiter of explicit switches)
+
+ -- All switches that come before -gnatea have been added by
+ -- the GCC driver and are not stored in the ALI file.
+ -- See also -gnatez below.
+
+ when 'a' =>
+ Store_Switch := False;
+ Enable_Switch_Storing;
+ Ptr := Ptr + 1;
+
-- -gnatec (configuration pragmas)
when 'c' =>
end if;
if Ptr > Max then
- Bad_Switch (C);
+ Bad_Switch ("-gnatec");
end if;
declare
return;
+ -- -gnateC switch (CodePeer SCIL generation)
+
+ -- Not enabled for now, keep it for later???
+ -- use -gnatd.I only for now
+
+ -- when 'C' =>
+ -- Ptr := Ptr + 1;
+ -- Generate_SCIL := True;
+
-- -gnateD switch (preprocessing symbol definition)
when 'D' =>
Ptr := Ptr + 1;
if Ptr > Max then
- Bad_Switch (C);
+ Bad_Switch ("-gnateD");
end if;
Add_Symbol_Definition (Switch_Chars (Ptr .. Max));
Store_Switch := False;
Ptr := Ptr + 1;
Full_Path_Name_For_Brief_Errors := True;
- return;
+
+ -- -gnateG (save preprocessor output)
+
+ when 'G' =>
+ Generate_Processed_File := True;
+ Ptr := Ptr + 1;
-- -gnateI (index of unit in multi-unit source)
end if;
if Ptr > Max then
- Bad_Switch (C);
+ Bad_Switch ("-gnatem");
end if;
Mapping_File_Name :=
end if;
if Ptr > Max then
- Bad_Switch (C);
+ Bad_Switch ("-gnatep");
end if;
Preprocessing_Data_File :=
Ptr := Max + 1;
+ -- -gnatez (final delimiter of explicit switches)
+
+ -- All switches that come after -gnatez have been added by
+ -- the GCC driver and are not stored in the ALI file. See
+ -- also -gnatea above.
+
when 'z' =>
Store_Switch := False;
Disable_Switch_Storing;
Ptr := Ptr + 1;
+ -- -gnateS (generate SCO information)
+
+ -- Include Source Coverage Obligation information in ALI
+ -- files for the benefit of source coverage analysis tools
+ -- (xcov).
+
+ when 'S' =>
+ Generate_SCO := True;
+ Ptr := Ptr + 1;
+
-- All other -gnate? switches are unassigned
when others =>
- Bad_Switch (C);
+ Bad_Switch ("-gnate" & Switch_Chars (Ptr .. Max));
end case;
-- -gnatE (dynamic elaboration checks)
Ada_Version := Ada_05;
Ada_Version_Explicit := Ada_Version;
- -- Set default warnings for -gnatg (same set as -gnatwa)
-
- Check_Unreferenced := True;
- Check_Unreferenced_Formals := True;
- Check_Withs := True;
- Constant_Condition_Warnings := True;
- Implementation_Unit_Warnings := True;
- Ineffective_Inline_Warnings := True;
- Warn_On_Assumed_Low_Bound := True;
- Warn_On_Bad_Fixed_Value := True;
- Warn_On_Constant := True;
- Warn_On_Export_Import := True;
- Warn_On_Modified_Unread := True;
- Warn_On_No_Value_Assigned := True;
- Warn_On_Obsolescent_Feature := True;
- Warn_On_Redundant_Constructs := True;
- Warn_On_Unchecked_Conversion := True;
- Warn_On_Unrecognized_Pragma := True;
-
- Set_Style_Check_Options ("3aAbcdefhiklmnprstux");
+ -- Set default warnings and style checks for -gnatg
+
+ Set_GNAT_Mode_Warnings;
+ Set_GNAT_Style_Check_Options;
-- Processing for G switch
Ptr := Ptr + 1;
Print_Generated_Code := True;
+ -- Scan optional integer line limit value
+
+ if Nat_Present (Switch_Chars, Max, Ptr) then
+ Scan_Nat (Switch_Chars, Max, Ptr, Sprint_Line_Limit, 'G');
+ Sprint_Line_Limit := Nat'Max (Sprint_Line_Limit, 40);
+ end if;
+
-- Processing for h switch
when 'h' =>
when 'i' =>
if Ptr = Max then
- Bad_Switch (C);
+ Bad_Switch ("-gnati");
end if;
Ptr := Ptr + 1;
Ptr := Ptr + 1;
else
- Bad_Switch (C);
+ Bad_Switch ("-gnati" & Switch_Chars (Ptr .. Max));
end if;
- -- Processing for j switch
+ -- Processing for I switch
- when 'j' =>
+ when 'I' =>
Ptr := Ptr + 1;
+ Ignore_Rep_Clauses := True;
- -- There may be an equal sign between -gnatj and the value
-
- if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
- Ptr := Ptr + 1;
- end if;
+ -- Processing for j switch
+ when 'j' =>
+ Ptr := Ptr + 1;
Scan_Nat (Switch_Chars, Max, Ptr, Error_Msg_Line_Length, C);
-- Processing for k switch
when 'm' =>
Ptr := Ptr + 1;
-
- -- There may be an equal sign between -gnatm and the value
-
- if Ptr <= Max and then Switch_Chars (Ptr) = '=' then
- Ptr := Ptr + 1;
- end if;
-
- Scan_Nat (Switch_Chars, Max, Ptr, Maximum_Errors, C);
+ Scan_Nat (Switch_Chars, Max, Ptr, Maximum_Messages, C);
-- Processing for n switch
Ptr := Ptr + 1;
Try_Semantics := True;
- -- Processing for q switch
+ -- Processing for Q switch
when 'Q' =>
Ptr := Ptr + 1;
Force_ALI_Tree_File := True;
Try_Semantics := True;
+ -- Processing for r switch
+
+ when 'r' =>
+ Ptr := Ptr + 1;
+ Treat_Restrictions_As_Warnings := True;
+
-- Processing for R switch
when 'R' =>
List_Representation_Info_Mechanisms := True;
else
- Bad_Switch (C);
+ Bad_Switch ("-gnatR" & Switch_Chars (Ptr .. Max));
end if;
Ptr := Ptr + 1;
when 't' =>
Ptr := Ptr + 1;
Tree_Output := True;
-
- if Operating_Mode = Check_Semantics then
- ASIS_Mode := True;
- end if;
-
Back_Annotate_Rep_Info := True;
-- Processing for T switch
Ptr := Ptr + 1;
if Ptr > Max then
- Bad_Switch (C);
+ Bad_Switch ("-gnatV");
else
declare
(Switch_Chars (Ptr .. Max), OK, Ptr);
if not OK then
- Bad_Switch (C);
+ Bad_Switch ("-gnatV" & Switch_Chars (Ptr .. Max));
end if;
for Index in First_Char + 1 .. Max loop
Ptr := Ptr + 1;
if Ptr > Max then
- Bad_Switch (C);
+ Bad_Switch ("-gnatw");
end if;
while Ptr <= Max loop
if Set_Dot_Warning_Switch (C) then
Store_Compilation_Switch ("-gnatw." & C);
else
- Bad_Switch (C);
+ Bad_Switch ("-gnatw." & Switch_Chars (Ptr .. Max));
end if;
-- Normal case, no dot
if Set_Warning_Switch (C) then
Store_Compilation_Switch ("-gnatw" & C);
else
- Bad_Switch (C);
+ Bad_Switch ("-gnatw" & Switch_Chars (Ptr .. Max));
end if;
end if;
Ptr := Ptr + 1;
if Ptr > Max then
- Bad_Switch (C);
+ Bad_Switch ("-gnatW");
end if;
begin
Get_WC_Encoding_Method (Switch_Chars (Ptr));
exception
when Constraint_Error =>
- Bad_Switch (C);
+ Bad_Switch ("-gnatW" & Switch_Chars (Ptr .. Max));
end;
+ Wide_Character_Encoding_Method_Specified := True;
+
Upper_Half_Encoding :=
Wide_Character_Encoding_Method in
- WC_Upper_Half_Encoding_Method;
+ WC_Upper_Half_Encoding_Method;
Ptr := Ptr + 1;
-- Processing for z switch
when 'z' =>
+ -- -gnatz must be the first and only switch in Switch_Chars,
+ -- and is a two-letter switch.
+
+ if Ptr /= Switch_Chars'First + 5
+ or else (Max - Ptr + 1) > 2
+ then
+ Osint.Fail
+ ("-gnatz* may not be combined with other switches");
+ end if;
+
+ if Ptr = Max then
+ Bad_Switch ("-gnatz");
+ end if;
+
Ptr := Ptr + 1;
- -- Allowed for compiler only if this is the only
- -- -z switch, we do not allow multiple occurrences
+ -- Only one occurrence of -gnat* is permitted
if Distribution_Stub_Mode = No_Stubs then
case Switch_Chars (Ptr) is
Distribution_Stub_Mode := Generate_Caller_Stub_Body;
when others =>
- Bad_Switch (C);
+ Bad_Switch ("-gnatz" & Switch_Chars (Ptr .. Max));
end case;
Ptr := Ptr + 1;
+
+ else
+ Osint.Fail ("only one -gnatz* switch allowed");
end if;
-- Processing for Z switch
when '8' =>
if Ptr = Max then
- Bad_Switch (C);
+ Bad_Switch ("-gnat8");
end if;
Ptr := Ptr + 1;
if Switch_Chars (Ptr) /= '3' then
- Bad_Switch (C);
+ Bad_Switch ("-gnat8" & Switch_Chars (Ptr .. Max));
else
Ptr := Ptr + 1;
Ada_Version := Ada_83;
when '9' =>
if Ptr = Max then
- Bad_Switch (C);
+ Bad_Switch ("-gnat9");
end if;
Ptr := Ptr + 1;
if Switch_Chars (Ptr) /= '5' then
- Bad_Switch (C);
+ Bad_Switch ("-gnat9" & Switch_Chars (Ptr .. Max));
else
Ptr := Ptr + 1;
Ada_Version := Ada_95;
when '0' =>
if Ptr = Max then
- Bad_Switch (C);
+ Bad_Switch ("-gnat0");
end if;
Ptr := Ptr + 1;
if Switch_Chars (Ptr) /= '5' then
- Bad_Switch (C);
+ Bad_Switch ("-gnat0" & Switch_Chars (Ptr .. Max));
else
Ptr := Ptr + 1;
Ada_Version := Ada_05;
-- Anything else is an error (illegal switch character)
when others =>
- Bad_Switch (C);
+ Bad_Switch ("-gnat" & Switch_Chars (Ptr .. Max));
end case;
if Store_Switch then