From 816a8c6d003ef2425e67de47cb8fcd4722b05536 Mon Sep 17 00:00:00 2001 From: jakub Date: Wed, 26 Oct 2016 16:21:56 +0000 Subject: [PATCH] PR fortran/77973 * gimplify.c (gimplify_adjust_omp_clauses_1): For all added map clauses with OMP_CLAUSE_SIZE being a decl, call omp_notice_variable on outer context if any. * gfortran.dg/gomp/pr77973.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241581 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 8 ++++++++ gcc/gimplify.c | 13 ++++++++++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/gomp/pr77973.f90 | 12 ++++++++++++ 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/gomp/pr77973.f90 diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4af539e39a8..4f5c3c220a7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,4 +1,12 @@ 2016-10-26 Jakub Jelinek + Martin Liska + + PR fortran/77973 + * gimplify.c (gimplify_adjust_omp_clauses_1): For all added map + clauses with OMP_CLAUSE_SIZE being a decl, call omp_notice_variable + on outer context if any. + +2016-10-26 Jakub Jelinek * gen-pass-instances.awk (adjust_linenos): INcrement pass_lines[p] by increment rather than double it. diff --git a/gcc/gimplify.c b/gcc/gimplify.c index d855c670012..5da1725acd1 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -8421,9 +8421,10 @@ gimplify_adjust_omp_clauses_1 (splay_tree_node n, void *data) && omp_shared_to_firstprivate_optimizable_decl_p (decl)) omp_mark_stores (gimplify_omp_ctxp->outer_context, decl); + tree chain = *list_p; clause = build_omp_clause (input_location, code); OMP_CLAUSE_DECL (clause) = decl; - OMP_CLAUSE_CHAIN (clause) = *list_p; + OMP_CLAUSE_CHAIN (clause) = chain; if (private_debug) OMP_CLAUSE_PRIVATE_DEBUG (clause) = 1; else if (code == OMP_CLAUSE_PRIVATE && (flags & GOVD_PRIVATE_OUTER_REF)) @@ -8450,7 +8451,7 @@ gimplify_adjust_omp_clauses_1 (splay_tree_node n, void *data) OMP_CLAUSE_SET_MAP_KIND (clause, GOMP_MAP_ALLOC); OMP_CLAUSE_MAP_MAYBE_ZERO_LENGTH_ARRAY_SECTION (clause) = 1; OMP_CLAUSE_SET_MAP_KIND (nc, GOMP_MAP_FIRSTPRIVATE_POINTER); - OMP_CLAUSE_CHAIN (nc) = *list_p; + OMP_CLAUSE_CHAIN (nc) = chain; OMP_CLAUSE_CHAIN (clause) = nc; struct gimplify_omp_ctx *ctx = gimplify_omp_ctxp; gimplify_omp_ctxp = ctx->outer_context; @@ -8520,7 +8521,7 @@ gimplify_adjust_omp_clauses_1 (splay_tree_node n, void *data) tree nc = build_omp_clause (input_location, OMP_CLAUSE_LASTPRIVATE); OMP_CLAUSE_DECL (nc) = decl; OMP_CLAUSE_LASTPRIVATE_FIRSTPRIVATE (nc) = 1; - OMP_CLAUSE_CHAIN (nc) = *list_p; + OMP_CLAUSE_CHAIN (nc) = chain; OMP_CLAUSE_CHAIN (clause) = nc; struct gimplify_omp_ctx *ctx = gimplify_omp_ctxp; gimplify_omp_ctxp = ctx->outer_context; @@ -8531,6 +8532,12 @@ gimplify_adjust_omp_clauses_1 (splay_tree_node n, void *data) struct gimplify_omp_ctx *ctx = gimplify_omp_ctxp; gimplify_omp_ctxp = ctx->outer_context; lang_hooks.decls.omp_finish_clause (clause, pre_p); + if (gimplify_omp_ctxp) + for (; clause != chain; clause = OMP_CLAUSE_CHAIN (clause)) + if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP + && DECL_P (OMP_CLAUSE_SIZE (clause))) + omp_notice_variable (gimplify_omp_ctxp, OMP_CLAUSE_SIZE (clause), + true); gimplify_omp_ctxp = ctx; return 0; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 84dc56df113..0ceb8d1cbb7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-10-26 Jakub Jelinek + + PR fortran/77973 + * gfortran.dg/gomp/pr77973.f90: New test. + 2016-10-26 Paul Thomas PR fortran/78108 diff --git a/gcc/testsuite/gfortran.dg/gomp/pr77973.f90 b/gcc/testsuite/gfortran.dg/gomp/pr77973.f90 new file mode 100644 index 00000000000..0fcc2f273cc --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/pr77973.f90 @@ -0,0 +1,12 @@ +! PR fortran/77973 +! { dg-do compile } + +subroutine s(x) + integer :: x(:) + integer :: i +!$omp parallel +!$omp target + x(1) = 1 +!$omp end target +!$omp end parallel +end -- 2.11.4.GIT