1! { dg-do compile }
2! { dg-options "-std=f2003" }
3!
4module x
5  use, intrinsic :: iso_c_binding, only: c_double
6  implicit none
7
8  common /mycom/ r, s ! { dg-error "In Fortran 2003 COMMON 'mycom' block at .1. is a global identifier and must thus have the same binding name as the same-named COMMON block at .2.: my_common_block vs .blank.|In Fortran 2003 COMMON 'mycom' block at .1. is a global identifier and must thus have the same binding name as the same-named COMMON block at .2.: my_common_block_2 vs .blank." }
9  real(c_double) :: r
10  real(c_double) :: s
11  bind(c, name="my_common_block") :: /mycom/
12end module x
13
14module y
15  use, intrinsic :: iso_c_binding, only: c_double, c_int
16  implicit none
17  
18  common /mycom/ r, s ! { dg-error "In Fortran 2003 COMMON 'mycom' block at .1. is a global identifier and must thus have the same binding name as the same-named COMMON block at .2.: my_common_block vs .blank." }
19  real(c_double) :: r
20  real(c_double) :: s
21  bind(c, name="my_common_block") :: /mycom/
22
23  common /com2/ i ! { dg-error " In Fortran 2003 COMMON 'com2' block at .1. is a global identifier and must thus have the same binding name as the same-named COMMON block at .2.: mycom2 vs .blank." }
24  integer(c_int) :: i
25  bind(c, name="") /com2/
26end module y
27
28module z
29  use, intrinsic :: iso_c_binding, only: c_double, c_int
30  implicit none
31  
32  common /mycom/ r, s ! { dg-error "In Fortran 2003 COMMON 'mycom' block at .1. is a global identifier and must thus have the same binding name as the same-named COMMON block at .2.: my_common_block_2 vs .blank." }
33  real(c_double) :: r
34  real(c_double) :: s
35  ! this next line is an error; if a common block is bind(c), the binding label
36  ! for it must match across all scoping units that declare it.
37  bind(c, name="my_common_block_2") :: /mycom/ 
38
39  common /com2/ i ! { dg-error " In Fortran 2003 COMMON 'com2' block at .1. is a global identifier and must thus have the same binding name as the same-named COMMON block at .2.: mycom2 vs .blank." }
40  integer(c_int) :: i
41  bind(c, name="mycom2") /com2/
42end module z
43