[flang-commits] [PATCH] D113711: [flang] Handle ENTRY names in IsPureProcedure() predicate
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Thu Nov 11 13:39:23 PST 2021
klausler created this revision.
klausler added a reviewer: schweitz.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
klausler requested review of this revision.
Fortran defines an ENTRY point name as being pure if its enclosing
subprogram scope defines a pure procedure.
https://reviews.llvm.org/D113711
Files:
flang/include/flang/Evaluate/tools.h
flang/lib/Evaluate/tools.cpp
Index: flang/lib/Evaluate/tools.cpp
===================================================================
--- flang/lib/Evaluate/tools.cpp
+++ flang/lib/Evaluate/tools.cpp
@@ -1031,6 +1031,19 @@
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 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
Index: flang/include/flang/Evaluate/tools.h
===================================================================
--- flang/include/flang/Evaluate/tools.h
+++ flang/include/flang/Evaluate/tools.h
@@ -1035,6 +1035,10 @@
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113711.386651.patch
Type: text/x-patch
Size: 1759 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20211111/263c90fe/attachment.bin>
More information about the flang-commits
mailing list