Skip to content

Commit 5ffa159

Browse files
Restored CheckHelper::CheckGlobalName() to original implementation.
Instead, added IsAlternateEntry() and modified IsExternalProcedureDefinition().
1 parent 440fe5c commit 5ffa159

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

flang/include/flang/Evaluate/tools.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,6 +1531,15 @@ class Scope;
15311531
// point to its subprogram.
15321532
const Symbol *GetMainEntry(const Symbol *);
15331533

1534+
inline bool IsAlternateEntry(const Symbol *symbol) {
1535+
// If symbol is not alternate entry symbol, GetMainEntry() returns the same
1536+
// symbol.
1537+
return symbol && GetMainEntry(symbol) != symbol;
1538+
}
1539+
inline bool IsAlternateEntry(const Symbol &symbol) {
1540+
return IsAlternateEntry(&symbol);
1541+
}
1542+
15341543
// These functions are used in Evaluate so they are defined here rather than in
15351544
// Semantics to avoid a link-time dependency on Semantics.
15361545
// All of these apply GetUltimate() or ResolveAssociations() to their arguments.

flang/lib/Semantics/check-declarations.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2950,7 +2950,7 @@ static bool IsSubprogramDefinition(const Symbol &symbol) {
29502950

29512951
static bool IsExternalProcedureDefinition(const Symbol &symbol) {
29522952
return IsBlockData(symbol) ||
2953-
(IsSubprogramDefinition(symbol) &&
2953+
((IsSubprogramDefinition(symbol) || IsAlternateEntry(symbol)) &&
29542954
(IsExternal(symbol) || symbol.GetBindName()));
29552955
}
29562956

@@ -2997,12 +2997,9 @@ void CheckHelper::CheckGlobalName(const Symbol &symbol) {
29972997
// they're not in the same scope.
29982998
} else if ((IsProcedure(symbol) || IsBlockData(symbol)) &&
29992999
(IsProcedure(other) || IsBlockData(other)) &&
3000-
(!(IsExternalProcedureDefinition(symbol) || GetMainEntry(&symbol)) ||
3001-
!(IsExternalProcedureDefinition(other) ||
3002-
GetMainEntry(&other)))) {
3003-
// Both are procedures/BLOCK DATA, not both definitions.
3004-
// Note: GetMainEntry() above returns non-null in case symbol
3005-
// is an alternate entry.
3000+
(!IsExternalProcedureDefinition(symbol) ||
3001+
!IsExternalProcedureDefinition(other))) {
3002+
// both are procedures/BLOCK DATA, not both definitions
30063003
} else if (IsSameSymbolFromHermeticModule(symbol, other)) {
30073004
// Both symbols are the same thing.
30083005
} else if (symbol.has<ModuleDetails>()) {

0 commit comments

Comments
 (0)