Skip to content

Commit

Permalink
[flang] Catch error: COMMON block and implicit interface external sub…
Browse files Browse the repository at this point in the history
…program with same name

Declaration checking catches the error of a COMMON block and a subprogram
definition having the same name, but misses the case of a COMMON block
and an a reference to an external subprogram with an implicit interface.
Fix.  Fixes bug #63247.

Differential Revision: https://reviews.llvm.org/D153786
  • Loading branch information
klausler committed Jun 27, 2023
1 parent 49428ba commit 1c900ed
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion flang/lib/Semantics/check-declarations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2552,7 +2552,8 @@ static std::optional<std::string> DefinesGlobalName(const Symbol &symbol) {
} else {
const std::string *bindC{symbol.GetBindName()};
if (symbol.has<CommonBlockDetails>() ||
IsExternalProcedureDefinition(symbol)) {
IsExternalProcedureDefinition(symbol) ||
(symbol.owner().IsGlobal() && IsExternal(symbol))) {
return bindC ? *bindC : symbol.name().ToString();
} else if (bindC &&
(symbol.has<ObjectEntityDetails>() || IsModuleProcedure(symbol))) {
Expand Down
6 changes: 6 additions & 0 deletions flang/test/Semantics/declarations04.f90
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@ block data ext3
!PORTABILITY: Global name 'ext4' conflicts with a module
common /ext4/ x
end

subroutine s
!ERROR: Two entities have the same global name 'foo'
common /foo/n
call foo
end

0 comments on commit 1c900ed

Please sign in to comment.