[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 10:01:06 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG17853928a69b: [flang] Correct implementation of WAIT with no ID (authored by klausler).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127979/new/

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.437585.patch
Type: text/x-patch
Size: 1412 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220616/f7e3e315/attachment.bin>


More information about the flang-commits mailing list