[flang-commits] [flang] 1c900ed - [flang] Catch error: COMMON block and implicit interface external subprogram with same name
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Tue Jun 27 13:18:40 PDT 2023
Author: Peter Klausler
Date: 2023-06-27T13:18:30-07:00
New Revision: 1c900ed373983d52a230b6baf7bfb49eaec155a5
URL: https://github.com/llvm/llvm-project/commit/1c900ed373983d52a230b6baf7bfb49eaec155a5
DIFF: https://github.com/llvm/llvm-project/commit/1c900ed373983d52a230b6baf7bfb49eaec155a5.diff
LOG: [flang] Catch error: COMMON block and implicit interface external subprogram 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 https://github.com/llvm/llvm-project/issues/63247.
Differential Revision: https://reviews.llvm.org/D153786
Added:
Modified:
flang/lib/Semantics/check-declarations.cpp
flang/test/Semantics/declarations04.f90
Removed:
################################################################################
diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp
index baf7af2b60611..24ee1b240115c 100644
--- a/flang/lib/Semantics/check-declarations.cpp
+++ b/flang/lib/Semantics/check-declarations.cpp
@@ -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))) {
diff --git a/flang/test/Semantics/declarations04.f90 b/flang/test/Semantics/declarations04.f90
index f061cb9e5300f..6b33578ca9c05 100644
--- a/flang/test/Semantics/declarations04.f90
+++ b/flang/test/Semantics/declarations04.f90
@@ -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
More information about the flang-commits
mailing list