1 // RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s 2 foo()3void foo() { 4 } 5 foobool(int argc)6bool 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 15 public: S2()16 S2() : a(0) {} S2(const S2 & s2)17 S2(const S2 &s2) : a(s2.a) {} 18 static float S2s; 19 static const float S2sc; 20 }; 21 const float S2::S2sc = 0; 22 const S2 b; 23 const S2 ba[5]; 24 class S3 { 25 int a; 26 27 public: S3()28 S3() : a(0) {} S3(const S3 & s3)29 S3(const S3 &s3) : a(s3.a) {} 30 }; 31 const S3 c; 32 const S3 ca[5]; 33 extern const int f; 34 class S4 { 35 int a; 36 S4(); 37 S4(const S4 &s4); // expected-note {{implicitly declared private here}} 38 public: S4(int v)39 S4(int v) : a(v) {} 40 }; 41 class S5 { 42 int a; S5()43 S5() : a(0) {} S5(const S5 & s5)44 S5(const S5 &s5) : a(s5.a) {} // expected-note {{implicitly declared private here}} 45 public: S5(int v)46 S5(int v) : a(v) {} 47 }; 48 49 S3 h; 50 #pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}} 51 main(int argc,char ** argv)52int main(int argc, char **argv) { 53 const int d = 5; 54 const int da[5] = {0}; 55 S4 e(4); 56 S5 g(5); 57 int i; 58 int &j = i; // expected-note {{'j' defined here}} 59 #pragma omp target 60 #pragma omp teams firstprivate // expected-error {{expected '(' after 'firstprivate'}} 61 foo(); 62 #pragma omp target 63 #pragma omp teams firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 64 foo(); 65 #pragma omp target 66 #pragma omp teams firstprivate() // expected-error {{expected expression}} 67 foo(); 68 #pragma omp target 69 #pragma omp teams firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} 70 foo(); 71 #pragma omp target 72 #pragma omp teams firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 73 foo(); 74 #pragma omp target 75 #pragma omp teams firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} 76 foo(); 77 #pragma omp target 78 #pragma omp teams firstprivate(argc) 79 foo(); 80 #pragma omp target 81 #pragma omp teams firstprivate(S1) // expected-error {{'S1' does not refer to a value}} 82 foo(); 83 #pragma omp target 84 #pragma omp teams firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} 85 foo(); 86 #pragma omp target 87 #pragma omp teams firstprivate(argv[1]) // expected-error {{expected variable name}} 88 foo(); 89 #pragma omp target 90 #pragma omp teams firstprivate(ba) 91 foo(); 92 #pragma omp target 93 #pragma omp teams firstprivate(ca) 94 foo(); 95 #pragma omp target 96 #pragma omp teams firstprivate(da) 97 foo(); 98 #pragma omp target 99 #pragma omp teams firstprivate(S2::S2s) 100 foo(); 101 #pragma omp target 102 #pragma omp teams firstprivate(S2::S2sc) 103 foo(); 104 #pragma omp target 105 #pragma omp teams firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} 106 foo(); 107 #pragma omp target 108 #pragma omp teams firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}} 109 foo(); 110 #pragma omp target 111 #pragma omp teams private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note{{defined as private}} 112 foo(); 113 #pragma omp target 114 #pragma omp teams shared(i) 115 foo(); 116 #pragma omp target 117 #pragma omp teams firstprivate(i) 118 foo(); 119 #pragma omp target 120 #pragma omp teams firstprivate(j) // expected-error {{arguments of OpenMP clause 'firstprivate' cannot be of reference type}} 121 foo(); 122 123 return 0; 124 } 125