Skip to content

[flang] handle intrinsic interfaces in FunctionRef::GetType #89583

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

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions flang/include/flang/Evaluate/call.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,18 @@ template <typename A> class FunctionRef : public ProcedureRef {
: ProcedureRef{std::move(p), std::move(a)} {}

std::optional<DynamicType> GetType() const {
if (auto type{proc_.GetType()}) {
if constexpr (IsLengthlessIntrinsicType<A>) {
return A::GetType();
} else if (auto type{proc_.GetType()}) {
// TODO: Non constant explicit length parameters of PDTs result should
// likely be dropped too. This is not as easy as for characters since some
// long lived DerivedTypeSpec pointer would need to be created here. It is
// not clear if this is causing any issue so far since the storage size of
// PDTs is independent of length parameters.
return type->DropNonConstantCharacterLength();
} else {
return std::nullopt;
}
return std::nullopt;
}
};
} // namespace Fortran::evaluate
Expand Down
13 changes: 13 additions & 0 deletions flang/test/Lower/HLFIR/calls-f77.f90
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,16 @@ subroutine alternate_return_call(n1, n2, k)
! CHECK: ^[[block2]]: // pred: ^bb0
7 k = 1; return
end

! -----------------------------------------------------------------------------
! Test calls to user procedures with intrinsic interfaces
! -----------------------------------------------------------------------------

! CHECK-NAME: func.func @_QPintrinsic_iface()
subroutine intrinsic_iface()
intrinsic acos
real :: x
procedure(acos) :: proc
x = proc(1.0)
end subroutine
! CHECK" fir.call @_QPproc(%{{.*}}) {{.*}}: (!fir.ref<f32>) -> f32