1 // RUN: %clang_cc1 -verify -fopenmp %s 2 3 void foo() { 4 } 5 6 bool foobool(int argc) { 7 return argc; 8 } 9 10 struct S1; // expected-note {{declared here}} expected-note {{forward declaration of 'S1'}} 11 extern S1 a; 12 class S2 { 13 mutable int a; 14 public: 15 S2():a(0) { } 16 static float S2s; // expected-note {{predetermined as shared}} 17 }; 18 const S2 b; 19 const S2 ba[5]; 20 class S3 { 21 int a; 22 public: 23 S3():a(0) { } 24 }; 25 const S3 c; // expected-note {{predetermined as shared}} 26 const S3 ca[5]; // expected-note {{predetermined as shared}} 27 extern const int f; // expected-note {{predetermined as shared}} 28 class S4 { 29 int a; 30 S4(); // expected-note {{implicitly declared private here}} 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 public: 38 S5(int v):a(v) { } 39 }; 40 41 S3 h; 42 #pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}} 43 44 45 int main(int argc, char **argv) { 46 const int d = 5; // expected-note {{predetermined as shared}} 47 const int da[5] = { 0 }; // expected-note {{predetermined as shared}} 48 S4 e(4); 49 S5 g(5); 50 int i; 51 int &j = i; 52 53 #pragma omp target 54 #pragma omp teams distribute parallel for private // expected-error {{expected '(' after 'private'}} 55 for (int k = 0; k < argc; ++k) ++k; 56 57 #pragma omp target 58 #pragma omp teams distribute parallel for private ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 59 for (int k = 0; k < argc; ++k) ++k; 60 61 #pragma omp target 62 #pragma omp teams distribute parallel for private () // expected-error {{expected expression}} 63 for (int k = 0; k < argc; ++k) ++k; 64 65 #pragma omp target 66 #pragma omp teams distribute parallel for private (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} 67 for (int k = 0; k < argc; ++k) ++k; 68 69 #pragma omp target 70 #pragma omp teams distribute parallel for private (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 71 for (int k = 0; k < argc; ++k) ++k; 72 73 #pragma omp target 74 #pragma omp teams distribute parallel for private (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} 75 for (int k = 0; k < argc; ++k) ++k; 76 77 #pragma omp target 78 #pragma omp teams distribute parallel for private (argc) 79 for (int k = 0; k < argc; ++k) ++k; 80 81 #pragma omp target 82 #pragma omp teams distribute parallel for private (S1) // expected-error {{'S1' does not refer to a value}} 83 for (int k = 0; k < argc; ++k) ++k; 84 85 #pragma omp target 86 #pragma omp teams distribute parallel for private (a, b, c, d, f) // expected-error {{private variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be private}} 87 for (int k = 0; k < argc; ++k) ++k; 88 89 #pragma omp target 90 #pragma omp teams distribute parallel for private (argv[1]) // expected-error {{expected variable name}} 91 for (int k = 0; k < argc; ++k) ++k; 92 93 #pragma omp target 94 #pragma omp teams distribute parallel for private(ba) 95 for (int k = 0; k < argc; ++k) ++k; 96 97 #pragma omp target 98 #pragma omp teams distribute parallel for private(ca) // expected-error {{shared variable cannot be private}} 99 for (int k = 0; k < argc; ++k) ++k; 100 101 #pragma omp target 102 #pragma omp teams distribute parallel for private(da) // expected-error {{shared variable cannot be private}} 103 for (int k = 0; k < argc; ++k) ++k; 104 105 #pragma omp target 106 #pragma omp teams distribute parallel for private(S2::S2s) // expected-error {{shared variable cannot be private}} 107 for (int k = 0; k < argc; ++k) ++k; 108 109 #pragma omp target 110 #pragma omp teams distribute parallel for private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} 111 for (int k = 0; k < argc; ++k) ++k; 112 113 #pragma omp target 114 #pragma omp teams distribute parallel for private(h) // expected-error {{threadprivate or thread local variable cannot be private}} 115 for (int k = 0; k < argc; ++k) ++k; 116 117 #pragma omp target 118 #pragma omp teams distribute parallel for shared(i) 119 for (int k = 0; k < argc; ++k) ++k; 120 121 #pragma omp target 122 #pragma omp teams distribute parallel for firstprivate(i), private(i) // expected-error {{firstprivate variable cannot be private}} expected-note {{defined as firstprivate}} 123 for (int k = 0; k < argc; ++k) ++k; 124 125 #pragma omp target 126 #pragma omp teams distribute parallel for private(j) 127 for (int k = 0; k < argc; ++k) ++k; 128 129 #pragma omp target 130 #pragma omp teams distribute parallel for reduction(+:i) 131 for (int k = 0; k < argc; ++k) ++k; 132 133 #pragma omp distribute private(i) 134 for (int k = 0; k < 10; ++k) { 135 #pragma omp target 136 #pragma omp teams distribute parallel for private(i) 137 for (int x = 0; x < 10; ++x) foo(); 138 } 139 140 #pragma omp target 141 #pragma omp teams distribute parallel for firstprivate(i) 142 for (int k = 0; k < 10; ++k) { 143 } 144 145 return 0; 146 } 147