FLANG

iostat.h
1 //===-- runtime/iostat.h ----------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 // Defines the values returned by the runtime for IOSTAT= specifiers
10 // on I/O statements.
11
12 #ifndef FORTRAN_RUNTIME_IOSTAT_H_
13 #define FORTRAN_RUNTIME_IOSTAT_H_
14 #include "magic-numbers.h"
15 namespace Fortran::runtime::io {
16
17 // The value of IOSTAT= is zero when no error, end-of-record,
18 // or end-of-file condition has arisen; errors are positive values.
19 // (See 12.11.5 in Fortran 2018 for the complete requirements;
20 // these constants must match the values of their corresponding
21 // named constants in the predefined module ISO_FORTRAN_ENV, so
22 // they're actually defined in another magic-numbers.h header file
23 // so that they can be included both here and there.)
24 enum Iostat {
25 IostatOk = 0, // no error, EOF, or EOR condition
26
27 // These error codes are required by Fortran (see 12.10.2.16-17) to be
28 // negative integer values
29 IostatEnd = FORTRAN_RUNTIME_IOSTAT_END, // end-of-file on input & no error
30 // End-of-record on non-advancing input, no EOF or error
31 IostatEor = FORTRAN_RUNTIME_IOSTAT_EOR,
32
33 // This value is also required to be negative (12.11.5 bullet 6).
34 // It signifies a FLUSH statement on an unflushable unit.
35 IostatUnflushable = FORTRAN_RUNTIME_IOSTAT_FLUSH,
36
37 // Other errors are positive. We use "errno" values unchanged.
38 // This error is exported in ISO_Fortran_env.
39 IostatInquireInternalUnit = FORTRAN_RUNTIME_IOSTAT_INQUIRE_INTERNAL_UNIT,
40
41 // The remaining error codes are not exported.
42 IostatGenericError = 1001, // see IOMSG= for details
43 IostatRecordWriteOverrun,
44 IostatRecordReadOverrun,
45 IostatInternalWriteOverrun,
46 IostatErrorInFormat,
47 IostatErrorInKeyword,
48 IostatEndfileNonSequential,
49 IostatEndfileUnwritable,
50 IostatOpenBadRecl,
51 IostatOpenUnknownSize,
52 IostatOpenBadAppend,
53 IostatWriteToReadOnly,
54 IostatReadFromWriteOnly,
55 IostatBackspaceNonSequential,
56 IostatBackspaceAtFirstRecord,
57 IostatRewindNonSequential,
58 };
59
60 const char *IostatErrorString(int);
61
62 } // namespace Fortran::runtime::io
63 #endif // FORTRAN_RUNTIME_IOSTAT_H_