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