This is the mail archive of the 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]

[Ada] Abnormal completion of file Close operation

Procedure Close in Ada.*_IO, and various other procedures involving calls
to Close (namely, Delete, Reset, and Set_Mode in Ada.Streams.Stream_IO)
take an IN OUT File_Type parameter: when the passed file is closed, it
is assigned a special value denoting a closed file. However, the Close
operation may raise a Device_Error exception, if the underlying OS file
close operation fails. In that abnormal completion case, we still want the
assignment to be effective, since the file actually is closed anyway.

This implies that the File parameter of these procedues must be passed
by reference. The full view of the various File_Type types are access types,
which are passed by copy by default. We therefore force by-reference passing
using appropriate pragmas Export_Procedure.

In the internal supporting unit (System.File_IO), we do not have to retain
the IN OUT mode parameter, and so we change the corresponding supporting
subprogram's profiles to use an access parameter instead.

No simple test (requires forcing an fclose(3) call to fail).

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

2008-05-27  Thomas Quinot  <>

	(System.File_IO.{Close, Delete, Reset}):
	Change File parameter from "in out AFCB_Ptr" to "access AFCB_Ptr".

	(Ada.*_IO.{Close, Delete, Reset, Set_Mode}):
	Pass File parameter by reference.

Attachment: difs
Description: Text document

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