[fortran] PR47203 Use of module with same name as subroutine

Submitted by Mikael Morin on Jan. 8, 2013, 9:06 p.m.

Details

Message ID 50EC8A49.5080802@sfr.fr
State New
Headers show

Commit Message

Mikael Morin Jan. 8, 2013, 9:06 p.m.
Hello,

a small, unexciting bug.
For the case:

    subroutine m()
       use m
    end subroutine m

the USE statement is rejected, but it is not if the subroutine is contained.
In the latter case, the namespace of the symbol of the subroutine is the 
parent namespace, which confuses the error condition in check_for_ambiguous.

Regression tested on x86_64-unknown-linux-gnu. OK for trunk?

Mikael
2013-01-08  Mikael Morin  <mikael@gcc.gnu.org>

	PR fortran/47203
	* module.c (check_for_ambiguous): Get the current program unit using
	gfc_current_ns.

2013-01-08  Mikael Morin  <mikael@gcc.gnu.org>

	PR fortran/47203
	* gfortran.dg/use_28.f90: New test.

Comments

Steve Kargl Jan. 8, 2013, 9:47 p.m.
On Tue, Jan 08, 2013 at 10:06:17PM +0100, Mikael Morin wrote:
>
> a small, unexciting bug.
> For the case:
> 
>     subroutine m()
>        use m
>     end subroutine m
> 
> the USE statement is rejected, but it is not if the subroutine is contained.
> In the latter case, the namespace of the symbol of the subroutine is the 
> parent namespace, which confuses the error condition in check_for_ambiguous.
> 
> Regression tested on x86_64-unknown-linux-gnu. OK for trunk?
> 

OK.  Note, RM sent a status report stating that
trunk was closed except for regression and doc
fixes.  Other changes (may) need RM approval.

Patch hide | download patch | download mbox

diff --git a/module.c b/module.c
index f3b3caa..604acbb 100644
--- a/module.c
+++ b/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);