File: iso_c_binding_rename_1.f03

package info (click to toggle)
gcc-arm-none-eabi 15%3A12.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 959,712 kB
  • sloc: cpp: 3,275,382; ansic: 2,061,766; ada: 840,956; f90: 208,513; makefile: 76,132; asm: 73,433; xml: 50,448; exp: 34,146; sh: 32,436; objc: 15,637; fortran: 14,012; python: 11,991; pascal: 6,787; awk: 4,779; perl: 3,054; yacc: 338; ml: 285; lex: 201; haskell: 122
file content (82 lines) | stat: -rw-r--r-- 2,363 bytes parent folder | download | duplicates (3)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
! { dg-do run }
! { dg-additional-sources iso_c_binding_rename_1_driver.c }
module iso_c_binding_rename_0
  use, intrinsic :: iso_c_binding, only: my_c_ptr_0 => c_ptr, &
       c_associated
end module iso_c_binding_rename_0


module iso_c_binding_rename_1
  ! rename a couple of the symbols from iso_c_binding.  the compiler 
  ! needs to be able to recognize the derived types with names different
  ! from the one in iso_c_binding because it will look up the derived types
  ! to define the args and return values of some of the procedures in 
  ! iso_c_binding.  this should verify that this functionality works.
  use, intrinsic :: iso_c_binding, my_c_int => c_int, my_c_ptr => c_ptr, &
       my_c_associated => c_associated, my_c_f_pointer => c_f_pointer

contains
  subroutine sub0(my_int) bind(c)
    integer(my_c_int), value :: my_int
    if(my_int .ne. 1) then
       STOP 1
    end if
  end subroutine sub0

  subroutine sub1(my_ptr) bind(c)
    type(my_c_ptr), value :: my_ptr

    if(.not. my_c_associated(my_ptr)) then
       STOP 2
    end if
  end subroutine sub1

  subroutine sub2(my_int, my_long) bind(c)
    use, intrinsic :: iso_c_binding, my_c_int_2 => c_int, &
         my_c_long_2 => c_long
    integer(my_c_int_2), value :: my_int
    integer(my_c_long_2), value :: my_long

    if(my_int .ne. 1) then
       STOP 3
    end if
    if(my_long .ne. 1) then
       STOP 4
    end if
  end subroutine sub2

  subroutine sub3(cptr1, cptr2) bind(c)
    type(my_c_ptr), value :: cptr1
    type(my_c_ptr), value :: cptr2
    integer(my_c_int), pointer :: my_f90_c_ptr

    if(.not. my_c_associated(cptr1)) then
       STOP 5
    end if

    if(.not. my_c_associated(cptr1, cptr2)) then
       STOP 6
    end if

    call my_c_f_pointer(cptr1, my_f90_c_ptr)
  end subroutine sub3

  subroutine sub4(cptr1, cptr2) bind(c)
    ! rename the my_c_ptr_0 from iso_c_binding_rename_0 just to further test
    ! both are actually aliases to c_ptr
    use iso_c_binding_rename_0, my_c_ptr_local => my_c_ptr_0, &
         my_c_associated_2 => c_associated

    implicit none
    type(my_c_ptr_local), value :: cptr1
    type(my_c_ptr_local), value :: cptr2

    if(.not. my_c_associated_2(cptr1)) then
       STOP 7
    end if
    
    if(.not. my_c_associated_2(cptr2)) then
       STOP 8
    end if
  end subroutine sub4
end module iso_c_binding_rename_1