Files
clang-p2996/flang/test/Lower/pointer.f90
Valentin Clement 3de6b1ce0d [flang][NFC] Add pointer dummy arguments tests
This patch adds test for calls with POINTER dummy arguments on the caller side.

It also fixes some formatting error that was introduced when upstreaming
the other pointer tests.

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

Reviewed By: PeteSteinfeld

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
2022-03-22 20:57:15 +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