[flang-commits] [flang] 7e4ac85 - [Flang] Use specific symbol rather than generic symbol as procInterface to declare procedure pointer. (#80738)
via flang-commits
flang-commits at lists.llvm.org
Wed Feb 7 08:36:30 PST 2024
Author: Daniel Chen
Date: 2024-02-07T11:36:26-05:00
New Revision: 7e4ac8541dcc389ca8f0d11614e19ea7bae07af7
URL: https://github.com/llvm/llvm-project/commit/7e4ac8541dcc389ca8f0d11614e19ea7bae07af7
DIFF: https://github.com/llvm/llvm-project/commit/7e4ac8541dcc389ca8f0d11614e19ea7bae07af7.diff
LOG: [Flang] Use specific symbol rather than generic symbol as procInterface to declare procedure pointer. (#80738)
Flang crashes when lowering the type of `p1` with the following code.
The problem is when it sets up the `procInterface`, 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
```
Added:
Modified:
flang/lib/Semantics/resolve-names.cpp
Removed:
################################################################################
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