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

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


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-semantics

Author: Daniel Chen (DanielCChen)

<details>
<summary>Changes</summary>

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
  ```

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


1 Files Affected:

- (modified) flang/lib/Semantics/resolve-names.cpp (+3-1) 


``````````diff
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 6914f95837f676..36deab969456d0 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};

``````````

</details>


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


More information about the flang-commits mailing list