blob: 9775bfa458f49101f9e79a262210287327aa49da [file] [log] [blame]
Samuel Antaof8b50122015-07-13 22:54:53 +00001// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -fnoopenmp-use-tls -ferror-limit 100 -emit-llvm -o - %s
Alexey Bataevdb390212015-05-20 04:24:19 +00002// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -emit-llvm -o - %s
Alexey Bataeva769e072013-03-22 06:34:35 +00003
Alexey Bataev5ec3eb12013-07-19 03:13:43 +00004#pragma omp threadprivate // expected-error {{expected '(' after 'threadprivate'}}
Alexey Bataev6f6f3b42013-05-13 04:18:18 +00005#pragma omp threadprivate( // expected-error {{expected identifier}} expected-error {{expected ')'}} expected-note {{to match this '('}}
6#pragma omp threadprivate() // expected-error {{expected identifier}}
Alexey Bataeva769e072013-03-22 06:34:35 +00007#pragma omp threadprivate(1) // expected-error {{expected unqualified-id}}
8struct CompleteSt{
9 int a;
10};
11
12struct CompleteSt1{
13#pragma omp threadprivate(1) // expected-error {{expected unqualified-id}}
14 int a;
Alexey Bataev6f6f3b42013-05-13 04:18:18 +000015} d; // expected-note {{'d' defined here}}
Alexey Bataeva769e072013-03-22 06:34:35 +000016
Alexey Bataev6f6f3b42013-05-13 04:18:18 +000017int a; // expected-note {{'a' defined here}}
Alexey Bataeva769e072013-03-22 06:34:35 +000018
19#pragma omp threadprivate(a)
20#pragma omp threadprivate(u) // expected-error {{use of undeclared identifier 'u'}}
Alexey Bataev7c2ed442015-04-08 12:45:41 +000021#pragma omp threadprivate(d, a)
Alexey Bataeva769e072013-03-22 06:34:35 +000022int foo() { // expected-note {{declared here}}
23 static int l;
Alexey Bataev6f6f3b42013-05-13 04:18:18 +000024#pragma omp threadprivate(l)) // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}}
Alexey Bataeva769e072013-03-22 06:34:35 +000025 return (a);
26}
27
Alp Toker1d8362c2013-12-18 22:34:19 +000028#pragma omp threadprivate (a) (
Alexey Bataev7c2ed442015-04-08 12:45:41 +000029// 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 Bataev5ec3eb12013-07-19 03:13:43 +000035#pragma omp threadprivate a // expected-error {{expected '(' after 'threadprivate'}}
Alexey Bataev7c2ed442015-04-08 12:45:41 +000036#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 Bataeva769e072013-03-22 06:34:35 +000038int x, y;
Alexey Bataev6f6f3b42013-05-13 04:18:18 +000039#pragma omp threadprivate(x)) // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}}
Alp Toker1d8362c2013-12-18 22:34:19 +000040#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 Bataev6f6f3b42013-05-13 04:18:18 +000043#pragma omp threadprivate(d.a) // expected-error {{expected identifier}}
Alexey Bataeva769e072013-03-22 06:34:35 +000044#pragma omp threadprivate((float)a) // expected-error {{expected unqualified-id}}
Richard Smithf9b15102013-08-17 00:46:16 +000045int foa; // expected-note {{'foa' declared here}}
Alexey Bataeva769e072013-03-22 06:34:35 +000046#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
50struct IncompleteSt; // expected-note {{forward declaration of 'IncompleteSt'}}
51
52extern IncompleteSt e;
Alexey Bataev6f6f3b42013-05-13 04:18:18 +000053#pragma omp threadprivate (e) // expected-error {{threadprivate variable with incomplete type 'IncompleteSt'}}
Alexey Bataeva769e072013-03-22 06:34:35 +000054
Alexey Bataev6f6f3b42013-05-13 04:18:18 +000055int &f = a; // expected-note {{'f' defined here}}
Alexey Bataev5ec3eb12013-07-19 03:13:43 +000056#pragma omp threadprivate (f) // expected-error {{arguments of '#pragma omp threadprivate' cannot be of reference type 'int &'}}
Alexey Bataeva769e072013-03-22 06:34:35 +000057
Alexey Bataev15e4ee72014-06-06 03:41:14 +000058class TestClass {
Alexey Bataeva769e072013-03-22 06:34:35 +000059 private:
60 int a; // expected-note {{declared here}}
Alexey Bataev6f6f3b42013-05-13 04:18:18 +000061 static int b; // expected-note {{'b' declared here}}
Alexey Bataev15e4ee72014-06-06 03:41:14 +000062 TestClass() : a(0){}
Alexey Bataeva769e072013-03-22 06:34:35 +000063 public:
Alexey Bataev15e4ee72014-06-06 03:41:14 +000064 TestClass (int aaa) : a(aaa) {}
Alexey Bataeva769e072013-03-22 06:34:35 +000065#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 Bataev15e4ee72014-06-06 03:41:14 +000068#pragma omp threadprivate (TestClass::b) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'TestClass::b' variable declaration}}
Alexey Bataeva769e072013-03-22 06:34:35 +000069#pragma omp threadprivate (g)
70
71namespace ns {
Alexey Bataev7d2960b2013-09-26 03:24:06 +000072 int m;
Alexey Bataev376b4a42016-02-09 09:41:09 +000073#pragma omp threadprivate (m, m)
Alexey Bataeva769e072013-03-22 06:34:35 +000074}
75#pragma omp threadprivate (m) // expected-error {{use of undeclared identifier 'm'}}
Alexey Bataev7c2ed442015-04-08 12:45:41 +000076#pragma omp threadprivate (ns::m)
77#pragma omp threadprivate (ns:m) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'?}}
Alexey Bataeva769e072013-03-22 06:34:35 +000078
79const int h = 12;
80const volatile int i = 10;
81#pragma omp threadprivate (h, i)
82
83
84template <class T>
85class 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 Bataev6f6f3b42013-05-13 04:18:18 +000096static __thread int t; // expected-note {{'t' defined here}}
Alexey Bataeva769e072013-03-22 06:34:35 +000097#pragma omp threadprivate (t) // expected-error {{variable 't' cannot be threadprivate because it is thread-local}}
98
Akira Hatanaka8c26ea62015-11-18 00:15:28 +000099// Register "0" is currently an invalid register for global register variables.
100// Use "esp" instead of "0".
101// register int reg0 __asm__("0");
102register int reg0 __asm__("esp"); // expected-note {{'reg0' defined here}}
Alexey Bataev26a39242015-01-13 03:35:30 +0000103#pragma omp threadprivate (reg0) // expected-error {{variable 'reg0' cannot be threadprivate because it is a global named register variable}}
104
Alexey Bataeva769e072013-03-22 06:34:35 +0000105int o; // expected-note {{candidate found by name lookup is 'o'}}
Alexey Bataev6f6f3b42013-05-13 04:18:18 +0000106#pragma omp threadprivate (o)
Alexey Bataeva769e072013-03-22 06:34:35 +0000107namespace {
David Blaikieabe1a392014-04-02 05:58:29 +0000108int o; // expected-note {{candidate found by name lookup is '(anonymous namespace)::o'}}
Alexey Bataev6f6f3b42013-05-13 04:18:18 +0000109#pragma omp threadprivate (o)
Alexey Bataev7c2ed442015-04-08 12:45:41 +0000110#pragma omp threadprivate (o)
Alexey Bataeva769e072013-03-22 06:34:35 +0000111}
112#pragma omp threadprivate (o) // expected-error {{reference to 'o' is ambiguous}}
Alexey Bataev7c2ed442015-04-08 12:45:41 +0000113#pragma omp threadprivate (::o)
Alexey Bataeva769e072013-03-22 06:34:35 +0000114
Alexey Bataev6f6f3b42013-05-13 04:18:18 +0000115int main(int argc, char **argv) { // expected-note {{'argc' defined here}}
Alexey Bataeva769e072013-03-22 06:34:35 +0000116
Alexey Bataev18b92ee2014-05-28 07:40:25 +0000117 int x, y = argc; // expected-note 2 {{'y' defined here}}
Alexey Bataeva769e072013-03-22 06:34:35 +0000118 static double d1;
119 static double d2;
Alexey Bataev6f6f3b42013-05-13 04:18:18 +0000120 static double d3; // expected-note {{'d3' defined here}}
Alexey Bataevc4fad652016-01-13 11:18:54 +0000121 static double d4;
Alexey Bataev15e4ee72014-06-06 03:41:14 +0000122 static TestClass LocalClass(y); // expected-error {{variable with local storage in initial value of threadprivate variable}}
Alexey Bataev18b92ee2014-05-28 07:40:25 +0000123#pragma omp threadprivate(LocalClass)
Alexey Bataeva769e072013-03-22 06:34:35 +0000124
125 d.a = a;
126 d2++;
127 ;
Alexey Bataev6f6f3b42013-05-13 04:18:18 +0000128#pragma omp threadprivate(argc+y) // expected-error {{expected identifier}}
Alexey Bataeva769e072013-03-22 06:34:35 +0000129#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 Bataevc4fad652016-01-13 11:18:54 +0000137label:
138#pragma omp threadprivate(d4) // expected-error {{'#pragma omp threadprivate' cannot be an immediate substatement}}
Alexey Bataeva769e072013-03-22 06:34:35 +0000139
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}