diff --git a/flang/runtime/io-stmt.cpp b/flang/runtime/io-stmt.cpp --- a/flang/runtime/io-stmt.cpp +++ b/flang/runtime/io-stmt.cpp @@ -243,6 +243,10 @@ } unit().isUnformatted = *isUnformatted_; } + if (!unit().isUnformatted) { + // Set default format (C.7.4 point 2). + unit().isUnformatted = unit().access != Access::Sequential; + } return ExternalIoStatementBase::EndIoStatement(); } @@ -969,7 +973,7 @@ : "ASCII"; break; case HashInquiryKeyword("FORM"): - str = !unit().isUnformatted ? "UNKNOWN" + str = !unit().isUnformatted ? "UNDEFINED" : *unit().isUnformatted ? "UNFORMATTED" : "FORMATTED"; break;