114a388f4SAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
214a388f4SAlexey Bataev
314a388f4SAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
414a388f4SAlexey Bataev
514a388f4SAlexey Bataev typedef void **omp_allocator_handle_t;
6*8026394dSAlexey Bataev extern const omp_allocator_handle_t omp_null_allocator;
714a388f4SAlexey Bataev extern const omp_allocator_handle_t omp_default_mem_alloc;
814a388f4SAlexey Bataev extern const omp_allocator_handle_t omp_large_cap_mem_alloc;
914a388f4SAlexey Bataev extern const omp_allocator_handle_t omp_const_mem_alloc;
1014a388f4SAlexey Bataev extern const omp_allocator_handle_t omp_high_bw_mem_alloc;
1114a388f4SAlexey Bataev extern const omp_allocator_handle_t omp_low_lat_mem_alloc;
1214a388f4SAlexey Bataev extern const omp_allocator_handle_t omp_cgroup_mem_alloc;
1314a388f4SAlexey Bataev extern const omp_allocator_handle_t omp_pteam_mem_alloc;
1414a388f4SAlexey Bataev extern const omp_allocator_handle_t omp_thread_mem_alloc;
1514a388f4SAlexey Bataev
foo()1614a388f4SAlexey Bataev void foo() {
1714a388f4SAlexey Bataev }
1814a388f4SAlexey Bataev
foobool(int argc)1914a388f4SAlexey Bataev bool foobool(int argc) {
2014a388f4SAlexey Bataev return argc;
2114a388f4SAlexey Bataev }
2214a388f4SAlexey Bataev
2314a388f4SAlexey Bataev struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
2414a388f4SAlexey Bataev extern S1 a;
2514a388f4SAlexey Bataev class S2 {
2614a388f4SAlexey Bataev mutable int a;
2714a388f4SAlexey Bataev
2814a388f4SAlexey Bataev public:
S2()2914a388f4SAlexey Bataev S2() : a(0) {}
3014a388f4SAlexey Bataev };
3114a388f4SAlexey Bataev const S2 b;
3214a388f4SAlexey Bataev const S2 ba[5];
3314a388f4SAlexey Bataev class S3 {
3414a388f4SAlexey Bataev int a;
3514a388f4SAlexey Bataev
3614a388f4SAlexey Bataev public:
S3()3714a388f4SAlexey Bataev S3() : a(0) {}
3814a388f4SAlexey Bataev };
3914a388f4SAlexey Bataev const S3 ca[5];
4014a388f4SAlexey Bataev class S4 {
4114a388f4SAlexey Bataev int a;
4214a388f4SAlexey Bataev S4(); // expected-note {{implicitly declared private here}}
4314a388f4SAlexey Bataev
4414a388f4SAlexey Bataev public:
S4(int v)4514a388f4SAlexey Bataev S4(int v) : a(v) {
4614a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(a) private(this->a)
4714a388f4SAlexey Bataev for (int k = 0; k < v; ++k)
4814a388f4SAlexey Bataev ++this->a;
4914a388f4SAlexey Bataev }
5014a388f4SAlexey Bataev };
5114a388f4SAlexey Bataev class S5 {
5214a388f4SAlexey Bataev int a;
S5()5314a388f4SAlexey Bataev S5() : a(0) {} // expected-note {{implicitly declared private here}}
5414a388f4SAlexey Bataev
5514a388f4SAlexey Bataev public:
S5(int v)5614a388f4SAlexey Bataev S5(int v) : a(v) {}
operator =(S5 & s)5714a388f4SAlexey Bataev S5 &operator=(S5 &s) {
5814a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(a) private(this->a) private(s.a) // expected-error {{expected variable name or data member of current class}}
5914a388f4SAlexey Bataev for (int k = 0; k < s.a; ++k)
6014a388f4SAlexey Bataev ++s.a;
6114a388f4SAlexey Bataev return *this;
6214a388f4SAlexey Bataev }
6314a388f4SAlexey Bataev };
6414a388f4SAlexey Bataev
6514a388f4SAlexey Bataev template <typename T>
6614a388f4SAlexey Bataev class S6 {
6714a388f4SAlexey Bataev public:
6814a388f4SAlexey Bataev T a;
6914a388f4SAlexey Bataev
S6()7014a388f4SAlexey Bataev S6() : a(0) {}
S6(T v)7114a388f4SAlexey Bataev S6(T v) : a(v) {
7214a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(a) private(this->a) allocate(omp_thread_mem_alloc: a) // expected-warning {{allocator with the 'thread' trait access has unspecified behavior on 'parallel master taskloop simd' directive}}
7314a388f4SAlexey Bataev for (int k = 0; k < v; ++k)
7414a388f4SAlexey Bataev ++this->a;
7514a388f4SAlexey Bataev }
operator =(S6 & s)7614a388f4SAlexey Bataev S6 &operator=(S6 &s) {
7714a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(a) private(this->a) private(s.a) // expected-error {{expected variable name or data member of current class}}
7814a388f4SAlexey Bataev for (int k = 0; k < s.a; ++k)
7914a388f4SAlexey Bataev ++s.a;
8014a388f4SAlexey Bataev return *this;
8114a388f4SAlexey Bataev }
8214a388f4SAlexey Bataev };
8314a388f4SAlexey Bataev
8414a388f4SAlexey Bataev template <typename T>
8514a388f4SAlexey Bataev class S7 : public T {
8614a388f4SAlexey Bataev T a;
S7()8714a388f4SAlexey Bataev S7() : a(0) {}
8814a388f4SAlexey Bataev
8914a388f4SAlexey Bataev public:
S7(T v)9014a388f4SAlexey Bataev S7(T v) : a(v) {
9114a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(a) private(this->a) private(T::a)
9214a388f4SAlexey Bataev for (int k = 0; k < a.a; ++k)
9314a388f4SAlexey Bataev ++this->a.a;
9414a388f4SAlexey Bataev }
operator =(S7 & s)9514a388f4SAlexey Bataev S7 &operator=(S7 &s) {
9614a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(a) private(this->a) private(s.a) private(s.T::a) // expected-error 2 {{expected variable name or data member of current class}}
9714a388f4SAlexey Bataev for (int k = 0; k < s.a.a; ++k)
9814a388f4SAlexey Bataev ++s.a.a;
9914a388f4SAlexey Bataev return *this;
10014a388f4SAlexey Bataev }
10114a388f4SAlexey Bataev };
10214a388f4SAlexey Bataev
10314a388f4SAlexey Bataev S3 h;
10414a388f4SAlexey Bataev #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
10514a388f4SAlexey Bataev
10614a388f4SAlexey Bataev template <class I, class C>
foomain(I argc,C ** argv)10714a388f4SAlexey Bataev int foomain(I argc, C **argv) {
10814a388f4SAlexey Bataev I e(4);
10914a388f4SAlexey Bataev I g(5);
11014a388f4SAlexey Bataev int i, z;
11114a388f4SAlexey Bataev int &j = i;
11214a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private // expected-error {{expected '(' after 'private'}}
11314a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
11414a388f4SAlexey Bataev ++k;
11514a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
11614a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
11714a388f4SAlexey Bataev ++k;
11814a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private() // expected-error {{expected expression}}
11914a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
12014a388f4SAlexey Bataev ++k;
12114a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
12214a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
12314a388f4SAlexey Bataev ++k;
12414a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
12514a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
12614a388f4SAlexey Bataev ++k;
12714a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
12814a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
12914a388f4SAlexey Bataev ++k;
13014a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(argc) allocate , allocate(, allocate(omp_default , allocate(omp_default_mem_alloc, allocate(omp_default_mem_alloc:, allocate(omp_default_mem_alloc: argc, allocate(omp_default_mem_alloc: argv), allocate(argv) // expected-error {{expected '(' after 'allocate'}} expected-error 2 {{expected expression}} expected-error 2 {{expected ')'}} expected-error {{use of undeclared identifier 'omp_default'}} expected-note 2 {{to match this '('}}
13114a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
13214a388f4SAlexey Bataev ++k;
13314a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(S1) // expected-error {{'S1' does not refer to a value}}
13414a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
13514a388f4SAlexey Bataev ++k;
13614a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(a, b) // expected-error {{private variable with incomplete type 'S1'}}
13714a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
13814a388f4SAlexey Bataev ++k;
13914a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(argv[1]) // expected-error {{expected variable name}}
14014a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
14114a388f4SAlexey Bataev ++k;
14214a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(e, g, z)
14314a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
14414a388f4SAlexey Bataev ++k;
14514a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
14614a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
14714a388f4SAlexey Bataev ++k;
14814a388f4SAlexey Bataev #pragma omp parallel master taskloop simd shared(i)
14914a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
15014a388f4SAlexey Bataev ++k;
15114a388f4SAlexey Bataev #pragma omp parallel
15214a388f4SAlexey Bataev {
15314a388f4SAlexey Bataev int v = 0;
15414a388f4SAlexey Bataev int i;
15514a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(i)
15614a388f4SAlexey Bataev for (int k = 0; k < argc; ++k) {
15714a388f4SAlexey Bataev i = k;
15814a388f4SAlexey Bataev v += i;
15914a388f4SAlexey Bataev }
16014a388f4SAlexey Bataev }
16114a388f4SAlexey Bataev #pragma omp parallel shared(i)
16214a388f4SAlexey Bataev #pragma omp parallel private(i)
16314a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(j)
16414a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
16514a388f4SAlexey Bataev ++k;
16614a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(i)
16714a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
16814a388f4SAlexey Bataev ++k;
16914a388f4SAlexey Bataev return 0;
17014a388f4SAlexey Bataev }
17114a388f4SAlexey Bataev
bar(S4 a[2])17214a388f4SAlexey Bataev void bar(S4 a[2]) {
17314a388f4SAlexey Bataev #pragma omp parallel
17414a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(a)
17514a388f4SAlexey Bataev for (int i = 0; i < 2; ++i)
17614a388f4SAlexey Bataev foo();
17714a388f4SAlexey Bataev }
17814a388f4SAlexey Bataev
17914a388f4SAlexey Bataev namespace A {
18014a388f4SAlexey Bataev double x;
18114a388f4SAlexey Bataev #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
18214a388f4SAlexey Bataev }
18314a388f4SAlexey Bataev namespace B {
18414a388f4SAlexey Bataev using A::x;
18514a388f4SAlexey Bataev }
18614a388f4SAlexey Bataev
main(int argc,char ** argv)18714a388f4SAlexey Bataev int main(int argc, char **argv) {
18814a388f4SAlexey Bataev S4 e(4);
18914a388f4SAlexey Bataev S5 g(5);
19014a388f4SAlexey Bataev S6<float> s6(0.0) , s6_0(1.0); // expected-note {{in instantiation of member function 'S6<float>::S6' requested here}}
19114a388f4SAlexey Bataev S7<S6<float> > s7(0.0) , s7_0(1.0);
19214a388f4SAlexey Bataev int i, z;
19314a388f4SAlexey Bataev int &j = i;
19414a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private // expected-error {{expected '(' after 'private'}}
19514a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
19614a388f4SAlexey Bataev ++k;
19714a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
19814a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
19914a388f4SAlexey Bataev ++k;
20014a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private() // expected-error {{expected expression}}
20114a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
20214a388f4SAlexey Bataev ++k;
20314a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
20414a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
20514a388f4SAlexey Bataev ++k;
20614a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
20714a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
20814a388f4SAlexey Bataev ++k;
20914a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
21014a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
21114a388f4SAlexey Bataev ++k;
21214a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(argc)
21314a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
21414a388f4SAlexey Bataev ++k;
21514a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(S1) // expected-error {{'S1' does not refer to a value}}
21614a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
21714a388f4SAlexey Bataev ++k;
21814a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(a, b) // expected-error {{private variable with incomplete type 'S1'}}
21914a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
22014a388f4SAlexey Bataev ++k;
22114a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(argv[1]) // expected-error {{expected variable name}}
22214a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
22314a388f4SAlexey Bataev ++k;
22414a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
22514a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
22614a388f4SAlexey Bataev ++k;
22714a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
22814a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
22914a388f4SAlexey Bataev ++k;
23014a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(B::x) // expected-error {{threadprivate or thread local variable cannot be private}}
23114a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
23214a388f4SAlexey Bataev ++k;
23314a388f4SAlexey Bataev #pragma omp parallel master taskloop simd shared(i)
23414a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
23514a388f4SAlexey Bataev ++k;
23614a388f4SAlexey Bataev #pragma omp parallel
23714a388f4SAlexey Bataev {
23814a388f4SAlexey Bataev int i;
23914a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(i)
24014a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
24114a388f4SAlexey Bataev ++k;
24214a388f4SAlexey Bataev }
24314a388f4SAlexey Bataev #pragma omp parallel shared(i)
24414a388f4SAlexey Bataev #pragma omp parallel private(i)
24514a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(j)
24614a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
24714a388f4SAlexey Bataev ++k;
24814a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(i, z)
24914a388f4SAlexey Bataev for (int k = 0; k < argc; ++k)
25014a388f4SAlexey Bataev ++k;
25114a388f4SAlexey Bataev static int si;
25214a388f4SAlexey Bataev #pragma omp parallel master taskloop simd private(si) // OK
25314a388f4SAlexey Bataev for(int k = 0; k < argc; ++k)
25414a388f4SAlexey Bataev si = k + 1;
25514a388f4SAlexey Bataev
25614a388f4SAlexey Bataev s6 = s6_0; // expected-note {{in instantiation of member function 'S6<float>::operator=' requested here}}
25714a388f4SAlexey Bataev s7 = s7_0; // expected-note {{in instantiation of member function 'S7<S6<float>>::operator=' requested here}}
25814a388f4SAlexey Bataev return foomain(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}}
25914a388f4SAlexey Bataev }
26014a388f4SAlexey Bataev
261