[flang-commits] [flang] 9772dbb - [flang] Set right "inNamelist" flag
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Wed Feb 2 09:33:29 PST 2022
Author: Peter Klausler
Date: 2022-02-02T09:33:19-08:00
New Revision: 9772dbba74375da8dd16349dbe92e91a67c155e0
URL: https://github.com/llvm/llvm-project/commit/9772dbba74375da8dd16349dbe92e91a67c155e0
DIFF: https://github.com/llvm/llvm-project/commit/9772dbba74375da8dd16349dbe92e91a67c155e0.diff
LOG: [flang] Set right "inNamelist" flag
NAMELIST I/O was inconsistent in its choice of which set of I/O modes
to set the "inNamelist" flag. The wrong choice was in the set of modes
that are part of the persistent state of an I/O connection; the right
place is the set of modes that are reinitialized at the beginning of
each I/O statement so that they can be modified by READ/WRITE control
list specifiers and FORMAT control edit descriptors. Fix.
Differential Revision: https://reviews.llvm.org/D118745
Added:
Modified:
flang/runtime/io-stmt.h
flang/runtime/namelist.cpp
Removed:
################################################################################
diff --git a/flang/runtime/io-stmt.h b/flang/runtime/io-stmt.h
index 32e546e5c082d..93b3bed732949 100644
--- a/flang/runtime/io-stmt.h
+++ b/flang/runtime/io-stmt.h
@@ -220,7 +220,7 @@ class IoStatementState {
// Skips spaces, advances records, and ignores NAMELIST comments
std::optional<char32_t> GetNextNonBlank() {
auto ch{GetCurrentChar()};
- bool inNamelist{GetConnectionState().modes.inNamelist};
+ bool inNamelist{mutableModes().inNamelist};
while (!ch || *ch == ' ' || *ch == '\t' || (inNamelist && *ch == '!')) {
if (ch && (*ch == ' ' || *ch == '\t')) {
HandleRelativePosition(1);
diff --git a/flang/runtime/namelist.cpp b/flang/runtime/namelist.cpp
index 8d291619b8f5c..96bffa77b4d5a 100644
--- a/flang/runtime/namelist.cpp
+++ b/flang/runtime/namelist.cpp
@@ -28,9 +28,9 @@ static inline char32_t GetComma(IoStatementState &io) {
bool IONAME(OutputNamelist)(Cookie cookie, const NamelistGroup &group) {
IoStatementState &io{*cookie};
io.CheckFormattedStmtType<Direction::Output>("OutputNamelist");
- ConnectionState &connection{io.GetConnectionState()};
- connection.modes.inNamelist = true;
+ io.mutableModes().inNamelist = true;
char comma{static_cast<char>(GetComma(io))};
+ ConnectionState &connection{io.GetConnectionState()};
// Internal functions to advance records and convert case
const auto EmitWithAdvance{[&](char ch) -> bool {
return (!connection.NeedAdvance(1) || io.AdvanceRecord()) &&
@@ -355,8 +355,7 @@ static void SkipNamelistGroup(IoStatementState &io) {
bool IONAME(InputNamelist)(Cookie cookie, const NamelistGroup &group) {
IoStatementState &io{*cookie};
io.CheckFormattedStmtType<Direction::Input>("InputNamelist");
- ConnectionState &connection{io.GetConnectionState()};
- connection.modes.inNamelist = true;
+ io.mutableModes().inNamelist = true;
IoErrorHandler &handler{io.GetIoErrorHandler()};
auto *listInput{io.get_if<ListDirectedStatementState<Direction::Input>>()};
RUNTIME_CHECK(handler, listInput != nullptr);
@@ -485,8 +484,7 @@ bool IONAME(InputNamelist)(Cookie cookie, const NamelistGroup &group) {
bool IsNamelistName(IoStatementState &io) {
if (io.get_if<ListDirectedStatementState<Direction::Input>>()) {
- ConnectionState &connection{io.GetConnectionState()};
- if (connection.modes.inNamelist) {
+ if (io.mutableModes().inNamelist) {
SavedPosition savedPosition{io};
if (auto ch{io.GetNextNonBlank()}) {
if (IsLegalIdStart(*ch)) {
More information about the flang-commits
mailing list