1 // RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s 2 3 void foo() { 4 } 5 6 bool foobool(int argc) { 7 return argc; 8 } 9 10 struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}} 11 extern S1 a; 12 class S2 { 13 mutable int a; 14 15 public: 16 S2() : a(0) {} 17 S2(S2 &s2) : a(s2.a) {} 18 static float S2s; // expected-note {{static data member is predetermined as shared}} 19 static const float S2sc; 20 }; 21 const float S2::S2sc = 0; // expected-note {{static data member is predetermined as shared}} 22 const S2 b; 23 const S2 ba[5]; 24 class S3 { // expected-note 2 {{'S3' declared here}} 25 int a; 26 S3 &operator=(const S3 &s3); 27 28 public: 29 S3() : a(0) {} 30 S3(S3 &s3) : a(s3.a) {} 31 }; 32 const S3 c; // expected-note {{global variable is predetermined as shared}} 33 const S3 ca[5]; // expected-note {{global variable is predetermined as shared}} 34 extern const int f; // expected-note {{global variable is predetermined as shared}} 35 class S4 { // expected-note 3 {{'S4' declared here}} 36 int a; 37 S4(); 38 S4(const S4 &s4); 39 40 public: 41 S4(int v) : a(v) {} 42 }; 43 class S5 { // expected-note {{'S5' declared here}} 44 int a; 45 S5() : a(0) {} 46 47 public: 48 S5(const S5 &s5) : a(s5.a) {} 49 S5(int v) : a(v) {} 50 }; 51 class S6 { 52 int a; 53 S6() : a(0) {} 54 55 public: 56 S6(const S6 &s6) : a(s6.a) {} 57 S6(int v) : a(v) {} 58 }; 59 60 S3 h; 61 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} 62 63 template <class I, class C> 64 int foomain(int argc, char **argv) { 65 I e(4); // expected-note {{'e' defined here}} 66 I g(5); // expected-note {{'g' defined here}} 67 int i; 68 int &j = i; // expected-note {{'j' defined here}} 69 #pragma omp parallel for lastprivate // expected-error {{expected '(' after 'lastprivate'}} 70 for (int k = 0; k < argc; ++k) 71 ++k; 72 #pragma omp parallel for lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 73 for (int k = 0; k < argc; ++k) 74 ++k; 75 #pragma omp parallel for lastprivate() // expected-error {{expected expression}} 76 for (int k = 0; k < argc; ++k) 77 ++k; 78 #pragma omp parallel for lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} 79 for (int k = 0; k < argc; ++k) 80 ++k; 81 #pragma omp parallel for lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 82 for (int k = 0; k < argc; ++k) 83 ++k; 84 #pragma omp parallel for lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} 85 for (int k = 0; k < argc; ++k) 86 ++k; 87 #pragma omp parallel for lastprivate(argc) 88 for (int k = 0; k < argc; ++k) 89 ++k; 90 #pragma omp parallel for lastprivate(S1) // expected-error {{'S1' does not refer to a value}} 91 for (int k = 0; k < argc; ++k) 92 ++k; 93 #pragma omp parallel for lastprivate(a, b) // expected-error {{lastprivate variable with incomplete type 'S1'}} 94 for (int k = 0; k < argc; ++k) 95 ++k; 96 #pragma omp parallel for lastprivate(argv[1]) // expected-error {{expected variable name}} 97 for (int k = 0; k < argc; ++k) 98 ++k; 99 #pragma omp parallel for lastprivate(e, g) // expected-error 2 {{lastprivate variable must have an accessible, unambiguous default constructor}} 100 for (int k = 0; k < argc; ++k) 101 ++k; 102 #pragma omp parallel for lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}} 103 for (int k = 0; k < argc; ++k) 104 ++k; 105 #pragma omp parallel for linear(i) // expected-error {{unexpected OpenMP clause 'linear' in directive '#pragma omp parallel for'}} 106 for (int k = 0; k < argc; ++k) 107 ++k; 108 #pragma omp parallel 109 { 110 int v = 0; 111 int i; 112 #pragma omp parallel for lastprivate(i) 113 for (int k = 0; k < argc; ++k) { 114 i = k; 115 v += i; 116 } 117 } 118 #pragma omp parallel shared(i) 119 #pragma omp parallel private(i) 120 #pragma omp parallel for lastprivate(j) // expected-error {{arguments of OpenMP clause 'lastprivate' cannot be of reference type}} 121 for (int k = 0; k < argc; ++k) 122 ++k; 123 #pragma omp parallel for lastprivate(i) 124 for (int k = 0; k < argc; ++k) 125 ++k; 126 return 0; 127 } 128 129 int main(int argc, char **argv) { 130 const int d = 5; // expected-note {{constant variable is predetermined as shared}} 131 const int da[5] = {0}; // expected-note {{constant variable is predetermined as shared}} 132 S4 e(4); // expected-note {{'e' defined here}} 133 S5 g(5); // expected-note {{'g' defined here}} 134 S3 m; // expected-note 2 {{'m' defined here}} 135 S6 n(2); 136 int i; 137 int &j = i; // expected-note {{'j' defined here}} 138 #pragma omp parallel for lastprivate // expected-error {{expected '(' after 'lastprivate'}} 139 for (i = 0; i < argc; ++i) 140 foo(); 141 #pragma omp parallel for lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 142 for (i = 0; i < argc; ++i) 143 foo(); 144 #pragma omp parallel for lastprivate() // expected-error {{expected expression}} 145 for (i = 0; i < argc; ++i) 146 foo(); 147 #pragma omp parallel for lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} 148 for (i = 0; i < argc; ++i) 149 foo(); 150 #pragma omp parallel for lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 151 for (i = 0; i < argc; ++i) 152 foo(); 153 #pragma omp parallel for lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} 154 for (i = 0; i < argc; ++i) 155 foo(); 156 #pragma omp parallel for lastprivate(argc) 157 for (i = 0; i < argc; ++i) 158 foo(); 159 #pragma omp parallel for lastprivate(S1) // expected-error {{'S1' does not refer to a value}} 160 for (i = 0; i < argc; ++i) 161 foo(); 162 #pragma omp parallel for lastprivate(a, b, c, d, f) // expected-error {{lastprivate variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be lastprivate}} 163 for (i = 0; i < argc; ++i) 164 foo(); 165 #pragma omp parallel for lastprivate(argv[1]) // expected-error {{expected variable name}} 166 for (i = 0; i < argc; ++i) 167 foo(); 168 #pragma omp parallel for lastprivate(2 * 2) // expected-error {{expected variable name}} 169 for (i = 0; i < argc; ++i) 170 foo(); 171 #pragma omp parallel for lastprivate(ba) 172 for (i = 0; i < argc; ++i) 173 foo(); 174 #pragma omp parallel for lastprivate(ca) // expected-error {{shared variable cannot be lastprivate}} 175 for (i = 0; i < argc; ++i) 176 foo(); 177 #pragma omp parallel for lastprivate(da) // expected-error {{shared variable cannot be lastprivate}} 178 for (i = 0; i < argc; ++i) 179 foo(); 180 int xa; 181 #pragma omp parallel for lastprivate(xa) // OK 182 for (i = 0; i < argc; ++i) 183 foo(); 184 #pragma omp parallel for lastprivate(S2::S2s) // expected-error {{shared variable cannot be lastprivate}} 185 for (i = 0; i < argc; ++i) 186 foo(); 187 #pragma omp parallel for lastprivate(S2::S2sc) // expected-error {{shared variable cannot be lastprivate}} 188 for (i = 0; i < argc; ++i) 189 foo(); 190 #pragma omp parallel for safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp parallel for'}} 191 for (i = 0; i < argc; ++i) 192 foo(); 193 #pragma omp parallel for lastprivate(e, g) // expected-error 2 {{lastprivate variable must have an accessible, unambiguous default constructor}} 194 for (i = 0; i < argc; ++i) 195 foo(); 196 #pragma omp parallel for lastprivate(m) // expected-error {{lastprivate variable must have an accessible, unambiguous copy assignment operator}} 197 for (i = 0; i < argc; ++i) 198 foo(); 199 #pragma omp parallel for lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}} 200 for (i = 0; i < argc; ++i) 201 foo(); 202 #pragma omp parallel for private(xa), lastprivate(xa) // expected-error {{private variable cannot be lastprivate}} expected-note {{defined as private}} 203 for (i = 0; i < argc; ++i) 204 foo(); 205 #pragma omp parallel for lastprivate(i) 206 for (i = 0; i < argc; ++i) 207 foo(); 208 #pragma omp parallel private(xa) 209 #pragma omp parallel for lastprivate(xa) 210 for (i = 0; i < argc; ++i) 211 foo(); 212 #pragma omp parallel reduction(+ : xa) 213 #pragma omp parallel for lastprivate(xa) 214 for (i = 0; i < argc; ++i) 215 foo(); 216 #pragma omp parallel for lastprivate(j) // expected-error {{arguments of OpenMP clause 'lastprivate' cannot be of reference type}} 217 for (i = 0; i < argc; ++i) 218 foo(); 219 #pragma omp parallel for firstprivate(m) lastprivate(m) // expected-error {{lastprivate variable must have an accessible, unambiguous copy assignment operator}} 220 for (i = 0; i < argc; ++i) 221 foo(); 222 #pragma omp parallel for lastprivate(n) firstprivate(n) // OK 223 for (i = 0; i < argc; ++i) 224 foo(); 225 return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}} 226 } 227