This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/52751] private module variable are not exported as local
- From: "burnus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 03 Apr 2012 15:15:31 +0000
- Subject: [Bug fortran/52751] private module variable are not exported as local
- Auto-submitted: auto-generated
- References: <bug-52751-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52751
--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-04-03 15:15:31 UTC ---
Another caveat (as in PR40973): If the variable has a C-binding (other than
'bind(C,name="")'), it is accessible from other translation units.
(Actually, NAG exactly handles it like that: With name='' it is "static" with
another C binding, it is not.)
Draft patch:
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -565,7 +565,8 @@ gfc_finish_var_decl (tree decl, gfc_symbol * sym)
/* TODO: Don't set sym->module for result or dummy variables. */
gcc_assert (current_function_decl == NULL_TREE || sym->result == sym);
/* This is the declaration of a module variable. */
- TREE_PUBLIC (decl) = 1;
+ if (sym->attr.access != ACCESS_PRIVATE || sym->binding_label)
+ TREE_PUBLIC (decl) = 1;
TREE_STATIC (decl) = 1;
}