Alexander Musman | 1bb328c | 2014-06-04 13:06:39 +0000 | [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 | public: |
| 15 | S2():a(0) { } |
| 16 | S2(S2 &s2):a(s2.a) { } |
| 17 | static float S2s; // expected-note {{predetermined as shared}} |
| 18 | static const float S2sc; |
| 19 | }; |
| 20 | const float S2::S2sc = 0; // expected-note {{predetermined as shared}} |
| 21 | const S2 b; |
| 22 | const S2 ba[5]; |
| 23 | class S3 { // expected-note {{'S3' declared here}} |
| 24 | int a; |
| 25 | S3& operator =(const S3& s3); |
| 26 | public: |
| 27 | S3():a(0) { } |
| 28 | S3(S3 &s3):a(s3.a) { } |
| 29 | }; |
| 30 | const S3 c; // expected-note {{predetermined as shared}} |
| 31 | const S3 ca[5]; // expected-note {{predetermined as shared}} |
| 32 | extern const int f; // expected-note {{predetermined as shared}} |
| 33 | class S4 { // expected-note {{'S4' declared here}} |
| 34 | int a; |
| 35 | S4(); |
| 36 | S4(const S4 &s4); |
| 37 | public: |
| 38 | S4(int v):a(v) { } |
| 39 | }; |
| 40 | class S5 { // expected-note {{'S5' declared here}} |
| 41 | int a; |
| 42 | S5():a(0) {} |
| 43 | public: |
| 44 | S5(const S5 &s5):a(s5.a) { } |
| 45 | S5(int v):a(v) { } |
| 46 | }; |
| 47 | |
| 48 | S3 h; |
| 49 | #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} |
| 50 | |
| 51 | template<class I, class C> int foomain(I argc, C **argv) { |
| 52 | I e(4); |
| 53 | I g(5); |
| 54 | int i; |
| 55 | int &j = i; // expected-note {{'j' defined here}} |
| 56 | #pragma omp simd lastprivate // expected-error {{expected '(' after 'lastprivate'}} |
| 57 | for (int k = 0; k < argc; ++k) ++k; |
| 58 | #pragma omp simd lastprivate ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 59 | for (int k = 0; k < argc; ++k) ++k; |
| 60 | #pragma omp simd lastprivate () // expected-error {{expected expression}} |
| 61 | for (int k = 0; k < argc; ++k) ++k; |
| 62 | #pragma omp simd lastprivate (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 63 | for (int k = 0; k < argc; ++k) ++k; |
| 64 | #pragma omp simd lastprivate (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 65 | for (int k = 0; k < argc; ++k) ++k; |
| 66 | #pragma omp simd lastprivate (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} |
| 67 | for (int k = 0; k < argc; ++k) ++k; |
| 68 | #pragma omp simd lastprivate (argc) |
| 69 | for (int k = 0; k < argc; ++k) ++k; |
| 70 | #pragma omp simd lastprivate (S1) // expected-error {{'S1' does not refer to a value}} |
| 71 | for (int k = 0; k < argc; ++k) ++k; |
| 72 | #pragma omp simd lastprivate (a, b) // expected-error {{lastprivate variable with incomplete type 'S1'}} |
| 73 | for (int k = 0; k < argc; ++k) ++k; |
| 74 | #pragma omp simd lastprivate (argv[1]) // expected-error {{expected variable name}} |
| 75 | for (int k = 0; k < argc; ++k) ++k; |
| 76 | #pragma omp simd lastprivate(e, g) |
| 77 | for (int k = 0; k < argc; ++k) ++k; |
| 78 | #pragma omp simd lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}} |
| 79 | for (int k = 0; k < argc; ++k) ++k; |
| 80 | #pragma omp simd firstprivate(i) // expected-error {{unexpected OpenMP clause 'firstprivate' in directive '#pragma omp simd'}} |
| 81 | for (int k = 0; k < argc; ++k) ++k; |
| 82 | #pragma omp parallel |
| 83 | { |
| 84 | int v = 0; |
| 85 | int i; |
| 86 | #pragma omp simd lastprivate(i) |
| 87 | for (int k = 0; k < argc; ++k) { i = k; v += i; } |
| 88 | } |
| 89 | #pragma omp parallel shared(i) |
| 90 | #pragma omp parallel private(i) |
| 91 | #pragma omp simd lastprivate (j) // expected-error {{arguments of OpenMP clause 'lastprivate' cannot be of reference type}} |
| 92 | for (int k = 0; k < argc; ++k) ++k; |
| 93 | #pragma omp simd lastprivate(i) |
| 94 | for (int k = 0; k < argc; ++k) ++k; |
| 95 | return 0; |
| 96 | } |
| 97 | |
| 98 | int main(int argc, char **argv) { |
| 99 | const int d = 5; // expected-note {{predetermined as shared}} |
| 100 | const int da[5] = { 0 }; // expected-note {{predetermined as shared}} |
| 101 | S4 e(4); // expected-note {{'e' defined here}} |
| 102 | S5 g(5); // expected-note {{'g' defined here}} |
| 103 | S3 m; // expected-note {{'m' defined here}} |
| 104 | int i; |
| 105 | int &j = i; // expected-note {{'j' defined here}} |
| 106 | #pragma omp simd lastprivate // expected-error {{expected '(' after 'lastprivate'}} |
| 107 | for (i = 0; i < argc; ++i) foo(); |
| 108 | #pragma omp simd lastprivate ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 109 | for (i = 0; i < argc; ++i) foo(); |
| 110 | #pragma omp simd lastprivate () // expected-error {{expected expression}} |
| 111 | for (i = 0; i < argc; ++i) foo(); |
| 112 | #pragma omp simd lastprivate (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 113 | for (i = 0; i < argc; ++i) foo(); |
| 114 | #pragma omp simd lastprivate (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 115 | for (i = 0; i < argc; ++i) foo(); |
| 116 | #pragma omp simd lastprivate (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} |
| 117 | for (i = 0; i < argc; ++i) foo(); |
| 118 | #pragma omp simd lastprivate (argc) |
| 119 | for (i = 0; i < argc; ++i) foo(); |
| 120 | #pragma omp simd lastprivate (S1) // expected-error {{'S1' does not refer to a value}} |
| 121 | for (i = 0; i < argc; ++i) foo(); |
| 122 | #pragma omp simd lastprivate (a, b, c, d, f) // expected-error {{lastprivate variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be lastprivate}} |
| 123 | for (i = 0; i < argc; ++i) foo(); |
| 124 | #pragma omp simd lastprivate (argv[1]) // expected-error {{expected variable name}} |
| 125 | for (i = 0; i < argc; ++i) foo(); |
| 126 | #pragma omp simd lastprivate (2*2) // expected-error {{expected variable name}} |
| 127 | for (i = 0; i < argc; ++i) foo(); |
| 128 | #pragma omp simd lastprivate(ba) |
| 129 | for (i = 0; i < argc; ++i) foo(); |
| 130 | #pragma omp simd lastprivate(ca) // expected-error {{shared variable cannot be lastprivate}} |
| 131 | for (i = 0; i < argc; ++i) foo(); |
| 132 | #pragma omp simd lastprivate(da) // expected-error {{shared variable cannot be lastprivate}} |
| 133 | for (i = 0; i < argc; ++i) foo(); |
| 134 | int xa; |
| 135 | #pragma omp simd lastprivate(xa) // OK |
| 136 | for (i = 0; i < argc; ++i) foo(); |
| 137 | #pragma omp simd lastprivate(S2::S2s) // expected-error {{shared variable cannot be lastprivate}} |
| 138 | for (i = 0; i < argc; ++i) foo(); |
| 139 | #pragma omp simd lastprivate(S2::S2sc) // expected-error {{shared variable cannot be lastprivate}} |
| 140 | for (i = 0; i < argc; ++i) foo(); |
| 141 | #pragma omp simd firstprivate (g) // expected-error {{unexpected OpenMP clause 'firstprivate' in directive '#pragma omp simd'}} |
| 142 | for (i = 0; i < argc; ++i) foo(); |
| 143 | #pragma omp simd lastprivate(e, g) // expected-error 2 {{lastprivate variable must have an accessible, unambiguous default constructor}} |
| 144 | for (i = 0; i < argc; ++i) foo(); |
| 145 | #pragma omp simd lastprivate(m) // expected-error {{lastprivate variable must have an accessible, unambiguous copy assignment operator}} |
| 146 | for (i = 0; i < argc; ++i) foo(); |
| 147 | #pragma omp simd lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}} |
| 148 | for (i = 0; i < argc; ++i) foo(); |
| 149 | #pragma omp simd private(xa), lastprivate(xa) // expected-error {{private variable cannot be lastprivate}} expected-note {{defined as private}} |
| 150 | for (i = 0; i < argc; ++i) foo(); |
| 151 | #pragma omp simd lastprivate(i) |
| 152 | for (i = 0; i < argc; ++i) foo(); |
| 153 | #pragma omp parallel private(xa) |
| 154 | #pragma omp simd lastprivate(xa) // OK: may be lastprivate |
| 155 | for (i = 0; i < argc; ++i) foo(); |
| 156 | #pragma omp parallel |
| 157 | #pragma omp simd lastprivate(j) // expected-error {{arguments of OpenMP clause 'lastprivate' cannot be of reference type}} |
| 158 | for (i = 0; i < argc; ++i) foo(); |
| 159 | return 0; |
| 160 | } |