re PR ada/21346 (Ada.Directories.Compose raises exception if Containing_Directory...
authorSamuel Tardieu <sam@rfc1149.net>
Fri, 7 Dec 2007 18:03:20 +0000 (18:03 +0000)
committerSamuel Tardieu <sam@gcc.gnu.org>
Fri, 7 Dec 2007 18:03:20 +0000 (18:03 +0000)
    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.

From-SVN: r130692

gcc/ada/ChangeLog
gcc/ada/a-direct.adb
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/compose.adb [new file with mode: 0644]

index 0b1afbc785ae77b891d456efcc60af132d04a17e..49f226f4021cf11d28d6521155d38b1c48853158 100644 (file)
@@ -14,6 +14,9 @@
        when an access to constant is used to initialize an access
        value.
 
+       PR ada/21346
+       * a-direct.adb (Compose): Containing_Directory can be an empty string.
+
 2007-12-07  Olivier Hainque  <hainque@adacore.com>
 
        PR ada/34173
index 1d7ea552be269e0d6e7fd9c21389b8fd19d1ecfe..52ad1b306d8330693df801bbb404f103d01495eb 100644 (file)
@@ -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;
index 1b0fbbd00195d3b61ceb5e55267ae15460e8a4fa..62a7a15a3e14fb067d89b80bb4ed3dbdbd308816 100644 (file)
@@ -15,6 +15,9 @@
 
        * gnat.dg/specs/access_constant_decl.ads: New test.
 
+       PR ada/21346
+       * gnat.dg/compose.adb: New test.
+
 2007-12-07  Olivier Hainque  <hainque@adacore.com>
 
        PR ada/34173
diff --git a/gcc/testsuite/gnat.dg/compose.adb b/gcc/testsuite/gnat.dg/compose.adb
new file mode 100644 (file)
index 0000000..4ee3c57
--- /dev/null
@@ -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;