Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 %s |
| 2 | |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 3 | #pragma omp threadprivate // expected-error {{expected '(' after 'threadprivate'}} expected-error {{expected identifier}} |
| 4 | #pragma omp threadprivate( // expected-error {{expected identifier}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 5 | #pragma omp threadprivate() // expected-error {{expected identifier}} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 6 | #pragma omp threadprivate(1) // expected-error {{expected unqualified-id}} |
| 7 | struct CompleteSt{ |
| 8 | int a; |
| 9 | }; |
| 10 | |
| 11 | struct CompleteSt1{ |
| 12 | #pragma omp threadprivate(1) // expected-error {{expected unqualified-id}} |
| 13 | int a; |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 14 | } d; // expected-note {{'d' defined here}} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 15 | |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 16 | int a; // expected-note {{'a' defined here}} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 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'}} |
| 21 | int foo() { // expected-note {{declared here}} |
| 22 | static int l; |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 23 | #pragma omp threadprivate(l)) // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 24 | return (a); |
| 25 | } |
| 26 | |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 27 | #pragma omp threadprivate a // expected-error {{expected '(' after 'threadprivate'}} expected-error {{'#pragma omp threadprivate' must precede all references to variable 'a'}} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 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'}} |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 29 | #pragma omp threadprivate(d)) // expected-error {{'#pragma omp threadprivate' must precede all references to variable 'd'}} expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 30 | int x, y; |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 31 | #pragma omp threadprivate(x)) // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} |
| 32 | #pragma omp threadprivate(y)), // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 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'}} |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 34 | #pragma omp threadprivate(d.a) // expected-error {{expected identifier}} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 35 | #pragma omp threadprivate((float)a) // expected-error {{expected unqualified-id}} |
| 36 | int 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 | |
| 41 | struct IncompleteSt; // expected-note {{forward declaration of 'IncompleteSt'}} |
| 42 | |
| 43 | extern IncompleteSt e; |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 44 | #pragma omp threadprivate (e) // expected-error {{threadprivate variable with incomplete type 'IncompleteSt'}} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 45 | |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 46 | int &f = a; // expected-note {{'f' defined here}} |
| 47 | #pragma omp threadprivate (f) // expected-error {{arguments of '#pragma omp threadprivate' cannot be of reference type}} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 48 | |
| 49 | class Class { |
| 50 | private: |
| 51 | int a; // expected-note {{declared here}} |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 52 | static int b; // expected-note {{'b' declared here}} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 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'}} |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 59 | #pragma omp threadprivate (Class::b) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'Class::b' variable declaration}} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 60 | #pragma omp threadprivate (g) |
| 61 | |
| 62 | namespace ns { |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 63 | int m; // expected-note 2 {{'m' defined here}} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 64 | #pragma omp threadprivate (m) |
| 65 | } |
| 66 | #pragma omp threadprivate (m) // expected-error {{use of undeclared identifier 'm'}} |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 67 | #pragma omp threadprivate (ns::m) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'ns::m' variable declaration}} |
| 68 | #pragma omp threadprivate (ns:m) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'?}} expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'ns::m' variable declaration}} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 69 | |
| 70 | const int h = 12; |
| 71 | const volatile int i = 10; |
| 72 | #pragma omp threadprivate (h, i) |
| 73 | |
| 74 | |
| 75 | template <class T> |
| 76 | class 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 | |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 87 | static __thread int t; // expected-note {{'t' defined here}} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 88 | #pragma omp threadprivate (t) // expected-error {{variable 't' cannot be threadprivate because it is thread-local}} |
| 89 | |
| 90 | int o; // expected-note {{candidate found by name lookup is 'o'}} |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 91 | #pragma omp threadprivate (o) |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 92 | namespace { |
| 93 | int o; // expected-note {{candidate found by name lookup is '<anonymous namespace>::o'}} |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 94 | #pragma omp threadprivate (o) |
| 95 | #pragma omp threadprivate (o) // expected-error {{'#pragma omp threadprivate' must precede all references to variable '<anonymous namespace>::o'}} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 96 | } |
| 97 | #pragma omp threadprivate (o) // expected-error {{reference to 'o' is ambiguous}} |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 98 | #pragma omp threadprivate (::o) // expected-error {{'#pragma omp threadprivate' must precede all references to variable 'o'}} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 99 | |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 100 | int main(int argc, char **argv) { // expected-note {{'argc' defined here}} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 101 | |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 102 | int x, y = argc; // expected-note {{'y' defined here}} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 103 | static double d1; |
| 104 | static double d2; |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 105 | static double d3; // expected-note {{'d3' defined here}} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 106 | |
| 107 | d.a = a; |
| 108 | d2++; |
| 109 | ; |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 110 | #pragma omp threadprivate(argc+y) // expected-error {{expected identifier}} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 111 | #pragma omp threadprivate(argc,y) // expected-error 2 {{arguments of '#pragma omp threadprivate' must have static storage duration}} |
| 112 | #pragma omp threadprivate(d2) // expected-error {{'#pragma omp threadprivate' must precede all references to variable 'd2'}} |
| 113 | #pragma omp threadprivate(d1) |
| 114 | { |
| 115 | ++a;d2=0; |
| 116 | #pragma omp threadprivate(d3) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'd3' variable declaration}} |
| 117 | } |
| 118 | #pragma omp threadprivate(d3) |
| 119 | |
| 120 | #pragma omp threadprivate(a) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'a' variable declaration}} |
| 121 | return (y); |
| 122 | #pragma omp threadprivate(d) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'd' variable declaration}} |
| 123 | } |