public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, fortran] PR47203 Use of module with same name as subroutine
@ 2013-01-08 21:06 Mikael Morin
  2013-01-08 21:47 ` Steve Kargl
  0 siblings, 1 reply; 2+ messages in thread
From: Mikael Morin @ 2013-01-08 21:06 UTC (permalink / raw)
  To: gfortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 401 bytes --]

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


[-- Attachment #2: pr47203.CL --]
[-- Type: text/plain, Size: 154 bytes --]

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.


[-- Attachment #3: pr47203.diff --]
[-- Type: text/plain, Size: 506 bytes --]

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);


[-- Attachment #4: pr47203-test.CL --]
[-- Type: text/plain, Size: 104 bytes --]

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

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


[-- Attachment #5: use_28.f90 --]
[-- Type: text/x-fortran, Size: 368 bytes --]

! { 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 <burnus@net-b.de>

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Patch, fortran] PR47203 Use of module with same name as subroutine
  2013-01-08 21:06 [Patch, fortran] PR47203 Use of module with same name as subroutine Mikael Morin
@ 2013-01-08 21:47 ` Steve Kargl
  0 siblings, 0 replies; 2+ messages in thread
From: Steve Kargl @ 2013-01-08 21:47 UTC (permalink / raw)
  To: Mikael Morin; +Cc: gfortran, gcc-patches

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.

-- 
Steve

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-01-08 21:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-08 21:06 [Patch, fortran] PR47203 Use of module with same name as subroutine Mikael Morin
2013-01-08 21:47 ` Steve Kargl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).