File: c_loc01.f90

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,998,492 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (65 lines) | stat: -rw-r--r-- 2,469 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic
module m
  use iso_c_binding
  type haslen(L)
    integer, len :: L
  end type
  integer, target :: targ
 contains
  subroutine subr
  end
  subroutine test(assumedType, poly, nclen, n)
    type(*), target :: assumedType
    class(*), target ::  poly
    type(c_ptr) cp
    type(c_funptr) cfp
    real notATarget
    !PORTABILITY: Procedure pointer 'pptr' should not have an ELEMENTAL intrinsic as its interface
    procedure(sin), pointer :: pptr
    real, target :: arr(3)
    type(hasLen(1)), target :: clen
    type(hasLen(*)), target :: nclen
    integer, intent(in) :: n
    character(2), target :: ch
    real :: arr1(purefun1(c_loc(targ))) ! ok
    real :: arr2(purefun2(c_funloc(subr))) ! ok
    character(:), allocatable, target :: deferred
    character(n), pointer :: p2ch
    !ERROR: C_LOC() argument must be a data pointer or target
    cp = c_loc(notATarget)
    !ERROR: C_LOC() argument must be a data pointer or target
    cp = c_loc(pptr)
    !ERROR: C_LOC() argument must be contiguous
    cp = c_loc(arr(1:3:2))
    !ERROR: C_LOC() argument may not be a zero-sized array
    cp = c_loc(arr(3:1))
    !ERROR: C_LOC() argument must have an intrinsic type, assumed type, or non-polymorphic derived type with no non-constant length parameter
    cp = c_loc(poly)
    cp = c_loc(clen) ! ok
    !ERROR: C_LOC() argument must have an intrinsic type, assumed type, or non-polymorphic derived type with no non-constant length parameter
    cp = c_loc(nclen)
    !ERROR: C_LOC() argument may not be zero-length character
    cp = c_loc(ch(2:1))
    !WARNING: C_LOC() argument has non-interoperable intrinsic type, kind, or length
    cp = c_loc(ch)
    cp = c_loc(ch(1:1)) ! ok
    cp = c_loc(deferred) ! ok
    cp = c_loc(p2ch) ! ok
    !ERROR: PRIVATE name '__address' is only accessible within module '__fortran_builtins'
    cp = c_ptr(0)
    !ERROR: PRIVATE name '__address' is only accessible within module '__fortran_builtins'
    cfp = c_funptr(0)
    !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches operand types TYPE(c_ptr) and TYPE(c_funptr)
    cp = cfp
    !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches operand types TYPE(c_funptr) and TYPE(c_ptr)
    cfp = cp
  end
  pure integer function purefun1(p)
    type(c_ptr), intent(in) :: p
    purefun1 = 1
  end
  pure integer function purefun2(p)
    type(c_funptr), intent(in) :: p
    purefun2 = 1
  end
end module