Alexey Bataev | db39021 | 2015-05-20 04:24:19 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++11 -o - %s |
Alexey Bataev | 9c2e8ee | 2014-07-11 11:25:16 +0000 | [diff] [blame] | 2 | |
| 3 | void foo() { |
| 4 | } |
| 5 | |
| 6 | #pragma omp task // expected-error {{unexpected OpenMP directive '#pragma omp task'}} |
| 7 | |
Alexey Bataev | 4a5bb77 | 2014-10-08 14:01:46 +0000 | [diff] [blame] | 8 | class S { |
Alexey Bataev | bd9fec1 | 2015-08-18 06:47:21 +0000 | [diff] [blame^] | 9 | S(const S &s) { a = s.a + 12; } // expected-note 10 {{implicitly declared private here}} |
Alexey Bataev | 9c2e8ee | 2014-07-11 11:25:16 +0000 | [diff] [blame] | 10 | int a; |
| 11 | |
| 12 | public: |
| 13 | S() : a(0) {} |
| 14 | S(int a) : a(a) {} |
| 15 | operator int() { return a; } |
| 16 | S &operator++() { return *this; } |
| 17 | S operator+(const S &) { return *this; } |
| 18 | }; |
| 19 | |
Alexey Bataev | 4a5bb77 | 2014-10-08 14:01:46 +0000 | [diff] [blame] | 20 | class S1 { |
| 21 | int a; |
| 22 | |
| 23 | public: |
| 24 | S1() : a(0) {} |
| 25 | S1 &operator++() { return *this; } |
| 26 | S1(const S1 &) = delete; // expected-note 2 {{'S1' has been explicitly marked deleted here}} |
| 27 | }; |
| 28 | |
Alexey Bataev | 9c2e8ee | 2014-07-11 11:25:16 +0000 | [diff] [blame] | 29 | template <class T> |
| 30 | int foo() { |
Alexey Bataev | 4a5bb77 | 2014-10-08 14:01:46 +0000 | [diff] [blame] | 31 | T a; |
Alexey Bataev | bd9fec1 | 2015-08-18 06:47:21 +0000 | [diff] [blame^] | 32 | T &b = a; |
Alexey Bataev | 9c2e8ee | 2014-07-11 11:25:16 +0000 | [diff] [blame] | 33 | int r; |
Alexey Bataev | 4a5bb77 | 2014-10-08 14:01:46 +0000 | [diff] [blame] | 34 | S1 s1; |
| 35 | // expected-error@+1 2 {{call to deleted constructor of 'S1'}} |
| 36 | #pragma omp task |
| 37 | // expected-note@+1 2 {{predetermined as a firstprivate in a task construct here}} |
| 38 | ++s1; |
Alexey Bataev | 9c2e8ee | 2014-07-11 11:25:16 +0000 | [diff] [blame] | 39 | #pragma omp task default(none) |
| 40 | #pragma omp task default(shared) |
| 41 | ++a; |
Alexey Bataev | 9c2e8ee | 2014-07-11 11:25:16 +0000 | [diff] [blame] | 42 | #pragma omp task default(none) |
| 43 | #pragma omp task |
Alexey Bataev | 4a5bb77 | 2014-10-08 14:01:46 +0000 | [diff] [blame] | 44 | // expected-error@+1 {{calling a private constructor of class 'S'}} |
Alexey Bataev | 9c2e8ee | 2014-07-11 11:25:16 +0000 | [diff] [blame] | 45 | ++a; |
| 46 | #pragma omp task |
Alexey Bataev | 9c2e8ee | 2014-07-11 11:25:16 +0000 | [diff] [blame] | 47 | #pragma omp task |
Alexey Bataev | 4a5bb77 | 2014-10-08 14:01:46 +0000 | [diff] [blame] | 48 | // expected-error@+1 {{calling a private constructor of class 'S'}} |
Alexey Bataev | 9c2e8ee | 2014-07-11 11:25:16 +0000 | [diff] [blame] | 49 | ++a; |
| 50 | #pragma omp task default(shared) |
| 51 | #pragma omp task |
| 52 | ++a; |
| 53 | #pragma omp task |
| 54 | #pragma omp parallel |
| 55 | ++a; |
Alexey Bataev | 4a5bb77 | 2014-10-08 14:01:46 +0000 | [diff] [blame] | 56 | // expected-error@+2 {{calling a private constructor of class 'S'}} |
Alexey Bataev | bd9fec1 | 2015-08-18 06:47:21 +0000 | [diff] [blame^] | 57 | #pragma omp task |
| 58 | ++b; |
| 59 | #pragma omp task |
| 60 | // expected-error@+1 2 {{calling a private constructor of class 'S'}} |
Alexey Bataev | 9c2e8ee | 2014-07-11 11:25:16 +0000 | [diff] [blame] | 61 | #pragma omp parallel shared(a, b) |
| 62 | ++a, ++b; |
| 63 | // expected-note@+1 3 {{defined as reduction}} |
| 64 | #pragma omp parallel reduction(+ : r) |
| 65 | // expected-error@+1 {{argument of a reduction clause of a parallel construct must not appear in a firstprivate clause on a task construct}} |
| 66 | #pragma omp task firstprivate(r) |
| 67 | // expected-error@+1 2 {{reduction variables may not be accessed in an explicit task}} |
| 68 | ++r; |
| 69 | // expected-note@+1 2 {{defined as reduction}} |
| 70 | #pragma omp parallel reduction(+ : r) |
| 71 | #pragma omp task default(shared) |
| 72 | // expected-error@+1 2 {{reduction variables may not be accessed in an explicit task}} |
| 73 | ++r; |
| 74 | // expected-note@+1 2 {{defined as reduction}} |
| 75 | #pragma omp parallel reduction(+ : r) |
| 76 | #pragma omp task |
| 77 | // expected-error@+1 2 {{reduction variables may not be accessed in an explicit task}} |
| 78 | ++r; |
| 79 | #pragma omp parallel |
| 80 | // expected-note@+1 3 {{defined as reduction}} |
| 81 | #pragma omp for reduction(+ : r) |
| 82 | for (int i = 0; i < 10; ++i) |
| 83 | // expected-error@+1 {{argument of a reduction clause of a for construct must not appear in a firstprivate clause on a task construct}} |
| 84 | #pragma omp task firstprivate(r) |
| 85 | // expected-error@+1 2 {{reduction variables may not be accessed in an explicit task}} |
| 86 | ++r; |
| 87 | #pragma omp parallel |
| 88 | // expected-note@+1 2 {{defined as reduction}} |
| 89 | #pragma omp for reduction(+ : r) |
| 90 | for (int i = 0; i < 10; ++i) |
| 91 | #pragma omp task default(shared) |
| 92 | // expected-error@+1 2 {{reduction variables may not be accessed in an explicit task}} |
| 93 | ++r; |
| 94 | #pragma omp parallel |
| 95 | // expected-note@+1 2 {{defined as reduction}} |
| 96 | #pragma omp for reduction(+ : r) |
| 97 | for (int i = 0; i < 10; ++i) |
| 98 | #pragma omp task |
| 99 | // expected-error@+1 2 {{reduction variables may not be accessed in an explicit task}} |
| 100 | ++r; |
| 101 | // expected-note@+1 {{non-shared variable in a task construct is predetermined as firstprivate}} |
| 102 | #pragma omp task |
| 103 | // expected-error@+2 {{reduction variable must be shared}} |
| 104 | // expected-error@+1 {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} |
| 105 | #pragma omp for reduction(+ : r) |
| 106 | ++r; |
Alexey Bataev | 7aea99a | 2014-07-17 12:19:31 +0000 | [diff] [blame] | 107 | // expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'untied' clause}} |
| 108 | #pragma omp task untied untied |
| 109 | ++r; |
Alexey Bataev | 74ba3a5 | 2014-07-17 12:47:03 +0000 | [diff] [blame] | 110 | // expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'mergeable' clause}} |
| 111 | #pragma omp task mergeable mergeable |
| 112 | ++r; |
Alexey Bataev | 9c2e8ee | 2014-07-11 11:25:16 +0000 | [diff] [blame] | 113 | return a + b; |
| 114 | } |
| 115 | |
| 116 | int main(int argc, char **argv) { |
| 117 | int a; |
Alexey Bataev | bd9fec1 | 2015-08-18 06:47:21 +0000 | [diff] [blame^] | 118 | int &b = a; |
Alexey Bataev | 4a5bb77 | 2014-10-08 14:01:46 +0000 | [diff] [blame] | 119 | S sa; |
Alexey Bataev | bd9fec1 | 2015-08-18 06:47:21 +0000 | [diff] [blame^] | 120 | S &sb = sa; |
Alexey Bataev | 9c2e8ee | 2014-07-11 11:25:16 +0000 | [diff] [blame] | 121 | int r; |
| 122 | #pragma omp task { // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}} |
| 123 | foo(); |
| 124 | #pragma omp task( // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}} |
| 125 | foo(); |
| 126 | #pragma omp task[ // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}} |
| 127 | foo(); |
| 128 | #pragma omp task] // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}} |
| 129 | foo(); |
| 130 | #pragma omp task) // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}} |
| 131 | foo(); |
| 132 | #pragma omp task } // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}} |
| 133 | foo(); |
| 134 | #pragma omp task |
| 135 | // expected-warning@+1 {{extra tokens at the end of '#pragma omp task' are ignored}} |
| 136 | #pragma omp task unknown() |
| 137 | foo(); |
| 138 | L1: |
| 139 | foo(); |
| 140 | #pragma omp task |
| 141 | ; |
| 142 | #pragma omp task |
| 143 | { |
| 144 | goto L1; // expected-error {{use of undeclared label 'L1'}} |
| 145 | argc++; |
| 146 | } |
| 147 | |
| 148 | for (int i = 0; i < 10; ++i) { |
| 149 | switch (argc) { |
| 150 | case (0): |
| 151 | #pragma omp task |
| 152 | { |
| 153 | foo(); |
| 154 | break; // expected-error {{'break' statement not in loop or switch statement}} |
| 155 | continue; // expected-error {{'continue' statement not in loop statement}} |
| 156 | } |
| 157 | default: |
| 158 | break; |
| 159 | } |
| 160 | } |
| 161 | #pragma omp task default(none) |
| 162 | ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}} |
| 163 | |
| 164 | goto L2; // expected-error {{use of undeclared label 'L2'}} |
| 165 | #pragma omp task |
| 166 | L2: |
| 167 | foo(); |
| 168 | #pragma omp task |
| 169 | { |
| 170 | return 1; // expected-error {{cannot return from OpenMP region}} |
| 171 | } |
| 172 | |
| 173 | [[]] // expected-error {{an attribute list cannot appear here}} |
| 174 | #pragma omp task |
| 175 | for (int n = 0; n < 100; ++n) { |
| 176 | } |
| 177 | |
| 178 | #pragma omp task default(none) |
| 179 | #pragma omp task default(shared) |
| 180 | ++a; |
| 181 | #pragma omp task default(none) |
| 182 | #pragma omp task |
| 183 | ++a; |
| 184 | #pragma omp task default(shared) |
| 185 | #pragma omp task |
| 186 | ++a; |
| 187 | #pragma omp task |
| 188 | #pragma omp parallel |
| 189 | ++a; |
Alexey Bataev | 9c2e8ee | 2014-07-11 11:25:16 +0000 | [diff] [blame] | 190 | #pragma omp task |
Alexey Bataev | 9c2e8ee | 2014-07-11 11:25:16 +0000 | [diff] [blame] | 191 | ++b; |
Alexey Bataev | 9c2e8ee | 2014-07-11 11:25:16 +0000 | [diff] [blame] | 192 | #pragma omp task |
Alexey Bataev | 9c2e8ee | 2014-07-11 11:25:16 +0000 | [diff] [blame] | 193 | #pragma omp parallel shared(a, b) |
| 194 | ++a, ++b; |
| 195 | #pragma omp task default(none) |
| 196 | #pragma omp task default(shared) |
| 197 | ++sa; |
| 198 | #pragma omp task default(none) |
Alexey Bataev | 9c2e8ee | 2014-07-11 11:25:16 +0000 | [diff] [blame] | 199 | #pragma omp task |
Alexey Bataev | 4a5bb77 | 2014-10-08 14:01:46 +0000 | [diff] [blame] | 200 | // expected-error@+1 {{calling a private constructor of class 'S'}} |
Alexey Bataev | 9c2e8ee | 2014-07-11 11:25:16 +0000 | [diff] [blame] | 201 | ++sa; |
| 202 | #pragma omp task |
Alexey Bataev | 9c2e8ee | 2014-07-11 11:25:16 +0000 | [diff] [blame] | 203 | #pragma omp task |
Alexey Bataev | 4a5bb77 | 2014-10-08 14:01:46 +0000 | [diff] [blame] | 204 | // expected-error@+1 {{calling a private constructor of class 'S'}} |
Alexey Bataev | 9c2e8ee | 2014-07-11 11:25:16 +0000 | [diff] [blame] | 205 | ++sa; |
| 206 | #pragma omp task default(shared) |
| 207 | #pragma omp task |
| 208 | ++sa; |
| 209 | #pragma omp task |
| 210 | #pragma omp parallel |
| 211 | ++sa; |
Alexey Bataev | 4a5bb77 | 2014-10-08 14:01:46 +0000 | [diff] [blame] | 212 | // expected-error@+2 {{calling a private constructor of class 'S'}} |
Alexey Bataev | bd9fec1 | 2015-08-18 06:47:21 +0000 | [diff] [blame^] | 213 | #pragma omp task |
| 214 | ++sb; |
| 215 | // expected-error@+2 2 {{calling a private constructor of class 'S'}} |
| 216 | #pragma omp task |
Alexey Bataev | 9c2e8ee | 2014-07-11 11:25:16 +0000 | [diff] [blame] | 217 | #pragma omp parallel shared(sa, sb) |
| 218 | ++sa, ++sb; |
| 219 | // expected-note@+1 2 {{defined as reduction}} |
| 220 | #pragma omp parallel reduction(+ : r) |
| 221 | // expected-error@+1 {{argument of a reduction clause of a parallel construct must not appear in a firstprivate clause on a task construct}} |
| 222 | #pragma omp task firstprivate(r) |
| 223 | // expected-error@+1 {{reduction variables may not be accessed in an explicit task}} |
| 224 | ++r; |
| 225 | // expected-note@+1 {{defined as reduction}} |
| 226 | #pragma omp parallel reduction(+ : r) |
| 227 | #pragma omp task default(shared) |
| 228 | // expected-error@+1 {{reduction variables may not be accessed in an explicit task}} |
| 229 | ++r; |
| 230 | // expected-note@+1 {{defined as reduction}} |
| 231 | #pragma omp parallel reduction(+ : r) |
| 232 | #pragma omp task |
| 233 | // expected-error@+1 {{reduction variables may not be accessed in an explicit task}} |
| 234 | ++r; |
| 235 | #pragma omp parallel |
| 236 | // expected-note@+1 2 {{defined as reduction}} |
| 237 | #pragma omp for reduction(+ : r) |
| 238 | for (int i = 0; i < 10; ++i) |
| 239 | // expected-error@+1 {{argument of a reduction clause of a for construct must not appear in a firstprivate clause on a task construct}} |
| 240 | #pragma omp task firstprivate(r) |
| 241 | // expected-error@+1 {{reduction variables may not be accessed in an explicit task}} |
| 242 | ++r; |
| 243 | #pragma omp parallel |
| 244 | // expected-note@+1 {{defined as reduction}} |
| 245 | #pragma omp for reduction(+ : r) |
| 246 | for (int i = 0; i < 10; ++i) |
| 247 | #pragma omp task default(shared) |
| 248 | // expected-error@+1 {{reduction variables may not be accessed in an explicit task}} |
| 249 | ++r; |
| 250 | #pragma omp parallel |
| 251 | // expected-note@+1 {{defined as reduction}} |
| 252 | #pragma omp for reduction(+ : r) |
| 253 | for (int i = 0; i < 10; ++i) |
| 254 | #pragma omp task |
| 255 | // expected-error@+1 {{reduction variables may not be accessed in an explicit task}} |
| 256 | ++r; |
| 257 | // expected-note@+1 {{non-shared variable in a task construct is predetermined as firstprivate}} |
| 258 | #pragma omp task |
| 259 | // expected-error@+2 {{reduction variable must be shared}} |
| 260 | // expected-error@+1 {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} |
| 261 | #pragma omp for reduction(+ : r) |
| 262 | ++r; |
Alexey Bataev | 7aea99a | 2014-07-17 12:19:31 +0000 | [diff] [blame] | 263 | // expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'untied' clause}} |
| 264 | #pragma omp task untied untied |
| 265 | ++r; |
Alexey Bataev | 74ba3a5 | 2014-07-17 12:47:03 +0000 | [diff] [blame] | 266 | // expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'mergeable' clause}} |
| 267 | #pragma omp task mergeable mergeable |
| 268 | ++r; |
Alexey Bataev | 9c2e8ee | 2014-07-11 11:25:16 +0000 | [diff] [blame] | 269 | // expected-note@+2 {{in instantiation of function template specialization 'foo<int>' requested here}} |
| 270 | // expected-note@+1 {{in instantiation of function template specialization 'foo<S>' requested here}} |
| 271 | return foo<int>() + foo<S>(); |
| 272 | } |
| 273 | |