Debian Codegraph @

gcc/testsuite/gcc.dg/gomp/attrs-11.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-fopenmp -std=c23 -Wno-attributes" } */
3
4 void
5 foo ()
6 {
7 [[omp::directive (parallel)]] __asm ("");
8 __extension__ [[omp::directive (parallel)]] asm (""); /* { dg-error "expected" } */
9 [[omp::directive (parallel)]] __label__ foo; /* { dg-error "expected" } */
10 [[omp::directive (parallel)]] static_assert (true, ""); /* { dg-error "expected" } */
11 [[omp::directive (parallel)]] int a = 5; /* { dg-error "not allowed to be specified in this context" } */
12 int b = 0;
13 #pragma GCC diagnostic push
14 #pragma GCC diagnostic warning "-Wattributes"
15 [[omp::directive (parallel)]] l: b++; /* { dg-warning "'omp::directive' scoped attribute directive ignored" } */
16 switch (0)
17 {
18 [[omp::directive (parallel)]] case 6: break; /* { dg-warning "'omp::directive' scoped attribute directive ignored" } */
19 [[omp::directive (parallel)]] default: break; /* { dg-warning "'omp::directive' scoped attribute directive ignored" } */
20 }
21 #pragma GCC diagnostic pop
22 }
23
24 void
25 bar ()
26 {
27 [[omp::directive (declare simd)]] int a; /* { dg-error "not allowed to be specified in this context|not immediately followed by a function declaration or definition" } */
28 [[omp::directive (declare simd)]] int b, f1 (int); /* { dg-error "not allowed to be specified in this context|not immediately followed by a function declaration or definition" } */
29 [[omp::directive (declare simd)]] int f2 (int), c; /* { dg-error "not immediately followed by a function declaration or definition" } */
30 int d [[omp::directive (declare simd)]]; /* { dg-error "not immediately followed by a function declaration or definition" } */
31 int f3 [[omp::directive (declare simd)]] (int), f4 [[omp::directive (declare simd)]] (int);
32 __extension__ [[omp::directive (declare simd)]] int f5 (int);
33 __extension__ int f6 [[omp::directive (declare simd, notinbranch)]] (int);
34 #pragma omp declare simd notinbranch
35 [[omp::directive (declare simd inbranch)]] int f7 (int); /* { dg-error "mixing OpenMP directives with attribute and pragma syntax on the same declaration" } */
36 [[omp::directive (declare simd notinbranch)]]
37 #pragma omp declare simd inbranch /* { dg-error "mixing OpenMP directives with attribute and pragma syntax on the same statement" } */
38 int f8 (int);
39 static int t1, t2, t3, t4;
40 [[omp::directive (declare simd), omp::directive (foobar)]] int f9 (int); /* { dg-error "unknown OpenMP directive name" } */
41 /* { dg-error "'omp::directive' not allowed to be specified in this context" "" { target *-*-* } .-1 } */
42 [[omp::directive (foobar), omp::directive (declare simd)]] int f10 (int); /* { dg-error "unknown OpenMP directive name" } */
43 /* { dg-error "'omp::directive' not allowed to be specified in this context" "" { target *-*-* } .-1 } */
44 [[omp::directive (threadprivate (t1)), omp::directive (declare simd)]] int f10 (int); /* { dg-error "'omp::directive' not allowed to be specified in this context" } */
45 [[omp::directive (declare simd), omp::directive (threadprivate (t2))]] int f11 (int); /* { dg-error "'omp::directive' not allowed to be specified in this context" } */
46 int f12 [[omp::directive (declare simd), omp::directive (foobar)]] (int); /* { dg-error "unknown OpenMP directive name" } */
47 /* { dg-error "'omp::directive' not allowed to be specified in this context" "" { target *-*-* } .-1 } */
48 int f13 [[omp::directive (foobar), omp::directive (declare simd)]] (int); /* { dg-error "unknown OpenMP directive name" } */
49 /* { dg-error "'omp::directive' not allowed to be specified in this context" "" { target *-*-* } .-1 } */
50 int f14 [[omp::directive (threadprivate (t3)), omp::directive (declare simd)]] (int); /* { dg-error "'omp::directive' not allowed to be specified in this context" } */
51 int f15 [[omp::directive (declare simd), omp::directive (threadprivate (t4))]] (int); /* { dg-error "'omp::directive' not allowed to be specified in this context" } */
52 }
53
54 [[omp::directive (declare simd)]] int a; /* { dg-error "not allowed to be specified in this context|not immediately followed by a function declaration or definition" } */
55 [[omp::directive (declare simd)]] int b, f16 (int); /* { dg-error "not allowed to be specified in this context|not immediately followed by a function declaration or definition" } */
56 [[omp::directive (declare simd)]] int f17 (int), c; /* { dg-error "not immediately followed by a function declaration or definition" } */
57 int d [[omp::directive (declare simd)]]; /* { dg-error "not immediately followed by a function declaration or definition" } */
58 int f18 [[omp::directive (declare simd)]] (int), f19 [[omp::directive (declare simd)]] (int);
59 __extension__ [[omp::directive (declare simd)]] int f20 (int);
60 __extension__ int f21 [[omp::directive (declare simd, notinbranch)]] (int);
61 #pragma omp declare simd notinbranch
62 [[omp::directive (declare simd inbranch)]] int f22 (int); /* { dg-error "mixing OpenMP directives with attribute and pragma syntax on the same declaration" } */
63 [[omp::directive (declare simd notinbranch)]]
64 #pragma omp declare simd inbranch /* { dg-error "before '#pragma'" } */
65 int f23 (int); /* { dg-error "not immediately followed by a function declaration or definition" "" { target *-*-* } .-1 } */
66 int t5, t6, t7, t8;
67 [[omp::directive (declare simd), omp::directive (foobar)]] int f24 (int); /* { dg-error "unknown OpenMP directive name" } */
68 /* { dg-error "'omp::directive' not allowed to be specified in this context" "" { target *-*-* } .-1 } */
69 [[omp::directive (foobar), omp::directive (declare simd)]] int f25 (int); /* { dg-error "unknown OpenMP directive name" } */
70 /* { dg-error "'omp::directive' not allowed to be specified in this context" "" { target *-*-* } .-1 } */
71 [[omp::directive (threadprivate (t5)), omp::directive (declare simd)]] int f26 (int); /* { dg-error "'omp::directive' not allowed to be specified in this context" } */
72 [[omp::directive (declare simd), omp::directive (threadprivate (t6))]] int f27 (int); /* { dg-error "'omp::directive' not allowed to be specified in this context" } */
73 int f28 [[omp::directive (declare simd), omp::directive (foobar)]] (int); /* { dg-error "unknown OpenMP directive name" } */
74 /* { dg-error "'omp::directive' not allowed to be specified in this context" "" { target *-*-* } .-1 } */
75 int f29 [[omp::directive (foobar), omp::directive (declare simd)]] (int); /* { dg-error "unknown OpenMP directive name" } */
76 /* { dg-error "'omp::directive' not allowed to be specified in this context" "" { target *-*-* } .-1 } */
77 int f30 [[omp::directive (threadprivate (t7)), omp::directive (declare simd)]] (int); /* { dg-error "'omp::directive' not allowed to be specified in this context" } */
78 int f31 [[omp::directive (declare simd), omp::directive (threadprivate (t8))]] (int); /* { dg-error "'omp::directive' not allowed to be specified in this context" } */
79
80 void
81 baz ()
82 {
83 #pragma omp parallel
84 [[omp::directive (declare simd)]]; /* { dg-error "mixing OpenMP directives with attribute and pragma syntax on the same statement" } */
85 [[omp::directive (parallel)]]
86 #pragma omp declare simd /* { dg-error "mixing OpenMP directives with attribute and pragma syntax on the same statement" } */
87 extern int f34 (int);
88 }