Skip to content

Commit 06fb26c

Browse files
authored
[flang] Silence bogus error (#160173)
One of the checks for implicitly-typed names under IMPLICIT NONE has a false positive case for USE-associated items in COMMON blocks. Fixes #159977.
1 parent ea5262f commit 06fb26c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

flang/lib/Semantics/resolve-names.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3359,7 +3359,8 @@ bool ScopeHandler::CheckPossibleBadForwardRef(const Symbol &symbol) {
33593359
context().SetError(symbol);
33603360
return true;
33613361
}
3362-
if ((IsDummy(symbol) || FindCommonBlockContaining(symbol)) &&
3362+
if ((IsDummy(symbol) ||
3363+
(!symbol.has<UseDetails>() && FindCommonBlockContaining(symbol))) &&
33633364
isImplicitNoneType() && symbol.test(Symbol::Flag::Implicit) &&
33643365
!context().HasError(symbol)) {
33653366
// Dummy or COMMON was implicitly typed despite IMPLICIT NONE(TYPE) in

flang/test/Semantics/bug159977.f90

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
! RUN: %flang_fc1 -fsyntax-only -pedantic %s 2>&1 | FileCheck %s --allow-empty
2+
! Ensure no bogus "no explicit type for ..." error on USE-associated
3+
! implicitly-typed COMMON block object in scope with IMPLICIT NONE.
4+
! CHECK-NOT: error:
5+
module m
6+
common /block/ var
7+
end
8+
subroutine test
9+
use m
10+
implicit none
11+
end

0 commit comments

Comments
 (0)