1a914888bSAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized
2d5af8e47SAlexey Bataev 
3a914888bSAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
4a8a9153aSAlexey Bataev 
5e04483eeSAlexey Bataev extern int omp_default_mem_alloc;
foo()6d5af8e47SAlexey Bataev void foo() {
7d5af8e47SAlexey Bataev }
8d5af8e47SAlexey Bataev 
foobool(int argc)9d5af8e47SAlexey Bataev bool foobool(int argc) {
10d5af8e47SAlexey Bataev   return argc;
11d5af8e47SAlexey Bataev }
12d5af8e47SAlexey Bataev 
xxx(int argc)13*25569296SAlexey Bataev void xxx(int argc) {
14*25569296SAlexey Bataev   int fp; // expected-note {{initialize the variable 'fp' to silence this warning}}
15*25569296SAlexey Bataev #pragma omp parallel firstprivate(fp) // expected-warning {{variable 'fp' is uninitialized when used here}}
16*25569296SAlexey Bataev   for (int i = 0; i < 10; ++i)
17*25569296SAlexey Bataev     ;
18*25569296SAlexey Bataev }
19*25569296SAlexey Bataev 
20d5af8e47SAlexey Bataev struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}}
21d5af8e47SAlexey Bataev extern S1 a;
22d5af8e47SAlexey Bataev class S2 {
23d5af8e47SAlexey Bataev   mutable int a;
24d5af8e47SAlexey Bataev public:
S2()25d5af8e47SAlexey Bataev   S2():a(0) { }
S2(const S2 & s2)264a5bb772SAlexey Bataev   S2(const S2 &s2):a(s2.a) { }
27d5af8e47SAlexey Bataev   static float S2s;
28d5af8e47SAlexey Bataev   static const float S2sc;
29d5af8e47SAlexey Bataev };
30d5af8e47SAlexey Bataev const float S2::S2sc = 0;
31d5af8e47SAlexey Bataev const S2 b;
32d5af8e47SAlexey Bataev const S2 ba[5];
33d5af8e47SAlexey Bataev class S3 {
34d5af8e47SAlexey Bataev   int a;
35d5af8e47SAlexey Bataev public:
S3()36d5af8e47SAlexey Bataev   S3():a(0) { }
S3(const S3 & s3)374a5bb772SAlexey Bataev   S3(const S3 &s3):a(s3.a) { }
38d5af8e47SAlexey Bataev };
39d5af8e47SAlexey Bataev const S3 c;
40d5af8e47SAlexey Bataev const S3 ca[5];
41d5af8e47SAlexey Bataev extern const int f;
424a5bb772SAlexey Bataev class S4 {
43d5af8e47SAlexey Bataev   int a;
44d5af8e47SAlexey Bataev   S4();
454a5bb772SAlexey Bataev   S4(const S4 &s4); // expected-note {{implicitly declared private here}}
46d5af8e47SAlexey Bataev public:
S4(int v)47d5af8e47SAlexey Bataev   S4(int v):a(v) { }
48d5af8e47SAlexey Bataev };
494a5bb772SAlexey Bataev class S5 {
50d5af8e47SAlexey Bataev   int a;
S5()51d5af8e47SAlexey Bataev   S5():a(0) {}
S5(const S5 & s5)524a5bb772SAlexey Bataev   S5(const S5 &s5):a(s5.a) { } // expected-note {{implicitly declared private here}}
53d5af8e47SAlexey Bataev public:
S5(int v)54d5af8e47SAlexey Bataev   S5(int v):a(v) { }
55d5af8e47SAlexey Bataev };
56d5af8e47SAlexey Bataev 
57d5af8e47SAlexey Bataev S3 h;
58d5af8e47SAlexey Bataev #pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
59d5af8e47SAlexey Bataev 
606ddfe1a6SAlexey Bataev namespace A {
616ddfe1a6SAlexey Bataev double x;
626ddfe1a6SAlexey Bataev #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
636ddfe1a6SAlexey Bataev }
646ddfe1a6SAlexey Bataev namespace B {
656ddfe1a6SAlexey Bataev using A::x;
666ddfe1a6SAlexey Bataev }
676ddfe1a6SAlexey Bataev 
main(int argc,char ** argv)68d5af8e47SAlexey Bataev int main(int argc, char **argv) {
6977aed73cSAlexey Bataev   const int d = 5; // expected-note {{variable 'd' declared const here}}
70d5af8e47SAlexey Bataev   const int da[5] = { 0 };
714a5bb772SAlexey Bataev   S4 e(4);
724a5bb772SAlexey Bataev   S5 g(5);
73a914888bSAlexey Bataev   int i, z;
74bd9fec1eSAlexey Bataev   int &j = i;
754eea8c6bSKelvin Li   static int m;
76d5af8e47SAlexey Bataev   #pragma omp parallel firstprivate // expected-error {{expected '(' after 'firstprivate'}}
77d5af8e47SAlexey Bataev   #pragma omp parallel firstprivate ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
78d5af8e47SAlexey Bataev   #pragma omp parallel firstprivate () // expected-error {{expected expression}}
79d5af8e47SAlexey Bataev   #pragma omp parallel firstprivate (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
80c5970623SAlexey Bataev   #pragma omp parallel firstprivate (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
81d5af8e47SAlexey Bataev   #pragma omp parallel firstprivate (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
82e04483eeSAlexey Bataev   #pragma omp parallel firstprivate (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 '('}}
83d5af8e47SAlexey Bataev   #pragma omp parallel firstprivate (S1) // expected-error {{'S1' does not refer to a value}}
84d5af8e47SAlexey Bataev   #pragma omp parallel firstprivate (a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
85a914888bSAlexey Bataev   #pragma omp parallel firstprivate (z, d)
8677aed73cSAlexey Bataev     d = 5; // expected-error {{cannot assign to variable 'd' with const-qualified type}}
87d5af8e47SAlexey Bataev   #pragma omp parallel firstprivate (argv[1]) // expected-error {{expected variable name}}
88d5af8e47SAlexey Bataev   #pragma omp parallel firstprivate(ba)
89d5af8e47SAlexey Bataev   #pragma omp parallel firstprivate(ca)
90d5af8e47SAlexey Bataev   #pragma omp parallel firstprivate(da)
91d5af8e47SAlexey Bataev   #pragma omp parallel firstprivate(S2::S2s)
92d5af8e47SAlexey Bataev   #pragma omp parallel firstprivate(S2::S2sc)
934a5bb772SAlexey Bataev   #pragma omp parallel firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
946ddfe1a6SAlexey Bataev   #pragma omp parallel firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}}
95d5af8e47SAlexey Bataev   #pragma omp parallel private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note{{defined as private}}
96d5af8e47SAlexey Bataev   foo();
97d5af8e47SAlexey Bataev   #pragma omp parallel shared(i)
98d5af8e47SAlexey Bataev   #pragma omp parallel firstprivate(i)
99bd9fec1eSAlexey Bataev   #pragma omp parallel firstprivate(j)
1004eea8c6bSKelvin Li   #pragma omp parallel firstprivate(m)
101d5af8e47SAlexey Bataev   foo();
102d5af8e47SAlexey Bataev 
103d5af8e47SAlexey Bataev   return 0;
104d5af8e47SAlexey Bataev }
105