Samuel Antao | f8b5012 | 2015-07-13 22:54:53 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -fnoopenmp-use-tls -ferror-limit 100 -emit-llvm -o - %s |
Alexey Bataev | db39021 | 2015-05-20 04:24:19 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -emit-llvm -o - %s |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 3 | |
Alexey Bataev | 5ec3eb1 | 2013-07-19 03:13:43 +0000 | [diff] [blame] | 4 | #pragma omp threadprivate // expected-error {{expected '(' after 'threadprivate'}} |
Alexey Bataev | 6f6f3b4 | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 5 | #pragma omp threadprivate( // expected-error {{expected identifier}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 6 | #pragma omp threadprivate() // expected-error {{expected identifier}} |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 7 | #pragma omp threadprivate(1) // expected-error {{expected unqualified-id}} |
| 8 | struct CompleteSt{ |
| 9 | int a; |
| 10 | }; |
| 11 | |
| 12 | struct CompleteSt1{ |
| 13 | #pragma omp threadprivate(1) // expected-error {{expected unqualified-id}} |
| 14 | int a; |
Alexey Bataev | 6f6f3b4 | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 15 | } d; // expected-note {{'d' defined here}} |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 16 | |
Alexey Bataev | 6f6f3b4 | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 17 | int a; // expected-note {{'a' defined here}} |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 18 | |
| 19 | #pragma omp threadprivate(a) |
| 20 | #pragma omp threadprivate(u) // expected-error {{use of undeclared identifier 'u'}} |
Alexey Bataev | 7c2ed44 | 2015-04-08 12:45:41 +0000 | [diff] [blame] | 21 | #pragma omp threadprivate(d, a) |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 22 | int foo() { // expected-note {{declared here}} |
| 23 | static int l; |
Alexey Bataev | 6f6f3b4 | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 24 | #pragma omp threadprivate(l)) // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 25 | return (a); |
| 26 | } |
| 27 | |
Alp Toker | 1d8362c | 2013-12-18 22:34:19 +0000 | [diff] [blame] | 28 | #pragma omp threadprivate (a) ( |
Alexey Bataev | 7c2ed44 | 2015-04-08 12:45:41 +0000 | [diff] [blame] | 29 | // expected-warning@-1 {{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}} |
| 34 | #pragma omp threadprivate (a) } // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} |
Alexey Bataev | 5ec3eb1 | 2013-07-19 03:13:43 +0000 | [diff] [blame] | 35 | #pragma omp threadprivate a // expected-error {{expected '(' after 'threadprivate'}} |
Alexey Bataev | 7c2ed44 | 2015-04-08 12:45:41 +0000 | [diff] [blame] | 36 | #pragma omp threadprivate(d // expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 37 | #pragma omp threadprivate(d)) // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 38 | int x, y; |
Alexey Bataev | 6f6f3b4 | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 39 | #pragma omp threadprivate(x)) // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} |
Alp Toker | 1d8362c | 2013-12-18 22:34:19 +0000 | [diff] [blame] | 40 | #pragma omp threadprivate(y)), |
| 41 | // expected-warning@-1 {{extra tokens at the end of '#pragma omp threadprivate' are ignored}} |
| 42 | #pragma omp threadprivate(a,d) |
Alexey Bataev | 6f6f3b4 | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 43 | #pragma omp threadprivate(d.a) // expected-error {{expected identifier}} |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 44 | #pragma omp threadprivate((float)a) // expected-error {{expected unqualified-id}} |
Richard Smith | f9b1510 | 2013-08-17 00:46:16 +0000 | [diff] [blame] | 45 | int foa; // expected-note {{'foa' declared here}} |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 46 | #pragma omp threadprivate(faa) // expected-error {{use of undeclared identifier 'faa'; did you mean 'foa'?}} |
| 47 | #pragma omp threadprivate(foo) // expected-error {{'foo' is not a global variable, static local variable or static data member}} |
| 48 | #pragma omp threadprivate (int a=2) // expected-error {{expected unqualified-id}} |
| 49 | |
| 50 | struct IncompleteSt; // expected-note {{forward declaration of 'IncompleteSt'}} |
| 51 | |
| 52 | extern IncompleteSt e; |
Alexey Bataev | 6f6f3b4 | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 53 | #pragma omp threadprivate (e) // expected-error {{threadprivate variable with incomplete type 'IncompleteSt'}} |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 54 | |
Alexey Bataev | 6f6f3b4 | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 55 | int &f = a; // expected-note {{'f' defined here}} |
Alexey Bataev | 5ec3eb1 | 2013-07-19 03:13:43 +0000 | [diff] [blame] | 56 | #pragma omp threadprivate (f) // expected-error {{arguments of '#pragma omp threadprivate' cannot be of reference type 'int &'}} |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 57 | |
Alexey Bataev | 15e4ee7 | 2014-06-06 03:41:14 +0000 | [diff] [blame] | 58 | class TestClass { |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 59 | private: |
| 60 | int a; // expected-note {{declared here}} |
Alexey Bataev | 6f6f3b4 | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 61 | static int b; // expected-note {{'b' declared here}} |
Alexey Bataev | 15e4ee7 | 2014-06-06 03:41:14 +0000 | [diff] [blame] | 62 | TestClass() : a(0){} |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 63 | public: |
Alexey Bataev | 15e4ee7 | 2014-06-06 03:41:14 +0000 | [diff] [blame] | 64 | TestClass (int aaa) : a(aaa) {} |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 65 | #pragma omp threadprivate (b, a) // expected-error {{'a' is not a global variable, static local variable or static data member}} |
| 66 | } g(10); |
| 67 | #pragma omp threadprivate (b) // expected-error {{use of undeclared identifier 'b'}} |
Alexey Bataev | 15e4ee7 | 2014-06-06 03:41:14 +0000 | [diff] [blame] | 68 | #pragma omp threadprivate (TestClass::b) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'TestClass::b' variable declaration}} |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 69 | #pragma omp threadprivate (g) |
| 70 | |
| 71 | namespace ns { |
Alexey Bataev | 7d2960b | 2013-09-26 03:24:06 +0000 | [diff] [blame] | 72 | int m; |
Alexey Bataev | 376b4a4 | 2016-02-09 09:41:09 +0000 | [diff] [blame] | 73 | #pragma omp threadprivate (m, m) |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 74 | } |
| 75 | #pragma omp threadprivate (m) // expected-error {{use of undeclared identifier 'm'}} |
Alexey Bataev | 7c2ed44 | 2015-04-08 12:45:41 +0000 | [diff] [blame] | 76 | #pragma omp threadprivate (ns::m) |
| 77 | #pragma omp threadprivate (ns:m) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'?}} |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 78 | |
| 79 | const int h = 12; |
| 80 | const volatile int i = 10; |
| 81 | #pragma omp threadprivate (h, i) |
| 82 | |
| 83 | |
| 84 | template <class T> |
| 85 | class TempClass { |
| 86 | private: |
| 87 | T a; |
| 88 | TempClass() : a(){} |
| 89 | public: |
| 90 | TempClass (T aaa) : a(aaa) {} |
| 91 | static T s; |
| 92 | #pragma omp threadprivate (s) |
| 93 | }; |
| 94 | #pragma omp threadprivate (s) // expected-error {{use of undeclared identifier 's'}} |
| 95 | |
Alexey Bataev | 6f6f3b4 | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 96 | static __thread int t; // expected-note {{'t' defined here}} |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 97 | #pragma omp threadprivate (t) // expected-error {{variable 't' cannot be threadprivate because it is thread-local}} |
| 98 | |
Akira Hatanaka | 8c26ea6 | 2015-11-18 00:15:28 +0000 | [diff] [blame] | 99 | // Register "0" is currently an invalid register for global register variables. |
| 100 | // Use "esp" instead of "0". |
| 101 | // register int reg0 __asm__("0"); |
| 102 | register int reg0 __asm__("esp"); // expected-note {{'reg0' defined here}} |
Alexey Bataev | 26a3924 | 2015-01-13 03:35:30 +0000 | [diff] [blame] | 103 | #pragma omp threadprivate (reg0) // expected-error {{variable 'reg0' cannot be threadprivate because it is a global named register variable}} |
| 104 | |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 105 | int o; // expected-note {{candidate found by name lookup is 'o'}} |
Alexey Bataev | 6f6f3b4 | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 106 | #pragma omp threadprivate (o) |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 107 | namespace { |
David Blaikie | abe1a39 | 2014-04-02 05:58:29 +0000 | [diff] [blame] | 108 | int o; // expected-note {{candidate found by name lookup is '(anonymous namespace)::o'}} |
Alexey Bataev | 6f6f3b4 | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 109 | #pragma omp threadprivate (o) |
Alexey Bataev | 7c2ed44 | 2015-04-08 12:45:41 +0000 | [diff] [blame] | 110 | #pragma omp threadprivate (o) |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 111 | } |
| 112 | #pragma omp threadprivate (o) // expected-error {{reference to 'o' is ambiguous}} |
Alexey Bataev | 7c2ed44 | 2015-04-08 12:45:41 +0000 | [diff] [blame] | 113 | #pragma omp threadprivate (::o) |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 114 | |
Alexey Bataev | 6f6f3b4 | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 115 | int main(int argc, char **argv) { // expected-note {{'argc' defined here}} |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 116 | |
Alexey Bataev | 18b92ee | 2014-05-28 07:40:25 +0000 | [diff] [blame] | 117 | int x, y = argc; // expected-note 2 {{'y' defined here}} |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 118 | static double d1; |
| 119 | static double d2; |
Alexey Bataev | 6f6f3b4 | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 120 | static double d3; // expected-note {{'d3' defined here}} |
Alexey Bataev | c4fad65 | 2016-01-13 11:18:54 +0000 | [diff] [blame] | 121 | static double d4; |
Alexey Bataev | 15e4ee7 | 2014-06-06 03:41:14 +0000 | [diff] [blame] | 122 | static TestClass LocalClass(y); // expected-error {{variable with local storage in initial value of threadprivate variable}} |
Alexey Bataev | 18b92ee | 2014-05-28 07:40:25 +0000 | [diff] [blame] | 123 | #pragma omp threadprivate(LocalClass) |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 124 | |
| 125 | d.a = a; |
| 126 | d2++; |
| 127 | ; |
Alexey Bataev | 6f6f3b4 | 2013-05-13 04:18:18 +0000 | [diff] [blame] | 128 | #pragma omp threadprivate(argc+y) // expected-error {{expected identifier}} |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 129 | #pragma omp threadprivate(argc,y) // expected-error 2 {{arguments of '#pragma omp threadprivate' must have static storage duration}} |
| 130 | #pragma omp threadprivate(d2) // expected-error {{'#pragma omp threadprivate' must precede all references to variable 'd2'}} |
| 131 | #pragma omp threadprivate(d1) |
| 132 | { |
| 133 | ++a;d2=0; |
| 134 | #pragma omp threadprivate(d3) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'd3' variable declaration}} |
| 135 | } |
| 136 | #pragma omp threadprivate(d3) |
Alexey Bataev | c4fad65 | 2016-01-13 11:18:54 +0000 | [diff] [blame] | 137 | label: |
| 138 | #pragma omp threadprivate(d4) // expected-error {{'#pragma omp threadprivate' cannot be an immediate substatement}} |
Alexey Bataev | a769e07 | 2013-03-22 06:34:35 +0000 | [diff] [blame] | 139 | |
| 140 | #pragma omp threadprivate(a) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'a' variable declaration}} |
| 141 | return (y); |
| 142 | #pragma omp threadprivate(d) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'd' variable declaration}} |
| 143 | } |