xref: /llvm-project/flang/test/Semantics/bind-c02.f90 (revision d03cd05f077f92e87f354aca4cdea599b678b64e)
1! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic
2! Check for 8.6.4(1)
3! The BIND statement specifies the BIND attribute for a list of variables and
4! common blocks.
5
6module m
7
8  interface
9    subroutine proc()
10    end
11  end interface
12  procedure(proc) :: pc1
13  !ERROR: Only variable and named common block can be in BIND statement
14  bind(c) :: proc
15  !ERROR: Only variable and named common block can be in BIND statement
16  bind(c) :: pc1
17
18  !ERROR: BIND_C attribute was already specified on 'sub'
19  !ERROR: Only variable and named common block can be in BIND statement
20  bind(c) :: sub
21
22  !PORTABILITY: Global name 'm' conflicts with a module
23  !PORTABILITY: Name 'm' declared in a module should not have the same name as the module
24  bind(c) :: m ! no error for implicit type variable
25
26  type my_type
27    integer :: i
28  end type
29  !ERROR: Only variable and named common block can be in BIND statement
30  bind(c) :: my_type
31
32  enum, bind(c) ! no error
33    enumerator :: SUNDAY, MONDAY
34  end enum
35
36  integer :: x, y, z = 1
37  common /blk/ y
38  bind(c) :: x, /blk/, z ! no error for variable and common block
39
40  bind(c) :: implicit_i ! no error for implicit type variable
41
42  !ERROR: 'implicit_blk' appears as a COMMON block in a BIND statement but not in a COMMON statement
43  bind(c) :: /implicit_blk/
44
45contains
46
47  subroutine sub() bind(c)
48  end
49
50end
51