1 ! RUN: bbc -emit-fir %s -o - | FileCheck %s
3 ! TODO: Descriptor (fir.box) will most likely be used for pointers
4 ! (at least for the character case below). This code is hitting a
5 ! hard todo until pointers are handled correctly.
8 ! CHECK-LABEL: func @_QPpointertests
9 subroutine pointerTests
10 ! CHECK: fir.global internal @_QFpointertestsEptr1 : !fir.ptr<i32>
11 integer, pointer :: ptr1
=> NULL()
12 ! CHECK: %[[c0:.*]] = arith.constant 0 : index
13 ! CHECK: [[reg1:%[0-9]+]] = fir.convert %[[c0:.*]] : (index) -> !fir.ref<none>
14 ! CHECK: [[reg2:%[0-9]+]] = fir.convert [[reg1]] : (!fir.ref<none>) -> !fir.ptr<i32>
15 ! CHECK: fir.has_value [[reg2]] : !fir.ptr<i32>
17 ! CHECK: fir.global internal @_QFpointertestsEptr2 : !fir.ptr<f32>
18 real, pointer :: ptr2
=> NULL()
19 ! CHECK: %[[c0:.*]] = arith.constant 0 : index
20 ! CHECK: [[reg1:%[0-9]+]] = fir.convert %[[c0:.*]] : (index) -> !fir.ref<none>
21 ! CHECK: [[reg2:%[0-9]+]] = fir.convert [[reg1]] : (!fir.ref<none>) -> !fir.ptr<f32>
22 ! CHECK: fir.has_value [[reg2]] : !fir.ptr<f32>
24 ! CHECK: fir.global internal @_QFpointertestsEptr3 : !fir.ptr<!fir.complex<4>>
25 complex, pointer :: ptr3
=> NULL()
26 ! CHECK: %[[c0:.*]] = arith.constant 0 : index
27 ! CHECK: [[reg1:%[0-9]+]] = fir.convert %[[c0:.*]] : (index) -> !fir.ref<none>
28 ! CHECK: [[reg2:%[0-9]+]] = fir.convert [[reg1]] : (!fir.ref<none>) -> !fir.ptr<!fir.complex<4>>
29 ! CHECK: fir.has_value [[reg2]] : !fir.ptr<!fir.complex<4>>
31 ! CHECK: fir.global internal @_QFpointertestsEptr4 : !fir.ptr<!fir.char<1,?>>
32 character(:), pointer :: ptr4
=> NULL()
33 ! CHECK: %[[c0:.*]] = arith.constant 0 : index
34 ! CHECK: [[reg1:%[0-9]+]] = fir.convert %[[c0:.*]] : (index) -> !fir.ref<none>
35 ! CHECK: [[reg2:%[0-9]+]] = fir.convert [[reg1]] : (!fir.ref<none>) -> !fir.ptr<!fir.char<1,?>>
36 ! CHECK: fir.has_value [[reg2]] : !fir.ptr<!fir.char<1,?>>
38 ! CHECK: fir.global internal @_QFpointertestsEptr5 : !fir.ptr<!fir.logical<4>>
39 logical, pointer :: ptr5
=> NULL()
40 ! CHECK: %[[c0:.*]] = arith.constant 0 : index
41 ! CHECK: [[reg1:%[0-9]+]] = fir.convert %[[c0:.*]] : (index) -> !fir.ref<none>
42 ! CHECK: [[reg2:%[0-9]+]] = fir.convert [[reg1]] : (!fir.ref<none>) -> !fir.ptr<!fir.logical<4>>
43 ! CHECK: fir.has_value [[reg2]] : !fir.ptr<!fir.logical<4>>
45 end subroutine pointerTests