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