aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-decl.c
diff options
context:
space:
mode:
authorTobias Burnus <burnus@net-b.de>2012-08-12 11:52:33 +0200
committerTobias Burnus <burnus@gcc.gnu.org>2012-08-12 11:52:33 +0200
commit58341a42945fd052a5d27ef932a41038f11e3398 (patch)
tree0548329e2709a7fd00b2711e09a8cd7dfa34c31b /gcc/fortran/trans-decl.c
parent46d2f0c2bc4654815ea3f484a9fd59c8ec0ad362 (diff)
downloadgcc-58341a42945fd052a5d27ef932a41038f11e3398.zip
gcc-58341a42945fd052a5d27ef932a41038f11e3398.tar.gz
gcc-58341a42945fd052a5d27ef932a41038f11e3398.tar.bz2
re PR fortran/54221 (Explicit private access specifier signals "unexpected defined but not used [-Wunused-function]" warning)
2012-08-12 Tobias Burnus <burnus@net-b.de> PR fortran/54221 * trans-decl.c (gfc_finish_var_decl, build_function_decl): Fix setting private module vars/procs as TREE_PUBLIC(...) = 0. 2012-08-12 Tobias Burnus <burnus@net-b.de> PR fortran/54221 * vect/vect-gems.f90: Don't mark module vars as PRIVATE as they appear uninitialized on the RHS. * gfortran.dg/public_private_module_6.f90: New. From-SVN: r190325
Diffstat (limited to 'gcc/fortran/trans-decl.c')
-rw-r--r--gcc/fortran/trans-decl.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index f1b7444..6ef00e1 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -562,6 +562,12 @@ 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. */
+ if (sym->attr.access == ACCESS_UNKNOWN
+ && (sym->ns->default_access == ACCESS_PRIVATE
+ || (sym->ns->default_access == ACCESS_UNKNOWN
+ && gfc_option.flag_module_private)))
+ sym->attr.access = ACCESS_PRIVATE;
+
if (sym->attr.access != ACCESS_PRIVATE || sym->attr.public_used)
TREE_PUBLIC (decl) = 1;
TREE_STATIC (decl) = 1;
@@ -1839,6 +1845,12 @@ build_function_decl (gfc_symbol * sym, bool global)
the opposite of declaring a function as static in C). */
DECL_EXTERNAL (fndecl) = 0;
+ if (sym->attr.access == ACCESS_UNKNOWN && sym->module
+ && (sym->ns->default_access == ACCESS_PRIVATE
+ || (sym->ns->default_access == ACCESS_UNKNOWN
+ && gfc_option.flag_module_private)))
+ sym->attr.access = ACCESS_PRIVATE;
+
if (!current_function_decl
&& !sym->attr.entry_master && !sym->attr.is_main_program
&& (sym->attr.access != ACCESS_PRIVATE || sym->binding_label