aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2005-10-12 07:19:56 +0000
committerPaul Thomas <pault@gcc.gnu.org>2005-10-12 07:19:56 +0000
commit0f9d970d60d34ab6d7f47e741df998e396c999c3 (patch)
treeca9382afc31efcb893f774020f10757dce4a8bdc /gcc
parent81871c2a0501a25b3f038286268e0ce84936fdf2 (diff)
downloadgcc-0f9d970d60d34ab6d7f47e741df998e396c999c3.zip
gcc-0f9d970d60d34ab6d7f47e741df998e396c999c3.tar.gz
gcc-0f9d970d60d34ab6d7f47e741df998e396c999c3.tar.bz2
re PR fortran/24207 (PRIVATE/PUBLIC attribute confusion screws NAMELIST)
2005-10-12 Paul Thomas <pault@gcc.gnu.org> PR fortran/24207 * resolve.c (resolve_symbol): Exclude use and host associated symbols from the test for private objects in a public namelist. 2005-10-12 Paul Thomas <pault@gcc.gnu.org> PR fortran/24207 gfortran.dg/private_type_3.f90: New test. From-SVN: r105289
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/resolve.c7
-rw-r--r--gcc/testsuite/ChangeLog5
-rwxr-xr-xgcc/testsuite/gfortran.dg/private_type_3.f9033
4 files changed, 50 insertions, 1 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 74e74af..b7eec33 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,9 @@
+2005-10-12 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/24207
+ * resolve.c (resolve_symbol): Exclude use and host associated
+ symbols from the test for private objects in a public namelist.
+
2005-10-12 Jakub Jelinek <jakub@redhat.com>
* trans-common.c (build_field): Fix comment typo.
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index f057340..5de16ba 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -4310,6 +4310,7 @@ resolve_symbol (gfc_symbol * sym)
{
if (arg->sym
&& arg->sym->ts.type == BT_DERIVED
+ && !arg->sym->ts.derived->attr.use_assoc
&& !gfc_check_access(arg->sym->ts.derived->attr.access,
arg->sym->ts.derived->ns->default_access))
{
@@ -4412,7 +4413,11 @@ resolve_symbol (gfc_symbol * sym)
{
for (nl = sym->namelist; nl; nl = nl->next)
{
- if (!gfc_check_access(nl->sym->attr.access,
+ if (!nl->sym->attr.use_assoc
+ &&
+ !(sym->ns->parent == nl->sym->ns)
+ &&
+ !gfc_check_access(nl->sym->attr.access,
nl->sym->ns->default_access))
gfc_error ("PRIVATE symbol '%s' cannot be member of "
"PUBLIC namelist at %L", nl->sym->name,
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 340cfa3..a184ea4 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2005-10-12 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/24207
+ gfortran.dg/private_type_3.f90: New test.
+
2005-10-11 Steven G. Kargl <kargls@comcast.net>
PR fortran/20786
diff --git a/gcc/testsuite/gfortran.dg/private_type_3.f90 b/gcc/testsuite/gfortran.dg/private_type_3.f90
new file mode 100755
index 0000000..b8fad66
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/private_type_3.f90
@@ -0,0 +1,33 @@
+! { dg-do compile }
+! { dg-options "-O0" }
+! Tests the fix for PR24207 and the problems associated
+! with the fix for PR21986. In two cases, use associated
+! public symbols were taking on the default private access
+! attribute of the local namespace. In the third, a private
+! symbol was not available to a namelist in contained
+! procedure in the same module.
+!
+! Based on the example in PR24207.
+!
+module a
+ implicit none
+ real b
+ type :: mytype
+ integer :: c
+ end type mytype
+end module a
+module c
+ use a
+ implicit none
+ public d
+ private
+ real x
+ contains
+ subroutine d (arg_t) ! This would cause an error
+ type (mytype) :: arg_t
+ namelist /e/ b, x ! .... as would this.
+ read(5,e)
+ arg_t%c = 42
+ end subroutine d
+end module c
+