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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@139192
138bc75d-0d04-0410-961f-
82ee72b054a4
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,
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 ("");
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
--- /dev/null
+-- { 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;