[flang-commits] [PATCH] D119564: [flang] Ensure a characterized ENTRY in a PURE subprogram is also marked PURE
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Fri Feb 11 10:48:59 PST 2022
klausler created this revision.
klausler added a reviewer: mleair.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
klausler requested review of this revision.
ENTRY point symbols aren't marked PURE in the symbol table, but must
instead inherit the attribute from their containing subprograms.
There's a predicate in semantics that does this, but it wasn't being
used in the context of actual procedure argument characterization.
https://reviews.llvm.org/D119564
Files:
flang/lib/Evaluate/characteristics.cpp
Index: flang/lib/Evaluate/characteristics.cpp
===================================================================
--- flang/lib/Evaluate/characteristics.cpp
+++ flang/lib/Evaluate/characteristics.cpp
@@ -371,13 +371,13 @@
seenProcs.insert(symbol);
CopyAttrs<Procedure, Procedure::Attr>(symbol, result,
{
- {semantics::Attr::PURE, Procedure::Attr::Pure},
{semantics::Attr::ELEMENTAL, Procedure::Attr::Elemental},
{semantics::Attr::BIND_C, Procedure::Attr::BindC},
});
- if (result.attrs.test(Procedure::Attr::Elemental) &&
- !symbol.attrs().test(semantics::Attr::IMPURE)) {
- result.attrs.set(Procedure::Attr::Pure); // explicitly flag pure procedures
+ if (IsPureProcedure(symbol) || // works for ENTRY too
+ (!symbol.attrs().test(semantics::Attr::IMPURE) &&
+ result.attrs.test(Procedure::Attr::Elemental))) {
+ result.attrs.set(Procedure::Attr::Pure);
}
return std::visit(
common::visitors{
@@ -809,8 +809,8 @@
std::optional<Procedure> Procedure::Characterize(
const ProcedureDesignator &proc, FoldingContext &context) {
if (const auto *symbol{proc.GetSymbol()}) {
- if (auto result{characteristics::Procedure::Characterize(
- ResolveAssociations(*symbol), context)}) {
+ if (auto result{
+ characteristics::Procedure::Characterize(*symbol, context)}) {
return result;
}
} else if (const auto *intrinsic{proc.GetSpecificIntrinsic()}) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119564.407951.patch
Type: text/x-patch
Size: 1481 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220211/9f437627/attachment.bin>
More information about the flang-commits
mailing list