Debian Codegraph @

gcc/testsuite/g++.dg/gomp/attrs-11.C

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