[flang-commits] [flang] 79c4307 - [flang][runtime] INQUIRE(UNIT=-666, EXIST=x) should be .FALSE. (#66239)

via flang-commits flang-commits at lists.llvm.org
Mon Sep 18 08:39:00 PDT 2023


Author: Peter Klausler
Date: 2023-09-18T08:38:55-07:00
New Revision: 79c430787f0c2c78f3f4b8bf877fafab6cc8c5cf

URL: https://github.com/llvm/llvm-project/commit/79c430787f0c2c78f3f4b8bf877fafab6cc8c5cf
DIFF: https://github.com/llvm/llvm-project/commit/79c430787f0c2c78f3f4b8bf877fafab6cc8c5cf.diff

LOG: [flang][runtime] INQUIRE(UNIT=-666, EXIST=x) should be .FALSE. (#66239)

The runtime implementation for INQUIRE(EXIST=x) is returning .TRUE. for
all non-existent unit, which is incorrect for valid unit numbers.

Added: 
    

Modified: 
    flang/runtime/io-stmt.cpp

Removed: 
    


################################################################################
diff  --git a/flang/runtime/io-stmt.cpp b/flang/runtime/io-stmt.cpp
index 6ce66911292a708..1d951a4157d3199 100644
--- a/flang/runtime/io-stmt.cpp
+++ b/flang/runtime/io-stmt.cpp
@@ -1271,7 +1271,7 @@ bool InquireNoUnitState::Inquire(
 bool InquireNoUnitState::Inquire(InquiryKeywordHash inquiry, bool &result) {
   switch (inquiry) {
   case HashInquiryKeyword("EXIST"):
-    result = true;
+    result = badUnitNumber() >= 0;
     return true;
   case HashInquiryKeyword("NAMED"):
   case HashInquiryKeyword("OPENED"):


        


More information about the flang-commits mailing list