public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Mikael Morin <mikael.morin@sfr.fr>
To: gfortran <fortran@gcc.gnu.org>, gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [Patch, fortran] PR47203 Use of module with same name as subroutine
Date: Tue, 08 Jan 2013 21:06:00 -0000	[thread overview]
Message-ID: <50EC8A49.5080802@sfr.fr> (raw)

[-- 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


             reply	other threads:[~2013-01-08 21:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-08 21:06 Mikael Morin [this message]
2013-01-08 21:47 ` Steve Kargl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50EC8A49.5080802@sfr.fr \
    --to=mikael.morin@sfr.fr \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).