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