Index: flang/lib/Semantics/check-declarations.cpp =================================================================== --- flang/lib/Semantics/check-declarations.cpp +++ flang/lib/Semantics/check-declarations.cpp @@ -2552,7 +2552,8 @@ } else { const std::string *bindC{symbol.GetBindName()}; if (symbol.has() || - IsExternalProcedureDefinition(symbol)) { + IsExternalProcedureDefinition(symbol) || + (symbol.owner().IsGlobal() && IsExternal(symbol))) { return bindC ? *bindC : symbol.name().ToString(); } else if (bindC && (symbol.has() || IsModuleProcedure(symbol))) { Index: flang/test/Semantics/declarations04.f90 =================================================================== --- flang/test/Semantics/declarations04.f90 +++ flang/test/Semantics/declarations04.f90 @@ -23,3 +23,9 @@ !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