diff options
author | peter klausler <pklausler@nvidia.com> | 2020-01-16 13:51:25 -0800 |
---|---|---|
committer | peter klausler <pklausler@nvidia.com> | 2020-01-24 12:33:47 -0800 |
commit | 491122d1cd52dc0870b04d0cc0e05dffec194958 (patch) | |
tree | 67913c202168537943ec96930b3d71f8595c4b64 /flang/runtime/io-error.h | |
parent | 6149ff9bc95259a4cf8a05882186736365c81182 (diff) | |
download | llvm-491122d1cd52dc0870b04d0cc0e05dffec194958.tar.gz |
[flang] Drill down to a working implementation of the APIs for an
internal formatted WRITE with no data list items.
Improve argument names in io-api.h
Bump up error number to not conflict with errno values
Use Fortran::runtime::io namespace
Add wrapper around malloc/free, allow use of unique_ptr with wrapper
IoErrorHandler
Revamp FormatContext, use virtual member functions
Update comment syntax, allow for old C
12HHELLO, WORLD
Remove files not yet ready for review
Use std::forward
Fix gcc build warnings
Fix redundant filename in license boilerplate
Reduce runtime dependence on compiler binary libraries, fixing shared lib builds
Original-commit: flang-compiler/f18@839a91f1d699cd839767407bcdb1e384f2d2b730
Reviewed-on: https://github.com/flang-compiler/f18/pull/946
Diffstat (limited to 'flang/runtime/io-error.h')
-rw-r--r-- | flang/runtime/io-error.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/flang/runtime/io-error.h b/flang/runtime/io-error.h new file mode 100644 index 000000000000..08aea4e9a506 --- /dev/null +++ b/flang/runtime/io-error.h @@ -0,0 +1,50 @@ +//===-- runtime/io-error.h --------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// Distinguishes I/O error conditions; fatal ones lead to termination, +// and those that the user program has chosen to handle are recorded +// so that the highest-priority one can be returned as IOSTAT=. + +#ifndef FORTRAN_RUNTIME_IO_ERROR_H_ +#define FORTRAN_RUNTIME_IO_ERROR_H_ + +#include "terminator.h" +#include <cinttypes> + +namespace Fortran::runtime::io { + +class IoErrorHandler : virtual public Terminator { +public: + using Terminator::Terminator; + void Begin(const char *sourceFileName, int sourceLine); + void HasIoStat() { flags_ |= hasIoStat; } + void HasErrLabel() { flags_ |= hasErr; } + void HasEndLabel() { flags_ |= hasEnd; } + void HasEorLabel() { flags_ |= hasEor; } + + void SignalError(int iostatOrErrno); + void SignalEnd(); + void SignalEor(); + + int GetIoStat() const; + +private: + enum Flag : std::uint8_t { + hasIoStat = 1, // IOSTAT= + hasErr = 2, // ERR= + hasEnd = 4, // END= + hasEor = 8, // EOR= + }; + std::uint8_t flags_{0}; + bool hitEnd_{false}; + bool hitEor_{false}; + int ioStat_{0}; +}; + +} +#endif // FORTRAN_RUNTIME_IO_ERROR_H_ |