[flang-commits] [flang] [Flang] Use specific symbol rather than generic symbol as proceInterface to declare procedure pointer. (PR #80738)

Daniel Chen via flang-commits flang-commits at lists.llvm.org
Mon Feb 5 12:14:00 PST 2024


https://github.com/DanielCChen created https://github.com/llvm/llvm-project/pull/80738

Flang crashes when lowering the type of `p1` with the following code. The problem is when it sets up the `proceInterface`, it uses the generic symbol `int`, not the specific `int`. This PR is to correct that.

```
  INTERFACE Int
    integer FUNCTION Int(arg)
      integer :: arg
    END FUNCTION
  END INTERFACE

  integer :: res
  procedure(int), pointer :: p1
  p1 => int
  res = p1(4)
  end
  ```

>From 0bd861af68e2e5cca6ce1bf627e095a12a00c82e Mon Sep 17 00:00:00 2001
From: cdchen-ca <cdchen at ca.ibm.com>
Date: Mon, 5 Feb 2024 15:07:44 -0500
Subject: [PATCH] [Flang] Use specific symbol rather than generic symbol in
 procedureInterface to declare procedure pointer.

---
 flang/lib/Semantics/resolve-names.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 6914f95837f67..36deab969456d 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -5648,7 +5648,9 @@ void DeclarationVisitor::Post(const parser::ProcDecl &x) {
   const auto &name{std::get<parser::Name>(x.t)};
   const Symbol *procInterface{nullptr};
   if (interfaceName_) {
-    procInterface = interfaceName_->symbol;
+    procInterface = interfaceName_->symbol->has<GenericDetails>()
+        ? interfaceName_->symbol->get<GenericDetails>().specific()
+        : interfaceName_->symbol;
   }
   auto attrs{HandleSaveName(name.source, GetAttrs())};
   DerivedTypeDetails *dtDetails{nullptr};



More information about the flang-commits mailing list