xref: /llvm-project/flang/test/Semantics/bind-c12.f90 (revision e2a3880d7ffeefb433d686b0eda59a9e34d98e16)
1!RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic -Werror
2
3!PORTABILITY: An interoperable procedure should have an interface
4subroutine subr1(e) bind(c)
5  external e
6end
7
8subroutine subr2(p) bind(c)
9  !PORTABILITY: An interoperable procedure should have an interface
10  procedure() :: p
11end
12
13subroutine subr3(p) bind(c)
14  !PORTABILITY: An interoperable procedure should have an interface
15  procedure(real) :: p
16end
17
18subroutine subr4(p) bind(c)
19  interface
20    !PORTABILITY: A dummy procedure of an interoperable procedure should be BIND(C)
21    subroutine p(n)
22      integer, intent(in) :: n
23    end
24  end interface
25end
26
27subroutine subr5(p) bind(c)
28  interface
29    !WARNING: A dummy procedure of an interoperable procedure should be BIND(C)
30    subroutine p(c)
31      character(*), intent(in) :: c
32    end
33  end interface
34end
35
36subroutine subr6(p) bind(c)
37  interface
38    function p()
39      !ERROR: Interoperable function result must be scalar
40      real p(1)
41    end
42  end interface
43end
44
45subroutine subr7(p) bind(c)
46  interface
47    !ERROR: Interoperable character function result must have length one
48    character(*) function p()
49    end
50  end interface
51end
52
53subroutine subr8(p) bind(c)
54  interface
55    !WARNING: A dummy procedure of an interoperable procedure should be BIND(C)
56    subroutine p(n)
57      integer, intent(in), value :: n
58    end
59  end interface
60end
61
62subroutine subr9(p) bind(c)
63  !ERROR: An interface name with the BIND attribute must appear if the BIND attribute appears in a procedure declaration
64  procedure(q), bind(c), pointer :: p
65  interface
66    function q()
67      real q(1)
68    end
69  end interface
70end
71