1 | // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s |
2 | |
3 | // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s |
4 | |
5 | void foo() { |
6 | } |
7 | |
8 | bool foobool(int argc) { |
9 | return argc; |
10 | } |
11 | |
12 | struct S1; // expected-note {{declared here}} |
13 | extern S1 a; |
14 | class S2 { |
15 | mutable int a; |
16 | |
17 | public: |
18 | S2() : a(0) {} |
19 | S2(S2 &s2) : a(s2.a) {} |
20 | }; |
21 | const S2 b; |
22 | const S2 ba[5]; |
23 | class S3 { |
24 | int a; |
25 | |
26 | public: |
27 | S3() : a(0) {} |
28 | S3(S3 &s3) : a(s3.a) {} |
29 | }; |
30 | const S3 c; |
31 | const S3 ca[5]; |
32 | extern const int f; |
33 | class S4 { |
34 | int a; |
35 | S4(); |
36 | S4(const S4 &s4); |
37 | |
38 | public: |
39 | S4(int v) : a(v) {} |
40 | }; |
41 | class S5 { |
42 | int a; |
43 | S5() : a(0) {} |
44 | S5(const S5 &s5) : a(s5.a) {} |
45 | |
46 | public: |
47 | S5(int v) : a(v) {} |
48 | }; |
49 | |
50 | S3 h; |
51 | #pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}} |
52 | |
53 | namespace A { |
54 | double x; |
55 | #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} |
56 | } |
57 | namespace B { |
58 | using A::x; |
59 | } |
60 | |
61 | int main(int argc, char **argv) { |
62 | const int d = 5; |
63 | const int da[5] = {0}; |
64 | S4 e(4); |
65 | S5 g(5); |
66 | int i; |
67 | int &j = i; |
68 | #pragma omp task shared // expected-error {{expected '(' after 'shared'}} |
69 | foo(); |
70 | #pragma omp task shared( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
71 | foo(); |
72 | #pragma omp task shared() // expected-error {{expected expression}} |
73 | foo(); |
74 | #pragma omp task shared(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} |
75 | foo(); |
76 | #pragma omp task shared(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
77 | foo(); |
78 | #pragma omp task shared(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} |
79 | foo(); |
80 | #pragma omp task shared(argc) |
81 | foo(); |
82 | #pragma omp task shared(S1) // expected-error {{'S1' does not refer to a value}} |
83 | foo(); |
84 | #pragma omp task shared(a, b, c, d, f) |
85 | foo(); |
86 | #pragma omp task shared(argv[1]) // expected-error {{expected variable name}} |
87 | foo(); |
88 | #pragma omp task shared(ba) |
89 | foo(); |
90 | #pragma omp task shared(ca) |
91 | foo(); |
92 | #pragma omp task shared(da) |
93 | foo(); |
94 | #pragma omp task shared(e, g) |
95 | foo(); |
96 | #pragma omp task shared(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be shared}} |
97 | foo(); |
98 | #pragma omp task private(i), shared(i) // expected-error {{private variable cannot be shared}} expected-note {{defined as private}} |
99 | foo(); |
100 | #pragma omp task firstprivate(i), shared(i) // expected-error {{firstprivate variable cannot be shared}} expected-note {{defined as firstprivate}} |
101 | foo(); |
102 | #pragma omp parallel private(i) |
103 | #pragma omp task shared(i) |
104 | #pragma omp task shared(j) |
105 | foo(); |
106 | #pragma omp parallel firstprivate(i) |
107 | #pragma omp task shared(i) |
108 | #pragma omp task shared(j) |
109 | foo(); |
110 | |
111 | return 0; |
112 | } |
113 | |