From ba29dca90d1b948654eeb69c25cfc763c99b1971 Mon Sep 17 00:00:00 2001 From: Mikael Morin Date: Wed, 9 Jan 2013 20:18:44 +0000 Subject: [PATCH] re PR fortran/47203 (USE of module with same name as SUBROUTINE not reject, but also not working) PR fortran/47203 * module.c (check_for_ambiguous): Get the current program unit using gfc_current_ns. PR fortran/47203 * gfortran.dg/use_28.f90: New test. From-SVN: r195065 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/module.c | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/use_28.f90 | 18 ++++++++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/use_28.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index d8c5448..cfaae77 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2013-01-09 Mikael Morin + + PR fortran/47203 + * module.c (check_for_ambiguous): Get the current program unit using + gfc_current_ns. + 2013-01-09 Tobias Burnus PR fortran/55758 diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index f3b3caa..604acbb 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -4493,7 +4493,7 @@ 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) + if (st_sym->name == gfc_current_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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1e66c77..238d752 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-01-09 Mikael Morin + + PR fortran/47203 + * gfortran.dg/use_28.f90: New test. + 2012-01-09 Uros Bizjak * gfortran.dg/intrinsic_size_3.f90: Make scan-tree-dump-times diff --git a/gcc/testsuite/gfortran.dg/use_28.f90 b/gcc/testsuite/gfortran.dg/use_28.f90 new file mode 100644 index 0000000..4972bea --- /dev/null +++ b/gcc/testsuite/gfortran.dg/use_28.f90 @@ -0,0 +1,18 @@ +! { dg-do compile } +! +! PR fortran/47203 +! The USE statement of a module was not rejected in a procedure with the same +! name if the procedure was contained. +! +! Contributed by Tobias Burnus + +module m +end module m + +call m +contains + subroutine m() + use m ! { dg-error "is also the name of the current program unit" } + end subroutine m +end + -- 2.7.4