summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/test_common_binding_labels.f03
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gfortran.dg/test_common_binding_labels.f03')
-rw-r--r--gcc/testsuite/gfortran.dg/test_common_binding_labels.f0342
1 files changed, 42 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/test_common_binding_labels.f03 b/gcc/testsuite/gfortran.dg/test_common_binding_labels.f03
new file mode 100644
index 000000000..ea9a59a35
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/test_common_binding_labels.f03
@@ -0,0 +1,42 @@
+! { dg-do compile }
+module x
+ use, intrinsic :: iso_c_binding, only: c_double
+ implicit none
+
+ common /mycom/ r, s ! { dg-error "does not match" }
+ real(c_double) :: r
+ real(c_double) :: s
+ bind(c, name="my_common_block") :: /mycom/
+end module x
+
+module y
+ use, intrinsic :: iso_c_binding, only: c_double, c_int
+ implicit none
+
+ common /mycom/ r, s
+ real(c_double) :: r
+ real(c_double) :: s
+ bind(c, name="my_common_block") :: /mycom/
+
+ common /com2/ i ! { dg-error "does not match" }
+ integer(c_int) :: i
+ bind(c, name="") /com2/
+end module y
+
+module z
+ use, intrinsic :: iso_c_binding, only: c_double, c_int
+ implicit none
+
+ common /mycom/ r, s ! { dg-error "does not match" }
+ real(c_double) :: r
+ real(c_double) :: s
+ ! this next line is an error; if a common block is bind(c), the binding label
+ ! for it must match across all scoping units that declare it.
+ bind(c, name="my_common_block_2") :: /mycom/
+
+ common /com2/ i ! { dg-error "does not match" }
+ integer(c_int) :: i
+ bind(c, name="mycom2") /com2/
+end module z
+
+! { dg-final { cleanup-modules "x y" } }