From: Tobias Burnus Date: Sun, 17 Jul 2011 19:57:10 +0000 (+0200) Subject: re PR fortran/34657 (program-unit MY_SUB imports symbol MY_SUB) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=63523a1fa58d1059e9c2d9ac926873fae010a367;p=gcc.git re PR fortran/34657 (program-unit MY_SUB imports symbol MY_SUB) 2011-07-17 Tobias Burnus PR fortran/34657 * module.c (check_for_ambiguous): Check whether the name is * matches the current program unit. 2011-07-17 Tobias Burnus Thomas Koenig PR fortran/34657 * gfortran.dg/generic_17.f90: Fix testcase. * gfortran.dg/interface_3.f90: Add dg-error. * gfortran.dg/use_14.f90: New. * gfortran.dg/use_15.f90: New. Co-Authored-By: Thomas Koenig From-SVN: r176375 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 19339a6a13f..d1f354e13c6 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2011-07-17 Tobias Burnus + + PR fortran/34657 + * module.c (check_for_ambiguous): Check whether the name is matches + the current program unit. + 2011-07-17 Tobias Burnus PR fortran/49624 diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index 4afe4672db8..b62ad8d08e0 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -4278,6 +4278,13 @@ check_for_ambiguous (gfc_symbol *st_sym, pointer_info *info) module_locus locus; symbol_attribute attr; + if (st_sym->ns->proc_name && st_sym->name == st_sym->ns->proc_name->name) + { + gfc_error ("'%s' of module '%s', imported at %C, is also the name of the " + "current program unit", st_sym->name, module_name); + return true; + } + rsym = info->u.rsym.sym; if (st_sym == rsym) return false; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2e5683c623a..9eb36a76045 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2011-07-17 Tobias Burnus + Thomas Koenig + + PR fortran/34657 + * gfortran.dg/generic_17.f90: Fix testcase. + * gfortran.dg/interface_3.f90: Add dg-error. + * gfortran.dg/use_14.f90: New. + * gfortran.dg/use_15.f90: New. + 2011-07-17 Eric Botcazou * gnat.dg/pointer_controlled.adb: New test. diff --git a/gcc/testsuite/gfortran.dg/generic_17.f90 b/gcc/testsuite/gfortran.dg/generic_17.f90 index 968d9c10c37..0e9a41d5b02 100644 --- a/gcc/testsuite/gfortran.dg/generic_17.f90 +++ b/gcc/testsuite/gfortran.dg/generic_17.f90 @@ -34,7 +34,7 @@ module foo_mod use d_foo_mod end module foo_mod -subroutine s_foobar(x) +subroutine s_foobar2(x) use foo_mod -end subroutine s_foobar +end subroutine s_foobar2 ! { dg-final { cleanup-modules "s_foo_mod d_foo_mod foo_mod" } } diff --git a/gcc/testsuite/gfortran.dg/interface_3.f90 b/gcc/testsuite/gfortran.dg/interface_3.f90 index 0a23fb09806..1d954eef8b6 100644 --- a/gcc/testsuite/gfortran.dg/interface_3.f90 +++ b/gcc/testsuite/gfortran.dg/interface_3.f90 @@ -5,6 +5,8 @@ ! ! Contributed by Joost VandeVondele ! +! Modified for PR fortran/34657 +! module test_mod interface subroutine my_sub (a) @@ -30,14 +32,14 @@ end module ! This is the original PR, excepting that the error requires the symbol ! to be referenced. subroutine my_sub (a) - use test_mod + use test_mod ! { dg-error "is also the name of the current program unit" } real a call my_sub (a) ! { dg-error "ambiguous reference" } print *, a end subroutine integer function my_fun (a) - use test_mod + use test_mod ! { dg-error "is also the name of the current program unit" } real a print *, a my_fun = 1 ! { dg-error "ambiguous reference" } diff --git a/gcc/testsuite/gfortran.dg/use_14.f90 b/gcc/testsuite/gfortran.dg/use_14.f90 new file mode 100644 index 00000000000..63f3dff98b0 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/use_14.f90 @@ -0,0 +1,19 @@ +! { dg-do compile } +! +! PR fortran/34657 +! +module test_mod +interface + subroutine my_sub (a) + real a + end subroutine +end interface +end module + +subroutine my_sub (a) + use test_mod, gugu => my_sub + real a + print *, a +end subroutine + +END diff --git a/gcc/testsuite/gfortran.dg/use_15.f90 b/gcc/testsuite/gfortran.dg/use_15.f90 new file mode 100644 index 00000000000..099588836e0 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/use_15.f90 @@ -0,0 +1,39 @@ +! { dg-do compile } +! +! PR fortran/34657 +! +module test_mod +interface + subroutine my_sub (a) + real a + end subroutine +end interface +end module + +subroutine my_sub (a) + use test_mod ! { dg-error "is also the name of the current program unit" } + real a + print *, a +end subroutine + + +module test_mod2 + integer :: my_sub2 +end module + +subroutine my_sub2 (a) + use test_mod2 ! { dg-error "is also the name of the current program unit" } + real a + print *, a +end subroutine + + +subroutine my_sub3 (a) + use test_mod2, my_sub3 => my_sub2 ! { dg-error "is also the name of the current program unit" } + real a + print *, a +end subroutine + +END + +! { dg-final { cleanup-modules "test_mod test_mod2" } }