llvm-project
129 строк · 4.9 Кб
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
11namespace Fortran::runtime::io {
12RT_OFFLOAD_API_GROUP_BEGIN
13
14const char *IostatErrorString(int iostat) {
15switch (iostat) {
16case IostatOk:
17return "No error";
18case IostatEnd:
19return "End of file during input";
20case IostatEor:
21return "End of record during non-advancing input";
22case IostatUnflushable:
23return "FLUSH not possible";
24case IostatInquireInternalUnit:
25return "INQUIRE on internal unit";
26case IostatGenericError:
27return "I/O error"; // dummy value, there's always a message
28case IostatRecordWriteOverrun:
29return "Excessive output to fixed-size record";
30case IostatRecordReadOverrun:
31return "Excessive input from fixed-size record";
32case IostatInternalWriteOverrun:
33return "Internal write overran available records";
34case IostatErrorInFormat:
35return "Bad FORMAT";
36case IostatErrorInKeyword:
37return "Bad keyword argument value";
38case IostatEndfileDirect:
39return "ENDFILE on direct-access file";
40case IostatEndfileUnwritable:
41return "ENDFILE on read-only file";
42case IostatOpenBadRecl:
43return "OPEN with bad RECL= value";
44case IostatOpenUnknownSize:
45return "OPEN of file of unknown size";
46case IostatOpenBadAppend:
47return "OPEN(POSITION='APPEND') of unpositionable file";
48case IostatWriteToReadOnly:
49return "Attempted output to read-only file";
50case IostatReadFromWriteOnly:
51return "Attempted input from write-only file";
52case IostatBackspaceNonSequential:
53return "BACKSPACE on non-sequential file";
54case IostatBackspaceAtFirstRecord:
55return "BACKSPACE at first record";
56case IostatRewindNonSequential:
57return "REWIND on non-sequential file";
58case IostatWriteAfterEndfile:
59return "WRITE after ENDFILE";
60case IostatFormattedIoOnUnformattedUnit:
61return "Formatted I/O on unformatted file";
62case IostatUnformattedIoOnFormattedUnit:
63return "Unformatted I/O on formatted file";
64case IostatListIoOnDirectAccessUnit:
65return "List-directed or NAMELIST I/O on direct-access file";
66case IostatUnformattedChildOnFormattedParent:
67return "Unformatted child I/O on formatted parent unit";
68case IostatFormattedChildOnUnformattedParent:
69return "Formatted child I/O on unformatted parent unit";
70case IostatChildInputFromOutputParent:
71return "Child input from output parent unit";
72case IostatChildOutputToInputParent:
73return "Child output to input parent unit";
74case IostatShortRead:
75return "Read from external unit returned insufficient data";
76case IostatMissingTerminator:
77return "Sequential record missing its terminator";
78case IostatBadUnformattedRecord:
79return "Erroneous unformatted sequential file record structure";
80case IostatUTF8Decoding:
81return "UTF-8 decoding error";
82case IostatUnitOverflow:
83return "UNIT number is out of range";
84case IostatBadRealInput:
85return "Bad REAL input value";
86case IostatBadScaleFactor:
87return "Bad REAL output scale factor (kP)";
88case IostatBadAsynchronous:
89return "READ/WRITE(ASYNCHRONOUS='YES') on unit without "
90"OPEN(ASYNCHRONOUS='YES')";
91case IostatBadWaitUnit:
92return "WAIT(UNIT=) for a bad or unconnected unit number";
93case IostatBOZInputOverflow:
94return "B/O/Z input value overflows variable";
95case IostatIntegerInputOverflow:
96return "Integer input value overflows variable";
97case IostatRealInputOverflow:
98return "Real or complex input value overflows type";
99case IostatCannotReposition:
100return "Attempt to reposition a unit which is connected to a file that can "
101"only be processed sequentially";
102case IostatOpenAlreadyConnected:
103return "OPEN of file already connected to another unit";
104case IostatBadWaitId:
105return "WAIT(ID=nonzero) for an ID value that is not a pending operation";
106case IostatTooManyAsyncOps:
107return "Too many asynchronous operations pending on unit";
108case IostatBadBackspaceUnit:
109return "BACKSPACE on unconnected unit";
110case IostatBadUnitNumber:
111return "Negative unit number is not allowed";
112case IostatBadFlushUnit:
113return "FLUSH attempted on a bad or unconnected unit number";
114case IostatBadOpOnChildUnit:
115return "Impermissible I/O statement on child I/O unit";
116case IostatBadNewUnit:
117return "NEWUNIT= without FILE= or STATUS='SCRATCH'";
118case IostatBadListDirectedInputSeparator:
119return "List-directed input value has trailing unused characters";
120case IostatNonExternalDefinedUnformattedIo:
121return "Defined unformatted I/O without an external unit";
122default:
123return nullptr;
124}
125}
126
127RT_OFFLOAD_API_GROUP_END
128
129} // namespace Fortran::runtime::io
130