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

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Tue May 7 11:07:53 PDT 2024


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

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.

>From 8ef58d9bb4a9d3d05905d12ec906ffd857c3b129 Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Tue, 7 May 2024 11:04:32 -0700
Subject: [PATCH] [flang] Don't crash on not-yet-implemented feature

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.
---
 flang/lib/Semantics/data-to-inits.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/flang/lib/Semantics/data-to-inits.cpp b/flang/lib/Semantics/data-to-inits.cpp
index 64050874bcdecb..605a9f10712e79 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);



More information about the flang-commits mailing list