Files
clang-p2996/flang/test/Lower/pointer.f90
Valentin Clement a1425019e7 [flang] Lower more pointer assignments/disassociation cases
This patch lowers more cases of pointer assignments and
disassociations.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld, schweitz

Differential Revision: https://reviews.llvm.org/D121697

Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: mleair <leairmark@gmail.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2022-03-15 21:58:33 +01:00

46 lines
2.3 KiB
Fortran

! RUN: bbc -emit-fir %s -o - | FileCheck %s
! TODO: Descriptor (fir.box) will most likely be used for pointers
! (at least for the character case below). This code is hitting a
! hard todo until pointers are handled correctly.
! XFAIL: true
! CHECK-LABEL: func @_QPpointertests
subroutine pointerTests
! CHECK: fir.global internal @_QFpointertestsEptr1 : !fir.ptr<i32>
integer, pointer :: ptr1 => NULL()
! CHECK: %[[c0:.*]] = arith.constant 0 : index
! CHECK: [[reg1:%[0-9]+]] = fir.convert %[[c0:.*]] : (index) -> !fir.ref<none>
! CHECK: [[reg2:%[0-9]+]] = fir.convert [[reg1]] : (!fir.ref<none>) -> !fir.ptr<i32>
! CHECK: fir.has_value [[reg2]] : !fir.ptr<i32>
! CHECK: fir.global internal @_QFpointertestsEptr2 : !fir.ptr<f32>
real, pointer :: ptr2 => NULL()
! CHECK: %[[c0:.*]] = arith.constant 0 : index
! CHECK: [[reg1:%[0-9]+]] = fir.convert %[[c0:.*]] : (index) -> !fir.ref<none>
! CHECK: [[reg2:%[0-9]+]] = fir.convert [[reg1]] : (!fir.ref<none>) -> !fir.ptr<f32>
! CHECK: fir.has_value [[reg2]] : !fir.ptr<f32>
! CHECK: fir.global internal @_QFpointertestsEptr3 : !fir.ptr<!fir.complex<4>>
complex, pointer :: ptr3 => NULL()
! CHECK: %[[c0:.*]] = arith.constant 0 : index
! CHECK: [[reg1:%[0-9]+]] = fir.convert %[[c0:.*]] : (index) -> !fir.ref<none>
! CHECK: [[reg2:%[0-9]+]] = fir.convert [[reg1]] : (!fir.ref<none>) -> !fir.ptr<!fir.complex<4>>
! CHECK: fir.has_value [[reg2]] : !fir.ptr<!fir.complex<4>>
! CHECK: fir.global internal @_QFpointertestsEptr4 : !fir.ptr<!fir.char<1,?>>
character(:), pointer :: ptr4 => NULL()
! CHECK: %[[c0:.*]] = arith.constant 0 : index
! CHECK: [[reg1:%[0-9]+]] = fir.convert %[[c0:.*]] : (index) -> !fir.ref<none>
! CHECK: [[reg2:%[0-9]+]] = fir.convert [[reg1]] : (!fir.ref<none>) -> !fir.ptr<!fir.char<1,?>>
! CHECK: fir.has_value [[reg2]] : !fir.ptr<!fir.char<1,?>>
! CHECK: fir.global internal @_QFpointertestsEptr5 : !fir.ptr<!fir.logical<4>>
logical, pointer :: ptr5 => NULL()
! CHECK: %[[c0:.*]] = arith.constant 0 : index
! CHECK: [[reg1:%[0-9]+]] = fir.convert %[[c0:.*]] : (index) -> !fir.ref<none>
! CHECK: [[reg2:%[0-9]+]] = fir.convert [[reg1]] : (!fir.ref<none>) -> !fir.ptr<!fir.logical<4>>
! CHECK: fir.has_value [[reg2]] : !fir.ptr<!fir.logical<4>>
end subroutine pointerTests