diff --git a/flang/lib/Semantics/check-io.cpp b/flang/lib/Semantics/check-io.cpp index 10b32d9af0f8..a1ff4b922268 100644 --- a/flang/lib/Semantics/check-io.cpp +++ b/flang/lib/Semantics/check-io.cpp @@ -478,6 +478,8 @@ void IoChecker::Enter(const parser::InquireSpec::LogVar &spec) { specKind = IoSpecKind::Pending; break; } + CheckForDefinableVariable(std::get(spec.t), + parser::ToUpperCaseLetters(common::EnumToString(specKind))); SetSpecifier(specKind); } diff --git a/flang/test/Semantics/bug144453.f90 b/flang/test/Semantics/bug144453.f90 new file mode 100644 index 000000000000..85c0892bffb5 --- /dev/null +++ b/flang/test/Semantics/bug144453.f90 @@ -0,0 +1,10 @@ +!RUN: %python %S/test_errors.py %s %flang_fc1 +function func(immutable) + logical func + logical, intent(in) :: immutable + !No warning about an undefined function result should appear + INQUIRE(file="/usr/local/games/adventure", EXIST=func) + !ERROR: EXIST variable 'immutable' is not definable + !BECAUSE: 'immutable' is an INTENT(IN) dummy argument + INQUIRE(file="/usr/local/games/adventure", EXIST=immutable) +end