Commit 340772c0 by Robert Dewar Committed by Arnaud Charlet

gnat1drv.adb (Gnat1drv): Test Target_Dependent_Info_Write_Name.

2013-04-12  Robert Dewar  <dewar@adacore.com>

	* gnat1drv.adb (Gnat1drv): Test Target_Dependent_Info_Write_Name.
	* opt.ads (Target_Dependent_Info_Read): Add _Name, now an access
	type (Target_Dependent_Info_Write): Add _Name, now an access type.
	* set_targ.adb (Write_Target_Dependent_Values): Use name
	from -gnatet switch stored in Target_Dependent_Info_Write_Name
	(Read_Target_Dependent_Values): Use name from -gnateT switch
	stored in Target_Dependent_Info_Read_Name.
	* switch-c.adb: New form of -gnatet and -gnateT switches.
	* usage.adb: New form of -gnatet and -gnateT switches with
	file name.

From-SVN: r197898
parent d3afd9aa
2013-04-12 Robert Dewar <dewar@adacore.com>
* gnat1drv.adb (Gnat1drv): Test Target_Dependent_Info_Write_Name.
* opt.ads (Target_Dependent_Info_Read): Add _Name, now an access
type (Target_Dependent_Info_Write): Add _Name, now an access type.
* set_targ.adb (Write_Target_Dependent_Values): Use name
from -gnatet switch stored in Target_Dependent_Info_Write_Name
(Read_Target_Dependent_Values): Use name from -gnateT switch
stored in Target_Dependent_Info_Read_Name.
* switch-c.adb: New form of -gnatet and -gnateT switches.
* usage.adb: New form of -gnatet and -gnateT switches with
file name.
2013-04-11 Eric Botcazou <ebotcazou@adacore.com> 2013-04-11 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/decl.c (elaborate_expression_1): Skip only constant * gcc-interface/decl.c (elaborate_expression_1): Skip only constant
......
...@@ -881,7 +881,7 @@ begin ...@@ -881,7 +881,7 @@ begin
-- Generate target dependent output file if requested -- Generate target dependent output file if requested
if Target_Dependent_Info_Write then if Target_Dependent_Info_Write_Name /= null then
Set_Targ.Write_Target_Dependent_Values; Set_Targ.Write_Target_Dependent_Values;
end if; end if;
......
...@@ -1331,18 +1331,19 @@ package Opt is ...@@ -1331,18 +1331,19 @@ package Opt is
-- types and dispatching calls, assuming the underlying target supports -- types and dispatching calls, assuming the underlying target supports
-- it (e.g. in the JVM case). -- it (e.g. in the JVM case).
Target_Dependent_Info_Read : Boolean := False; Target_Dependent_Info_Read_Name : String_Ptr := null;
-- GNAT -- GNAT
-- Set True to override the normal processing in Get_Targ and set the -- Set non-null to override the normal processing in Get_Targ and set the
-- necessary information by reading the target dependent information -- necessary information by reading the target dependent information file
-- file (see packages Get_Targ and Set_Targ for full details). Set True -- whose name is given here (see packages Get_Targ and Set_Targ for full
-- by use of the -gnateT switch. -- details). Set to non-null file name by use of the -gnateT switch.
Target_Dependent_Info_Write : Boolean := False; Target_Dependent_Info_Write_Name : String_Ptr := null;
-- GNAT -- GNAT
-- Set True to enable a call to Set_Targ.Write_Target_Dependent_Info which -- Set non-null to enable a call to Set_Targ.Write_Target_Dependent_Info
-- writes a target independent information file (see packages Get_Targ and -- which writes a target independent information file (see packages
-- Set_Targ for full details). Set True by use of the -gnatet switch. -- Get_Targ and Set_Targ for full details) using the name given by
-- this switch. Set to non-null file name by use of the -gnatet switch.
Task_Dispatching_Policy : Character := ' '; Task_Dispatching_Policy : Character := ' ';
-- GNAT, GNATBIND -- GNAT, GNATBIND
......
...@@ -35,12 +35,9 @@ with Unchecked_Conversion; ...@@ -35,12 +35,9 @@ with Unchecked_Conversion;
package body Set_Targ is package body Set_Targ is
--------------------------------------------- --------------------------------------------------------
-- Data Used to Read/Write target.atp File -- -- Data Used to Read/Write Target Dependent Info File --
--------------------------------------------- --------------------------------------------------------
File_Name : aliased constant String := "target.atp";
-- Name of file to read/write
-- Table of string names written to file -- Table of string names written to file
...@@ -369,8 +366,9 @@ package body Set_Targ is ...@@ -369,8 +366,9 @@ package body Set_Targ is
AddC (ASCII.LF); AddC (ASCII.LF);
if Buflen /= Write (Fdesc, Buffer'Address, Buflen) then if Buflen /= Write (Fdesc, Buffer'Address, Buflen) then
Delete_File (File_Name'Address, OK); Delete_File (Target_Dependent_Info_Write_Name'Address, OK);
Fail ("disk full writing target.atp"); Fail ("disk full writing file "
& Target_Dependent_Info_Write_Name.all);
end if; end if;
Buflen := 0; Buflen := 0;
...@@ -379,10 +377,11 @@ package body Set_Targ is ...@@ -379,10 +377,11 @@ package body Set_Targ is
-- Start of processing for Write_Target_Dependent_Values -- Start of processing for Write_Target_Dependent_Values
begin begin
Fdesc := Create_File (File_Name'Address, Text); Fdesc :=
Create_File (Target_Dependent_Info_Write_Name.all'Address, Text);
if Fdesc = Invalid_FD then if Fdesc = Invalid_FD then
Fail ("cannot create target.atp"); Fail ("cannot create file " & Target_Dependent_Info_Write_Name.all);
end if; end if;
-- Loop through values -- Loop through values
...@@ -459,7 +458,8 @@ package body Set_Targ is ...@@ -459,7 +458,8 @@ package body Set_Targ is
Close (Fdesc, OK); Close (Fdesc, OK);
if not OK then if not OK then
Fail ("disk full writing target.atp"); Fail ("disk full writing file "
& Target_Dependent_Info_Write_Name.all);
end if; end if;
end Write_Target_Dependent_Values; end Write_Target_Dependent_Values;
...@@ -471,7 +471,7 @@ begin ...@@ -471,7 +471,7 @@ begin
-- First step: see if the -gnateT switch is present. As we have noted, -- First step: see if the -gnateT switch is present. As we have noted,
-- this has to be done very early, so can not depend on the normal circuit -- this has to be done very early, so can not depend on the normal circuit
-- for reading switches and setting switches in Opt. The following code -- for reading switches and setting switches in Opt. The following code
-- will set Opt.Target_Dependent_Info_Read if an option starting -gnateT -- will set Opt.Target_Dependent_Info_Read_Name if the switch -gnateT=name
-- is present in the options string. -- is present in the options string.
declare declare
...@@ -513,11 +513,14 @@ begin ...@@ -513,11 +513,14 @@ begin
declare declare
Argv_Ptr : constant Big_String_Ptr := save_argv (Arg); Argv_Ptr : constant Big_String_Ptr := save_argv (Arg);
Argv_Len : constant Nat := Len_Arg (Arg); Argv_Len : constant Nat := Len_Arg (Arg);
begin begin
if Argv_Len = 7 if Argv_Len > 8
and then Argv_Ptr (1 .. 7) = "-gnateT" and then Argv_Ptr (1 .. 8) = "-gnateT="
then then
Opt.Target_Dependent_Info_Read := True; Opt.Target_Dependent_Info_Read_Name :=
new String'(Argv_Ptr (9 .. Natural (Argv_Len)));
elsif Argv_Len >= 8 elsif Argv_Len >= 8
and then Argv_Ptr (1 .. 8) = "-gnatd.b" and then Argv_Ptr (1 .. 8) = "-gnatd.b"
then then
...@@ -529,7 +532,7 @@ begin ...@@ -529,7 +532,7 @@ begin
-- If the switch is not set, we get all values from the back end -- If the switch is not set, we get all values from the back end
if not Opt.Target_Dependent_Info_Read then if Opt.Target_Dependent_Info_Read_Name = null then
-- Set values by direct calls to the back end -- Set values by direct calls to the back end
...@@ -560,7 +563,7 @@ begin ...@@ -560,7 +563,7 @@ begin
Register_Back_End_Types (Register_Float_Type'Access); Register_Back_End_Types (Register_Float_Type'Access);
-- Case of reading the target dependent values from target.atp -- Case of reading the target dependent values from file
-- This is bit more complex than might be expected, because it has to be -- This is bit more complex than might be expected, because it has to be
-- done very early. All kinds of packages depend on these values, and we -- done very early. All kinds of packages depend on these values, and we
...@@ -569,7 +572,7 @@ begin ...@@ -569,7 +572,7 @@ begin
-- too early to be using Osint directly. -- too early to be using Osint directly.
else else
Read_File : declare Read_Target_Dependent_Values : declare
File_Desc : File_Descriptor; File_Desc : File_Descriptor;
N : Natural; N : Natural;
...@@ -592,9 +595,9 @@ begin ...@@ -592,9 +595,9 @@ begin
-- Checks that we have one or more spaces and skips them -- Checks that we have one or more spaces and skips them
procedure FailN (S : String); procedure FailN (S : String);
-- Calls Fail prefixing "target.atp: " to the start of the given -- Calls Fail adding " name in file xxx", where name is the currently
-- string, and " name" to the end where name is the currently -- gathered name in Nam_Buf, surrounded by quotes, and xxx is the
-- gathered name in Nam_Buf, surrounded by quotes. -- name of the file.
procedure Get_Name; procedure Get_Name;
-- Scan out name, leaving it in Nam_Buf with Nam_Len set. Calls -- Scan out name, leaving it in Nam_Buf with Nam_Len set. Calls
...@@ -628,7 +631,8 @@ begin ...@@ -628,7 +631,8 @@ begin
procedure FailN (S : String) is procedure FailN (S : String) is
begin begin
Fail ("target.atp: " & S & " """ & Nam_Buf (1 .. Nam_Len) & '"'); Fail (S & " """ & Nam_Buf (1 .. Nam_Len) & """ in file "
& Target_Dependent_Info_Read_Name.all);
end FailN; end FailN;
-------------- --------------
...@@ -700,19 +704,19 @@ begin ...@@ -700,19 +704,19 @@ begin
end loop; end loop;
end Skip_Spaces; end Skip_Spaces;
-- Start of processing for Read_File -- Start of processing for Read_Target_Dependent_Values
begin begin
File_Desc := Open_Read ("target.atp", Text); File_Desc := Open_Read (Target_Dependent_Info_Read_Name.all, Text);
if File_Desc = Invalid_FD then if File_Desc = Invalid_FD then
Fail ("cannot read target.atp file"); Fail ("cannot read file " & Target_Dependent_Info_Read_Name.all);
end if; end if;
Buflen := Read (File_Desc, Buffer'Address, Buffer'Length); Buflen := Read (File_Desc, Buffer'Address, Buffer'Length);
if Buflen = Buffer'Length then if Buflen = Buffer'Length then
Fail ("target.atp file is too long"); Fail ("file is too long: " & Target_Dependent_Info_Read_Name.all);
end if; end if;
-- Scan through file for properly formatted entries in first section -- Scan through file for properly formatted entries in first section
...@@ -753,20 +757,23 @@ begin ...@@ -753,20 +757,23 @@ begin
for J in DTR'Range loop for J in DTR'Range loop
if not DTR (J) then if not DTR (J) then
Fail ("missing entry in target.atp for " & DTN (J).all); Fail ("missing entry for " & DTN (J).all & " in file "
& Target_Dependent_Info_Read_Name.all);
end if; end if;
end loop; end loop;
-- Now acquire FPT entries -- Now acquire FPT entries
if N >= Buflen then if N >= Buflen then
Fail ("target.atp is missing entries for FPT modes"); Fail ("missing entries for FPT modes in file "
& Target_Dependent_Info_Read_Name.all);
end if; end if;
if Buffer (N) = ASCII.LF then if Buffer (N) = ASCII.LF then
N := N + 1; N := N + 1;
else else
Fail ("target.atp is missing blank line"); Fail ("missing blank line in file "
& Target_Dependent_Info_Read_Name.all);
end if; end if;
Num_FPT_Modes := 0; Num_FPT_Modes := 0;
...@@ -810,6 +817,6 @@ begin ...@@ -810,6 +817,6 @@ begin
N := N + 1; N := N + 1;
end; end;
end loop; end loop;
end Read_File; end Read_Target_Dependent_Values;
end if; end if;
end Set_Targ; end Set_Targ;
...@@ -597,7 +597,6 @@ package body Switch.C is ...@@ -597,7 +597,6 @@ package body Switch.C is
if Ptr >= Max or else Switch_Chars (Ptr) /= '=' then if Ptr >= Max or else Switch_Chars (Ptr) /= '=' then
Bad_Switch ("-gnateO"); Bad_Switch ("-gnateO");
else else
Object_Path_File_Name := Object_Path_File_Name :=
new String'(Switch_Chars (Ptr + 1 .. Max)); new String'(Switch_Chars (Ptr + 1 .. Max));
...@@ -651,9 +650,25 @@ package body Switch.C is ...@@ -651,9 +650,25 @@ package body Switch.C is
-- -gnatet (write target dependent information) -- -gnatet (write target dependent information)
when 't' => when 't' =>
Target_Dependent_Info_Write := True; if not First_Switch then
Osint.Fail
("-gnatet must be first if combined with "
& "other switches");
end if;
-- Check for '='
Ptr := Ptr + 1; Ptr := Ptr + 1;
if Ptr >= Max or else Switch_Chars (Ptr) /= '=' then
Bad_Switch ("-gnatet");
else
Target_Dependent_Info_Write_Name :=
new String'(Switch_Chars (Ptr + 1 .. Max));
end if;
return;
-- -gnateT (read target dependent information) -- -gnateT (read target dependent information)
when 'T' => when 'T' =>
...@@ -663,9 +678,23 @@ package body Switch.C is ...@@ -663,9 +678,23 @@ package body Switch.C is
& "other switches"); & "other switches");
end if; end if;
Target_Dependent_Info_Read := True; -- Check for '='
Ptr := Ptr + 1; Ptr := Ptr + 1;
if Ptr >= Max or else Switch_Chars (Ptr) /= '=' then
Bad_Switch ("-gnateT");
else
-- This parameter was stored by Set_Targ earlier
pragma Assert
(Target_Dependent_Info_Read_Name.all =
Switch_Chars (Ptr + 1 .. Max));
null;
end if;
return;
-- -gnateV (validity checks on parameters) -- -gnateV (validity checks on parameters)
when 'V' => when 'V' =>
......
...@@ -243,13 +243,13 @@ begin ...@@ -243,13 +243,13 @@ begin
-- Line for -gnatet switch -- Line for -gnatet switch
Write_Switch_Char ("et"); Write_Switch_Char ("et=?");
Write_Line ("Write target dependent information file"); Write_Line ("Write target dependent information file ?, e.g. gnatet=tdf");
-- Line for -gnateT switch -- Line for -gnateT switch
Write_Switch_Char ("eT"); Write_Switch_Char ("eT=?");
Write_Line ("Read target dependent information file"); Write_Line ("Read target dependent information file ?, e.g. gnateT=tdf");
-- Line for -gnateV switch -- Line for -gnateV switch
......
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