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 { // expected-note {{'S4' declared here}} 28 int a; 29 S4(); 30 31 public: 32 S4(int v) : a(v) {} 33 }; 34 class S5 { // expected-note {{'S5' declared here}} 35 int a; 36 S5() : a(0) {} 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 parallel for private // expected-error {{expected '(' after 'private'}} 52 for (int k = 0; k < argc; ++k) 53 ++k; 54 #pragma omp parallel for 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 parallel for private() // expected-error {{expected expression}} 58 for (int k = 0; k < argc; ++k) 59 ++k; 60 #pragma omp parallel for private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} 61 for (int k = 0; k < argc; ++k) 62 ++k; 63 #pragma omp parallel for 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 parallel for 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 parallel for private(argc) 70 for (int k = 0; k < argc; ++k) 71 ++k; 72 #pragma omp parallel for private(S1) // expected-error {{'S1' does not refer to a value}} 73 for (int k = 0; k < argc; ++k) 74 ++k; 75 #pragma omp parallel for private(a, b) // expected-error {{private variable with incomplete type 'S1'}} 76 for (int k = 0; k < argc; ++k) 77 ++k; 78 #pragma omp parallel for private(argv[1]) // expected-error {{expected variable name}} 79 for (int k = 0; k < argc; ++k) 80 ++k; 81 #pragma omp parallel for private(e, g) 82 for (int k = 0; k < argc; ++k) 83 ++k; 84 #pragma omp parallel for 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 parallel for nowait // expected-error {{unexpected OpenMP clause 'nowait' in directive '#pragma omp parallel for'}} 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 parallel for 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 parallel for 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 parallel for private(i) 106 for (int k = 0; k < argc; ++k) 107 ++k; 108 return 0; 109 } 110 111 int main(int argc, char **argv) { 112 S4 e(4); // expected-note {{'e' defined here}} 113 S5 g(5); // expected-note {{'g' defined here}} 114 int i; 115 int &j = i; // expected-note {{'j' defined here}} 116 #pragma omp parallel for private // expected-error {{expected '(' after 'private'}} 117 for (int k = 0; k < argc; ++k) 118 ++k; 119 #pragma omp parallel for private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 120 for (int k = 0; k < argc; ++k) 121 ++k; 122 #pragma omp parallel for private() // expected-error {{expected expression}} 123 for (int k = 0; k < argc; ++k) 124 ++k; 125 #pragma omp parallel for private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} 126 for (int k = 0; k < argc; ++k) 127 ++k; 128 #pragma omp parallel for private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 129 for (int k = 0; k < argc; ++k) 130 ++k; 131 #pragma omp parallel for private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} 132 for (int k = 0; k < argc; ++k) 133 ++k; 134 #pragma omp parallel for private(argc) 135 for (int k = 0; k < argc; ++k) 136 ++k; 137 #pragma omp parallel for private(S1) // expected-error {{'S1' does not refer to a value}} 138 for (int k = 0; k < argc; ++k) 139 ++k; 140 #pragma omp parallel for private(a, b) // expected-error {{private variable with incomplete type 'S1'}} 141 for (int k = 0; k < argc; ++k) 142 ++k; 143 #pragma omp parallel for private(argv[1]) // expected-error {{expected variable name}} 144 for (int k = 0; k < argc; ++k) 145 ++k; 146 #pragma omp parallel for private(e, g) // expected-error 2 {{private variable must have an accessible, unambiguous default constructor}} 147 for (int k = 0; k < argc; ++k) 148 ++k; 149 #pragma omp parallel for private(h) // expected-error {{threadprivate or thread local variable cannot be private}} 150 for (int k = 0; k < argc; ++k) 151 ++k; 152 #pragma omp parallel for nowait // expected-error {{unexpected OpenMP clause 'nowait' in directive '#pragma omp parallel for'}} 153 for (int k = 0; k < argc; ++k) 154 ++k; 155 #pragma omp parallel 156 { 157 int i; 158 #pragma omp parallel for private(i) 159 for (int k = 0; k < argc; ++k) 160 ++k; 161 } 162 #pragma omp parallel shared(i) 163 #pragma omp parallel private(i) 164 #pragma omp parallel for private(j) // expected-error {{arguments of OpenMP clause 'private' cannot be of reference type}} 165 for (int k = 0; k < argc; ++k) 166 ++k; 167 #pragma omp parallel for private(i) 168 for (int k = 0; k < argc; ++k) 169 ++k; 170 171 return 0; 172 } 173 174