This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] ada: In Compose, Containing_Directory can be an empty string


Tested on i686-pc-linux-gnu.

    gcc/ada/
	PR ada/21346
	* a-direct.adb (Compose): Containing_Directory can be an empty string.

    gcc/testsuite/
	PR ada/21346
	* gnat.dg/compose.adb: New test.
---
 gcc/ada/a-direct.adb              |    6 ++++--
 gcc/testsuite/gnat.dg/compose.adb |   11 +++++++++++
 2 files changed, 15 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/gnat.dg/compose.adb

diff --git a/gcc/ada/a-direct.adb b/gcc/ada/a-direct.adb
index 1d7ea55..52ad1b3 100644
--- a/gcc/ada/a-direct.adb
+++ b/gcc/ada/a-direct.adb
@@ -155,7 +155,9 @@ package body Ada.Directories is
    begin
       --  First, deal with the invalid cases
 
-      if not Is_Valid_Path_Name (Containing_Directory) then
+      if Containing_Directory /= ""
+        and then not Is_Valid_Path_Name (Containing_Directory)
+      then
          raise Name_Error;
 
       elsif
@@ -176,7 +178,7 @@ package body Ada.Directories is
 
          --  Add a directory separator if needed
 
-         if Result (Last) /= Dir_Separator then
+         if Last /= 0 and then Result (Last) /= Dir_Separator then
             Last := Last + 1;
             Result (Last) := Dir_Separator;
          end if;
diff --git a/gcc/testsuite/gnat.dg/compose.adb b/gcc/testsuite/gnat.dg/compose.adb
new file mode 100644
index 0000000..4ee3c57
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/compose.adb
@@ -0,0 +1,11 @@
+-- { dg-do run }
+with Ada.Directories;
+with Ada.Text_IO;
+
+procedure Compose is
+   Result : constant String := Ada.Directories.Compose (Name      => "foo",
+                                                        Extension => "txt");
+   pragma Unreferenced (Result);
+begin
+   null;
+end Compose;
-- 
1.5.3.7


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]