xref: /llvm-project/flang/runtime/iostat.cpp (revision bafbae238aa1948aa511c734a613a95d89a72546)
1 //===-- runtime/iostat.cpp ------------------------------------------------===//
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 #include "flang/Runtime/iostat.h"
10 
11 namespace Fortran::runtime::io {
12 const char *IostatErrorString(int iostat) {
13   switch (iostat) {
14   case IostatOk:
15     return "No error";
16   case IostatEnd:
17     return "End of file during input";
18   case IostatEor:
19     return "End of record during non-advancing input";
20   case IostatUnflushable:
21     return "FLUSH not possible";
22   case IostatInquireInternalUnit:
23     return "INQUIRE on internal unit";
24   case IostatGenericError:
25     return "I/O error"; // dummy value, there's always a message
26   case IostatRecordWriteOverrun:
27     return "Excessive output to fixed-size record";
28   case IostatRecordReadOverrun:
29     return "Excessive input from fixed-size record";
30   case IostatInternalWriteOverrun:
31     return "Internal write overran available records";
32   case IostatErrorInFormat:
33     return "Bad FORMAT";
34   case IostatErrorInKeyword:
35     return "Bad keyword argument value";
36   case IostatEndfileDirect:
37     return "ENDFILE on direct-access file";
38   case IostatEndfileUnwritable:
39     return "ENDFILE on read-only file";
40   case IostatOpenBadRecl:
41     return "OPEN with bad RECL= value";
42   case IostatOpenUnknownSize:
43     return "OPEN of file of unknown size";
44   case IostatOpenBadAppend:
45     return "OPEN(POSITION='APPEND') of unpositionable file";
46   case IostatWriteToReadOnly:
47     return "Attempted output to read-only file";
48   case IostatReadFromWriteOnly:
49     return "Attempted input from write-only file";
50   case IostatBackspaceNonSequential:
51     return "BACKSPACE on non-sequential file";
52   case IostatBackspaceAtFirstRecord:
53     return "BACKSPACE at first record";
54   case IostatRewindNonSequential:
55     return "REWIND on non-sequential file";
56   case IostatWriteAfterEndfile:
57     return "WRITE after ENDFILE";
58   case IostatFormattedIoOnUnformattedUnit:
59     return "Formatted I/O on unformatted file";
60   case IostatUnformattedIoOnFormattedUnit:
61     return "Unformatted I/O on formatted file";
62   case IostatListIoOnDirectAccessUnit:
63     return "List-directed or NAMELIST I/O on direct-access file";
64   case IostatUnformattedChildOnFormattedParent:
65     return "Unformatted child I/O on formatted parent unit";
66   case IostatFormattedChildOnUnformattedParent:
67     return "Formatted child I/O on unformatted parent unit";
68   case IostatChildInputFromOutputParent:
69     return "Child input from output parent unit";
70   case IostatChildOutputToInputParent:
71     return "Child output to input parent unit";
72   case IostatShortRead:
73     return "Read from external unit returned insufficient data";
74   case IostatMissingTerminator:
75     return "Sequential record missing its terminator";
76   case IostatBadUnformattedRecord:
77     return "Erroneous unformatted sequential file record structure";
78   case IostatUTF8Decoding:
79     return "UTF-8 decoding error";
80   default:
81     return nullptr;
82   }
83 }
84 
85 } // namespace Fortran::runtime::io
86