1 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized
2 
3 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
4 
foo()5 void foo() {
6 }
7 
foobool(int argc)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:
S2()18   S2() : a(0) {}
S2(S2 & s2)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:
S3()27   S3() : a(0) {}
S3(S3 & s3)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:
S4(int v)39   S4(int v) : a(v) {}
40 };
41 class S5 {
42   int a;
S5()43   S5() : a(0) {}
S5(const S5 & s5)44   S5(const S5 &s5) : a(s5.a) {}
45 
46 public:
S5(int v)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 
main(int argc,char ** argv)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, k;
67   int &j = i;
68 #pragma omp parallel sections shared // expected-error {{expected '(' after 'shared'}}
69   { foo(); }
70 #pragma omp parallel sections shared( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
71   { foo(); }
72 #pragma omp parallel sections shared() // expected-error {{expected expression}}
73   { foo(); }
74 #pragma omp parallel sections shared(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
75   { foo(); }
76 #pragma omp parallel sections shared(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
77   { foo(); }
78 #pragma omp parallel sections shared(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
79   { foo(); }
80 #pragma omp parallel sections shared(argc)
81   { foo(); }
82 #pragma omp parallel sections shared(S1) // expected-error {{'S1' does not refer to a value}}
83   { foo(); }
84 #pragma omp parallel sections shared(a, b, c, d, f, k)
85   { foo(); }
86 #pragma omp parallel sections shared(argv[1]) // expected-error {{expected variable name}}
87   { foo(); }
88 #pragma omp parallel sections shared(ba)
89   { foo(); }
90 #pragma omp parallel sections shared(ca)
91   { foo(); }
92 #pragma omp parallel sections shared(da)
93   { foo(); }
94 #pragma omp parallel sections shared(e, g)
95   { foo(); }
96 #pragma omp parallel sections shared(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be shared}}
97   { foo(); }
98 #pragma omp parallel sections private(i), shared(i) // expected-error {{private variable cannot be shared}} expected-note {{defined as private}}
99   { foo(); }
100 #pragma omp parallel sections firstprivate(i), shared(i) // expected-error {{firstprivate variable cannot be shared}} expected-note {{defined as firstprivate}}
101   { foo(); }
102 #pragma omp parallel sections private(i)
103   {
104 #pragma omp parallel sections shared(i)
105     {
106 #pragma omp parallel sections shared(j)
107       { foo(); }
108     }
109   }
110 #pragma omp parallel sections firstprivate(i)
111   {
112 #pragma omp parallel sections shared(i)
113     {
114 #pragma omp parallel sections shared(j)
115       { foo(); }
116     }
117   }
118 
119   return 0;
120 }
121