Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 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 | }; |
| 18 | const S2 b; |
| 19 | const S2 ba[5]; |
| 20 | class S3 { |
| 21 | int a; |
| 22 | |
| 23 | public: |
| 24 | S3() : a(0) {} |
| 25 | }; |
| 26 | const S3 ca[5]; |
| 27 | class S4 { |
| 28 | int a; |
| 29 | S4(); // expected-note {{implicitly declared private here}} |
| 30 | |
| 31 | public: |
| 32 | S4(int v) : a(v) {} |
| 33 | }; |
| 34 | class S5 { |
| 35 | int a; |
| 36 | S5() : a(0) {} // expected-note {{implicitly declared private here}} |
| 37 | |
| 38 | public: |
| 39 | S5(int v) : a(v) {} |
| 40 | }; |
| 41 | |
| 42 | S3 h; |
| 43 | #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} |
| 44 | |
| 45 | template <class I, class C> |
| 46 | int foomain(I argc, C **argv) { |
| 47 | I e(4); |
| 48 | I g(5); |
| 49 | int i; |
| 50 | int &j = i; // expected-note {{'j' defined here}} |
| 51 | #pragma omp for simd private // expected-error {{expected '(' after 'private'}} |
| 52 | for (int k = 0; k < argc; ++k) |
| 53 | ++k; |
| 54 | #pragma omp for simd private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 55 | for (int k = 0; k < argc; ++k) |
| 56 | ++k; |
| 57 | #pragma omp for simd private() // expected-error {{expected expression}} |
| 58 | for (int k = 0; k < argc; ++k) |
| 59 | ++k; |
| 60 | #pragma omp for simd private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 61 | for (int k = 0; k < argc; ++k) |
| 62 | ++k; |
| 63 | #pragma omp for simd private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 64 | for (int k = 0; k < argc; ++k) |
| 65 | ++k; |
| 66 | #pragma omp for simd private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} |
| 67 | for (int k = 0; k < argc; ++k) |
| 68 | ++k; |
| 69 | #pragma omp for simd private(argc) |
| 70 | for (int k = 0; k < argc; ++k) |
| 71 | ++k; |
| 72 | #pragma omp for simd private(S1) // expected-error {{'S1' does not refer to a value}} |
| 73 | for (int k = 0; k < argc; ++k) |
| 74 | ++k; |
| 75 | #pragma omp for simd private(a, b) // expected-error {{private variable with incomplete type 'S1'}} |
| 76 | for (int k = 0; k < argc; ++k) |
| 77 | ++k; |
| 78 | #pragma omp for simd private(argv[1]) // expected-error {{expected variable name}} |
| 79 | for (int k = 0; k < argc; ++k) |
| 80 | ++k; |
| 81 | #pragma omp for simd private(e, g) |
| 82 | for (int k = 0; k < argc; ++k) |
| 83 | ++k; |
| 84 | #pragma omp for simd private(h) // expected-error {{threadprivate or thread local variable cannot be private}} |
| 85 | for (int k = 0; k < argc; ++k) |
| 86 | ++k; |
| 87 | #pragma omp for simd shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp for simd'}} |
| 88 | for (int k = 0; k < argc; ++k) |
| 89 | ++k; |
| 90 | #pragma omp parallel |
| 91 | { |
| 92 | int v = 0; |
| 93 | int i; |
| 94 | #pragma omp for simd private(i) |
| 95 | for (int k = 0; k < argc; ++k) { |
| 96 | i = k; |
| 97 | v += i; |
| 98 | } |
| 99 | } |
| 100 | #pragma omp parallel shared(i) |
| 101 | #pragma omp parallel private(i) |
| 102 | #pragma omp for simd private(j) // expected-error {{arguments of OpenMP clause 'private' cannot be of reference type}} |
| 103 | for (int k = 0; k < argc; ++k) |
| 104 | ++k; |
| 105 | #pragma omp for simd private(i) |
| 106 | for (int k = 0; k < argc; ++k) |
| 107 | ++k; |
| 108 | return 0; |
| 109 | } |
| 110 | |
Pirama Arumuga Nainar | 33337ca | 2015-05-06 11:48:57 -0700 | [diff] [blame] | 111 | namespace A { |
| 112 | double x; |
| 113 | #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} |
| 114 | } |
| 115 | namespace B { |
| 116 | using A::x; |
| 117 | } |
| 118 | |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 119 | int main(int argc, char **argv) { |
| 120 | S4 e(4); |
| 121 | S5 g(5); |
| 122 | int i; |
| 123 | int &j = i; // expected-note {{'j' defined here}} |
| 124 | #pragma omp for simd private // expected-error {{expected '(' after 'private'}} |
| 125 | for (int k = 0; k < argc; ++k) |
| 126 | ++k; |
| 127 | #pragma omp for simd private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 128 | for (int k = 0; k < argc; ++k) |
| 129 | ++k; |
| 130 | #pragma omp for simd private() // expected-error {{expected expression}} |
| 131 | for (int k = 0; k < argc; ++k) |
| 132 | ++k; |
| 133 | #pragma omp for simd private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 134 | for (int k = 0; k < argc; ++k) |
| 135 | ++k; |
| 136 | #pragma omp for simd private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 137 | for (int k = 0; k < argc; ++k) |
| 138 | ++k; |
| 139 | #pragma omp for simd private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} |
| 140 | for (int k = 0; k < argc; ++k) |
| 141 | ++k; |
| 142 | #pragma omp for simd private(argc) |
| 143 | for (int k = 0; k < argc; ++k) |
| 144 | ++k; |
| 145 | #pragma omp for simd private(S1) // expected-error {{'S1' does not refer to a value}} |
| 146 | for (int k = 0; k < argc; ++k) |
| 147 | ++k; |
| 148 | #pragma omp for simd private(a, b) // expected-error {{private variable with incomplete type 'S1'}} |
| 149 | for (int k = 0; k < argc; ++k) |
| 150 | ++k; |
| 151 | #pragma omp for simd private(argv[1]) // expected-error {{expected variable name}} |
| 152 | for (int k = 0; k < argc; ++k) |
| 153 | ++k; |
| 154 | #pragma omp for simd private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} |
| 155 | for (int k = 0; k < argc; ++k) |
| 156 | ++k; |
Pirama Arumuga Nainar | 33337ca | 2015-05-06 11:48:57 -0700 | [diff] [blame] | 157 | #pragma omp for simd private(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be private}} |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 158 | for (int k = 0; k < argc; ++k) |
| 159 | ++k; |
| 160 | #pragma omp for simd shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp for simd'}} |
| 161 | for (int k = 0; k < argc; ++k) |
| 162 | ++k; |
| 163 | #pragma omp parallel |
| 164 | { |
| 165 | int i; |
| 166 | #pragma omp for simd private(i) |
| 167 | for (int k = 0; k < argc; ++k) |
| 168 | ++k; |
| 169 | } |
| 170 | #pragma omp parallel shared(i) |
| 171 | #pragma omp parallel private(i) |
| 172 | #pragma omp for simd private(j) // expected-error {{arguments of OpenMP clause 'private' cannot be of reference type}} |
| 173 | for (int k = 0; k < argc; ++k) |
| 174 | ++k; |
| 175 | #pragma omp for simd private(i) |
| 176 | for (int k = 0; k < argc; ++k) |
| 177 | ++k; |
| 178 | |
| 179 | return 0; |
| 180 | } |
| 181 | |