This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch, fortran] PR 32535 - namelist with private items contained in sub-sub-procedure of a module rejected
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))
{