Commit 67e740fa by Vincent Celier Committed by Arnaud Charlet

back_end.adb (Scan_Compiler_Arguments): Put all arguments in new local Argument_List variable Args.

2010-06-17  Vincent Celier  <celier@adacore.com>

	* back_end.adb (Scan_Compiler_Arguments): Put all arguments in new
	local Argument_List variable Args.
	* switch-c.adb (Scan_Front_End_Switches): New Argument_List argument
	Args.
	(Switch_Subsequently_Cancelled): New Argument_List argument Args. Look
	for subsequent switches in Args.
	* switch-c.ads (Scan_Front_End_Switches): New Argument_List argument
	Args.
	* gcc-interface/Make-lang.in: Update dependencies.

From-SVN: r160890
parent bce79204
2010-06-17 Vincent Celier <celier@adacore.com>
* back_end.adb (Scan_Compiler_Arguments): Put all arguments in new
local Argument_List variable Args.
* switch-c.adb (Scan_Front_End_Switches): New Argument_List argument
Args.
(Switch_Subsequently_Cancelled): New Argument_List argument Args. Look
for subsequent switches in Args.
* switch-c.ads (Scan_Front_End_Switches): New Argument_List argument
Args.
* gcc-interface/Make-lang.in: Update dependencies.
2010-06-17 Robert Dewar <dewar@adacore.com> 2010-06-17 Robert Dewar <dewar@adacore.com>
* einfo.adb: Minor code fix, allow E_Class_Wide_Type for * einfo.adb: Minor code fix, allow E_Class_Wide_Type for
......
...@@ -40,6 +40,8 @@ with Switch.C; use Switch.C; ...@@ -40,6 +40,8 @@ with Switch.C; use Switch.C;
with System; use System; with System; use System;
with Types; use Types; with Types; use Types;
with System.OS_Lib; use System.OS_Lib;
package body Back_End is package body Back_End is
type Arg_Array is array (Nat) of Big_String_Ptr; type Arg_Array is array (Nat) of Big_String_Ptr;
...@@ -162,7 +164,7 @@ package body Back_End is ...@@ -162,7 +164,7 @@ package body Back_End is
procedure Scan_Compiler_Arguments is procedure Scan_Compiler_Arguments is
Next_Arg : Pos; Next_Arg : Positive;
-- Next argument to be scanned -- Next argument to be scanned
Output_File_Name_Seen : Boolean := False; Output_File_Name_Seen : Boolean := False;
...@@ -222,6 +224,11 @@ package body Back_End is ...@@ -222,6 +224,11 @@ package body Back_End is
end if; end if;
end Scan_Back_End_Switches; end Scan_Back_End_Switches;
-- Local variables
Arg_Count : constant Natural := Natural (save_argc - 1);
Args : Argument_List (1 .. Arg_Count);
-- Start of processing for Scan_Compiler_Arguments -- Start of processing for Scan_Compiler_Arguments
begin begin
...@@ -229,15 +236,26 @@ package body Back_End is ...@@ -229,15 +236,26 @@ package body Back_End is
Opt.Stack_Checking_Enabled := (flag_stack_check /= 0); Opt.Stack_Checking_Enabled := (flag_stack_check /= 0);
-- Put the arguments in Args
for Arg in Pos range 1 .. save_argc - 1 loop
declare
Argv_Ptr : constant Big_String_Ptr := save_argv (Arg);
Argv_Len : constant Nat := Len_Arg (Arg);
Argv : constant String :=
Argv_Ptr (1 .. Natural (Argv_Len));
begin
Args (Positive (Arg)) := new String'(Argv);
end;
end loop;
-- Loop through command line arguments, storing them for later access -- Loop through command line arguments, storing them for later access
Next_Arg := 1; Next_Arg := 1;
while Next_Arg < save_argc loop while Next_Arg < Args'Last loop
Look_At_Arg : declare Look_At_Arg : declare
Argv_Ptr : constant Big_String_Ptr := save_argv (Next_Arg); Argv : constant String := Args (Next_Arg).all;
Argv_Len : constant Nat := Len_Arg (Next_Arg);
Argv : constant String :=
Argv_Ptr (1 .. Natural (Argv_Len));
begin begin
-- If the previous switch has set the Output_File_Name_Present -- If the previous switch has set the Output_File_Name_Present
...@@ -284,7 +302,7 @@ package body Back_End is ...@@ -284,7 +302,7 @@ package body Back_End is
Opt.No_Stdlib := True; Opt.No_Stdlib := True;
elsif Is_Front_End_Switch (Argv) then elsif Is_Front_End_Switch (Argv) then
Scan_Front_End_Switches (Argv, Integer (Next_Arg)); Scan_Front_End_Switches (Argv, Args, Next_Arg);
-- All non-front-end switches are back-end switches -- All non-front-end switches are back-end switches
......
...@@ -120,7 +120,6 @@ GNAT1_C_OBJS = ada/b_gnat1.o ada/adadecode.o ada/adaint.o ada/cstreams.o \ ...@@ -120,7 +120,6 @@ GNAT1_C_OBJS = ada/b_gnat1.o ada/adadecode.o ada/adaint.o ada/cstreams.o \
GNAT_ADA_OBJS = \ GNAT_ADA_OBJS = \
ada/a-charac.o \ ada/a-charac.o \
ada/a-chlat1.o \ ada/a-chlat1.o \
ada/a-comlin.o \
ada/a-elchha.o \ ada/a-elchha.o \
ada/a-except.o \ ada/a-except.o \
ada/a-ioexce.o \ ada/a-ioexce.o \
...@@ -2913,16 +2912,10 @@ ada/prepcomp.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ...@@ -2913,16 +2912,10 @@ ada/prepcomp.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \
ada/table.adb ada/tree_io.ads ada/types.ads ada/uintp.ads \ ada/table.adb ada/tree_io.ads ada/types.ads ada/uintp.ads \
ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads ada/widechar.ads ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads ada/widechar.ads
ada/put_scos.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ada/put_scos.o : ada/ada.ads ada/a-unccon.ads ada/gnat.ads ada/g-table.ads \
ada/a-uncdea.ads ada/alloc.ads ada/atree.ads ada/debug.ads \ ada/g-table.adb ada/put_scos.ads ada/put_scos.adb ada/scos.ads \
ada/einfo.ads ada/gnat.ads ada/g-table.ads ada/g-table.adb \ ada/system.ads ada/s-exctab.ads ada/s-memory.ads ada/s-stalib.ads \
ada/hostparm.ads ada/namet.ads ada/opt.ads ada/output.ads \ ada/s-unstyp.ads ada/types.ads ada/unchconv.ads ada/unchdeal.ads
ada/put_scos.ads ada/put_scos.adb ada/scos.ads ada/sinfo.ads \
ada/snames.ads ada/system.ads ada/s-exctab.ads ada/s-memory.ads \
ada/s-os_lib.ads ada/s-parame.ads ada/s-stalib.ads ada/s-string.ads \
ada/s-traent.ads ada/s-unstyp.ads ada/s-wchcon.ads ada/table.ads \
ada/table.adb ada/tree_io.ads ada/types.ads ada/uintp.ads \
ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads
ada/repinfo.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ada/repinfo.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \
ada/a-uncdea.ads ada/alloc.ads ada/atree.ads ada/atree.adb \ ada/a-uncdea.ads ada/alloc.ads ada/atree.ads ada/atree.adb \
...@@ -3851,30 +3844,30 @@ ada/sem_prag.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ...@@ -3851,30 +3844,30 @@ ada/sem_prag.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \
ada/lib.ads ada/lib.adb ada/lib-list.adb ada/lib-sort.adb \ ada/lib.ads ada/lib.adb ada/lib-list.adb ada/lib-sort.adb \
ada/lib-writ.ads ada/lib-xref.ads ada/namet.ads ada/namet.adb \ ada/lib-writ.ads ada/lib-xref.ads ada/namet.ads ada/namet.adb \
ada/namet-sp.ads ada/nlists.ads ada/nlists.adb ada/nmake.ads \ ada/namet-sp.ads ada/nlists.ads ada/nlists.adb ada/nmake.ads \
ada/nmake.adb ada/opt.ads ada/output.ads ada/restrict.ads \ ada/nmake.adb ada/opt.ads ada/output.ads ada/par_sco.ads \
ada/restrict.adb ada/rident.ads ada/rtsfind.ads ada/scans.ads \ ada/restrict.ads ada/restrict.adb ada/rident.ads ada/rtsfind.ads \
ada/scn.ads ada/scng.ads ada/scng.adb ada/sem.ads ada/sem_aggr.ads \ ada/scans.ads ada/scn.ads ada/scng.ads ada/scng.adb ada/sem.ads \
ada/sem_attr.ads ada/sem_aux.ads ada/sem_cat.ads ada/sem_ch12.ads \ ada/sem_aggr.ads ada/sem_attr.ads ada/sem_aux.ads ada/sem_cat.ads \
ada/sem_ch13.ads ada/sem_ch3.ads ada/sem_ch4.ads ada/sem_ch6.ads \ ada/sem_ch12.ads ada/sem_ch13.ads ada/sem_ch3.ads ada/sem_ch4.ads \
ada/sem_ch8.ads ada/sem_disp.ads ada/sem_dist.ads ada/sem_elab.ads \ ada/sem_ch6.ads ada/sem_ch8.ads ada/sem_disp.ads ada/sem_dist.ads \
ada/sem_elim.ads ada/sem_eval.ads ada/sem_eval.adb ada/sem_intr.ads \ ada/sem_elab.ads ada/sem_elim.ads ada/sem_eval.ads ada/sem_eval.adb \
ada/sem_mech.ads ada/sem_prag.ads ada/sem_prag.adb ada/sem_res.ads \ ada/sem_intr.ads ada/sem_mech.ads ada/sem_prag.ads ada/sem_prag.adb \
ada/sem_res.adb ada/sem_scil.ads ada/sem_type.ads ada/sem_util.ads \ ada/sem_res.ads ada/sem_res.adb ada/sem_scil.ads ada/sem_type.ads \
ada/sem_util.adb ada/sem_vfpt.ads ada/sem_warn.ads ada/sinfo.ads \ ada/sem_util.ads ada/sem_util.adb ada/sem_vfpt.ads ada/sem_warn.ads \
ada/sinfo.adb ada/sinfo-cn.ads ada/sinput.ads ada/sinput.adb \ ada/sinfo.ads ada/sinfo.adb ada/sinfo-cn.ads ada/sinput.ads \
ada/snames.ads ada/snames.adb ada/stand.ads ada/stringt.ads \ ada/sinput.adb ada/snames.ads ada/snames.adb ada/stand.ads \
ada/stringt.adb ada/style.ads ada/styleg.ads ada/styleg.adb \ ada/stringt.ads ada/stringt.adb ada/style.ads ada/styleg.ads \
ada/stylesw.ads ada/system.ads ada/s-carun8.ads ada/s-crc32.ads \ ada/styleg.adb ada/stylesw.ads ada/system.ads ada/s-carun8.ads \
ada/s-exctab.ads ada/s-exctab.adb ada/s-htable.ads ada/s-imenne.ads \ ada/s-crc32.ads ada/s-exctab.ads ada/s-exctab.adb ada/s-htable.ads \
ada/s-memory.ads ada/s-os_lib.ads ada/s-parame.ads ada/s-rident.ads \ ada/s-imenne.ads ada/s-memory.ads ada/s-os_lib.ads ada/s-parame.ads \
ada/s-secsta.ads ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads \ ada/s-rident.ads ada/s-secsta.ads ada/s-soflin.ads ada/s-stache.ads \
ada/s-stoele.ads ada/s-stoele.adb ada/s-string.ads ada/s-traent.ads \ ada/s-stalib.ads ada/s-stoele.ads ada/s-stoele.adb ada/s-string.ads \
ada/s-unstyp.ads ada/s-utf_32.ads ada/s-wchcon.ads ada/table.ads \ ada/s-traent.ads ada/s-unstyp.ads ada/s-utf_32.ads ada/s-wchcon.ads \
ada/table.adb ada/targparm.ads ada/tbuild.ads ada/tbuild.adb \ ada/table.ads ada/table.adb ada/targparm.ads ada/tbuild.ads \
ada/tree_io.ads ada/ttypes.ads ada/types.ads ada/types.adb \ ada/tbuild.adb ada/tree_io.ads ada/ttypes.ads ada/types.ads \
ada/uintp.ads ada/uintp.adb ada/uname.ads ada/unchconv.ads \ ada/types.adb ada/uintp.ads ada/uintp.adb ada/uname.ads \
ada/unchdeal.ads ada/urealp.ads ada/urealp.adb ada/validsw.ads \ ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads ada/urealp.adb \
ada/widechar.ads ada/validsw.ads ada/widechar.ads
ada/sem_res.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ada/sem_res.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \
ada/a-uncdea.ads ada/alloc.ads ada/atree.ads ada/atree.adb \ ada/a-uncdea.ads ada/alloc.ads ada/atree.ads ada/atree.adb \
...@@ -4200,17 +4193,17 @@ ada/switch-b.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ...@@ -4200,17 +4193,17 @@ ada/switch-b.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \
ada/s-wchcon.ads ada/table.ads ada/table.adb ada/tree_io.ads \ ada/s-wchcon.ads ada/table.ads ada/table.adb ada/tree_io.ads \
ada/types.ads ada/unchconv.ads ada/unchdeal.ads ada/types.ads ada/unchconv.ads ada/unchdeal.ads
ada/switch-c.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ada/switch-c.o : ada/ada.ads ada/a-comlin.ads ada/a-except.ads \
ada/a-uncdea.ads ada/alloc.ads ada/back_end.ads ada/debug.ads \ ada/a-unccon.ads ada/a-uncdea.ads ada/alloc.ads ada/debug.ads \
ada/gnatvsn.ads ada/hostparm.ads ada/lib.ads ada/namet.ads ada/opt.ads \ ada/gnatvsn.ads ada/hostparm.ads ada/lib.ads ada/namet.ads ada/opt.ads \
ada/osint.ads ada/output.ads ada/prepcomp.ads ada/sem_warn.ads \ ada/osint.ads ada/output.ads ada/prepcomp.ads ada/sem_warn.ads \
ada/stylesw.ads ada/switch.ads ada/switch-c.ads ada/switch-c.adb \ ada/stylesw.ads ada/switch.ads ada/switch-c.ads ada/switch-c.adb \
ada/system.ads ada/s-exctab.ads ada/s-memory.ads ada/s-os_lib.ads \ ada/system.ads ada/s-exctab.ads ada/s-memory.ads ada/s-os_lib.ads \
ada/s-parame.ads ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads \ ada/s-parame.ads ada/s-secsta.ads ada/s-soflin.ads ada/s-stache.ads \
ada/s-stoele.ads ada/s-stoele.adb ada/s-string.ads ada/s-traent.ads \ ada/s-stalib.ads ada/s-stoele.ads ada/s-stoele.adb ada/s-string.ads \
ada/s-unstyp.ads ada/s-wchcon.ads ada/table.ads ada/table.adb \ ada/s-traent.ads ada/s-unstyp.ads ada/s-wchcon.ads ada/table.ads \
ada/tree_io.ads ada/types.ads ada/unchconv.ads ada/unchdeal.ads \ ada/table.adb ada/tree_io.ads ada/types.ads ada/unchconv.ads \
ada/validsw.ads ada/unchdeal.ads ada/validsw.ads
ada/switch.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ada/switch.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \
ada/a-uncdea.ads ada/alloc.ads ada/debug.ads ada/gnatvsn.ads \ ada/a-uncdea.ads ada/alloc.ads ada/debug.ads ada/gnatvsn.ads \
......
...@@ -32,9 +32,7 @@ with Validsw; use Validsw; ...@@ -32,9 +32,7 @@ with Validsw; use Validsw;
with Sem_Warn; use Sem_Warn; with Sem_Warn; use Sem_Warn;
with Stylesw; use Stylesw; with Stylesw; use Stylesw;
with Ada.Command_Line; use Ada.Command_Line; with System.Strings;
with System.OS_Lib; use System.OS_Lib;
with System.WCh_Con; use System.WCh_Con; with System.WCh_Con; use System.WCh_Con;
package body Switch.C is package body Switch.C is
...@@ -44,6 +42,7 @@ package body Switch.C is ...@@ -44,6 +42,7 @@ package body Switch.C is
function Switch_Subsequently_Cancelled function Switch_Subsequently_Cancelled
(C : String; (C : String;
Args : Argument_List;
Arg_Rank : Positive) return Boolean; Arg_Rank : Positive) return Boolean;
-- This function is called from Scan_Front_End_Switches. It determines if -- This function is called from Scan_Front_End_Switches. It determines if
-- the switch currently being scanned is followed by a switch of the form -- the switch currently being scanned is followed by a switch of the form
...@@ -57,6 +56,7 @@ package body Switch.C is ...@@ -57,6 +56,7 @@ package body Switch.C is
procedure Scan_Front_End_Switches procedure Scan_Front_End_Switches
(Switch_Chars : String; (Switch_Chars : String;
Args : Argument_List;
Arg_Rank : Positive) Arg_Rank : Positive)
is is
First_Switch : Boolean := True; First_Switch : Boolean := True;
...@@ -677,7 +677,7 @@ package body Switch.C is ...@@ -677,7 +677,7 @@ package body Switch.C is
-- Skip processing if cancelled by subsequent -gnat-p -- Skip processing if cancelled by subsequent -gnat-p
if Switch_Subsequently_Cancelled ("p", Arg_Rank) then if Switch_Subsequently_Cancelled ("p", Args, Arg_Rank) then
Store_Switch := False; Store_Switch := False;
else else
...@@ -1096,25 +1096,17 @@ package body Switch.C is ...@@ -1096,25 +1096,17 @@ package body Switch.C is
function Switch_Subsequently_Cancelled function Switch_Subsequently_Cancelled
(C : String; (C : String;
Args : Argument_List;
Arg_Rank : Positive) return Boolean Arg_Rank : Positive) return Boolean
is is
Arg : Positive; use type System.Strings.String_Access;
Max : constant Natural := Argument_Count;
begin begin
-- Loop through arguments following the current one -- Loop through arguments following the current one
Arg := Arg_Rank + 1; for Arg in Arg_Rank + 1 .. Args'Last loop
while Arg < Max loop if Args (Arg).all = "-gnat-" & C then
declare return True;
Argv : constant String := Argument (Arg); end if;
begin
if Argv = "-gnat-" & C then
return True;
end if;
end;
Arg := Arg + 1;
end loop; end loop;
-- No match found, not cancelled -- No match found, not cancelled
......
...@@ -29,10 +29,13 @@ ...@@ -29,10 +29,13 @@
-- switches that are recognized. In addition, package Debug documents -- switches that are recognized. In addition, package Debug documents
-- the otherwise undocumented debug switches that are also recognized. -- the otherwise undocumented debug switches that are also recognized.
with System.OS_Lib; use System.OS_Lib;
package Switch.C is package Switch.C is
procedure Scan_Front_End_Switches procedure Scan_Front_End_Switches
(Switch_Chars : String; (Switch_Chars : String;
Args : Argument_List;
Arg_Rank : Positive); Arg_Rank : Positive);
-- Procedures to scan out front end switches stored in the given string. -- Procedures to scan out front end switches stored in the given string.
-- The first character is known to be a valid switch character, and there -- The first character is known to be a valid switch character, and there
...@@ -42,8 +45,8 @@ package Switch.C is ...@@ -42,8 +45,8 @@ package Switch.C is
-- a fatal error exit and control does not return. The call also sets -- a fatal error exit and control does not return. The call also sets
-- Usage_Requested to True if a switch -gnath is encountered. -- Usage_Requested to True if a switch -gnath is encountered.
-- --
-- Arg_Rank is the position of the switch in the command line arguments. -- Args is the full list of command line arguments. Arg_Rank is the
-- It is used for certain switches -gnatx to check if a subsequent switch -- position of the switch in Args. It is used for certain switches -gnatx
-- -gnat-x cancels the switch -gnatx. -- to check if a subsequent switch -gnat-x cancels the switch -gnatx.
end Switch.C; end Switch.C;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment