[flang-commits] [PATCH] D127430: [flang] Handle USE association in parse tree rewriting

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Mon Jun 13 16:26:41 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rGf472c099be07: [flang] Handle USE association in parse tree rewriting (authored by klausler).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127430

Files:
  flang/lib/Semantics/rewrite-parse-tree.cpp


Index: flang/lib/Semantics/rewrite-parse-tree.cpp
===================================================================
--- flang/lib/Semantics/rewrite-parse-tree.cpp
+++ flang/lib/Semantics/rewrite-parse-tree.cpp
@@ -79,6 +79,19 @@
   }
 }
 
+static bool ReturnsDataPointer(const Symbol &symbol) {
+  if (const Symbol * funcRes{FindFunctionResult(symbol)}) {
+    return IsPointer(*funcRes) && !IsProcedure(*funcRes);
+  } else if (const auto *generic{symbol.detailsIf<GenericDetails>()}) {
+    for (auto ref : generic->specificProcs()) {
+      if (ReturnsDataPointer(*ref)) {
+        return true;
+      }
+    }
+  }
+  return false;
+}
+
 // Find mis-parsed statement functions and move to stmtFuncsToConvert_ list.
 void RewriteMutator::Post(parser::SpecificationPart &x) {
   auto &list{std::get<std::list<parser::DeclarationConstruct>>(x.t)};
@@ -87,9 +100,9 @@
     if (auto *stmt{std::get_if<stmtFuncType>(&it->u)}) {
       if (const Symbol *
           symbol{std::get<parser::Name>(stmt->statement.value().t).symbol}) {
-        const Symbol *funcRes{FindFunctionResult(*symbol)};
-        isAssignment = symbol->has<ObjectEntityDetails>() ||
-            (funcRes && IsPointer(*funcRes) && !IsProcedure(*funcRes));
+        const Symbol &ultimate{symbol->GetUltimate()};
+        isAssignment =
+            ultimate.has<ObjectEntityDetails>() || ReturnsDataPointer(ultimate);
         if (isAssignment) {
           stmtFuncsToConvert_.emplace_back(std::move(*stmt));
         }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127430.436601.patch
Type: text/x-patch
Size: 1494 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220613/5905d665/attachment.bin>


More information about the flang-commits mailing list