[flang-commits] [PATCH] D127979: [flang] Correct implementation of WAIT with no ID

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Thu Jun 16 08:59:01 PDT 2022


klausler created this revision.
klausler added a reviewer: vdonaldson.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
klausler requested review of this revision.

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


https://reviews.llvm.org/D127979

Files:
  flang/runtime/io-api.cpp
  flang/runtime/unit.cpp
  flang/runtime/unit.h


Index: flang/runtime/unit.h
===================================================================
--- flang/runtime/unit.h
+++ flang/runtime/unit.h
@@ -39,6 +39,7 @@
   explicit ExternalFileUnit(int unitNumber) : unitNumber_{unitNumber} {
     isUTF8 = executionEnvironment.defaultUTF8;
     asyncIdAvailable_.set();
+    asyncIdAvailable_.reset(0);
   }
   ~ExternalFileUnit() {}
 
Index: flang/runtime/unit.cpp
===================================================================
--- flang/runtime/unit.cpp
+++ flang/runtime/unit.cpp
@@ -918,11 +918,13 @@
 }
 
 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);
     }
Index: flang/runtime/io-api.cpp
===================================================================
--- flang/runtime/io-api.cpp
+++ flang/runtime/io-api.cpp
@@ -400,7 +400,7 @@
 }
 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)(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127979.437560.patch
Type: text/x-patch
Size: 1412 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220616/062b5248/attachment.bin>


More information about the flang-commits mailing list