From ab62397a1b51a925abf062999a96556241dc3478 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 1 Jun 2016 16:24:02 +0200 Subject: [PATCH] re PR middle-end/71371 (ICE with OpenMP taskloop and addressable iterator) PR middle-end/71371 * gimplify.c (gimplify_omp_for): Temporarily clear gimplify_omp_ctxp around creation of the temporary. * c-c++-common/gomp/pr71371.c: New test. From-SVN: r236994 --- gcc/ChangeLog | 6 ++++++ gcc/gimplify.c | 5 +++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/c-c++-common/gomp/pr71371.c | 25 +++++++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 gcc/testsuite/c-c++-common/gomp/pr71371.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0c4aa2d0935..128c2e4abef 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-06-01 Jakub Jelinek + + PR middle-end/71371 + * gimplify.c (gimplify_omp_for): Temporarily clear gimplify_omp_ctxp + around creation of the temporary. + 2016-06-01 Richard Biener PR tree-optimization/71366 diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 131fa2433ce..f12c6a11456 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -9009,7 +9009,12 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) || (ort == ORT_SIMD && TREE_VEC_LENGTH (OMP_FOR_INIT (for_stmt)) > 1)) { + struct gimplify_omp_ctx *ctx = gimplify_omp_ctxp; + /* Make sure omp_add_variable is not called on it prematurely. + We call it ourselves a few lines later. */ + gimplify_omp_ctxp = NULL; var = create_tmp_var (TREE_TYPE (decl), get_name (decl)); + gimplify_omp_ctxp = ctx; TREE_OPERAND (t, 0) = var; gimplify_seq_add_stmt (&for_body, gimple_build_assign (decl, var)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cb2f8c62407..e8e8e3bb231 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-06-01 Jakub Jelinek + + PR middle-end/71371 + * c-c++-common/gomp/pr71371.c: New test. + 2016-06-01 Richard Biener PR tree-optimization/71366 diff --git a/gcc/testsuite/c-c++-common/gomp/pr71371.c b/gcc/testsuite/c-c++-common/gomp/pr71371.c new file mode 100644 index 00000000000..da6e842b6e8 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/pr71371.c @@ -0,0 +1,25 @@ +/* PR middle-end/71371 */ +/* { dg-do compile } */ + +void baz (int *); + +void +foo (void) +{ + int i; + #pragma omp taskloop + for (i = 0; i < 100; i++) + baz (&i); +} + +void +bar (void) +{ + int i; + #pragma omp parallel + { + #pragma omp for + for (i = 0; i < 100; i++) + baz (&i); + } +} -- 2.30.2