[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
Mon Feb 14 15:34:54 PST 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG882d5f14adab: [flang] Ensure a characterized ENTRY in a PURE subprogram is also marked PURE (authored by klausler).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119564/new/

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.408647.patch
Type: text/x-patch
Size: 1481 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220214/5862f106/attachment-0001.bin>


More information about the flang-commits mailing list