This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] ada: Do not raise Use_Error in Reset if mode isn't changed
- From: Samuel Tardieu <sam at rfc1149 dot net>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 3 Dec 2007 16:27:44 +0100
- Subject: [PATCH] ada: Do not raise Use_Error in Reset if mode isn't changed
- Organisation: RFC1149 (see http://www.rfc1149.net/)
Regtested on i686-pc-linux-gnu.
Note that the existing comment above the change does describe the code...
after this patch is applied :)
gcc/ada/
PR ada/22255
* s-fileio.adb (Reset): Do not raise Use_Error if mode isn't changed.
gcc/testsuite/
PR ada/22255
* test_direct_io.adb: New file.
---
gcc/ada/s-fileio.adb | 9 +++++----
gcc/testsuite/gnat.dg/test_direct_io.adb | 15 +++++++++++++++
2 files changed, 20 insertions(+), 4 deletions(-)
create mode 100644 gcc/testsuite/gnat.dg/test_direct_io.adb
diff --git a/gcc/ada/s-fileio.adb b/gcc/ada/s-fileio.adb
index e2c0e3d..f44eaa2 100644
--- a/gcc/ada/s-fileio.adb
+++ b/gcc/ada/s-fileio.adb
@@ -1077,10 +1077,11 @@ package body System.File_IO is
-- Change of mode not allowed for shared file or file with no name
-- or file that is not a regular file, or for a system file.
- if File.Shared_Status = Yes
- or else File.Name'Length <= 1
- or else File.Is_System_File
- or else (not File.Is_Regular_File)
+ if Mode /= File.Mode
+ and then (File.Shared_Status = Yes
+ or else File.Name'Length <= 1
+ or else File.Is_System_File
+ or else (not File.Is_Regular_File))
then
raise Use_Error;
diff --git a/gcc/testsuite/gnat.dg/test_direct_io.adb b/gcc/testsuite/gnat.dg/test_direct_io.adb
new file mode 100644
index 0000000..0eb8aa2
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/test_direct_io.adb
@@ -0,0 +1,15 @@
+-- { dg-do run }
+with Ada.Direct_IO;
+
+procedure Test_Direct_IO is
+
+ package BDIO is new Ada.Direct_IO (Boolean);
+ use BDIO;
+
+ FD : File_Type;
+
+begin
+ Create (FD, Form => "shared=yes");
+ Reset (FD);
+ Close (FD);
+end Test_Direct_IO;
--
1.5.3.6