Commit c7d3bb76 by Jakub Jelinek Committed by Jakub Jelinek

re PR fortran/47331 (ICE in make_decl_rtl, at varasm.c:1133 (with -fopenmp))

	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.

	* gfortran.dg/gomp/pr47331.f90: New test.

From-SVN: r168935
parent f0fc7be5
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> 2011-01-17 Tobias Burnus <burnus@net-b.de>
PR fortran/47327 PR fortran/47327
......
...@@ -2651,11 +2651,14 @@ void gfc_free_case_list (gfc_case *); ...@@ -2651,11 +2651,14 @@ void gfc_free_case_list (gfc_case *);
gfc_expr *gfc_get_parentheses (gfc_expr *); gfc_expr *gfc_get_parentheses (gfc_expr *);
/* openmp.c */ /* openmp.c */
struct gfc_omp_saved_state { void *ptrs[2]; int ints[1]; };
void gfc_free_omp_clauses (gfc_omp_clauses *); void gfc_free_omp_clauses (gfc_omp_clauses *);
void gfc_resolve_omp_directive (gfc_code *, gfc_namespace *); void gfc_resolve_omp_directive (gfc_code *, gfc_namespace *);
void gfc_resolve_do_iterator (gfc_code *, gfc_symbol *); void gfc_resolve_do_iterator (gfc_code *, gfc_symbol *);
void gfc_resolve_omp_parallel_blocks (gfc_code *, gfc_namespace *); void gfc_resolve_omp_parallel_blocks (gfc_code *, gfc_namespace *);
void gfc_resolve_omp_do_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 */ /* expr.c */
void gfc_free_actual_arglist (gfc_actual_arglist *); void gfc_free_actual_arglist (gfc_actual_arglist *);
......
...@@ -1390,6 +1390,31 @@ gfc_resolve_omp_parallel_blocks (gfc_code *code, gfc_namespace *ns) ...@@ -1390,6 +1390,31 @@ gfc_resolve_omp_parallel_blocks (gfc_code *code, gfc_namespace *ns)
} }
/* 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 /* Note a DO iterator variable. This is special in !$omp parallel
construct, where they are predetermined private. */ construct, where they are predetermined private. */
......
...@@ -2011,11 +2011,14 @@ resolve_global_procedure (gfc_symbol *sym, locus *where, ...@@ -2011,11 +2011,14 @@ resolve_global_procedure (gfc_symbol *sym, locus *where,
if (!gsym->ns->resolved) if (!gsym->ns->resolved)
{ {
gfc_dt_list *old_dt_list; 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 /* Stash away derived types so that the backend_decls do not
get mixed up. */ get mixed up. */
old_dt_list = gfc_derived_types; old_dt_list = gfc_derived_types;
gfc_derived_types = NULL; gfc_derived_types = NULL;
/* And stash away openmp state. */
gfc_omp_save_and_clear_state (&old_omp_state);
gfc_resolve (gsym->ns); gfc_resolve (gsym->ns);
...@@ -2025,6 +2028,8 @@ resolve_global_procedure (gfc_symbol *sym, locus *where, ...@@ -2025,6 +2028,8 @@ resolve_global_procedure (gfc_symbol *sym, locus *where,
/* Restore the derived types of this namespace. */ /* Restore the derived types of this namespace. */
gfc_derived_types = old_dt_list; 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 /* 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> 2011-01-17 Nicola Pero <nicola.pero@meta-innovation.com>
PR objc/47314 PR objc/47314
......
! 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment