diff mbox series

[Ada] Error when closing c_stream

Message ID 20201023082640.GA127581@adacore.com
State New
Headers show
Series [Ada] Error when closing c_stream | expand

Commit Message

Pierre-Marie de Rodat Oct. 23, 2020, 8:26 a.m. UTC
When using xxxx.C_Streams.Open with a null Name, the File will be
incorrectly set as a temporary file, causing a wrong attempt to delete
it when closing it.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* libgnat/s-fileio.adb (Open): Fix setting of Tempfile.
diff mbox series

Patch

diff --git a/gcc/ada/libgnat/s-fileio.adb b/gcc/ada/libgnat/s-fileio.adb
--- a/gcc/ada/libgnat/s-fileio.adb
+++ b/gcc/ada/libgnat/s-fileio.adb
@@ -800,9 +800,9 @@  package body System.File_IO is
 
       Text_Encoding : Content_Encoding;
 
-      Tempfile : constant Boolean := Name = "";
+      Tempfile : constant Boolean := Name = "" and Stream = NULL_Stream;
       --  Indicates temporary file case, which is indicated by an empty file
-      --  name.
+      --  name and no specified Stream.
 
       Namelen : constant Integer := max_path_len;
       --  Length required for file name, not including final ASCII.NUL.