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