Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp=libiomp5 -ferror-limit 100 -emit-llvm -o - %s |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 2 | |
Alexey Bataev | 4fa7eab | 2013-07-19 03:13:43 +0000 | [diff] [blame] | 3 | #pragma omp threadprivate // expected-error {{expected '(' after 'threadprivate'}} |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 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'}} |
Pirama Arumuga Nainar | 33337ca | 2015-05-06 11:48:57 -0700 | [diff] [blame] | 20 | #pragma omp threadprivate(d, a) |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 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 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 27 | #pragma omp threadprivate (a) ( |
Pirama Arumuga Nainar | 33337ca | 2015-05-06 11:48:57 -0700 | [diff] [blame] | 28 | // expected-warning@-1 {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} |
| 29 | #pragma omp threadprivate (a) [ // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} |
| 30 | #pragma omp threadprivate (a) { // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} |
| 31 | #pragma omp threadprivate (a) ) // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} |
| 32 | #pragma omp threadprivate (a) ] // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} |
| 33 | #pragma omp threadprivate (a) } // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} |
Alexey Bataev | 4fa7eab | 2013-07-19 03:13:43 +0000 | [diff] [blame] | 34 | #pragma omp threadprivate a // expected-error {{expected '(' after 'threadprivate'}} |
Pirama Arumuga Nainar | 33337ca | 2015-05-06 11:48:57 -0700 | [diff] [blame] | 35 | #pragma omp threadprivate(d // expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 36 | #pragma omp threadprivate(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] | 37 | int x, y; |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 38 | #pragma omp threadprivate(x)) // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 39 | #pragma omp threadprivate(y)), |
| 40 | // expected-warning@-1 {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} |
| 41 | #pragma omp threadprivate(a,d) |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 42 | #pragma omp threadprivate(d.a) // expected-error {{expected identifier}} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 43 | #pragma omp threadprivate((float)a) // expected-error {{expected unqualified-id}} |
Richard Smith | 2d67097 | 2013-08-17 00:46:16 +0000 | [diff] [blame] | 44 | int foa; // expected-note {{'foa' declared here}} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 45 | #pragma omp threadprivate(faa) // expected-error {{use of undeclared identifier 'faa'; did you mean 'foa'?}} |
| 46 | #pragma omp threadprivate(foo) // expected-error {{'foo' is not a global variable, static local variable or static data member}} |
| 47 | #pragma omp threadprivate (int a=2) // expected-error {{expected unqualified-id}} |
| 48 | |
| 49 | struct IncompleteSt; // expected-note {{forward declaration of 'IncompleteSt'}} |
| 50 | |
| 51 | extern IncompleteSt e; |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 52 | #pragma omp threadprivate (e) // expected-error {{threadprivate variable with incomplete type 'IncompleteSt'}} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 53 | |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 54 | int &f = a; // expected-note {{'f' defined here}} |
Alexey Bataev | 4fa7eab | 2013-07-19 03:13:43 +0000 | [diff] [blame] | 55 | #pragma omp threadprivate (f) // expected-error {{arguments of '#pragma omp threadprivate' cannot be of reference type 'int &'}} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 56 | |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 57 | class TestClass { |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 58 | private: |
| 59 | int a; // expected-note {{declared here}} |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 60 | static int b; // expected-note {{'b' declared here}} |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 61 | TestClass() : a(0){} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 62 | public: |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 63 | TestClass (int aaa) : a(aaa) {} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 64 | #pragma omp threadprivate (b, a) // expected-error {{'a' is not a global variable, static local variable or static data member}} |
| 65 | } g(10); |
| 66 | #pragma omp threadprivate (b) // expected-error {{use of undeclared identifier 'b'}} |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 67 | #pragma omp threadprivate (TestClass::b) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'TestClass::b' variable declaration}} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 68 | #pragma omp threadprivate (g) |
| 69 | |
| 70 | namespace ns { |
Alexey Bataev | d0dbb7e | 2013-09-26 03:24:06 +0000 | [diff] [blame] | 71 | int m; |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 72 | #pragma omp threadprivate (m) |
| 73 | } |
| 74 | #pragma omp threadprivate (m) // expected-error {{use of undeclared identifier 'm'}} |
Pirama Arumuga Nainar | 33337ca | 2015-05-06 11:48:57 -0700 | [diff] [blame] | 75 | #pragma omp threadprivate (ns::m) |
| 76 | #pragma omp threadprivate (ns:m) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'?}} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 77 | |
| 78 | const int h = 12; |
| 79 | const volatile int i = 10; |
| 80 | #pragma omp threadprivate (h, i) |
| 81 | |
| 82 | |
| 83 | template <class T> |
| 84 | class TempClass { |
| 85 | private: |
| 86 | T a; |
| 87 | TempClass() : a(){} |
| 88 | public: |
| 89 | TempClass (T aaa) : a(aaa) {} |
| 90 | static T s; |
| 91 | #pragma omp threadprivate (s) |
| 92 | }; |
| 93 | #pragma omp threadprivate (s) // expected-error {{use of undeclared identifier 's'}} |
| 94 | |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 95 | static __thread int t; // expected-note {{'t' defined here}} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 96 | #pragma omp threadprivate (t) // expected-error {{variable 't' cannot be threadprivate because it is thread-local}} |
| 97 | |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 98 | register int reg0 __asm__("0"); // expected-note {{'reg0' defined here}} |
| 99 | #pragma omp threadprivate (reg0) // expected-error {{variable 'reg0' cannot be threadprivate because it is a global named register variable}} |
| 100 | |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 101 | int o; // expected-note {{candidate found by name lookup is 'o'}} |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 102 | #pragma omp threadprivate (o) |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 103 | namespace { |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 104 | 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] | 105 | #pragma omp threadprivate (o) |
Pirama Arumuga Nainar | 33337ca | 2015-05-06 11:48:57 -0700 | [diff] [blame] | 106 | #pragma omp threadprivate (o) |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 107 | } |
| 108 | #pragma omp threadprivate (o) // expected-error {{reference to 'o' is ambiguous}} |
Pirama Arumuga Nainar | 33337ca | 2015-05-06 11:48:57 -0700 | [diff] [blame] | 109 | #pragma omp threadprivate (::o) |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 110 | |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 111 | int main(int argc, char **argv) { // expected-note {{'argc' defined here}} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 112 | |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 113 | int x, y = argc; // expected-note 2 {{'y' defined here}} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 114 | static double d1; |
| 115 | static double d2; |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 116 | static double d3; // expected-note {{'d3' defined here}} |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 117 | static TestClass LocalClass(y); // expected-error {{variable with local storage in initial value of threadprivate variable}} |
| 118 | #pragma omp threadprivate(LocalClass) |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 119 | |
| 120 | d.a = a; |
| 121 | d2++; |
| 122 | ; |
Alexey Bataev | 6af701f | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 123 | #pragma omp threadprivate(argc+y) // expected-error {{expected identifier}} |
Alexey Bataev | c640058 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 124 | #pragma omp threadprivate(argc,y) // expected-error 2 {{arguments of '#pragma omp threadprivate' must have static storage duration}} |
| 125 | #pragma omp threadprivate(d2) // expected-error {{'#pragma omp threadprivate' must precede all references to variable 'd2'}} |
| 126 | #pragma omp threadprivate(d1) |
| 127 | { |
| 128 | ++a;d2=0; |
| 129 | #pragma omp threadprivate(d3) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'd3' variable declaration}} |
| 130 | } |
| 131 | #pragma omp threadprivate(d3) |
| 132 | |
| 133 | #pragma omp threadprivate(a) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'a' variable declaration}} |
| 134 | return (y); |
| 135 | #pragma omp threadprivate(d) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'd' variable declaration}} |
| 136 | } |