[flang] Add support for lowering intrinsic module procedure C_ASSOCIATED
authorPeixin-Qiao <qiaopeixin@huawei.com>
Wed, 26 Oct 2022 01:09:38 +0000 (09:09 +0800)
committerPeixin-Qiao <qiaopeixin@huawei.com>
Wed, 26 Oct 2022 01:09:38 +0000 (09:09 +0800)
commitb385395c97e1422ddd83e9cd3b93c6b15fbadc6e
treef6c1af337e6ee049a27e510e9d9910ff02fcb726
parentd24c93cc4107dca68a2760199e970cb04cdeed90
[flang] Add support for lowering intrinsic module procedure C_ASSOCIATED

As Fortran 2018 18.2.3.2, the arguments of C_ASSOCIATED have the same
type, a scalar of type C_PTR or C_FUNPTR, and the result has the default
logical scalar type. The interface is defined with two module procedures
c_associated_c_ptr/c_associated_c_funptr in flang/module/iso_c_binding.
The result is false if the first argument is a C null pointer. If the
second argument is present, the result is true only if the two arguments
are equal. Support the lowering by comparing the C pointer address
values of two arguments if the second argument is dynamically present
and comparing the C pointer address value of the first argument with the
value 0.

Reviewed By: jeanPerier

Differential Revision: https://reviews.llvm.org/D136419
flang/include/flang/Optimizer/Builder/FIRBuilder.h
flang/lib/Lower/IntrinsicCall.cpp
flang/lib/Optimizer/Builder/FIRBuilder.cpp
flang/test/Lower/Intrinsics/c_associated.f90 [new file with mode: 0644]