From 7db0610c0620a50c3abd9c4d518b63f5cb61f0a8 Mon Sep 17 00:00:00 2001 From: Peter Klausler Date: Wed, 23 Aug 2023 11:39:06 -0700 Subject: [PATCH] [flang] INQUIRE(FILE=path, READ/READWRITE/WRITE=x) should be UNKNOWN when unknown For nonexistent or inaccessible files, we're returning NO, which is indeed true, but we should return UNKNOWN instead. Differential Revision: https://reviews.llvm.org/D158653 --- flang/runtime/io-stmt.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/flang/runtime/io-stmt.cpp b/flang/runtime/io-stmt.cpp index 4be7e6135c04..6ce66911292a 100644 --- a/flang/runtime/io-stmt.cpp +++ b/flang/runtime/io-stmt.cpp @@ -1347,13 +1347,16 @@ bool InquireUnconnectedFileState::Inquire( str = "UNKNONN"; break; case HashInquiryKeyword("READ"): - str = MayRead(path_.get()) ? "YES" : "NO"; + str = + IsExtant(path_.get()) ? MayRead(path_.get()) ? "YES" : "NO" : "UNKNOWN"; break; case HashInquiryKeyword("READWRITE"): - str = MayReadAndWrite(path_.get()) ? "YES" : "NO"; + str = IsExtant(path_.get()) ? MayReadAndWrite(path_.get()) ? "YES" : "NO" + : "UNKNOWN"; break; case HashInquiryKeyword("WRITE"): - str = MayWrite(path_.get()) ? "YES" : "NO"; + str = IsExtant(path_.get()) ? MayWrite(path_.get()) ? "YES" : "NO" + : "UNKNOWN"; break; case HashInquiryKeyword("NAME"): str = path_.get();