aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/bind_c_usage_25.f90
blob: ae3cf07fcb8ef8b183c9b23aa92b4c94181601bf (plain)
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
! { dg-do compile }
! { dg-options "-Wno-c-binding-type" }
!
! That's a copy of "bind_c_usage_8.f03", "bind_c_dts_4.f03",
! "bind_c_implicit_vars.f03" and "c_kind_tests_2.f03"
! to check that with -Wno-c-binding-type no warning is printed.
!

MODULE ISO_C_UTILITIES
   USE ISO_C_BINDING
   implicit none
   CHARACTER(C_CHAR), DIMENSION(1), SAVE, TARGET, PRIVATE :: dummy_string="?"
CONTAINS
   FUNCTION C_F_STRING(CPTR) RESULT(FPTR)
     use, intrinsic :: iso_c_binding
      TYPE(C_PTR), INTENT(IN) :: CPTR ! The C address
      CHARACTER(KIND=C_CHAR), DIMENSION(:), POINTER :: FPTR
      INTERFACE
         FUNCTION strlen(string) RESULT(len) BIND(C,NAME="strlen")
            USE ISO_C_BINDING
            TYPE(C_PTR), VALUE :: string ! A C pointer
         END FUNCTION
      END INTERFACE
      CALL C_F_POINTER(FPTR=FPTR, CPTR=CPTR, SHAPE=[strlen(CPTR)])
   END FUNCTION
END MODULE ISO_C_UTILITIES

module test
use iso_c_binding, only: c_int
    type, bind(c) ::  foo
      integer :: p
    end type
    type(foo), bind(c) :: cp
end module test

module bind_c_implicit_vars

bind(c) :: j

contains
  subroutine sub0(i) bind(c)
    i = 0
  end subroutine sub0
end module bind_c_implicit_vars

module c_kind_tests_2
  use, intrinsic :: iso_c_binding

  integer, parameter :: myF = c_float
  real(myF), bind(c) :: myCFloat
  integer(myF), bind(c) :: myCInt       ! { dg-warning "is for type REAL" }
  integer(c_double), bind(c) :: myCInt2 ! { dg-warning "is for type REAL" }

  integer, parameter :: myI = c_int
  real(myI) :: myReal             ! { dg-warning "is for type INTEGER" }
  real(myI), bind(c) :: myCFloat2 ! { dg-warning "is for type INTEGER" }
  real(4), bind(c) :: myFloat
end module c_kind_tests_2