xref: /llvm-project/flang/test/Semantics/bind-c04.f90 (revision 2445a96ff2bd038295b313ee15d0d9ec3d033dbf)
1! RUN: %python %S/test_errors.py %s %flang_fc1
2! Check for C1520
3! If proc-language-binding-spec (bind(c)) with NAME= is specified, then
4! proc-decl-list shall contain exactly one proc-decl, which shall neither have
5! the POINTER attribute nor be a dummy procedure.
6
7subroutine sub(x, y)
8
9  interface
10    subroutine proc() bind(c)
11    end
12  end interface
13
14  abstract interface
15    !ERROR: An ABSTRACT interface may not have a BIND attribute with a name
16    subroutine aproc1() bind(c,name="foo")
17    end
18    subroutine aproc2() bind(c) ! ok
19    end
20  end interface
21
22  !ERROR: A procedure declaration statement with a binding name may not declare multiple procedures
23  procedure(proc), bind(c, name="aaa") :: pc1, pc2
24
25  !ERROR: A procedure pointer may not have a BIND attribute with a name
26  procedure(proc), bind(c, name="bbb"), pointer :: pc3
27
28  !ERROR: An internal or dummy procedure may not have a BIND(C,NAME=) binding label
29  procedure(proc), bind(c, name="ccc") :: x
30
31  procedure(proc), bind(c) :: pc4, pc5
32
33  !ERROR: A procedure pointer may not have a BIND attribute with a name
34  procedure(proc), bind(c, name="pc6"), pointer :: pc6
35
36  procedure(proc), bind(c), pointer :: pc7
37
38  procedure(proc), bind(c) :: y
39
40  !WARNING: Attribute 'BIND(C)' cannot be used more than once
41  !ERROR: A procedure pointer may not have a BIND attribute with a name
42  procedure(proc), bind(c, name="pc8"), bind(c), pointer :: pc8
43
44end
45