-
Notifications
You must be signed in to change notification settings - Fork 13.7k
[flang] Accept proc ptr function result as actual argument without IN… #128771
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
Conversation
@llvm/pr-subscribers-flang-semantics Author: Peter Klausler (klausler) Changes…TENT A dummy procedure pointer with no INTENT attribute may associate with an actual argument that is the result of a reference to a function that returns a procedure pointer, we think. Fixes #126950. Full diff: https://github.com/llvm/llvm-project/pull/128771.diff 2 Files Affected:
diff --git a/flang/lib/Semantics/check-call.cpp b/flang/lib/Semantics/check-call.cpp
index e396ece303103..4a421dcc75b7d 100644
--- a/flang/lib/Semantics/check-call.cpp
+++ b/flang/lib/Semantics/check-call.cpp
@@ -1185,7 +1185,7 @@ static void CheckProcedureArg(evaluate::ActualArgument &arg,
dummyName);
}
} else if (!(dummy.intent == common::Intent::Default &&
- IsNullProcedurePointer(*expr))) {
+ IsProcedurePointer(*expr))) {
// 15.5.2.9(5) -- dummy procedure POINTER
// Interface compatibility has already been checked above
messages.Say(
diff --git a/flang/test/Semantics/call09.f90 b/flang/test/Semantics/call09.f90
index b8583ba4a4907..79fbff14e8a1b 100644
--- a/flang/test/Semantics/call09.f90
+++ b/flang/test/Semantics/call09.f90
@@ -87,8 +87,7 @@ subroutine test1 ! 15.5.2.9(5)
call s02(p) ! ok
!ERROR: Actual procedure argument has interface incompatible with dummy argument 'p=': function results have distinct types: REAL(4) vs INTEGER(4)
call s02(ip)
- !ERROR: Actual argument associated with procedure pointer dummy argument 'p=' must be a pointer unless INTENT(IN)
- call s02(procptr())
+ call s02(procptr()) ! believed to be ok
call s02(null()) ! ok
!ERROR: Actual argument associated with procedure pointer dummy argument 'p=' must be a pointer unless INTENT(IN)
call s05(null())
@@ -99,8 +98,7 @@ subroutine test1 ! 15.5.2.9(5)
call s02b(p) ! ok
!ERROR: Actual argument function associated with procedure dummy argument 'p=' is not compatible: function results have distinct types: REAL(4) vs INTEGER(4)
call s02b(ip)
- !ERROR: Actual argument associated with procedure pointer dummy argument 'p=' must be a pointer unless INTENT(IN)
- call s02b(procptr())
+ call s02b(procptr()) ! believed to be ok
call s02b(null())
!ERROR: Actual argument associated with procedure pointer dummy argument 'p=' must be a pointer unless INTENT(IN)
call s02b(sin)
|
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.
I added intent(inout)
to the test case and got
./t4.f:12:16: error: Actual argument associated with procedure pointer dummy argument 'p=' must be a pointer unless INTENT(IN)
call test1(genF1(1))
^^^^^^^^
May be ... must be a pointer for INTENT(INOUT).
Just a nit.
Thanks for fixing it.
No. |
I added the following in the issue, and it is the reason I was thinking of the message text change. The standard does say the following for INTENT(OUT) and INTENT(INOUT)
So I think it should be the same for all non-definable actual argument, the check should be on the presence of those two intents rather than missing INTENT(IN). |
…TENT A dummy procedure pointer with no INTENT attribute may associate with an actual argument that is the result of a reference to a function that returns a procedure pointer, we think. Fixes llvm#126950.
llvm#128771) …TENT A dummy procedure pointer with no INTENT attribute may associate with an actual argument that is the result of a reference to a function that returns a procedure pointer, we think. Fixes llvm#126950.
…TENT
A dummy procedure pointer with no INTENT attribute may associate with an actual argument that is the result of a reference to a function that returns a procedure pointer, we think.
Fixes #126950.