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