threadprivate_messages.cpp revision c640058aa7f224a71ce3b1d2601d84e1b57f82d3
1// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 %s 2 3#pragma omp threadprivate // expected-error {{expected '(' after 'threadprivate'}} 4#pragma omp threadprivate( // expected-error {{expected unqualified-id}} 5#pragma omp threadprivate() // expected-error {{expected unqualified-id}} 6#pragma omp threadprivate(1) // expected-error {{expected unqualified-id}} 7struct CompleteSt{ 8 int a; 9}; 10 11struct CompleteSt1{ 12#pragma omp threadprivate(1) // expected-error {{expected unqualified-id}} 13 int a; 14} d; // expected-note {{forward declaration of 'd'}} 15 16int a; // expected-note {{forward declaration of 'a'}} 17 18#pragma omp threadprivate(a) 19#pragma omp threadprivate(u) // expected-error {{use of undeclared identifier 'u'}} 20#pragma omp threadprivate(d, a) // expected-error {{'#pragma omp threadprivate' must precede all references to variable 'a'}} 21int foo() { // expected-note {{declared here}} 22 static int l; 23#pragma omp threadprivate(l)) // expected-warning {{extra tokens at end of '#pragma omp threadprivate' are ignored}} 24 return (a); 25} 26 27#pragma omp threadprivate a // expected-error {{expected '(' after 'threadprivate'}} 28#pragma omp threadprivate(d // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{'#pragma omp threadprivate' must precede all references to variable 'd'}} 29#pragma omp threadprivate(d)) 30int x, y; 31#pragma omp threadprivate(x)) // expected-warning {{extra tokens at end of '#pragma omp threadprivate' are ignored}} 32#pragma omp threadprivate(y)), // expected-warning {{extra tokens at end of '#pragma omp threadprivate' are ignored}} 33#pragma omp threadprivate(a,d) // expected-error {{'#pragma omp threadprivate' must precede all references to variable 'a'}} expected-error {{'#pragma omp threadprivate' must precede all references to variable 'd'}} 34#pragma omp threadprivate(d.a) // expected-error {{expected unqualified-id}} 35#pragma omp threadprivate((float)a) // expected-error {{expected unqualified-id}} 36int foa; 37#pragma omp threadprivate(faa) // expected-error {{use of undeclared identifier 'faa'; did you mean 'foa'?}} 38#pragma omp threadprivate(foo) // expected-error {{'foo' is not a global variable, static local variable or static data member}} 39#pragma omp threadprivate (int a=2) // expected-error {{expected unqualified-id}} 40 41struct IncompleteSt; // expected-note {{forward declaration of 'IncompleteSt'}} 42 43extern IncompleteSt e; 44#pragma omp threadprivate (e) // expected-error {{a threadprivate variable must not have incomplete type 'IncompleteSt'}} 45 46int &f = a; // expected-note {{forward declaration of 'f'}} 47#pragma omp threadprivate (f) // expected-error {{arguments of '#pragma omp threadprivate' cannot be of reference type 'int &'}} 48 49class Class { 50 private: 51 int a; // expected-note {{declared here}} 52 static int b; 53 Class() : a(0){} 54 public: 55 Class (int aaa) : a(aaa) {} 56#pragma omp threadprivate (b, a) // expected-error {{'a' is not a global variable, static local variable or static data member}} 57} g(10); 58#pragma omp threadprivate (b) // expected-error {{use of undeclared identifier 'b'}} 59#pragma omp threadprivate (Class::b) // expected-error {{expected unqualified-id}} 60#pragma omp threadprivate (g) 61 62namespace ns { 63 int m; 64#pragma omp threadprivate (m) 65} 66#pragma omp threadprivate (m) // expected-error {{use of undeclared identifier 'm'}} 67#pragma omp threadprivate (ns::m) // expected-error {{expected unqualified-id}} 68#pragma omp threadprivate (ns:m) // expected-error {{expected unqualified-id}} 69 70const int h = 12; 71const volatile int i = 10; 72#pragma omp threadprivate (h, i) 73 74 75template <class T> 76class TempClass { 77 private: 78 T a; 79 TempClass() : a(){} 80 public: 81 TempClass (T aaa) : a(aaa) {} 82 static T s; 83#pragma omp threadprivate (s) 84}; 85#pragma omp threadprivate (s) // expected-error {{use of undeclared identifier 's'}} 86 87static __thread int t; // expected-note {{forward declaration of 't'}} 88#pragma omp threadprivate (t) // expected-error {{variable 't' cannot be threadprivate because it is thread-local}} 89 90int o; // expected-note {{candidate found by name lookup is 'o'}} 91namespace { 92int o; // expected-note {{candidate found by name lookup is '<anonymous namespace>::o'}} 93} 94#pragma omp threadprivate (o) // expected-error {{reference to 'o' is ambiguous}} 95 96int main(int argc, char **argv) { // expected-note {{forward declaration of 'argc'}} 97 98 int x, y = argc; // expected-note {{forward declaration of 'y'}} 99 static double d1; 100 static double d2; 101 static double d3; // expected-note {{forward declaration of 'd3'}} 102 103 d.a = a; 104 d2++; 105 ; 106#pragma omp threadprivate(argc+y) // expected-error {{expected unqualified-id}} 107#pragma omp threadprivate(argc,y) // expected-error 2 {{arguments of '#pragma omp threadprivate' must have static storage duration}} 108#pragma omp threadprivate(d2) // expected-error {{'#pragma omp threadprivate' must precede all references to variable 'd2'}} 109#pragma omp threadprivate(d1) 110 { 111 ++a;d2=0; 112#pragma omp threadprivate(d3) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'd3' variable declaration}} 113 } 114#pragma omp threadprivate(d3) 115 116#pragma omp threadprivate(a) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'a' variable declaration}} 117 return (y); 118#pragma omp threadprivate(d) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'd' variable declaration}} 119} 120