[AMDGPU] Test codegen'ing True16 additions.
[llvm-project.git] / flang / test / Semantics / c_loc01.f90
blob774ebc2f382e92a40a0d1eda08b63109f5b9d054
1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 module m
3 use iso_c_binding
4 type haslen(L)
5 integer, len :: L
6 end type
7 contains
8 subroutine test(assumedType, poly, nclen)
9 type(*), target :: assumedType
10 class(*), target :: poly
11 type(c_ptr) cp
12 type(c_funptr) cfp
13 real notATarget
14 !PORTABILITY: Procedure pointer 'pptr' should not have an ELEMENTAL intrinsic as its interface
15 procedure(sin), pointer :: pptr
16 real, target :: arr(3)
17 type(hasLen(1)), target :: clen
18 type(hasLen(*)), target :: nclen
19 character(2), target :: ch
20 !ERROR: C_LOC() argument must be a data pointer or target
21 cp = c_loc(notATarget)
22 !ERROR: C_LOC() argument must be a data pointer or target
23 cp = c_loc(pptr)
24 !ERROR: C_LOC() argument must be contiguous
25 cp = c_loc(arr(1:3:2))
26 !ERROR: C_LOC() argument may not be a zero-sized array
27 cp = c_loc(arr(3:1))
28 !ERROR: C_LOC() argument must have an intrinsic type, assumed type, or non-polymorphic derived type with no non-constant length parameter
29 cp = c_loc(poly)
30 cp = c_loc(clen) ! ok
31 !ERROR: C_LOC() argument must have an intrinsic type, assumed type, or non-polymorphic derived type with no non-constant length parameter
32 cp = c_loc(nclen)
33 !ERROR: C_LOC() argument may not be zero-length character
34 cp = c_loc(ch(2:1))
35 !WARNING: C_LOC() argument has non-interoperable intrinsic type, kind, or length
36 cp = c_loc(ch)
37 cp = c_loc(ch(1:1)) ! ok)
38 !ERROR: PRIVATE name '__address' is only accessible within module '__fortran_builtins'
39 cp = c_ptr(0)
40 !ERROR: PRIVATE name '__address' is only accessible within module '__fortran_builtins'
41 cfp = c_funptr(0)
42 !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches operand types TYPE(c_ptr) and TYPE(c_funptr)
43 cp = cfp
44 !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches operand types TYPE(c_funptr) and TYPE(c_ptr)
45 cfp = cp
46 end
47 end module