Commit 2b9fbec9 by Arnaud Charlet

[multiple changes]

2014-08-01  Robert Dewar  <dewar@adacore.com>

	* sem_case.adb (Dup_Choice): Improve message for integer constants.

2014-08-01  Arnaud Charlet  <charlet@adacore.com>

	* gnatlink.adb: Remove special handling of VMS, RTX and JVM.

2014-08-01  Pascal Obry  <obry@adacore.com>

	* adaint.h (GNAT_OPEN): Defines as open64 where supported.
	* adaint.c (GNAT_OPEN): Uses new macro where needed.

From-SVN: r213410
parent 0494285a
2014-08-01 Robert Dewar <dewar@adacore.com>
* sem_case.adb (Dup_Choice): Improve message for integer constants.
2014-08-01 Arnaud Charlet <charlet@adacore.com>
* gnatlink.adb: Remove special handling of VMS, RTX and JVM.
2014-08-01 Pascal Obry <obry@adacore.com>
* adaint.h (GNAT_OPEN): Defines as open64 where supported.
* adaint.c (GNAT_OPEN): Uses new macro where needed.
2014-07-31 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/utils.c (lookup_and_insert_pad_type): New function
......
......@@ -1007,7 +1007,7 @@ __gnat_open_read (char *path, int fmode)
fd = _topen (wpath, O_RDONLY | o_fmode, 0444);
}
#else
fd = open (path, O_RDONLY | o_fmode);
fd = GNAT_OPEN (path, O_RDONLY | o_fmode);
#endif
return fd < 0 ? -1 : fd;
......@@ -1048,7 +1048,7 @@ __gnat_open_rw (char *path, int fmode)
fd = _topen (wpath, O_RDWR | o_fmode, PERM);
}
#else
fd = open (path, O_RDWR | o_fmode, PERM);
fd = GNAT_OPEN (path, O_RDWR | o_fmode, PERM);
#endif
return fd < 0 ? -1 : fd;
......@@ -1074,7 +1074,7 @@ __gnat_open_create (char *path, int fmode)
fd = _topen (wpath, O_WRONLY | O_CREAT | O_TRUNC | o_fmode, PERM);
}
#else
fd = open (path, O_WRONLY | O_CREAT | O_TRUNC | o_fmode, PERM);
fd = GNAT_OPEN (path, O_WRONLY | O_CREAT | O_TRUNC | o_fmode, PERM);
#endif
return fd < 0 ? -1 : fd;
......@@ -1096,7 +1096,7 @@ __gnat_create_output_file (char *path)
fd = _topen (wpath, O_WRONLY | O_CREAT | O_TRUNC | O_TEXT, PERM);
}
#else
fd = open (path, O_WRONLY | O_CREAT | O_TRUNC | O_TEXT, PERM);
fd = GNAT_OPEN (path, O_WRONLY | O_CREAT | O_TRUNC | O_TEXT, PERM);
#endif
return fd < 0 ? -1 : fd;
......@@ -1118,7 +1118,7 @@ __gnat_create_output_file_new (char *path)
fd = _topen (wpath, O_WRONLY | O_CREAT | O_TRUNC | O_TEXT | O_EXCL, PERM);
}
#else
fd = open (path, O_WRONLY | O_CREAT | O_TRUNC | O_TEXT | O_EXCL, PERM);
fd = GNAT_OPEN (path, O_WRONLY | O_CREAT | O_TRUNC | O_TEXT | O_EXCL, PERM);
#endif
return fd < 0 ? -1 : fd;
......@@ -1144,7 +1144,7 @@ __gnat_open_append (char *path, int fmode)
fd = _topen (wpath, O_WRONLY | O_CREAT | O_APPEND | o_fmode, PERM);
}
#else
fd = open (path, O_WRONLY | O_CREAT | O_APPEND | o_fmode, PERM);
fd = GNAT_OPEN (path, O_WRONLY | O_CREAT | O_APPEND | o_fmode, PERM);
#endif
return fd < 0 ? -1 : fd;
......@@ -1172,7 +1172,7 @@ __gnat_open_new (char *path, int fmode)
fd = _topen (wpath, O_WRONLY | O_CREAT | O_EXCL | o_fmode, PERM);
}
#else
fd = open (path, O_WRONLY | O_CREAT | O_EXCL | o_fmode, PERM);
fd = GNAT_OPEN (path, O_WRONLY | O_CREAT | O_EXCL | o_fmode, PERM);
#endif
return fd < 0 ? -1 : fd;
......@@ -1213,7 +1213,7 @@ __gnat_open_new_temp (char *path, int fmode)
fmode ? "rfm=stmlf" : "rfm=udf", "ctx=rec", "rat=none",
"shr=del,get,put,upd", "mbc=16", "deq=64", "fop=tef");
#else
fd = open (path, O_WRONLY | O_CREAT | O_EXCL | o_fmode, PERM);
fd = GNAT_OPEN (path, O_WRONLY | O_CREAT | O_EXCL | o_fmode, PERM);
#endif
return fd < 0 ? -1 : fd;
......
......@@ -53,12 +53,14 @@ extern "C" {
#if defined (__GLIBC__) || defined (sun)
#define GNAT_FOPEN fopen64
#define GNAT_OPEN open64
#define GNAT_STAT stat64
#define GNAT_FSTAT fstat64
#define GNAT_LSTAT lstat64
#define GNAT_STRUCT_STAT struct stat64
#else
#define GNAT_FOPEN fopen
#define GNAT_OPEN open
#define GNAT_STAT stat
#define GNAT_FSTAT fstat
#define GNAT_LSTAT lstat
......
......@@ -28,7 +28,6 @@
with ALI; use ALI;
with Csets;
with Gnatvsn; use Gnatvsn;
with Hostparm;
with Indepsw; use Indepsw;
with Namet; use Namet;
with Opt;
......@@ -228,12 +227,6 @@ procedure Gnatlink is
procedure Process_Binder_File (Name : String);
-- Reads the binder file and extracts linker arguments
function To_Lower (A : Character) return Character;
-- Fold a character to lower case;
procedure To_Lower (A : in out String);
-- Fold a string to lower case;
procedure Usage;
-- Display usage
......@@ -794,10 +787,6 @@ procedure Gnatlink is
function Index (S, Pattern : String) return Natural;
-- Return the last occurrence of Pattern in S, or 0 if none
function Is_Option_Present (Opt : String) return Boolean;
-- Return true if the option Opt is already present in
-- Linker_Options table.
procedure Store_File_Context;
-- Store current file context, Fd position and current line data.
-- The file context is stored into the rollback data above (RB_*).
......@@ -856,23 +845,6 @@ procedure Gnatlink is
return 0;
end Index;
-----------------------
-- Is_Option_Present --
-----------------------
function Is_Option_Present (Opt : String) return Boolean is
begin
for I in 1 .. Linker_Options.Last loop
if Linker_Options.Table (I).all = Opt then
return True;
end if;
end loop;
return False;
end Is_Option_Present;
---------------------------
-- Rollback_File_Context --
---------------------------
......@@ -1098,13 +1070,7 @@ procedure Gnatlink is
-- Add binder options only if not already set on the command line.
-- This rule is a way to control the linker options order.
-- The following test needs comments, why is it VMS specific.
-- The above comment looks out of date ???
elsif not
(OpenVMS_On_Target
and then Is_Option_Present (Next_Line (Nfirst .. Nlast)))
then
else
if Nlast > Nfirst + 2 and then
Next_Line (Nfirst .. Nfirst + 1) = "-L"
then
......@@ -1126,8 +1092,7 @@ procedure Gnatlink is
Linker_Options.Table (Linker_Options.Last) :=
new String'(Next_Line (Nfirst .. Nlast));
elsif Next_Line (Nfirst .. Nlast) = "-ldecgnat"
or else Next_Line (Nfirst .. Nlast) = "-lgnarl"
elsif Next_Line (Nfirst .. Nlast) = "-lgnarl"
or else Next_Line (Nfirst .. Nlast) = "-lgnat"
or else
Next_Line
......@@ -1417,31 +1382,6 @@ procedure Gnatlink is
Status := fclose (Fd);
end Process_Binder_File;
--------------
-- To_Lower --
--------------
function To_Lower (A : Character) return Character is
A_Val : constant Natural := Character'Pos (A);
begin
if A in 'A' .. 'Z'
or else A_Val in 16#C0# .. 16#D6#
or else A_Val in 16#D8# .. 16#DE#
then
return Character'Val (A_Val + 16#20#);
else
return A;
end if;
end To_Lower;
procedure To_Lower (A : in out String) is
begin
for J in A'Range loop
A (J) := To_Lower (A (J));
end loop;
end To_Lower;
-----------
-- Usage --
-----------
......@@ -1507,13 +1447,10 @@ procedure Gnatlink is
begin
-- Add the directory where gnatlink is invoked in front of the path, if
-- gnatlink is invoked with directory information. Only do this if the
-- platform is not VMS, where the notion of path does not really exist.
-- gnatlink is invoked with directory information.
if not Hostparm.OpenVMS then
declare
Command : constant String := Command_Name;
begin
for Index in reverse Command'Range loop
if Command (Index) = Directory_Separator then
......@@ -1535,17 +1472,8 @@ begin
end if;
end loop;
end;
end if;
Base_Command_Name := new String'(Base_Name (Command_Name));
-- Fold to lower case "GNATLINK" on VMS to be consistent with output
-- from other GNAT utilities.
if Hostparm.OpenVMS then
To_Lower (Base_Command_Name.all);
end if;
Process_Args;
if Argument_Count = 0
......@@ -1676,13 +1604,11 @@ begin
Osint.Add_Default_Search_Dirs;
Targparm.Get_Target_Parameters;
if VM_Target /= No_VM then
case VM_Target is
when JVM_Target => Gcc := new String'("jvm-gnatcompile");
when CLI_Target => Gcc := new String'("dotnet-gnatcompile");
when No_VM => raise Program_Error;
when No_VM => null;
end case;
end if;
-- Compile the bind file with the following switches:
......@@ -1734,17 +1660,6 @@ begin
if Linker_Path = null then
Exit_With_Error ("Couldn't locate dotnet-ld");
end if;
elsif RTX_RTSS_Kernel_Module_On_Target then
-- Use Microsoft linker for RTSS modules
Linker_Path := System.OS_Lib.Locate_Exec_On_Path ("link");
if Linker_Path = null then
Exit_With_Error ("Couldn't locate link");
end if;
else
Linker_Path := Gcc_Path;
end if;
......@@ -1760,19 +1675,12 @@ begin
& Get_Target_Debuggable_Suffix.all);
end if;
if RTX_RTSS_Kernel_Module_On_Target then
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'("/OUT:" & Output_File_Name.all);
else
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) := new String'("-o");
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'(Output_File_Name.all);
end if;
Check_Existing_Executable (Output_File_Name.all);
......@@ -1828,11 +1736,10 @@ begin
end loop;
-- For now we detect windows by an output executable name ending with
-- the suffix .exe (excluding VMS which might use that same name).
-- the suffix .exe.
if FN'Length > 5
and then FN (FN'Last - 3 .. FN'Last) = ".exe"
and then not OpenVMS_On_Target
then
Check_File_Name ("install");
Check_File_Name ("setup");
......@@ -1880,11 +1787,7 @@ begin
begin
-- Set prefix
if OpenVMS_On_Target then
Bind_File_Prefix := new String'("b__");
else
Bind_File_Prefix := new String'("b~");
end if;
-- If the length of the binder file becomes too long due to
-- the addition of the "b?" prefix, then truncate it.
......@@ -1979,14 +1882,12 @@ begin
-- the actual link at run time. We might consider packing all class files
-- in a .zip file during this step.
if VM_Target /= JVM_Target then
Link_Step : declare
Num_Args : Natural :=
(Linker_Options.Last - Linker_Options.First + 1) +
(Gcc_Linker_Options.Last - Gcc_Linker_Options.First + 1) +
(Linker_Objects.Last - Linker_Objects.First + 1);
Stack_Op : Boolean := False;
IDENT_Op : Boolean := False;
begin
if AAMP_On_Target then
......@@ -2006,126 +1907,6 @@ begin
Num_Args := Num_Args - 1;
end if;
end loop;
elsif RTX_RTSS_Kernel_Module_On_Target then
-- Remove irrelevant flags for Microsoft linker, adapt some others
for J in reverse Linker_Options.First .. Linker_Options.Last loop
-- Remove flags that are not accepted
if Linker_Options.Table (J)'Length = 0
or else Linker_Options.Table (J) (1 .. 2) = "-l"
or else Linker_Options.Table (J) (1 .. 3) = "-Wl"
or else Linker_Options.Table (J) (1 .. 3) = "-sh"
or else Linker_Options.Table (J) (1 .. 2) = "-O"
or else Linker_Options.Table (J) (1 .. 8) = "-Xlinker"
or else Linker_Options.Table (J) (1 .. 9) = "-mthreads"
then
Linker_Options.Table (J .. Linker_Options.Last - 1) :=
Linker_Options.Table (J + 1 .. Linker_Options.Last);
Linker_Options.Decrement_Last;
Num_Args := Num_Args - 1;
-- Replace "-L" by its counterpart "/LIBPATH:" and UNIX "/" by
-- Windows "\".
elsif Linker_Options.Table (J) (1 .. 2) = "-L" then
declare
Libpath_Option : constant String_Access := new String'
("/LIBPATH:" &
Linker_Options.Table
(J) (3 .. Linker_Options.Table (J).all'Last));
begin
for Index in 10 .. Libpath_Option'Last loop
if Libpath_Option (Index) = '/' then
Libpath_Option (Index) := '\';
end if;
end loop;
Linker_Options.Table (J) := Libpath_Option;
end;
-- Replace "-g" by "/DEBUG"
elsif Linker_Options.Table (J) (1 .. 2) = "-g" then
Linker_Options.Table (J) := new String'("/DEBUG");
-- Replace "-o" by "/OUT:"
elsif Linker_Options.Table (J) (1 .. 2) = "-o" then
Linker_Options.Table (J + 1) := new String'
("/OUT:" & Linker_Options.Table (J + 1).all);
Linker_Options.Table (J .. Linker_Options.Last - 1) :=
Linker_Options.Table (J + 1 .. Linker_Options.Last);
Linker_Options.Decrement_Last;
Num_Args := Num_Args - 1;
-- Replace "--stack=" by "/STACK:"
elsif Linker_Options.Table (J) (1 .. 8) = "--stack=" then
Linker_Options.Table (J) := new String'
("/STACK:" &
Linker_Options.Table (J)
(9 .. Linker_Options.Table (J).all'Last));
-- Replace "-v" by its counterpart "/VERBOSE"
elsif Linker_Options.Table (J) (1 .. 2) = "-v" then
Linker_Options.Table (J) := new String'("/VERBOSE");
end if;
end loop;
-- Add some required flags to create RTSS modules
declare
Flags_For_Linker : constant array (1 .. 17) of String_Access :=
(new String'("/NODEFAULTLIB"),
new String'("/INCREMENTAL:NO"),
new String'("/NOLOGO"),
new String'("/DRIVER"),
new String'("/ALIGN:0x20"),
new String'("/SUBSYSTEM:NATIVE"),
new String'("/ENTRY:_RtapiProcessEntryCRT@8"),
new String'("/RELEASE"),
new String'("startupCRT.obj"),
new String'("rtxlibcmt.lib"),
new String'("oldnames.lib"),
new String'("rtapi_rtss.lib"),
new String'("Rtx_Rtss.lib"),
new String'("libkernel32.a"),
new String'("libws2_32.a"),
new String'("libmswsock.a"),
new String'("libadvapi32.a"));
-- These flags need to be passed to Microsoft linker. They
-- come from the RTX documentation.
Gcc_Lib_Path : constant String_Access := new String'
("/LIBPATH:" & Include_Dir_Default_Prefix & "\..\");
-- Place to look for gcc related libraries, such as libgcc
begin
-- Replace UNIX "/" by Windows "\" in the path
for Index in 10 .. Gcc_Lib_Path.all'Last loop
if Gcc_Lib_Path (Index) = '/' then
Gcc_Lib_Path (Index) := '\';
end if;
end loop;
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) := Gcc_Lib_Path;
Num_Args := Num_Args + 1;
for Index in Flags_For_Linker'Range loop
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
Flags_For_Linker (Index);
Num_Args := Num_Args + 1;
end loop;
end;
end if;
-- Remove duplicate stack size setting from the Linker_Options table.
......@@ -2205,23 +1986,6 @@ begin
end if;
end if;
-- Remove duplicate IDENTIFICATION directives (VMS)
if Linker_Options.Table (J)'Length > 29
and then Linker_Options.Table (J) (1 .. 30) =
"--for-linker=--identification="
then
if IDENT_Op then
Linker_Options.Table (J .. Linker_Options.Last - 1) :=
Linker_Options.Table (J + 1 .. Linker_Options.Last);
Linker_Options.Decrement_Last;
Num_Args := Num_Args - 1;
else
IDENT_Op := True;
end if;
end if;
J := J + 1;
end loop;
......@@ -2239,17 +2003,7 @@ begin
Linker_Options.Table (Linker_Options.Last) := Static_Libgcc;
Num_Args := Num_Args + 1;
end if;
elsif RTX_RTSS_Kernel_Module_On_Target then
-- Force the use of the static libgcc for RTSS modules
Linker_Options.Increment_Last;
Linker_Options.Table (Linker_Options.Last) :=
new String'("libgcc.a");
Num_Args := Num_Args + 1;
end if;
end Clean_Link_Option_Set;
-- Prepare arguments for call to linker
......@@ -2331,7 +2085,6 @@ begin
end if;
end Call_Linker;
end Link_Step;
end if;
-- Only keep the binder output file and it's associated object
-- file if compiling with the -g option. These files are only
......
......@@ -456,12 +456,33 @@ package body Sem_Case is
return;
end if;
-- Case of only one value that is missing
-- Case of only one value that is duplicated
if Lo = Hi then
-- Integer type
if Is_Integer_Type (Bounds_Type) then
-- We have an integer value, Lo, but if the given choice
-- placement is a constant with that value, then use the
-- name of that constant instead in the message:
if Nkind (C) = N_Identifier
and then Compile_Time_Known_Value (C)
and then Expr_Value (C) = Lo
then
Error_Msg_N ("duplication of choice value: &#!", C);
-- Not that special case, so just output the integer value
else
Error_Msg_Uint_1 := Lo;
Error_Msg_N ("duplication of choice value: ^#!", C);
end if;
-- Enumeration type
else
Error_Msg_Name_1 := Choice_Image (Lo, Bounds_Type);
Error_Msg_N ("duplication of choice value: %#!", C);
......@@ -470,10 +491,38 @@ package body Sem_Case is
-- More than one choice value, so print range of values
else
-- Integer type
if Is_Integer_Type (Bounds_Type) then
-- Similar to the above, if C is a range of known values which
-- match Lo and Hi, then use the names. We have to go to the
-- original nodes, since the values will have been rewritten
-- to their integer values.
if Nkind (C) = N_Range
and then Nkind (Original_Node (Low_Bound (C))) = N_Identifier
and then Nkind (Original_Node (High_Bound (C))) = N_Identifier
and then Compile_Time_Known_Value (Low_Bound (C))
and then Compile_Time_Known_Value (High_Bound (C))
and then Expr_Value (Low_Bound (C)) = Lo
and then Expr_Value (High_Bound (C)) = Hi
then
Error_Msg_Node_2 := Original_Node (High_Bound (C));
Error_Msg_N
("duplication of choice values: & .. &#!",
Original_Node (Low_Bound (C)));
-- Not that special case, output integer values
else
Error_Msg_Uint_1 := Lo;
Error_Msg_Uint_2 := Hi;
Error_Msg_N ("duplication of choice values: ^ .. ^#!", C);
end if;
-- Enumeration type
else
Error_Msg_Name_1 := Choice_Image (Lo, Bounds_Type);
Error_Msg_Name_2 := Choice_Image (Hi, Bounds_Type);
......
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