aboutsummaryrefslogtreecommitdiff
path: root/gcc/omp-low.c
diff options
context:
space:
mode:
authorChung-Lin Tang <cltang@codesourcery.com>2016-08-17 12:08:30 +0000
committerChung-Lin Tang <cltang@gcc.gnu.org>2016-08-17 12:08:30 +0000
commit11c4c4ba47fce0a6be2125e2bd7ee3d16bc8d8af (patch)
tree22f67221131bc8c5e54b3185038cc612ef12ab7f /gcc/omp-low.c
parent661d6efd62869911344c2d8bd57dd3ca8f4af1dc (diff)
downloadgcc-11c4c4ba47fce0a6be2125e2bd7ee3d16bc8d8af.zip
gcc-11c4c4ba47fce0a6be2125e2bd7ee3d16bc8d8af.tar.gz
gcc-11c4c4ba47fce0a6be2125e2bd7ee3d16bc8d8af.tar.bz2
omp-low.c (lower_oacc_reductions): Adjust variable lookup to use maybe_lookup_decl...
2016-08-17 Chung-Lin Tang <cltang@codesourcery.com> * omp-low.c (lower_oacc_reductions): Adjust variable lookup to use maybe_lookup_decl, to handle nested acc loop directives. testsuite/ * c-c++-common/goacc/reduction-6.c: New testcase. From-SVN: r239530
Diffstat (limited to 'gcc/omp-low.c')
-rw-r--r--gcc/omp-low.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 678c36e..3f7debf 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -5660,10 +5660,19 @@ lower_oacc_reductions (location_t loc, tree clauses, tree level, bool inner,
outgoing = var;
incoming = omp_reduction_init_op (loc, rcode, type);
}
- else if (ctx->outer)
- incoming = outgoing = lookup_decl (orig, ctx->outer);
else
- incoming = outgoing = orig;
+ {
+ /* Try to look at enclosing contexts for reduction var,
+ use original if no mapping found. */
+ tree t = NULL_TREE;
+ omp_context *c = ctx->outer;
+ while (c && !t)
+ {
+ t = maybe_lookup_decl (orig, c);
+ c = c->outer;
+ }
+ incoming = outgoing = (t ? t : orig);
+ }
has_outer_reduction:;
}