This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [patch, fortran] PR 32535 - namelist with private items contained in sub-sub-procedure of a module rejected
- From: "Janus Weil" <jaydub66 at googlemail dot com>
- To: "Steve Kargl" <sgk at troutmask dot apl dot washington dot edu>
- Cc: "Fortran List" <fortran at gcc dot gnu dot org>, gcc-patches at gcc dot gnu dot org, "Tobias Burnus" <burnus at net-b dot de>
- Date: Sun, 8 Jul 2007 00:12:15 +0200
- Subject: Re: [patch, fortran] PR 32535 - namelist with private items contained in sub-sub-procedure of a module rejected
- Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=googlemail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=WO72KQx2b2+HPUJJwI8wR28YzFbgMuLrqWpTU/3KnY+m7yF7uezlX8XgYr7BSqqRhu8+yf9JSvnUUonYfgrqE0BkPeKziKNcdLER2P16vjEetrS/Bbdpm0tqcdwRKS34bbqa0FX3UlrfCeF/rBWAnLBUPL6lYBUwxgC7orD0CY4=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=j4dworSz4lvTpsTvUFHDM1y7gJmU9zr2BwlpQCPxkPKiF2rfvihr1sb3eAmRteU2OLapCgAm8AHBOWDrcKzeyspzQIC53y1sJ+cXS00v82dilMUQE779n/Xk0q94e9RGlAYGyi+H0zSYJlaIp12sOcfSI+cYipahuYgRAtEGJ7k=
- References: <854832d40707071309hd8f3044gbb7f7e202dd1db0@mail.gmail.com> <20070707204353.GA62215@troutmask.apl.washington.edu>
Ok, thanks for the annotations, Steve. So ... here we go again.
The ChangeLog entry:
2007-07-08 Janus Weil <jaydub66@gmail.com>
PR fortran/32535
* resolve.c (resolve_fl_namelist): Allow for namelists in
contained (sub-)subroutines to have private components.
2007-07-08 Janus Weil <jaydub66@gmail.com>
PR fortran/32535
* gfortran.dg/pr32535.f90: New test.
This time I used diff -p and changed the formatting.
Finally, does this scale to arbitrarily deep contained subroutines?
As we just sorted out on IRC, Fortran doesn't support more than two
levels of nested subroutines, so we don't need to check for arbitrary
levels.
Any further comments are highly welcome,
Janus
Index: gcc/testsuite/gfortran.dg/pr32535.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr32535.f90 (revision 0)
+++ gcc/testsuite/gfortran.dg/pr32535.f90 (revision 0)
@@ -0,0 +1,62 @@
+! { dg-do compile }
+!
+! PR32535: namelist with private items contained in sub-sub-procedure of a module rejected
+!
+! Contributed by Janus Weil <jaydub66@gmail.com>
+
+module mo
+
+implicit none
+
+real,private:: a,b,c
+
+contains
+
+ subroutine sub
+ implicit none
+ namelist /nl1/ a,b,c
+
+ contains
+
+ subroutine subsub
+ implicit none
+ namelist /nl2/ a,b,c
+
+ end subroutine subsub
+
+ end subroutine sub
+
+end module mo
+
+! { dg-final { cleanup-modules "mo" } }
+! { dg-do compile }
+!
+! PR32535: namelist with private items contained in sub-sub-procedure of a module rejected
+!
+! Contributed by Janus Weil <jaydub66@gmail.com>
+
+module mo
+
+implicit none
+
+real,private:: a,b,c
+
+contains
+
+ subroutine sub
+ implicit none
+ namelist /nl1/ a,b,c
+
+ contains
+
+ subroutine subsub
+ implicit none
+ namelist /nl2/ a,b,c
+
+ end subroutine subsub
+
+ end subroutine sub
+
+end module mo
+
+! { dg-final { cleanup-modules "mo" } }
Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c (revision 126442)
+++ gcc/fortran/resolve.c (working copy)
@@ -6877,6 +6877,7 @@ resolve_fl_namelist (gfc_symbol *sym)
{
if (!nl->sym->attr.use_assoc
&& !(sym->ns->parent == nl->sym->ns)
+ && !(sym->ns->parent && sym->ns->parent->parent == nl->sym->ns)
&& !gfc_check_access(nl->sym->attr.access,
nl->sym->ns->default_access))
{