OSDN Git Service

2012-08-12 Tobias Burnus <burnus@net-b.de>
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 12 Aug 2012 09:52:33 +0000 (09:52 +0000)
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 12 Aug 2012 09:52:33 +0000 (09:52 +0000)
        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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@190325 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/trans-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/public_private_module_6.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/vect/vect-gems.f90

index bcdb679..b0fe190 100644 (file)
@@ -1,3 +1,9 @@
+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-09  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/54199
index f1b7444..6ef00e1 100644 (file)
@@ -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
index 5c5b9b5..a11888b 100644 (file)
@@ -1,3 +1,10 @@
+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.
+
 2012-08-11  Martin Jambor  <mjambor@suse.cz>
 
        PR fortran/48636
diff --git a/gcc/testsuite/gfortran.dg/public_private_module_6.f90 b/gcc/testsuite/gfortran.dg/public_private_module_6.f90
new file mode 100644 (file)
index 0000000..85d6930
--- /dev/null
@@ -0,0 +1,14 @@
+! { dg-do compile }
+! { dg-options "-O1" }
+!
+! PR fortran/54221
+!
+! Check that the unused PRIVATE "aaaa" variable is optimized away
+!
+
+module m
+  private
+  integer, save :: aaaa
+end module m
+
+! { dg-final { scan-assembler-not "aaaa" } }
index 019b415..2f75355 100644 (file)
@@ -5,9 +5,9 @@ MODULE UPML_mod
 
 IMPLICIT NONE
 
-PUBLIC UPMLupdateE
-
-PRIVATE
+!PUBLIC UPMLupdateE
+!
+!PRIVATE
 
 real(kind=8), dimension(:,:,:), allocatable :: Dx_ilow