At present, the fortran FE reports an error if the user adds an explicit private clause to an induction variable used by an acc loop. This patch teaches the fortran acc block resolver how to cope with "duplicate" private clauses, so that it doesn't error anymore.
Is this patch OK for trunk? I bootstrapped and regression tested it for x86_64 with nvptx offloading. Thanks, Cesar
>From 576b2a7d5574400f067ec309929b38b324d8c6f6 Mon Sep 17 00:00:00 2001 From: Cesar Philippidis <ce...@codesourcery.com> Date: Fri, 27 Jan 2017 14:58:16 +0000 Subject: [PATCH] [OpenACC] Don't error on implicitly private induction variables in gfortran 2018-XX-YY Cesar Philippidis <ce...@codesourcery.com> gcc/fortran/ * openmp.c (gfc_resolve_oacc_blocks): Populate list of private variables. gcc/testsuite/ * gfortran.dg/goacc/implicitly-private.f90: New test. --- gcc/fortran/openmp.c | 5 +++++ gcc/testsuite/gfortran.dg/goacc/implicitly-private.f90 | 12 ++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/goacc/implicitly-private.f90 diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c index b346b51..798c5fa 100644 --- a/gcc/fortran/openmp.c +++ b/gcc/fortran/openmp.c @@ -5951,6 +5951,7 @@ void gfc_resolve_oacc_blocks (gfc_code *code, gfc_namespace *ns) { fortran_omp_context ctx; + gfc_omp_namelist *n; resolve_oacc_loop_blocks (code); @@ -5961,6 +5962,10 @@ gfc_resolve_oacc_blocks (gfc_code *code, gfc_namespace *ns) ctx.is_openmp = false; omp_current_ctx = &ctx; + if (code->ext.omp_clauses) + for (n = code->ext.omp_clauses->lists[OMP_LIST_PRIVATE]; n; n = n->next) + ctx.private_iterators->add (n->sym); + gfc_resolve_blocks (code->block, ns); omp_current_ctx = ctx.previous; diff --git a/gcc/testsuite/gfortran.dg/goacc/implicitly-private.f90 b/gcc/testsuite/gfortran.dg/goacc/implicitly-private.f90 new file mode 100644 index 0000000..a687d8a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/implicitly-private.f90 @@ -0,0 +1,12 @@ +! Ensure that implicitly private variables do not clash with those +! that are explicitly private. + +program main + implicit none + + integer i + + !$acc parallel loop private(i) + do i = 1, 100 + end do +end program main -- 2.7.4