diff --git a/flang/lib/Semantics/scope.cpp b/flang/lib/Semantics/scope.cpp --- a/flang/lib/Semantics/scope.cpp +++ b/flang/lib/Semantics/scope.cpp @@ -272,7 +272,7 @@ ? "IMPORT,NONE must be the only IMPORT statement in a scope"_err_en_US : "IMPORT,ALL must be the only IMPORT statement in a scope"_err_en_US; } else if (kind != *importKind_ && - (kind != ImportKind::Only || kind != ImportKind::Only)) { + (kind != ImportKind::Only && *importKind_ != ImportKind::Only)) { return "Every IMPORT must have ONLY specifier if one of them does"_err_en_US; } else { return std::nullopt;