diff options
author | Tobias Burnus <burnus@net-b.de> | 2012-05-04 20:54:25 +0200 |
---|---|---|
committer | Tobias Burnus <burnus@gcc.gnu.org> | 2012-05-04 20:54:25 +0200 |
commit | ed4639a996cda959bf36c8fab94517a123978101 (patch) | |
tree | 433a90213b8b4c8613e31097b36bed3bd909cdb1 /gcc/fortran/resolve.c | |
parent | 6ba84c3143a13266f40ea804ae2fb98717ccfc04 (diff) | |
download | gcc-ed4639a996cda959bf36c8fab94517a123978101.zip gcc-ed4639a996cda959bf36c8fab94517a123978101.tar.gz gcc-ed4639a996cda959bf36c8fab94517a123978101.tar.bz2 |
re PR fortran/53175 (link failure for private module variables used in function specification)
2012-05-04 Tobias Burnus <burnus@net-b.de>
PR fortran/53175
* resolve.c (resolve_variable): Set public_used
if a private module variable is used in a (public)
specification expression.
* trans-decl.c (gfc_finish_var_decl): Mark those
TREE_PUBLIC.
2012-05-04 Tobias Burnus <burnus@net-b.de>
PR fortran/53175
gfortran.dg/public_private_module_5.f90: New.
From-SVN: r187175
Diffstat (limited to 'gcc/fortran/resolve.c')
-rw-r--r-- | gcc/fortran/resolve.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 411ebb5..e15d6e1 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -5124,6 +5124,19 @@ resolve_variable (gfc_expr *e) if (check_assumed_size_reference (sym, e)) return FAILURE; + /* If a PRIVATE variable is used in the specification expression of the + result variable, it might be accessed from outside the module and can + thus not be TREE_PUBLIC() = 0. + TODO: sym->attr.public_used only has to be set for the result variable's + type-parameter expression and not for dummies or automatic variables. + Additionally, it only has to be set if the function is either PUBLIC or + used in a generic interface or TBP; unfortunately, + proc_name->attr.public_used can get set at a later stage. */ + if (specification_expr && sym->attr.access == ACCESS_PRIVATE + && !sym->attr.function && !sym->attr.use_assoc + && gfc_current_ns->proc_name && gfc_current_ns->proc_name->attr.function) + sym->attr.public_used = 1; + /* Deal with forward references to entries during resolve_code, to satisfy, at least partially, 12.5.2.5. */ if (gfc_current_ns->entries |