1 // RUN: %clang_cc1 -verify -fopenmp %s
2
foo()3 void foo() {
4 }
5
foobool(int argc)6 bool foobool(int argc) {
7 return argc;
8 }
9
10 struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
11 extern S1 a;
12 class S2 {
13 mutable int a;
14 public:
S2()15 S2():a(0) { }
16 };
17 const S2 b;
18 const S2 ba[5];
19 class S3 {
20 int a;
21 public:
S3()22 S3():a(0) { }
23 };
24 const S3 ca[5];
25 class S4 {
26 int a;
27 S4(); // expected-note {{implicitly declared private here}}
28 public:
S4(int v)29 S4(int v) : a(v) {
30 #pragma omp simd private(a) private(this->a)
31 for (int k = 0; k < v; ++k)
32 ++this->a;
33 }
34 };
35 class S5 {
36 int a;
S5()37 S5():a(0) {} // expected-note {{implicitly declared private here}}
38 public:
S5(int v)39 S5(int v):a(v) { }
operator =(S5 & s)40 S5 &operator=(S5 &s) {
41 #pragma omp simd private(a) private(this->a) private(s.a) // expected-error {{expected variable name or data member of current class}}
42 for (int k = 0; k < s.a; ++k)
43 ++s.a;
44 return *this;
45 }
46 };
47
48 template <typename T>
49 class S6 {
50 public:
51 T a;
52
S6()53 S6() : a(0) {}
S6(T v)54 S6(T v) : a(v) {
55 #pragma omp simd private(a) private(this->a)
56 for (int k = 0; k < v; ++k)
57 ++this->a;
58 }
operator =(S6 & s)59 S6 &operator=(S6 &s) {
60 #pragma omp simd private(a) private(this->a) private(s.a) // expected-error {{expected variable name or data member of current class}}
61 for (int k = 0; k < s.a; ++k)
62 ++s.a;
63 return *this;
64 }
65 };
66
67 template <typename T>
68 class S7 : public T {
69 T a;
S7()70 S7() : a(0) {}
71
72 public:
S7(T v)73 S7(T v) : a(v) {
74 #pragma omp simd private(a) private(this->a) private(T::a)
75 for (int k = 0; k < a.a; ++k)
76 ++this->a.a;
77 }
operator =(S7 & s)78 S7 &operator=(S7 &s) {
79 #pragma omp 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}}
80 for (int k = 0; k < s.a.a; ++k)
81 ++s.a.a;
82 return *this;
83 }
84 };
85
86 S3 h;
87 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
88
foomain(I argc,C ** argv)89 template<class I, class C> int foomain(I argc, C **argv) {
90 I e(4);
91 I g(5);
92 int i;
93 int &j = i;
94 #pragma omp simd private // expected-error {{expected '(' after 'private'}}
95 for (int k = 0; k < argc; ++k) ++k;
96 #pragma omp simd private ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
97 for (int k = 0; k < argc; ++k) ++k;
98 #pragma omp simd private () // expected-error {{expected expression}}
99 for (int k = 0; k < argc; ++k) ++k;
100 #pragma omp simd private (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
101 for (int k = 0; k < argc; ++k) ++k;
102 #pragma omp simd private (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
103 for (int k = 0; k < argc; ++k) ++k;
104 #pragma omp simd private (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
105 for (int k = 0; k < argc; ++k) ++k;
106 #pragma omp simd private (argc)
107 for (int k = 0; k < argc; ++k) ++k;
108 #pragma omp simd private (S1) // expected-error {{'S1' does not refer to a value}}
109 for (int k = 0; k < argc; ++k) ++k;
110 #pragma omp simd private (a, b) // expected-error {{private variable with incomplete type 'S1'}}
111 for (int k = 0; k < argc; ++k) ++k;
112 #pragma omp simd private (argv[1]) // expected-error {{expected variable name}}
113 for (int k = 0; k < argc; ++k) ++k;
114 #pragma omp simd private(e, g)
115 for (int k = 0; k < argc; ++k) ++k;
116 #pragma omp simd private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
117 for (int k = 0; k < argc; ++k) ++k;
118 #pragma omp simd shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp simd'}}
119 for (int k = 0; k < argc; ++k) ++k;
120 #pragma omp parallel
121 {
122 int v = 0;
123 int i;
124 #pragma omp simd private(i)
125 for (int k = 0; k < argc; ++k) { i = k; v += i; }
126 }
127 #pragma omp parallel shared(i)
128 #pragma omp parallel private(i)
129 #pragma omp simd private(j)
130 for (int k = 0; k < argc; ++k) ++k;
131 #pragma omp simd private(i)
132 for (int k = 0; k < argc; ++k) ++k;
133 return 0;
134 }
135
136 namespace A {
137 double x;
138 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
139 }
140 namespace B {
141 using A::x;
142 }
143
main(int argc,char ** argv)144 int main(int argc, char **argv) {
145 S4 e(4);
146 S5 g(5);
147 S6<float> s6(0.0) , s6_0(1.0);
148 S7<S6<float> > s7(0.0) , s7_0(1.0);
149 int i;
150 int &j = i;
151 #pragma omp simd private // expected-error {{expected '(' after 'private'}}
152 for (int k = 0; k < argc; ++k) ++k;
153 #pragma omp simd private ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
154 for (int k = 0; k < argc; ++k) ++k;
155 #pragma omp simd private () // expected-error {{expected expression}}
156 for (int k = 0; k < argc; ++k) ++k;
157 #pragma omp simd private (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
158 for (int k = 0; k < argc; ++k) ++k;
159 #pragma omp simd private (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
160 for (int k = 0; k < argc; ++k) ++k;
161 #pragma omp simd private (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
162 for (int k = 0; k < argc; ++k) ++k;
163 #pragma omp simd private (argc)
164 for (int k = 0; k < argc; ++k) ++k;
165 #pragma omp simd private (S1) // expected-error {{'S1' does not refer to a value}}
166 for (int k = 0; k < argc; ++k) ++k;
167 #pragma omp simd private (a, b) // expected-error {{private variable with incomplete type 'S1'}}
168 for (int k = 0; k < argc; ++k) ++k;
169 #pragma omp simd private (argv[1]) // expected-error {{expected variable name}}
170 for (int k = 0; k < argc; ++k) ++k;
171 #pragma omp simd private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
172 for (int k = 0; k < argc; ++k) ++k;
173 #pragma omp simd private(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be private}}
174 for (int k = 0; k < argc; ++k) ++k;
175 #pragma omp simd shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp simd'}}
176 for (int k = 0; k < argc; ++k) ++k;
177 #pragma omp parallel
178 {
179 int i;
180 #pragma omp simd private(i)
181 for (int k = 0; k < argc; ++k) ++k;
182 }
183 #pragma omp parallel shared(i)
184 #pragma omp parallel private(i)
185 #pragma omp simd private(j)
186 for (int k = 0; k < argc; ++k) ++k;
187 #pragma omp simd private(i)
188 for (int k = 0; k < argc; ++k) ++k;
189
190 s6 = s6_0; // expected-note {{in instantiation of member function 'S6<float>::operator=' requested here}}
191 s7 = s7_0; // expected-note {{in instantiation of member function 'S7<S6<float> >::operator=' requested here}}
192 return foomain(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}}
193 }
194
195