xref: /llvm-project/flang/test/Semantics/bind-c15.f90 (revision 56cd8a50b3e37cbb3cd3dc49909bdd14939cfdee)
1! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic
2
3module m
4  type, bind(c) :: explicit_bind_c
5    real a
6  end type
7  type :: interoperable1
8    type(explicit_bind_c) a
9  end type
10  type, extends(interoperable1) :: interoperable2
11    real b
12  end type
13  type :: non_interoperable1
14    real, allocatable :: a
15  end type
16  type :: non_interoperable2
17    type(non_interoperable1) b
18  end type
19  type :: no_bind_c
20    real a
21  end type
22  type, bind(c) :: has_bind_c
23    !WARNING: Derived type of component 'a' of an interoperable derived type should have the BIND attribute
24    type(no_bind_c) :: a
25  end type
26  interface
27    subroutine sub_bind_c_1(x_bind_c) bind(c)
28      import explicit_bind_c
29      type(explicit_bind_c), intent(in) :: x_bind_c
30    end
31    subroutine sub_bind_c_2(x_interop1) bind(c)
32      import interoperable1
33      !WARNING: The derived type of an interoperable object should be BIND(C)
34      type(interoperable1), intent(in) :: x_interop1
35    end
36    subroutine sub_bind_c_3(x_interop2) bind(c)
37      import interoperable2
38      !WARNING: The derived type of an interoperable object should be BIND(C)
39      type(interoperable2), intent(in) :: x_interop2
40    end
41    subroutine sub_bind_c_4(x_non_interop1) bind(c)
42      import non_interoperable1
43      !ERROR: The derived type of an interoperable object must be interoperable, but is not
44      type(non_interoperable1), intent(in) :: x_non_interop1
45    end
46    subroutine sub_bind_c_5(x_non_interop2) bind(c)
47      import non_interoperable2
48      !ERROR: The derived type of an interoperable object must be interoperable, but is not
49      type(non_interoperable2), intent(in) :: x_non_interop2
50    end
51  end interface
52end
53