public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] ada: Do not raise Use_Error in Reset if mode isn't changed
@ 2007-12-03 15:57 Samuel Tardieu
  2008-02-26  8:31 ` Samuel Tardieu
  0 siblings, 1 reply; 4+ messages in thread
From: Samuel Tardieu @ 2007-12-03 15:57 UTC (permalink / raw)
  To: gcc-patches

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ada: Do not raise Use_Error in Reset if mode isn't changed
  2007-12-03 15:57 [PATCH] ada: Do not raise Use_Error in Reset if mode isn't changed Samuel Tardieu
@ 2008-02-26  8:31 ` Samuel Tardieu
  2008-02-27 12:33   ` Arnaud Charlet
  0 siblings, 1 reply; 4+ messages in thread
From: Samuel Tardieu @ 2008-02-26  8:31 UTC (permalink / raw)
  To: gcc-patches

>>>>> "Sam" == Samuel Tardieu <sam@rfc1149.net> writes:

Sam> PR ada/22255 * s-fileio.adb (Reset): Do not raise Use_Error if
Sam> mode isn't changed.

Arnaud,

I cannot seem to find an answer from you concerning this patch, and it
looks like it has been applied into AdaCore's repository
(http://tinyurl.com/3yzofa).

Ok for trunk?

  Sam
-- 
Samuel Tardieu -- sam@rfc1149.net -- http://www.rfc1149.net/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ada: Do not raise Use_Error in Reset if mode isn't changed
  2008-02-26  8:31 ` Samuel Tardieu
@ 2008-02-27 12:33   ` Arnaud Charlet
  2008-02-27 12:45     ` Samuel Tardieu
  0 siblings, 1 reply; 4+ messages in thread
From: Arnaud Charlet @ 2008-02-27 12:33 UTC (permalink / raw)
  To: Samuel Tardieu; +Cc: gcc-patches

> Sam> PR ada/22255 * s-fileio.adb (Reset): Do not raise Use_Error if
> Sam> mode isn't changed.
> 
> Arnaud,
> 
> I cannot seem to find an answer from you concerning this patch, and it
> looks like it has been applied into AdaCore's repository
> (http://tinyurl.com/3yzofa).
> 
> Ok for trunk?

I do not remember your suggested patch. The following below is OK for
commit (hopefully this should be the same):

<<
Index: s-fileio.adb
===================================================================
--- s-fileio.adb        (revision 132702)
+++ s-fileio.adb        (working copy)
@@ -1074,13 +1074,15 @@ package body System.File_IO is
    begin
       Check_File_Open (File);
 
-      --  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
+      --  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. Note that we
+      --  allow the "change" of mode if it is not in fact doing a change.
+
+      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;
 
>>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ada: Do not raise Use_Error in Reset if mode isn't  changed
  2008-02-27 12:33   ` Arnaud Charlet
@ 2008-02-27 12:45     ` Samuel Tardieu
  0 siblings, 0 replies; 4+ messages in thread
From: Samuel Tardieu @ 2008-02-27 12:45 UTC (permalink / raw)
  To: Arnaud Charlet; +Cc: gcc-patches

On 27/02, Arnaud Charlet wrote:

| > Sam> PR ada/22255 * s-fileio.adb (Reset): Do not raise Use_Error if
| > Sam> mode isn't changed.
| > 
| > I cannot seem to find an answer from you concerning this patch, and it
| > looks like it has been applied into AdaCore's repository
| > (http://tinyurl.com/3yzofa).
| > 
| > Ok for trunk?
| 
| I do not remember your suggested patch. The following below is OK for
| commit (hopefully this should be the same):

This is indeed the one I sent + extra comment. Will commit.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-02-27 12:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-03 15:57 [PATCH] ada: Do not raise Use_Error in Reset if mode isn't changed Samuel Tardieu
2008-02-26  8:31 ` Samuel Tardieu
2008-02-27 12:33   ` Arnaud Charlet
2008-02-27 12:45     ` Samuel Tardieu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).