From: Thomas Schwinge Date: Tue, 3 Nov 2020 21:06:29 +0000 (+0100) Subject: [OpenACC] Use proper location to 'inform' of enclosing parent compute construct X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fab72592d86d11b89a01f0f3c2c9c329d43466c1;p=gcc.git [OpenACC] Use proper location to 'inform' of enclosing parent compute construct Bug fix for recent commit beddd1762ad2bbe84dd776c54489153f83f21e56 "[OpenACC] More precise diagnostics for 'gang', 'worker', 'vector' clauses with arguments on 'loop' only allowed in 'kernels' regions": > [...], and 'inform' at the location of the enclosing parent > compute construct/[...]. Now really. gcc/ * omp-low.c (scan_omp_for) : Use proper location to 'inform' of enclosing parent compute construct. gcc/testsuite/ * c-c++-common/goacc/pr92793-1.c: Extend. * gfortran.dg/goacc/pr92793-1.f90: Likewise. --- diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 2f1a544bd46..ea9008b61c4 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -2443,7 +2443,7 @@ scan_omp_for (gomp_for *stmt, omp_context *outer_ctx) "argument not permitted on %qs clause", omp_clause_code_name[OMP_CLAUSE_CODE (c)]); if (tgt) - inform (gimple_location (outer_ctx->stmt), + inform (gimple_location (tgt->stmt), "enclosing parent compute construct"); else if (oacc_get_fn_attrib (current_function_decl)) inform (DECL_SOURCE_LOCATION (current_function_decl), diff --git a/gcc/testsuite/c-c++-common/goacc/pr92793-1.c b/gcc/testsuite/c-c++-common/goacc/pr92793-1.c index 77ebb20265c..71a556e2751 100644 --- a/gcc/testsuite/c-c++-common/goacc/pr92793-1.c +++ b/gcc/testsuite/c-c++-common/goacc/pr92793-1.c @@ -57,7 +57,7 @@ reduction(-:sum ) /* { dg-line sum2 } */ \ void -a_sl() { +gwv_sl_1() { #pragma acc serial loop /* { dg-message "9: enclosing parent compute construct" } */ \ gang(num:5) /* { dg-error "5: argument not permitted on 'gang' clause" } */ \ worker(num:5) /* { dg-error "3: argument not permitted on 'worker' clause" } */ \ @@ -67,7 +67,25 @@ a_sl() { } void -a_s_l() { +gwv_sl_2() { +#pragma acc serial loop /* { dg-message "9: enclosing parent compute construct" } */ + for (int i = 0; i < 10; i++) + { +#pragma acc loop /* { dg-bogus "enclosing parent compute construct" } */ + for (int j = 0; j < 10; j++) + { +#pragma acc loop \ + gang(num:5) /* { dg-error "9: argument not permitted on 'gang' clause" } */ \ + worker(num:5) /* { dg-error "5: argument not permitted on 'worker' clause" } */ \ + vector(length:5) /* { dg-error "3: argument not permitted on 'vector' clause" } */ + for (int k = 0; k < 10; k++) + ; + } + } +} + +void +gwv_s_l() { #pragma acc serial /* { dg-message "9: enclosing parent compute construct" } */ { #pragma acc loop \ @@ -76,18 +94,48 @@ a_s_l() { vector(length:5) /* { dg-error "3: argument not permitted on 'vector' clause" } */ for (int i = 0; i < 10; i++) ; + +#pragma acc loop + for (int i = 0; i < 10; i++) + { +#pragma acc loop /* { dg-bogus "enclosing parent compute construct" } */ + for (int j = 0; j < 10; j++) + { +#pragma acc loop \ + gang(num:5) /* { dg-error "10: argument not permitted on 'gang' clause" } */ \ + worker(num:5) /* { dg-error "7: argument not permitted on 'worker' clause" } */ \ + vector(length:5) /* { dg-error "5: argument not permitted on 'vector' clause" } */ + for (int k = 0; k < 10; k++) + ; + } + } } } -void a_r(); -#pragma acc routine(a_r) +void gwv_r(); +#pragma acc routine(gwv_r) void -a_r() { /* { dg-message "1: enclosing routine" } */ +gwv_r() { /* { dg-message "1: enclosing routine" } */ #pragma acc loop \ gang(num:5) /* { dg-error "4: argument not permitted on 'gang' clause" } */ \ worker(num:5) /* { dg-error "5: argument not permitted on 'worker' clause" } */ \ vector(length:5) /* { dg-error "3: argument not permitted on 'vector' clause" } */ for (int i = 0; i < 10; i++) ; + +#pragma acc loop + for (int i = 0; i < 10; i++) + { +#pragma acc loop + for (int j = 0; j < 10; j++) + { +#pragma acc loop \ + gang(num:5) /* { dg-error "6: argument not permitted on 'gang' clause" } */ \ + worker(num:5) /* { dg-error "4: argument not permitted on 'worker' clause" } */ \ + vector(length:5) /* { dg-error "6: argument not permitted on 'vector' clause" } */ + for (int k = 0; k < 10; k++) + ; + } + } } diff --git a/gcc/testsuite/gfortran.dg/goacc/pr92793-1.f90 b/gcc/testsuite/gfortran.dg/goacc/pr92793-1.f90 index 4651ccffaa1..422131ba473 100644 --- a/gcc/testsuite/gfortran.dg/goacc/pr92793-1.f90 +++ b/gcc/testsuite/gfortran.dg/goacc/pr92793-1.f90 @@ -47,7 +47,7 @@ subroutine check () end subroutine check -subroutine gwv_sl () +subroutine gwv_sl_1 () implicit none (type, external) integer :: i @@ -59,11 +59,30 @@ subroutine gwv_sl () do i = 0, 10 end do !$acc end serial loop -end subroutine gwv_sl +end subroutine gwv_sl_1 + +subroutine gwv_sl_2 () + implicit none (type, external) + integer :: i, j, k + + !$acc serial loop ! { dg-message "77: enclosing parent compute construct" } + do i = 0, 10 + !$acc loop ! { dg-bogus "enclosing parent compute construct" } + do j = 0, 10 + !$acc loop & + !$acc & gang(num:5) & ! { dg-error "35: argument not permitted on 'gang' clause" } + !$acc & worker(num:5) & ! { dg-error "32: argument not permitted on 'worker' clause" } + !$acc & vector(length:5) ! { dg-error "33: argument not permitted on 'vector' clause" } + do k = 0, 10 + end do + end do + end do + !$acc end serial loop +end subroutine gwv_sl_2 subroutine gwv_s_l () implicit none (type, external) - integer :: i + integer :: i, j, k !$acc serial ! { dg-message "72: enclosing parent compute construct" } !$acc loop & @@ -72,12 +91,25 @@ subroutine gwv_s_l () !$acc & vector(length:5) ! { dg-error "29: argument not permitted on 'vector' clause" } do i = 0, 10 end do - !$acc end serial + + !$acc loop + do i = 0, 10 + !$acc loop ! { dg-bogus "enclosing parent compute construct" } + do j = 0, 10 + !$acc loop & + !$acc & gang(num:5) & ! { dg-error "35: argument not permitted on 'gang' clause" } + !$acc & worker(num:5) & ! { dg-error "32: argument not permitted on 'worker' clause" } + !$acc & vector(length:5) ! { dg-error "37: argument not permitted on 'vector' clause" } + do k = 0, 10 + end do + end do + end do +!$acc end serial end subroutine gwv_s_l subroutine gwv_r () ! { dg-message "16: enclosing routine" } implicit none (type, external) - integer :: i + integer :: i, j, k !$acc routine(gwv_r) @@ -87,4 +119,17 @@ subroutine gwv_r () ! { dg-message "16: enclosing routine" } !$acc & vector(length:5) ! { dg-error "27: argument not permitted on 'vector' clause" } do i = 0, 10 end do + + !$acc loop + do i = 0, 10 + !$acc loop + do j = 0, 10 + !$acc loop & + !$acc & gang(num:5) & ! { dg-error "31: argument not permitted on 'gang' clause" } + !$acc & worker(num:5) & ! { dg-error "31: argument not permitted on 'worker' clause" } + !$acc & vector(length:5) ! { dg-error "36: argument not permitted on 'vector' clause" } + do k = 0, 10 + end do + end do + end do end subroutine gwv_r