Skip to content

Commit 5c549d9

Browse files
committed
[flang] Silence bogus error
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 c075fee commit 5c549d9

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
@@ -3376,7 +3376,8 @@ bool ScopeHandler::CheckPossibleBadForwardRef(const Symbol &symbol) {
33763376
context().SetError(symbol);
33773377
return true;
33783378
}
3379-
if ((IsDummy(symbol) || FindCommonBlockContaining(symbol)) &&
3379+
if ((IsDummy(symbol) ||
3380+
(!symbol.has<UseDetails>() && FindCommonBlockContaining(symbol))) &&
33803381
isImplicitNoneType() && symbol.test(Symbol::Flag::Implicit) &&
33813382
!context().HasError(symbol)) {
33823383
// 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)