Index: flang/runtime/io-stmt.cpp =================================================================== --- flang/runtime/io-stmt.cpp +++ flang/runtime/io-stmt.cpp @@ -25,17 +25,11 @@ return false; } -bool IoStatementBase::Emit(const char *, std::size_t) { - return false; -} +bool IoStatementBase::Emit(const char *, std::size_t) { return false; } -bool IoStatementBase::Emit(const char16_t *, std::size_t) { - return false; -} +bool IoStatementBase::Emit(const char16_t *, std::size_t) { return false; } -bool IoStatementBase::Emit(const char32_t *, std::size_t) { - return false; -} +bool IoStatementBase::Emit(const char32_t *, std::size_t) { return false; } std::size_t IoStatementBase::GetNextInputBytes(const char *&p) { p = nullptr; @@ -71,9 +65,7 @@ return false; } -bool IoStatementBase::Inquire(InquiryKeywordHash, bool &) { - return false; -} +bool IoStatementBase::Inquire(InquiryKeywordHash, bool &) { return false; } bool IoStatementBase::Inquire(InquiryKeywordHash, std::int64_t, bool &) { return false; @@ -1239,9 +1231,8 @@ const char *sourceFile, int sourceLine) : NoUnitIoStatementState{sourceFile, sourceLine, *this} {} -bool InquireIOLengthState::Emit( - const char *, std::size_t n, std::size_t elementBytes) { - bytes_ += n * elementBytes; +bool InquireIOLengthState::Emit(const char *, std::size_t n, std::size_t) { + bytes_ += n; return true; } Index: flang/unittests/Runtime/ExternalIOTest.cpp =================================================================== --- flang/unittests/Runtime/ExternalIOTest.cpp +++ flang/unittests/Runtime/ExternalIOTest.cpp @@ -12,6 +12,7 @@ #include "CrashHandlerFixture.h" #include "gtest/gtest.h" +#include "flang/Runtime/descriptor.h" #include "flang/Runtime/io-api.h" #include "flang/Runtime/main.h" #include "flang/Runtime/stop.h" @@ -19,6 +20,7 @@ #include #include +using namespace Fortran::runtime; using namespace Fortran::runtime::io; struct ExternalIOTests : public CrashHandlerFixture {}; @@ -44,7 +46,7 @@ // INQUIRE(IOLENGTH=) j io = IONAME(BeginInquireIoLength)(__FILE__, __LINE__); ASSERT_TRUE(IONAME(OutputUnformattedBlock)( - io, reinterpret_cast(&buffer), 1, recl)) + io, reinterpret_cast(&buffer), recl, 1)) << "OutputUnformattedBlock() for InquireIoLength"; ASSERT_EQ(IONAME(GetIoLength)(io), recl) << "GetIoLength"; ASSERT_EQ(IONAME(EndIoStatement)(io), IostatOk) @@ -171,13 +173,28 @@ io = IONAME(BeginInquireIoLength)(__FILE__, __LINE__); for (int j{1}; j <= 3; ++j) { ASSERT_TRUE(IONAME(OutputUnformattedBlock)( - io, reinterpret_cast(&buffer), 1, recl)) + io, reinterpret_cast(&buffer), recl, 1)) << "OutputUnformattedBlock() for InquireIoLength"; } ASSERT_EQ(IONAME(GetIoLength)(io), 3 * recl) << "GetIoLength"; ASSERT_EQ(IONAME(EndIoStatement)(io), IostatOk) << "EndIoStatement() for InquireIoLength"; + // INQUIRE(IOLENGTH=) j, ... + StaticDescriptor<0> staticDescriptor; + Descriptor &desc{staticDescriptor.descriptor()}; + desc.Establish(TypeCode{CFI_type_int64_t}, recl, &buffer, 0); + desc.Dump(stderr); + desc.Check(); + io = IONAME(BeginInquireIoLength)(__FILE__, __LINE__); + for (int j{1}; j <= 3; ++j) { + ASSERT_TRUE(IONAME(OutputDescriptor)(io, desc)) + << "OutputDescriptor() for InquireIoLength"; + } + ASSERT_EQ(IONAME(GetIoLength)(io), 3 * recl) << "GetIoLength"; + ASSERT_EQ(IONAME(EndIoStatement)(io), IostatOk) + << "EndIoStatement() for InquireIoLength"; + static const int records{10}; for (int j{1}; j <= records; ++j) { // DO J=1,RECORDS; WRITE(UNIT=unit) j; END DO