* gfortran.h (struct gfc_omp_saved_state): New type.
(gfc_omp_save_and_clear_state, gfc_omp_restore_state): New prototypes.
* resolve.c (resolve_global_procedure): Call it around gfc_resolve
call.
* openmp.c (gfc_omp_save_and_clear_state, gfc_omp_restore_state): New
functions.
* gfortran.dg/gomp/pr47331.f90: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@168935
138bc75d-0d04-0410-961f-
82ee72b054a4
+2011-01-17 Jakub Jelinek <jakub@redhat.com>
+
+ PR fortran/47331
+ * gfortran.h (struct gfc_omp_saved_state): New type.
+ (gfc_omp_save_and_clear_state, gfc_omp_restore_state): New prototypes.
+ * resolve.c (resolve_global_procedure): Call it around gfc_resolve
+ call.
+ * openmp.c (gfc_omp_save_and_clear_state, gfc_omp_restore_state): New
+ functions.
+
2011-01-17 Tobias Burnus <burnus@net-b.de>
PR fortran/47327
gfc_expr *gfc_get_parentheses (gfc_expr *);
/* openmp.c */
+struct gfc_omp_saved_state { void *ptrs[2]; int ints[1]; };
void gfc_free_omp_clauses (gfc_omp_clauses *);
void gfc_resolve_omp_directive (gfc_code *, gfc_namespace *);
void gfc_resolve_do_iterator (gfc_code *, gfc_symbol *);
void gfc_resolve_omp_parallel_blocks (gfc_code *, gfc_namespace *);
void gfc_resolve_omp_do_blocks (gfc_code *, gfc_namespace *);
+void gfc_omp_save_and_clear_state (struct gfc_omp_saved_state *);
+void gfc_omp_restore_state (struct gfc_omp_saved_state *);
/* expr.c */
void gfc_free_actual_arglist (gfc_actual_arglist *);
}
+/* Save and clear openmp.c private state. */
+
+void
+gfc_omp_save_and_clear_state (struct gfc_omp_saved_state *state)
+{
+ state->ptrs[0] = omp_current_ctx;
+ state->ptrs[1] = omp_current_do_code;
+ state->ints[0] = omp_current_do_collapse;
+ omp_current_ctx = NULL;
+ omp_current_do_code = NULL;
+ omp_current_do_collapse = 0;
+}
+
+
+/* Restore openmp.c private state from the saved state. */
+
+void
+gfc_omp_restore_state (struct gfc_omp_saved_state *state)
+{
+ omp_current_ctx = (struct omp_context *) state->ptrs[0];
+ omp_current_do_code = (gfc_code *) state->ptrs[1];
+ omp_current_do_collapse = state->ints[0];
+}
+
+
/* Note a DO iterator variable. This is special in !$omp parallel
construct, where they are predetermined private. */
if (!gsym->ns->resolved)
{
gfc_dt_list *old_dt_list;
+ struct gfc_omp_saved_state old_omp_state;
/* Stash away derived types so that the backend_decls do not
get mixed up. */
old_dt_list = gfc_derived_types;
gfc_derived_types = NULL;
+ /* And stash away openmp state. */
+ gfc_omp_save_and_clear_state (&old_omp_state);
gfc_resolve (gsym->ns);
/* Restore the derived types of this namespace. */
gfc_derived_types = old_dt_list;
+ /* And openmp state. */
+ gfc_omp_restore_state (&old_omp_state);
}
/* Make sure that translation for the gsymbol occurs before
+2011-01-17 Jakub Jelinek <jakub@redhat.com>
+
+ PR fortran/47331
+ * gfortran.dg/gomp/pr47331.f90: New test.
+
2011-01-17 Nicola Pero <nicola.pero@meta-innovation.com>
PR objc/47314
--- /dev/null
+! PR fortran/47331
+! { dg-do compile }
+! { dg-options "-fopenmp -fwhole-file" }
+
+subroutine foo
+ !$omp parallel
+ call bar ()
+ !$omp end parallel
+end subroutine foo
+
+subroutine bar
+ integer :: k
+ do k=1,5
+ call baz (k)
+ end do
+end subroutine bar
+
+subroutine baz (k)
+ integer :: k
+end subroutine
+
+program pr47331
+ call foo
+end program pr47331