-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Flang] Support passing a function that returns procedure pointer as actual corresponding to a procedure dummy. #80891
Conversation
@llvm/pr-subscribers-flang-fir-hlfir Author: Daniel Chen (DanielCChen) ChangesFlang crashes a with the following case. The problem is we missed the case when passing a reference to a function that returns a procedure pointer as actual that corresponds to a procedure dummy. This PR is to fix that.
Full diff: https://github.com/llvm/llvm-project/pull/80891.diff 1 Files Affected:
diff --git a/flang/lib/Lower/ConvertCall.cpp b/flang/lib/Lower/ConvertCall.cpp
index bb8fd2e945f43..bd6bd81117966 100644
--- a/flang/lib/Lower/ConvertCall.cpp
+++ b/flang/lib/Lower/ConvertCall.cpp
@@ -915,8 +915,10 @@ static PreparedDummyArgument preparePresentUserCallActualArgument(
// Handle procedure arguments (procedure pointers should go through
// prepareProcedurePointerActualArgument).
if (hlfir::isFortranProcedureValue(dummyType)) {
- // Procedure pointer actual to procedure dummy.
- if (actual.isProcedurePointer()) {
+ // Procedure pointer or function returns procedure pointer actual to
+ // procedure dummy.
+ if (actual.isProcedurePointer() ||
+ actual.getType().isa<fir::BoxProcType>()) {
actual = hlfir::derefPointersAndAllocatables(loc, builder, actual);
return PreparedDummyArgument{actual, /*cleanups=*/{}};
}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this, nit but otherwise LGTM.
5b02933
to
27866a3
Compare
…ctual corresponding to a procedure dummy.
27866a3
to
431d701
Compare
@jeanPerier Please let me know if you have some other cases in mind. I can try those to confirm if the fix of this PR is good or not. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank, LGTM
Flang crashes with the following case. The problem is we missed the case when passing a reference to a function that returns a procedure pointer as actual that corresponds to a procedure dummy. This PR is to fix that.