re PR fortran/35837 (rej.valid: Host-associated SAVEd variable and PURE function)
authorDaniel Kraft <d@domob.eu>
Fri, 5 Sep 2008 20:51:50 +0000 (22:51 +0200)
committerDaniel Kraft <domob@gcc.gnu.org>
Fri, 5 Sep 2008 20:51:50 +0000 (22:51 +0200)
2008-09-05  Daniel Kraft  <d@domob.eu>

PR fortran/35837
* resolve.c (resolve_types): Restore gfc_current_ns on exit.
* symbol.c (gfc_save_all): Removed blank line.

2008-09-05  Daniel Kraft  <d@domob.eu>

PR fortran/35837
* gfortran.dg/save_3.f90: New test.

From-SVN: r140046

gcc/fortran/ChangeLog
gcc/fortran/resolve.c
gcc/fortran/symbol.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/save_3.f90 [new file with mode: 0644]

index d9c65ff..2008990 100644 (file)
@@ -1,5 +1,11 @@
 2008-09-05  Daniel Kraft  <d@domob.eu>
 
+       PR fortran/35837
+       * resolve.c (resolve_types): Restore gfc_current_ns on exit.
+       * symbol.c (gfc_save_all): Removed blank line.
+
+2008-09-05  Daniel Kraft  <d@domob.eu>
+
        PR fortran/36746
        * primary.c (gfc_match_rvalue): Removed logic to handle implicit
        typing to a derived-type if a component reference is found.
index 8c41ce4..e28d704 100644 (file)
@@ -10116,8 +10116,7 @@ resolve_types (gfc_namespace *ns)
   gfc_charlen *cl;
   gfc_data *d;
   gfc_equiv *eq;
-
-  gfc_current_ns = ns;
+  gfc_namespace* old_ns = gfc_current_ns;
 
   /* Check that all IMPLICIT types are ok.  */
   if (!ns->seen_implicit_none)
@@ -10131,6 +10130,8 @@ resolve_types (gfc_namespace *ns)
          return;
     }
 
+  gfc_current_ns = ns;
+
   resolve_entries (ns);
 
   resolve_common_vars (ns->blank_common.head, false);
@@ -10185,6 +10186,8 @@ resolve_types (gfc_namespace *ns)
     warn_unused_fortran_label (ns->st_labels);
 
   gfc_resolve_uops (ns->uop_root);
+
+  gfc_current_ns = old_ns;
 }
 
 
index ee45f2a..0b58079 100644 (file)
@@ -3194,7 +3194,6 @@ save_symbol (gfc_symbol *sym)
 void
 gfc_save_all (gfc_namespace *ns)
 {
-
   gfc_traverse_ns (ns, save_symbol);
 }
 
index eb9da58..a31b444 100644 (file)
@@ -1,3 +1,8 @@
+2008-09-05  Daniel Kraft  <d@domob.eu>
+
+       PR fortran/35837
+       * gfortran.dg/save_3.f90: New test.
+
 2008-09-05  Douglas Gregor  <doug.gregor@gmail.com>
 
        PR c++/37342
diff --git a/gcc/testsuite/gfortran.dg/save_3.f90 b/gcc/testsuite/gfortran.dg/save_3.f90
new file mode 100644 (file)
index 0000000..d2deed1
--- /dev/null
@@ -0,0 +1,16 @@
+! { dg-do compile }
+
+! PR fortran/35837
+! We used do have a problem with resolving "save all" and nested namespaces.
+
+! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
+
+module g95bug
+save
+integer :: i=20
+contains
+pure function tell_i() result (answer)
+  integer :: answer
+  answer=i
+end function tell_i
+end module g95bug