Debian Codegraph @

gcc/testsuite/c-c++-common/gomp/attrs-metadirective-1.c

raw
1 /* { dg-do compile { target { c || c++11 } } } */
2 /* { dg-options "-fopenmp -std=c23" { target { c } } } */
3
4 #define N 100
5
6 void
7 f (int a[], int b[], int c[])
8 {
9 int i;
10
11 [[omp::directive (metadirective
12 default (teams loop)
13 default (parallel loop))]] /* { dg-error "too many 'otherwise' or 'default' clauses in 'metadirective'" } */
14 for (i = 0; i < N; i++) c[i] = a[i] * b[i];
15
16 [[omp::directive (metadirective
17 default (bad_directive))]] /* { dg-error "unknown directive name before '\\)' token" } */
18 for (i = 0; i < N; i++) c[i] = a[i] * b[i];
19
20 [[omp::directive (metadirective
21 where (device={arch("nvptx")}: parallel loop) /* { dg-error "'where' is not valid for 'metadirective'" } */
22 default (teams loop))]]
23 for (i = 0; i < N; i++) c[i] = a[i] * b[i];
24
25 [[omp::directive (metadirective
26 otherwise (teams loop)
27 when (device={arch("nvptx")}: parallel loop))]] /* { dg-error "'otherwise' or 'default' clause must appear last" } */
28 for (i = 0; i < N; i++) c[i] = a[i] * b[i];
29
30 [[omp::directive (metadirective
31 when (device={arch("nvptx")} parallel loop) /* { dg-error "expected ':' before 'parallel'" } */
32 default (teams loop))]]
33 for (i = 0; i < N; i++) c[i] = a[i] * b[i];
34
35 [[omp::directive (metadirective
36 default (metadirective default (flush)))]] /* { dg-error "metadirectives cannot be used as variants of a 'metadirective' before 'default'" } */
37 for (i = 0; i < N; i++) c[i] = a[i] * b[i];
38
39 /* Test improperly nested metadirectives - even though the second
40 metadirective resolves to 'omp nothing', that is not the same as there
41 being literally nothing there. */
42 [[omp::directive (metadirective
43 when (implementation={vendor("gnu")}: parallel for))]]
44 [[omp::directive (metadirective /* { dg-error "loop nest expected" } */
45 when (implementation={vendor("cray")}: parallel for))]]
46 for (i = 0; i < N; i++) c[i] = a[i] * b[i];
47 }