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