1 ! RUN: %python %S/test_errors.py %s %flang_fc1
5 use iso_c_binding
, only
: c_ptr
, c_f_pointer
6 type(c_ptr
) :: scalarC
, arrayC(1)
10 type(with_pointer
) :: coindexed
[*]
11 integer, pointer :: scalarIntF
, arrayIntF(:), multiDimIntF(:,:)
12 character(len
=:), pointer :: charDeferredF
14 integer, dimension(2, 2) :: rankTwoArray
15 rankTwoArray
= reshape([1, 2, 3, 4], shape(rankTwoArray
))
16 call c_f_pointer(scalarC
, scalarIntF
) ! ok
17 call c_f_pointer(scalarC
, arrayIntF
, [1_8]) ! ok
18 call c_f_pointer(shape
=[1_8], cptr
=scalarC
, fptr
=arrayIntF
) ! ok
19 call c_f_pointer(scalarC
, shape
=[1_8], fptr
=arrayIntF
) ! ok
20 !ERROR: A positional actual argument may not appear after any keyword arguments
21 call c_f_pointer(scalarC
, fptr
=arrayIntF
, [1_8])
22 !ERROR: CPTR= argument to C_F_POINTER() must be a C_PTR
23 call c_f_pointer(j
, scalarIntF
)
24 !ERROR: Rank of dummy argument is 0, but actual argument has rank 1
25 call c_f_pointer(arrayC
, scalarIntF
)
26 !ERROR: SHAPE= argument to C_F_POINTER() must appear when FPTR= is an array
27 call c_f_pointer(scalarC
, arrayIntF
)
28 !ERROR: SHAPE= argument to C_F_POINTER() may not appear when FPTR= is scalar
29 call c_f_pointer(scalarC
, scalarIntF
, [1_8])
30 !ERROR: FPTR= argument to C_F_POINTER() may not have a deferred type parameter
31 call c_f_pointer(scalarC
, charDeferredF
)
32 !ERROR: FPTR= argument to C_F_POINTER() may not be a coindexed object
33 call c_f_pointer(scalarC
, coindexed
[0]%p
)
34 !ERROR: FPTR= argument to C_F_POINTER() must have a type
35 call c_f_pointer(scalarC
, null())
36 !ERROR: SHAPE= argument to C_F_POINTER() must have size equal to the rank of FPTR=
37 call c_f_pointer(scalarC
, multiDimIntF
, shape
=[1_8])
38 !ERROR: SHAPE= argument to C_F_POINTER() must be a rank-one array.
39 call c_f_pointer(scalarC
, multiDimIntF
, shape
=rankTwoArray
)