Skip to content

Commit 348002e

Browse files
authored
[flang] Check definability for logical INQUIRE specifiers (llvm#144797)
check-io.cpp was missing checks for the definability of logical-valued specifiers in INQUIRE statements (e.g. EXIST=), and therefore also not noting the definitions of those variables. This could lead to bogus warnings about undefined function result variables, and also to missed errors about immutable objects appearing in those specifiers. Fixes llvm#144453.
1 parent dccc026 commit 348002e

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

flang/lib/Semantics/check-io.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,8 @@ void IoChecker::Enter(const parser::InquireSpec::LogVar &spec) {
478478
specKind = IoSpecKind::Pending;
479479
break;
480480
}
481+
CheckForDefinableVariable(std::get<parser::ScalarLogicalVariable>(spec.t),
482+
parser::ToUpperCaseLetters(common::EnumToString(specKind)));
481483
SetSpecifier(specKind);
482484
}
483485

flang/test/Semantics/bug144453.f90

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
!RUN: %python %S/test_errors.py %s %flang_fc1
2+
function func(immutable)
3+
logical func
4+
logical, intent(in) :: immutable
5+
!No warning about an undefined function result should appear
6+
INQUIRE(file="/usr/local/games/adventure", EXIST=func)
7+
!ERROR: EXIST variable 'immutable' is not definable
8+
!BECAUSE: 'immutable' is an INTENT(IN) dummy argument
9+
INQUIRE(file="/usr/local/games/adventure", EXIST=immutable)
10+
end

0 commit comments

Comments
 (0)