xref: /llvm-project/flang/test/Semantics/bind-c09.f90 (revision ab7930bd9f088c4fcdfd438b5207a4052c9669b8)
12d6e2802SPeixin Qiao! RUN: %python %S/test_errors.py %s %flang_fc1
22d6e2802SPeixin Qiao! Check for C1553 and 18.3.4(1)
32d6e2802SPeixin Qiao
42d6e2802SPeixin Qiaofunction func1() result(res) bind(c)
5*ab7930bdSPeter Klausler  ! ERROR: Interoperable function result may not have ALLOCATABLE or POINTER attribute
62d6e2802SPeixin Qiao  integer, pointer :: res
72d6e2802SPeixin Qiaoend
82d6e2802SPeixin Qiao
92d6e2802SPeixin Qiaofunction func2() result(res) bind(c)
10*ab7930bdSPeter Klausler  ! ERROR: Interoperable function result may not have ALLOCATABLE or POINTER attribute
112d6e2802SPeixin Qiao  integer, allocatable :: res
122d6e2802SPeixin Qiaoend
132d6e2802SPeixin Qiao
142d6e2802SPeixin Qiaofunction func3() result(res) bind(c)
15*ab7930bdSPeter Klausler  !ERROR: Interoperable function result must be scalar
162d6e2802SPeixin Qiao  integer :: res(2)
172d6e2802SPeixin Qiaoend
182d6e2802SPeixin Qiao
192d6e2802SPeixin Qiaofunction func4() result(res) bind(c)
20*ab7930bdSPeter Klausler  ! ERROR: Interoperable character function result must have length one
212d6e2802SPeixin Qiao  character(*) :: res
222d6e2802SPeixin Qiaoend
232d6e2802SPeixin Qiao
242d6e2802SPeixin Qiaofunction func5(n) result(res) bind(c)
252d6e2802SPeixin Qiao  integer :: n
26*ab7930bdSPeter Klausler  ! ERROR: Interoperable character function result must have length one
272d6e2802SPeixin Qiao  character(n) :: res
282d6e2802SPeixin Qiaoend
292d6e2802SPeixin Qiao
302d6e2802SPeixin Qiaofunction func6() result(res) bind(c)
31*ab7930bdSPeter Klausler  ! ERROR: Interoperable character function result must have length one
322d6e2802SPeixin Qiao  character(2) :: res
332d6e2802SPeixin Qiaoend
342d6e2802SPeixin Qiao
352d6e2802SPeixin Qiaofunction func7() result(res) bind(c)
362d6e2802SPeixin Qiao  integer, parameter :: n = 1
372d6e2802SPeixin Qiao  character(n) :: res ! OK
382d6e2802SPeixin Qiaoend
392d6e2802SPeixin Qiao
402d6e2802SPeixin Qiaofunction func8() result(res) bind(c)
41*ab7930bdSPeter Klausler  ! ERROR: Interoperable function result may not have ALLOCATABLE or POINTER attribute
42*ab7930bdSPeter Klausler  ! ERROR: Interoperable character function result must have length one
432d6e2802SPeixin Qiao  character(:), pointer :: res
442d6e2802SPeixin Qiaoend
452d6e2802SPeixin Qiao
462d6e2802SPeixin Qiaofunction func9() result(res) bind(c)
47*ab7930bdSPeter Klausler  ! ERROR: Interoperable function result may not be a coarray
482d6e2802SPeixin Qiao  integer :: res[10, *]
492d6e2802SPeixin Qiaoend
50