[flang] Handle ENTRY names in IsPureProcedure() predicate
Fortran defines an ENTRY point name as being pure if its enclosing subprogram scope defines a pure procedure. Differential Revision: https://reviews.llvm.org/D113711
This commit is contained in:
parent
8cf674f12e
commit
ece17064b5
|
@ -1035,6 +1035,10 @@ namespace Fortran::semantics {
|
|||
|
||||
class Scope;
|
||||
|
||||
// If a symbol represents an ENTRY, return the symbol of the main entry
|
||||
// point to its subprogram.
|
||||
const Symbol *GetMainEntry(const Symbol *);
|
||||
|
||||
// These functions are used in Evaluate so they are defined here rather than in
|
||||
// Semantics to avoid a link-time dependency on Semantics.
|
||||
// All of these apply GetUltimate() or ResolveAssociations() to their arguments.
|
||||
|
|
|
@ -1031,6 +1031,19 @@ const Symbol &GetAssociationRoot(const Symbol &original) {
|
|||
return symbol;
|
||||
}
|
||||
|
||||
const Symbol *GetMainEntry(const Symbol *symbol) {
|
||||
if (symbol) {
|
||||
if (const auto *subpDetails{symbol->detailsIf<SubprogramDetails>()}) {
|
||||
if (const Scope * scope{subpDetails->entryScope()}) {
|
||||
if (const Symbol * main{scope->symbol()}) {
|
||||
return main;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return symbol;
|
||||
}
|
||||
|
||||
bool IsVariableName(const Symbol &original) {
|
||||
const Symbol &symbol{ResolveAssociations(original)};
|
||||
if (symbol.has<ObjectEntityDetails>()) {
|
||||
|
@ -1044,7 +1057,8 @@ bool IsVariableName(const Symbol &original) {
|
|||
}
|
||||
|
||||
bool IsPureProcedure(const Symbol &original) {
|
||||
const Symbol &symbol{original.GetUltimate()};
|
||||
// An ENTRY is pure if its containing subprogram is
|
||||
const Symbol &symbol{DEREF(GetMainEntry(&original.GetUltimate()))};
|
||||
if (const auto *procDetails{symbol.detailsIf<ProcEntityDetails>()}) {
|
||||
if (const Symbol * procInterface{procDetails->interface().symbol()}) {
|
||||
// procedure component with a pure interface
|
||||
|
|
Loading…
Reference in New Issue