[flang-commits] [flang] [flang] Silence bogus error (PR #160173)
via flang-commits
flang-commits at lists.llvm.org
Mon Sep 22 11:47:33 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-semantics
Author: Peter Klausler (klausler)
<details>
<summary>Changes</summary>
One of the checks for implicitly-typed names under IMPLICIT NONE has a false positive case for USE-associated items in COMMON blocks.
Fixes https://github.com/llvm/llvm-project/issues/159977.
---
Full diff: https://github.com/llvm/llvm-project/pull/160173.diff
2 Files Affected:
- (modified) flang/lib/Semantics/resolve-names.cpp (+2-1)
- (added) flang/test/Semantics/bug159977.f90 (+11)
``````````diff
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index e97f0bf02a515..93fbbb58b06fd 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -3376,7 +3376,8 @@ bool ScopeHandler::CheckPossibleBadForwardRef(const Symbol &symbol) {
context().SetError(symbol);
return true;
}
- if ((IsDummy(symbol) || FindCommonBlockContaining(symbol)) &&
+ if ((IsDummy(symbol) ||
+ (!symbol.has<UseDetails>() && FindCommonBlockContaining(symbol))) &&
isImplicitNoneType() && symbol.test(Symbol::Flag::Implicit) &&
!context().HasError(symbol)) {
// Dummy or COMMON was implicitly typed despite IMPLICIT NONE(TYPE) in
diff --git a/flang/test/Semantics/bug159977.f90 b/flang/test/Semantics/bug159977.f90
new file mode 100644
index 0000000000000..ee731c9fb170e
--- /dev/null
+++ b/flang/test/Semantics/bug159977.f90
@@ -0,0 +1,11 @@
+! RUN: %flang_fc1 -fsyntax-only -pedantic %s 2>&1 | FileCheck %s --allow-empty
+! Ensure no bogus "no explicit type for ..." error on USE-associated
+! implicitly-typed COMMON block object in scope with IMPLICIT NONE.
+! CHECK-NOT: error:
+module m
+ common /block/ var
+end
+subroutine test
+ use m
+ implicit none
+end
``````````
</details>
https://github.com/llvm/llvm-project/pull/160173
More information about the flang-commits
mailing list