[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
This commit is contained in:
Peter Klausler 2023-08-23 11:39:06 -07:00
parent 9c0302a772
commit 7db0610c06
No known key found for this signature in database

View File

@ -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();