[flang-commits] [flang] [flang] Don't crash on not-yet-implemented feature (PR #91368)

via flang-commits flang-commits at lists.llvm.org
Tue May 7 11:08:30 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-semantics

Author: Peter Klausler (klausler)

<details>
<summary>Changes</summary>

A procedure pointer can be initialized in a DATA statement, but semantics crashes if the initializer is the name of an intrinsic function.  This patch fixes that crash so that compilation survives to the point where lowering admits that it doesn't yet support the feature.

---
Full diff: https://github.com/llvm/llvm-project/pull/91368.diff


1 Files Affected:

- (modified) flang/lib/Semantics/data-to-inits.cpp (+7-1) 


``````````diff
diff --git a/flang/lib/Semantics/data-to-inits.cpp b/flang/lib/Semantics/data-to-inits.cpp
index 64050874bcdec..605a9f10712e7 100644
--- a/flang/lib/Semantics/data-to-inits.cpp
+++ b/flang/lib/Semantics/data-to-inits.cpp
@@ -903,7 +903,13 @@ void ConstructInitializer(const Symbol &symbol,
       if (const auto *procDesignator{
               std::get_if<evaluate::ProcedureDesignator>(&expr->u)}) {
         CHECK(!procDesignator->GetComponent());
-        mutableProc.set_init(DEREF(procDesignator->GetSymbol()));
+        if (const auto *intrin{procDesignator->GetSpecificIntrinsic()}) {
+          const Symbol *intrinSymbol{
+              symbol.owner().FindSymbol(SourceName{intrin->name})};
+          mutableProc.set_init(DEREF(intrinSymbol));
+        } else {
+          mutableProc.set_init(DEREF(procDesignator->GetSymbol()));
+        }
       } else {
         CHECK(evaluate::IsNullProcedurePointer(*expr));
         mutableProc.set_init(nullptr);

``````````

</details>


https://github.com/llvm/llvm-project/pull/91368


More information about the flang-commits mailing list