Commit 79a14178 by Samuel Tardieu

[multiple changes]

2008-08-18  Samuel Tardieu  <sam@rfc1149.net>
            Robert Dewar  <dewar@adacore.com>
    gcc/ada/
	PR ada/30827
	* bindgen.adb (Gen_Output_File_Ada): Zero-terminate the
	version string.
	Move comment in the right place.
	* g-comver.adb (Version): Look for a zero-termination in
	addition to a closing parenthesis.

2008-08-18  Robert Dewar  <dewar@adacore.com>
    gcc/testsuite/
	PR ada/30827
	* gnat.dg/test_version.adb: New.

From-SVN: r139192
parent b9b2405f
2008-08-18 Samuel Tardieu <sam@rfc1149.net>
Robert Dewar <dewar@adacore.com>
PR ada/30827
* bindgen.adb (Gen_Output_File_Ada): Zero-terminate the
version string.
Move comment in the right place.
* g-comver.adb (Version): Look for a zero-termination in
addition to a closing parenthesis.
2008-08-18 Samuel Tardieu <sam@rfc1149.net>
* exp_ch13.adb, exp_disp.adb, sem_cat.adb, sem_ch10.adb,
* sem_ch12.adb, sem_ch6.adb, sem_ch7.adb, sem_ch8.adb,
......@@ -2267,17 +2267,19 @@ package body Bindgen is
WBI (" gnat_exit_status : Integer;");
WBI (" pragma Import (C, gnat_exit_status);");
end if;
-- Generate the GNAT_Version and Ada_Main_Program_Name info only
-- for the main program. Otherwise, it can lead under some
-- circumstances to a symbol duplication during the link (for
-- instance when a C program uses 2 Ada libraries)
end if;
-- Generate the GNAT_Version and Ada_Main_Program_Name info only for
-- the main program. Otherwise, it can lead under some circumstances
-- to a symbol duplication during the link (for instance when a C
-- program uses two Ada libraries). Also zero terminate the string
-- so that its end can be found reliably at run time.
WBI ("");
WBI (" GNAT_Version : constant String :=");
WBI (" ""GNAT Version: " &
Gnat_Version_String & """;");
Gnat_Version_String &
""" & ASCII.NUL;");
WBI (" pragma Export (C, GNAT_Version, ""__gnat_version"");");
WBI ("");
......
......@@ -53,15 +53,18 @@ package body GNAT.Compiler_Version is
function Version return String is
begin
-- Search for terminating right paren
-- Search for terminating right paren or NUL ending the string
for J in Ver_Prefix'Length + 1 .. GNAT_Version'Last loop
if GNAT_Version (J) = ')' then
return GNAT_Version (Ver_Prefix'Length + 1 .. J);
end if;
if GNAT_Version (J) = Character'Val (0) then
return GNAT_Version (Ver_Prefix'Length + 1 .. J - 1);
end if;
end loop;
-- This should not happen (no right paren found)
-- This should not happen (no right paren or NUL found)
return GNAT_Version;
end Version;
......
2008-08-18 Robert Dewar <dewar@adacore.com>
PR ada/30827
* gnat.dg/test_version.adb: New.
2008-08-18 Samuel Tardieu <sam@rfc1149.net>
PR ada/15808
......
-- { dg-do run }
with GNAT.Compiler_Version;
procedure Test_Version is
package Vsn is new GNAT.Compiler_Version;
use Vsn;
X : constant String := Version;
begin
if X'Length = 46 then
-- 46 = Ver_Len_Max + Ver_Prefix
-- actual version should be shorter than this
raise Program_Error;
end if;
end Test_Version;
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