[flang-commits] [flang] 882d5f1 - [flang] Ensure a characterized ENTRY in a PURE subprogram is also marked PURE
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Mon Feb 14 15:34:55 PST 2022
Author: Peter Klausler
Date: 2022-02-14T15:34:45-08:00
New Revision: 882d5f14adabdf642510cfe8e4a002833f585dda
URL: https://github.com/llvm/llvm-project/commit/882d5f14adabdf642510cfe8e4a002833f585dda
DIFF: https://github.com/llvm/llvm-project/commit/882d5f14adabdf642510cfe8e4a002833f585dda.diff
LOG: [flang] Ensure a characterized ENTRY in a PURE subprogram is also marked PURE
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.
Differential Revision: https://reviews.llvm.org/D119564
Added:
Modified:
flang/lib/Evaluate/characteristics.cpp
Removed:
################################################################################
diff --git a/flang/lib/Evaluate/characteristics.cpp b/flang/lib/Evaluate/characteristics.cpp
index fb2917af7b4d..c32c370f44c0 100644
--- a/flang/lib/Evaluate/characteristics.cpp
+++ b/flang/lib/Evaluate/characteristics.cpp
@@ -371,13 +371,13 @@ static std::optional<Procedure> CharacterizeProcedure(
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(
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()}) {
More information about the flang-commits
mailing list