1 // RUN: %clang_cc1 -verify -fopenmp %s 2 3 // RUN: %clang_cc1 -verify -fopenmp-simd %s 4 5 struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}} 6 extern S1 a; 7 class S2 { 8 mutable int a; 9 10 public: 11 S2() : a(0) {} 12 }; 13 const S2 b; 14 const S2 ba[5]; 15 class S3 { 16 int a; 17 18 public: 19 S3() : a(0) {} 20 }; 21 const S3 ca[5]; 22 class S4 { 23 int a; 24 S4(); 25 26 public: 27 S4(int v) : a(v) { 28 #pragma omp target firstprivate(a) firstprivate(this->a) 29 for (int k = 0; k < v; ++k) 30 ++this->a; 31 } 32 }; 33 class S5 { 34 int a; 35 S5() : a(0) {} 36 37 public: 38 S5(int v) : a(v) {} 39 S5 &operator=(S5 &s) { 40 #pragma omp target firstprivate(a) firstprivate(this->a) firstprivate(s.a) // expected-error {{expected variable name or data member of current class}} 41 for (int k = 0; k < s.a; ++k) 42 ++s.a; 43 return *this; 44 } 45 }; 46 47 template <typename T> 48 class S6 { 49 public: 50 T a; 51 52 S6() : a(0) {} 53 S6(T v) : a(v) { 54 #pragma omp target firstprivate(a) firstprivate(this->a) 55 for (int k = 0; k < v; ++k) 56 ++this->a; 57 } 58 S6 &operator=(S6 &s) { 59 #pragma omp target firstprivate(a) firstprivate(this->a) firstprivate(s.a) // expected-error {{expected variable name or data member of current class}} 60 for (int k = 0; k < s.a; ++k) 61 ++s.a; 62 return *this; 63 } 64 }; 65 66 template <typename T> 67 class S7 : public T { 68 T a; 69 S7() : a(0) {} 70 71 public: 72 S7(T v) : a(v) { 73 #pragma omp target firstprivate(a) firstprivate(this->a) firstprivate(T::a) 74 for (int k = 0; k < a.a; ++k) 75 ++this->a.a; 76 } 77 S7 &operator=(S7 &s) { 78 #pragma omp target firstprivate(a) firstprivate(this->a) firstprivate(s.a) firstprivate(s.T::a) // expected-error 2 {{expected variable name or data member of current class}} 79 for (int k = 0; k < s.a.a; ++k) 80 ++s.a.a; 81 return *this; 82 } 83 }; 84 85 S3 h; 86 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} 87 88 template <class I, class C> 89 int foomain(I argc, C **argv) { 90 I e(4); 91 I g(5); 92 int i; 93 int &j = i; 94 #pragma omp target firstprivate // expected-error {{expected '(' after 'firstprivate'}} 95 {} 96 #pragma omp target firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 97 {} 98 #pragma omp target firstprivate() // expected-error {{expected expression}} 99 {} 100 #pragma omp target firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} 101 {} 102 #pragma omp target firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 103 {} 104 #pragma omp target firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} 105 {} 106 #pragma omp target firstprivate(argc) 107 {} 108 #pragma omp target firstprivate(S1) // expected-error {{'S1' does not refer to a value}} 109 {} 110 #pragma omp target firstprivate(a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}} 111 {} 112 #pragma omp target firstprivate(argv[1]) // expected-error {{expected variable name}} 113 {} 114 #pragma omp target firstprivate(e, g) 115 {} 116 #pragma omp target firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}} 117 {} 118 #pragma omp target shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp target'}} 119 #pragma omp parallel 120 { 121 int v = 0; 122 int i; 123 } 124 #pragma omp parallel shared(i) 125 #pragma omp parallel firstprivate(i) 126 #pragma omp target firstprivate(j) 127 {} 128 #pragma omp target firstprivate(i) 129 {} 130 return 0; 131 } 132 133 void bar(S4 a[2]) { 134 #pragma omp parallel 135 #pragma omp target firstprivate(a) 136 {} 137 } 138 139 namespace A { 140 double x; 141 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} 142 } 143 namespace B { 144 using A::x; 145 } 146 147 int main(int argc, char **argv) { 148 S4 e(4); 149 S5 g(5); 150 S6<float> s6(0.0) , s6_0(1.0); 151 S7<S6<float> > s7(0.0) , s7_0(1.0); 152 int i; 153 int &j = i; 154 #pragma omp target firstprivate // expected-error {{expected '(' after 'firstprivate'}} 155 {} 156 #pragma omp target firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 157 {} 158 #pragma omp target firstprivate() // expected-error {{expected expression}} 159 {} 160 #pragma omp target firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} 161 {} 162 #pragma omp target firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 163 {} 164 #pragma omp target firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} 165 {} 166 #pragma omp target firstprivate(argc) 167 {} 168 #pragma omp target firstprivate(S1) // expected-error {{'S1' does not refer to a value}} 169 {} 170 #pragma omp target firstprivate(a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}} 171 {} 172 #pragma omp target firstprivate(argv[1]) // expected-error {{expected variable name}} 173 {} 174 #pragma omp target firstprivate(e, g) 175 {} 176 #pragma omp target firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}} 177 {} 178 #pragma omp target firstprivate(B::x) // expected-error {{threadprivate or thread local variable cannot be firstprivate}} 179 {} 180 #pragma omp target shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp target'}} 181 #pragma omp parallel 182 { 183 int i; 184 } 185 #pragma omp parallel shared(i) 186 #pragma omp parallel firstprivate(i) 187 #pragma omp target firstprivate(j) 188 {} 189 #pragma omp target firstprivate(i) 190 {} 191 static int si; 192 #pragma omp target firstprivate(si) // OK 193 {} 194 #pragma omp target map(i) firstprivate(i) // expected-error {{firstprivate variable cannot be in a map clause in '#pragma omp target' directive}} 195 {} 196 s6 = s6_0; // expected-note {{in instantiation of member function 'S6<float>::operator=' requested here}} 197 s7 = s7_0; // expected-note {{in instantiation of member function 'S7<S6<float> >::operator=' requested here}} 198 return foomain(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}} 199 } 200 201