https://gcc.gnu.org/g:d390c7e5bd03490485a0b036add096e2e8b811b9
commit r15-9731-gd390c7e5bd03490485a0b036add096e2e8b811b9 Author: Tobias Burnus <tbur...@baylibre.com> Date: Mon May 26 19:50:40 2025 +0200 c-c++-common/gomp/{attrs-,}metadirective-3.c: Fix expected result [PR118694] With compilation for nvptx enabled, two issues showed up: (a) "error: 'target' construct with nested 'teams' construct contains directives outside of the 'teams' construct" See PR comment 9 why this is difficult to fix. Solution: Add dg-bogus and accept/expect the error for 'target offload_nvptx'. (b) The assumptions about the dump for 'target offload_nvptx' were wrong as the metadirective was already expanded to a OMP_NEXT_VARIANT construct such that no 'omp metadirective' was left in either case. Solution: Check that no 'omp metadirective' is left; additionally, expect either OMP_NEXT_VARIANT (when offload_nvptx is available) or no 'teams' directive at all (if not). gcc/testsuite/ChangeLog: PR middle-end/118694 * c-c++-common/gomp/attrs-metadirective-3.c: Change to never expect 'omp metadirective' in the dump. If !offload_nvptx, check that no 'teams' shows up in the dump; for offload_nvptx, expect OMP_NEXT_VARIANT and an error about directive between 'target' and 'teams'. * c-c++-common/gomp/metadirective-3.c: Likewise. (cherry picked from commit 5d6ed6d604ff949b650e48fa4eaed3ec8b6489c1) Diff: --- gcc/testsuite/c-c++-common/gomp/attrs-metadirective-3.c | 7 ++++--- gcc/testsuite/c-c++-common/gomp/metadirective-3.c | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/gcc/testsuite/c-c++-common/gomp/attrs-metadirective-3.c b/gcc/testsuite/c-c++-common/gomp/attrs-metadirective-3.c index 31dd054922fc..803bf0ad1ebf 100644 --- a/gcc/testsuite/c-c++-common/gomp/attrs-metadirective-3.c +++ b/gcc/testsuite/c-c++-common/gomp/attrs-metadirective-3.c @@ -9,7 +9,7 @@ f (int x[], int y[], int z[]) { int i; - [[omp::sequence (directive (target map(to: x, y) map(from: z)), + [[omp::sequence (directive (target map(to: x, y) map(from: z)), /* { dg-bogus "'target' construct with nested 'teams' construct contains directives outside of the 'teams' construct" "PR118694" { xfail offload_nvptx } } */ directive (metadirective when (device={arch("nvptx")}: teams loop) default (parallel loop)))]] @@ -20,5 +20,6 @@ f (int x[], int y[], int z[]) /* If offload device "nvptx" isn't supported, the front end can eliminate that alternative and not produce a metadirective at all. Otherwise this won't be resolved until late. */ -/* { dg-final { scan-tree-dump-not "#pragma omp metadirective" "gimple" { target { ! offload_nvptx } } } } */ -/* { dg-final { scan-tree-dump "#pragma omp metadirective" "gimple" { target { offload_nvptx } } } } */ +/* { dg-final { scan-tree-dump-not "#pragma omp metadirective" "gimple" } } */ +/* { dg-final { scan-tree-dump-not " teams" "gimple" { target { ! offload_nvptx } } } } */ +/* { dg-final { scan-tree-dump "variant.\[0-9\]+ = \\\[omp_next_variant\\\] OMP_NEXT_VARIANT <0,\[\r\n \]+construct context = 14\[\r\n \]+1: device = \\{arch \\(.nvptx.\\)\\}\[\r\n \]+2: >;" "gimple" { target { offload_nvptx } } } } */ diff --git a/gcc/testsuite/c-c++-common/gomp/metadirective-3.c b/gcc/testsuite/c-c++-common/gomp/metadirective-3.c index 0ac0d1d329d8..b6c1601f7b10 100644 --- a/gcc/testsuite/c-c++-common/gomp/metadirective-3.c +++ b/gcc/testsuite/c-c++-common/gomp/metadirective-3.c @@ -8,7 +8,7 @@ f (int x[], int y[], int z[]) { int i; - #pragma omp target map(to: x, y) map(from: z) + #pragma omp target map(to: x, y) map(from: z) /* { dg-bogus "'target' construct with nested 'teams' construct contains directives outside of the 'teams' construct" "PR118694" { xfail offload_nvptx } } */ #pragma omp metadirective \ when (device={arch("nvptx")}: teams loop) \ default (parallel loop) @@ -19,5 +19,6 @@ f (int x[], int y[], int z[]) /* If offload device "nvptx" isn't supported, the front end can eliminate that alternative and not produce a metadirective at all. Otherwise this won't be resolved until late. */ -/* { dg-final { scan-tree-dump-not "#pragma omp metadirective" "gimple" { target { ! offload_nvptx } } } } */ -/* { dg-final { scan-tree-dump "#pragma omp metadirective" "gimple" { target { offload_nvptx } } } } */ +/* { dg-final { scan-tree-dump-not "#pragma omp metadirective" "gimple" } } */ +/* { dg-final { scan-tree-dump-not " teams" "gimple" { target { ! offload_nvptx } } } } */ +/* { dg-final { scan-tree-dump "variant.\[0-9\]+ = \\\[omp_next_variant\\\] OMP_NEXT_VARIANT <0,\[\r\n \]+construct context = 14\[\r\n \]+1: device = \\{arch \\(.nvptx.\\)\\}\[\r\n \]+2: >;" "gimple" { target { offload_nvptx } } } } */