diff options
author | Tobias Burnus <burnus@net-b.de> | 2007-09-17 17:55:22 +0200 |
---|---|---|
committer | Tobias Burnus <burnus@gcc.gnu.org> | 2007-09-17 17:55:22 +0200 |
commit | a08a5751bb82c7c754f45c67366e6f72f5ec35ca (patch) | |
tree | 9e93fc0f785ba702b30472f270693e92815ed9d6 /gcc/fortran/resolve.c | |
parent | 90b1c344ce29ca966bdc6b4eb63a37be194b79c1 (diff) | |
download | gcc-a08a5751bb82c7c754f45c67366e6f72f5ec35ca.zip gcc-a08a5751bb82c7c754f45c67366e6f72f5ec35ca.tar.gz gcc-a08a5751bb82c7c754f45c67366e6f72f5ec35ca.tar.bz2 |
re PR fortran/33106 (Access of components of public entities of private types wrongly allowed)
2007-09-17 Tobias Burnus <burnus@net-b.de>
PR fortran/33106
* resolve.c (resolve_symbol): Reject public variable of
private derived-types for Fortran 95.
2007-09-17 Tobias Burnus <burnus@net-b.de>
PR fortran/33106
* gfortran.dg/private_type_9.f90: New.
From-SVN: r128550
Diffstat (limited to 'gcc/fortran/resolve.c')
-rw-r--r-- | gcc/fortran/resolve.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index a2444a3..40c476a5 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -7581,6 +7581,22 @@ resolve_symbol (gfc_symbol *sym) return; } + /* Unless the derived-type declaration is use associated, Fortran 95 + does not allow public entries of private derived types. + See 4.4.1 (F95) and 4.5.1.1 (F2003); and related interpretation + 161 in 95-006r3. */ + if (sym->ts.type == BT_DERIVED + && gfc_check_access (sym->attr.access, sym->ns->default_access) + && !gfc_check_access (sym->ts.derived->attr.access, + sym->ts.derived->ns->default_access) + && !sym->ts.derived->attr.use_assoc + && gfc_notify_std (GFC_STD_F2003, "Fortran 2003: PUBLIC %s '%s' at %L " + "of PRIVATE derived type '%s'", + (sym->attr.flavor == FL_PARAMETER) ? "parameter" + : "variable", sym->name, &sym->declared_at, + sym->ts.derived->name) == FAILURE) + return; + /* An assumed-size array with INTENT(OUT) shall not be of a type for which default initialization is defined (5.1.2.4.4). */ if (sym->ts.type == BT_DERIVED |