1 // RUN: %clang_cc1 -verify -fopenmp -o - %s -Wuninitialized
2 
3 // RUN: %clang_cc1 -verify -fopenmp-simd -o - %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 class S2 {
14   mutable int a;
15 
16 public:
S2()17   S2() : a(0) {}
operator =(S2 & s2)18   S2 &operator=(S2 &s2) { return *this; }
19 };
20 class S3 {
21   int a;
22 
23 public:
S3()24   S3() : a(0) {}
operator =(S3 & s3)25   S3 &operator=(S3 &s3) { return *this; }
26 };
27 class S4 {
28   int a;
29   S4();
30   S4 &operator=(const S4 &s4); // expected-note {{implicitly declared private here}}
31 
32 public:
S4(int v)33   S4(int v) : a(v) {}
34 };
35 class S5 {
36   int a;
S5()37   S5() : a(0) {}
operator =(const S5 & s5)38   S5 &operator=(const S5 &s5) { return *this; } // expected-note {{implicitly declared private here}}
39 
40 public:
S5(int v)41   S5(int v) : a(v) {}
42 };
43 template <class T>
44 class ST {
45 public:
46   static T s;
47 };
48 
49 S2 k;
50 S3 h;
51 S4 l(3);
52 S5 m(4);
53 #pragma omp threadprivate(h, k, l, m)
54 
55 namespace A {
56 double x;
57 #pragma omp threadprivate(x)
58 }
59 namespace B {
60 using A::x;
61 }
62 
main(int argc,char ** argv)63 int main(int argc, char **argv) {
64   int i;
65 #pragma omp parallel for simd copyin // expected-error {{expected '(' after 'copyin'}}
66   for (i = 0; i < argc; ++i)
67     foo();
68 #pragma omp parallel for simd copyin( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
69   for (i = 0; i < argc; ++i)
70     foo();
71 #pragma omp parallel for simd copyin() // expected-error {{expected expression}}
72   for (i = 0; i < argc; ++i)
73     foo();
74 #pragma omp parallel for simd copyin(k // expected-error {{expected ')'}} expected-note {{to match this '('}}
75   for (i = 0; i < argc; ++i)
76     foo();
77 #pragma omp parallel for simd copyin(h, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
78   for (i = 0; i < argc; ++i)
79     foo();
80 #pragma omp parallel for simd copyin(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
81   for (i = 0; i < argc; ++i)
82     foo();
83 #pragma omp parallel for simd copyin(l) // expected-error {{'operator=' is a private member of 'S4'}}
84   for (i = 0; i < argc; ++i)
85     foo();
86 #pragma omp parallel for simd copyin(S1) // expected-error {{'S1' does not refer to a value}}
87   for (i = 0; i < argc; ++i)
88     foo();
89 #pragma omp parallel for simd copyin(argv[1]) // expected-error {{expected variable name}}
90   for (i = 0; i < argc; ++i)
91     foo();
92 #pragma omp parallel for simd copyin(i) // expected-error {{copyin variable must be threadprivate}}
93   for (i = 0; i < argc; ++i)
94     foo();
95 #pragma omp parallel for simd copyin(m) // expected-error {{'operator=' is a private member of 'S5'}}
96   for (i = 0; i < argc; ++i)
97     foo();
98 #pragma omp parallel for simd copyin(ST < int > ::s, B::x) // expected-error {{copyin variable must be threadprivate}}
99   for (i = 0; i < argc; ++i)
100     foo();
101 
102   return 0;
103 }
104