1 // RUN: %clang_cc1 -verify -fopenmp %s 2 3 void foo() { 4 } 5 6 bool foobool(int argc) { 7 return argc; 8 } 9 10 struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}} 11 extern S1 a; 12 class S2 { 13 mutable int a; 14 15 public: 16 S2() : a(0) {} 17 S2(const S2 &s2) : a(s2.a) {} 18 static float S2s; 19 static const float S2sc; 20 }; 21 const float S2::S2sc = 0; 22 const S2 b; 23 const S2 ba[5]; 24 class S3 { 25 int a; 26 S3 &operator=(const S3 &s3); 27 28 public: 29 S3() : a(0) {} // expected-note {{candidate constructor not viable: requires 0 arguments, but 1 was provided}} 30 S3(S3 &s3) : a(s3.a) {} // expected-note {{candidate constructor not viable: 1st argument ('const S3') would lose const qualifier}} 31 }; 32 const S3 c; 33 const S3 ca[5]; 34 extern const int f; 35 class S4 { 36 int a; 37 S4(); 38 S4(const S4 &s4); 39 public: 40 S4(int v):a(v) { } 41 }; 42 class S5 { 43 int a; 44 S5():a(0) {} 45 S5(const S5 &s5):a(s5.a) { } 46 public: 47 S5(int v):a(v) { } 48 }; 49 class S6 { 50 int a; 51 public: 52 S6() : a(0) { } 53 }; 54 55 S3 h; 56 #pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}} 57 58 int main(int argc, char **argv) { 59 const int d = 5; 60 const int da[5] = { 0 }; 61 S4 e(4); 62 S5 g(5); 63 S6 p; 64 int i; 65 int &j = i; 66 67 #pragma omp target 68 #pragma omp teams distribute parallel for firstprivate // expected-error {{expected '(' after 'firstprivate'}} 69 for (i = 0; i < argc; ++i) foo(); 70 71 #pragma omp target 72 #pragma omp teams distribute parallel for firstprivate ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 73 for (i = 0; i < argc; ++i) foo(); 74 75 #pragma omp target 76 #pragma omp teams distribute parallel for firstprivate () // expected-error {{expected expression}} 77 for (i = 0; i < argc; ++i) foo(); 78 79 #pragma omp target 80 #pragma omp teams distribute parallel for firstprivate (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} 81 for (i = 0; i < argc; ++i) foo(); 82 83 #pragma omp target 84 #pragma omp teams distribute parallel for firstprivate (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 85 for (i = 0; i < argc; ++i) foo(); 86 87 #pragma omp target 88 #pragma omp teams distribute parallel for firstprivate (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} 89 for (i = 0; i < argc; ++i) foo(); 90 91 #pragma omp target 92 #pragma omp teams distribute parallel for firstprivate (argc) 93 for (i = 0; i < argc; ++i) foo(); 94 95 #pragma omp target 96 #pragma omp teams distribute parallel for firstprivate (S1) // expected-error {{'S1' does not refer to a value}} 97 for (i = 0; i < argc; ++i) foo(); 98 99 #pragma omp target 100 #pragma omp teams distribute parallel for firstprivate (a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} 101 for (i = 0; i < argc; ++i) foo(); 102 103 #pragma omp target 104 #pragma omp teams distribute parallel for firstprivate (argv[1]) // expected-error {{expected variable name}} 105 for (i = 0; i < argc; ++i) foo(); 106 107 #pragma omp target 108 #pragma omp teams distribute parallel for firstprivate(ba) 109 for (i = 0; i < argc; ++i) foo(); 110 111 #pragma omp target 112 #pragma omp teams distribute parallel for firstprivate(ca) // expected-error {{no matching constructor for initialization of 'S3'}} 113 for (i = 0; i < argc; ++i) foo(); 114 115 #pragma omp target 116 #pragma omp teams distribute parallel for firstprivate(da) 117 for (i = 0; i < argc; ++i) foo(); 118 119 #pragma omp target 120 #pragma omp teams distribute parallel for firstprivate(S2::S2s) 121 for (i = 0; i < argc; ++i) foo(); 122 123 #pragma omp target 124 #pragma omp teams distribute parallel for firstprivate(S2::S2sc) 125 for (i = 0; i < argc; ++i) foo(); 126 127 #pragma omp target 128 #pragma omp teams distribute parallel for firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}} 129 for (i = 0; i < argc; ++i) foo(); 130 131 #pragma omp target 132 #pragma omp teams distribute parallel for private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}} 133 for (i = 0; i < argc; ++i) foo(); 134 135 #pragma omp target 136 #pragma omp teams distribute parallel for firstprivate(i) 137 for (j = 0; j < argc; ++j) foo(); 138 139 #pragma omp target 140 #pragma omp teams distribute parallel for firstprivate(i) // expected-note {{defined as firstprivate}} 141 for (i = 0; i < argc; ++i) foo(); // expected-error {{loop iteration variable in the associated loop of 'omp teams distribute parallel for' directive may not be firstprivate, predetermined as private}} 142 143 #pragma omp target 144 #pragma omp teams distribute parallel for firstprivate(j) 145 for (i = 0; i < argc; ++i) foo(); 146 147 #pragma omp target 148 #pragma omp teams distribute parallel for lastprivate(argc), firstprivate(argc) // OK 149 for (i = 0; i < argc; ++i) foo(); 150 151 return 0; 152 } 153