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 {{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 {{static data member is 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 {{global variable is predetermined as shared}} 26 const S3 ca[5]; // expected-note {{global variable is predetermined as shared}} 27 extern const int f; // expected-note {{global variable is 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 int threadvar; 42 #pragma omp threadprivate(threadvar) // expected-note {{defined as threadprivate or thread local}} 43 44 int main(int argc, char **argv) { 45 const int d = 5; // expected-note {{constant variable is predetermined as shared}} 46 const int da[5] = { 0 }; // expected-note {{constant variable is predetermined as shared}} 47 S4 e(4); 48 S5 g(5); 49 int i; 50 int &j = i; // expected-note {{'j' defined here}} 51 #pragma omp target 52 #pragma omp teams private // expected-error {{expected '(' after 'private'}} 53 foo(); 54 #pragma omp target 55 #pragma omp teams private ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 56 foo(); 57 #pragma omp target 58 #pragma omp teams private () // expected-error {{expected expression}} 59 foo(); 60 #pragma omp target 61 #pragma omp teams private (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} 62 foo(); 63 #pragma omp target 64 #pragma omp teams private (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 65 foo(); 66 #pragma omp target 67 #pragma omp teams private (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} 68 foo(); 69 #pragma omp target 70 #pragma omp teams private (argc argv) // expected-error {{expected ',' or ')' in 'private' clause}} 71 foo(); 72 #pragma omp target 73 #pragma omp teams private (S1) // expected-error {{'S1' does not refer to a value}} 74 foo(); 75 #pragma omp target 76 #pragma omp teams private (a, b, c, d, f) // expected-error {{a private variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be private}} 77 foo(); 78 #pragma omp target 79 #pragma omp teams private (argv[1]) // expected-error {{expected variable name}} 80 foo(); 81 #pragma omp target 82 #pragma omp teams private(ba) 83 foo(); 84 #pragma omp target 85 #pragma omp teams private(ca) // expected-error {{shared variable cannot be private}} 86 foo(); 87 #pragma omp target 88 #pragma omp teams private(da) // expected-error {{shared variable cannot be private}} 89 foo(); 90 #pragma omp target 91 #pragma omp teams private(S2::S2s) // expected-error {{shared variable cannot be private}} 92 foo(); 93 #pragma omp target 94 #pragma omp teams private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} 95 foo(); 96 #pragma omp target 97 #pragma omp teams private(threadvar) // expected-error {{threadprivate or thread local variable cannot be private}} 98 foo(); 99 #pragma omp target 100 #pragma omp teams shared(i), private(i) // expected-error {{shared variable cannot be private}} expected-note {{defined as shared}} 101 foo(); 102 #pragma omp target 103 #pragma omp teams firstprivate(i) private(i) // expected-error {{firstprivate variable cannot be private}} expected-note {{defined as firstprivate}} 104 foo(); 105 #pragma omp target 106 #pragma omp teams private(i) 107 foo(); 108 #pragma omp target 109 #pragma omp teams private(j) // expected-error {{arguments of OpenMP clause 'private' cannot be of reference type 'int &'}} 110 foo(); 111 #pragma omp target 112 #pragma omp teams firstprivate(i) 113 for (int k = 0; k < 10; ++k) { 114 #pragma omp parallel private(i) 115 foo(); 116 } 117 118 return 0; 119 } 120