diff options
author | Jakub Jelinek <jakub@redhat.com> | 2011-01-17 23:26:42 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2011-01-17 23:26:42 +0100 |
commit | c7d3bb7623a428af85bd04c7f225ed54241c29bd (patch) | |
tree | aa50e1a8b8b10ba96d0ffb0526298e3164516071 /gcc | |
parent | f0fc7be52568981d377ec6910013e75b39263276 (diff) | |
download | gcc-c7d3bb7623a428af85bd04c7f225ed54241c29bd.zip gcc-c7d3bb7623a428af85bd04c7f225ed54241c29bd.tar.gz gcc-c7d3bb7623a428af85bd04c7f225ed54241c29bd.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/fortran/gfortran.h | 3 | ||||
-rw-r--r-- | gcc/fortran/openmp.c | 25 | ||||
-rw-r--r-- | gcc/fortran/resolve.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/gomp/pr47331.f90 | 24 |
6 files changed, 72 insertions, 0 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 40167d1..50492cc 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,13 @@ +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 diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index 2622f22..ebba2a8 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -2651,11 +2651,14 @@ void gfc_free_case_list (gfc_case *); 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 *); diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c index 6e81821..24e32eb 100644 --- a/gcc/fortran/openmp.c +++ b/gcc/fortran/openmp.c @@ -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 construct, where they are predetermined private. */ diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index a1c9917..ed39e78 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -2011,11 +2011,14 @@ resolve_global_procedure (gfc_symbol *sym, locus *where, 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); @@ -2025,6 +2028,8 @@ resolve_global_procedure (gfc_symbol *sym, locus *where, /* 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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ad33134..33b7c54 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +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 diff --git a/gcc/testsuite/gfortran.dg/gomp/pr47331.f90 b/gcc/testsuite/gfortran.dg/gomp/pr47331.f90 new file mode 100644 index 0000000..71713e0 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/pr47331.f90 @@ -0,0 +1,24 @@ +! 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 |