[flang] Correct implementation of WAIT with no ID

Previous one was returning a bogus error status about a bad WAIT
statement ID number.

Differential Revision: https://reviews.llvm.org/D127979
This commit is contained in:
Peter Klausler 2022-06-15 16:53:56 -07:00
parent 5bcda1d3a9
commit 17853928a6
3 changed files with 6 additions and 3 deletions

View File

@ -400,7 +400,7 @@ Cookie IONAME(BeginWait)(ExternalUnit unitNumber, AsynchronousId id,
}
Cookie IONAME(BeginWaitAll)(
ExternalUnit unitNumber, const char *sourceFile, int sourceLine) {
return IONAME(BeginWait)(unitNumber, 0 /*no ID=*/);
return IONAME(BeginWait)(unitNumber, 0 /*no ID=*/, sourceFile, sourceLine);
}
Cookie IONAME(BeginClose)(

View File

@ -918,11 +918,13 @@ int ExternalFileUnit::GetAsynchronousId(IoErrorHandler &handler) {
}
bool ExternalFileUnit::Wait(int id) {
if (id < 0 || asyncIdAvailable_.test(id)) {
if (static_cast<std::size_t>(id) >= asyncIdAvailable_.size() ||
asyncIdAvailable_.test(id)) {
return false;
} else {
if (id == 0) {
if (id == 0) { // means "all IDs"
asyncIdAvailable_.set();
asyncIdAvailable_.reset(0);
} else {
asyncIdAvailable_.set(id);
}

View File

@ -39,6 +39,7 @@ public:
explicit ExternalFileUnit(int unitNumber) : unitNumber_{unitNumber} {
isUTF8 = executionEnvironment.defaultUTF8;
asyncIdAvailable_.set();
asyncIdAvailable_.reset(0);
}
~ExternalFileUnit() {}