diff options
Diffstat (limited to 'gcc/testsuite/gfortran.dg')
-rw-r--r-- | gcc/testsuite/gfortran.dg/common_18.f90 | 20 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/common_19.f90 | 9 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/common_20.f90 | 18 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/common_21.f90 | 18 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/test_common_binding_labels.f03 | 12 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/test_common_binding_labels_2_main.f03 | 11 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/test_common_binding_labels_3_main.f03 | 4 |
7 files changed, 81 insertions, 11 deletions
diff --git a/gcc/testsuite/gfortran.dg/common_18.f90 b/gcc/testsuite/gfortran.dg/common_18.f90 new file mode 100644 index 00000000000..374eda8eee1 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/common_18.f90 @@ -0,0 +1,20 @@ +! { dg-do compile } +! +! PR fortran/48858 +! +! +use iso_c_binding +contains +subroutine one() + bind(C, name="com1") :: /foo/ + integer(c_int) :: a + common /foo/ a +end subroutine +subroutine two() + integer(c_long) :: a + common /foo/ a +end subroutine two +end + +! { dg-final { scan-assembler "com1" } } +! { dg-final { scan-assembler "foo_" } } diff --git a/gcc/testsuite/gfortran.dg/common_19.f90 b/gcc/testsuite/gfortran.dg/common_19.f90 new file mode 100644 index 00000000000..020420193e7 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/common_19.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } +! { dg-options "-std=f95" } +! +! PR fortran/48858 +! +integer :: i +common /foo/ i +bind(C) :: /foo/ ! { dg-error "Fortran 2003: BIND.C. statement" } +end diff --git a/gcc/testsuite/gfortran.dg/common_20.f90 b/gcc/testsuite/gfortran.dg/common_20.f90 new file mode 100644 index 00000000000..836a9ecb3e4 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/common_20.f90 @@ -0,0 +1,18 @@ +! { dg-do compile } +! { dg-options "-std=f2003" } +! +! PR fortran/48858 +! +subroutine test + integer :: l, m + common /g/ l ! { dg-error "Fortran 2008: COMMON block 'g' with binding label at .1. sharing the identifier with global non-COMMON-block entity at .2." } + common /jj/ m ! { dg-error "Global name 'jj' at .1. is already being used as a COMMON at .2." } + bind(C,name="bar") :: /g/ + bind(C,name="foo") :: /jj/ +end + +subroutine g ! { dg-error "Fortran 2008: COMMON block 'g' with binding label at .1. sharing the identifier with global non-COMMON-block entity at .2." } + call jj() ! { dg-error "Global name 'jj' at .1. is already being used as a COMMON at .2." } +end + + diff --git a/gcc/testsuite/gfortran.dg/common_21.f90 b/gcc/testsuite/gfortran.dg/common_21.f90 new file mode 100644 index 00000000000..73a1b58a1ab --- /dev/null +++ b/gcc/testsuite/gfortran.dg/common_21.f90 @@ -0,0 +1,18 @@ +! { dg-do compile } +! { dg-options "-std=f2008" } +! +! PR fortran/48858 +! +subroutine test + integer :: l, m + common /g/ l + common /jj/ m + bind(C,name="bar") :: /g/ + bind(C,name="foo") :: /jj/ +end + +subroutine g + call jj() +end + + diff --git a/gcc/testsuite/gfortran.dg/test_common_binding_labels.f03 b/gcc/testsuite/gfortran.dg/test_common_binding_labels.f03 index 554a59dfc9c..8936fa87a89 100644 --- a/gcc/testsuite/gfortran.dg/test_common_binding_labels.f03 +++ b/gcc/testsuite/gfortran.dg/test_common_binding_labels.f03 @@ -1,9 +1,11 @@ ! { dg-do compile } +! { dg-options "-std=f2003" } +! module x use, intrinsic :: iso_c_binding, only: c_double implicit none - common /mycom/ r, s ! { dg-error "does not match" } + 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." } real(c_double) :: r real(c_double) :: s bind(c, name="my_common_block") :: /mycom/ @@ -13,12 +15,12 @@ module y use, intrinsic :: iso_c_binding, only: c_double, c_int implicit none - common /mycom/ r, s + 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." } real(c_double) :: r real(c_double) :: s bind(c, name="my_common_block") :: /mycom/ - common /com2/ i ! { dg-error "does not match" } + 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." } integer(c_int) :: i bind(c, name="") /com2/ end module y @@ -27,14 +29,14 @@ module z use, intrinsic :: iso_c_binding, only: c_double, c_int implicit none - common /mycom/ r, s ! { dg-error "does not match" } + 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." } 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" } + 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." } integer(c_int) :: i bind(c, name="mycom2") /com2/ end module z diff --git a/gcc/testsuite/gfortran.dg/test_common_binding_labels_2_main.f03 b/gcc/testsuite/gfortran.dg/test_common_binding_labels_2_main.f03 index eeb981ec40d..fb7778effa0 100644 --- a/gcc/testsuite/gfortran.dg/test_common_binding_labels_2_main.f03 +++ b/gcc/testsuite/gfortran.dg/test_common_binding_labels_2_main.f03 @@ -1,24 +1,27 @@ ! { dg-do compile } +! { dg-options "-std=f2003" } +! +! ! This file depends on the module test_common_binding_labels_2. That module ! must be compiled first and not be removed until after this test. module test_common_binding_labels_2_main use, intrinsic :: iso_c_binding, only: c_double, c_int implicit none - common /mycom/ r, s ! { dg-error "does not match" } + common /mycom/ r, s ! { dg-error "same binding name" } 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" } + common /com2/ i ! { dg-error "same binding name" } integer(c_int) :: i bind(c, name="mycom2") /com2/ end module test_common_binding_labels_2_main program main - use test_common_binding_labels_2 ! { dg-error "does not match" } - use test_common_binding_labels_2_main + use test_common_binding_labels_2 ! { dg-error "same binding name" } + use test_common_binding_labels_2_main ! { dg-error "same binding name" } end program main ! { dg-final { cleanup-modules "test_common_binding_labels_2" } } diff --git a/gcc/testsuite/gfortran.dg/test_common_binding_labels_3_main.f03 b/gcc/testsuite/gfortran.dg/test_common_binding_labels_3_main.f03 index 91fcff18245..3ccab0c89fe 100644 --- a/gcc/testsuite/gfortran.dg/test_common_binding_labels_3_main.f03 +++ b/gcc/testsuite/gfortran.dg/test_common_binding_labels_3_main.f03 @@ -3,11 +3,11 @@ ! must be compiled first and not be removed until after this test. module test_common_binding_labels_3_main use, intrinsic :: iso_c_binding, only: c_int - integer(c_int), bind(c, name="my_common_block") :: my_int ! { dg-error "collides" } + integer(c_int), bind(c, name="my_common_block") :: my_int ! { dg-error "COMMON block at .1. with binding label my_common_block uses the same global identifier as entity at .2." } end module test_common_binding_labels_3_main program main use test_common_binding_labels_3_main - use test_common_binding_labels_3 ! { dg-error "collides" } + use test_common_binding_labels_3 ! { dg-error "COMMON block at .1. with binding label my_common_block uses the same global identifier as entity at .2." } end program main ! { dg-final { cleanup-modules "test_common_binding_labels_3" } } |