blob: bf26c4f313db169404c4d574510e5cf8569a7282 [file] [log] [blame]
Pirama Arumuga Nainar3ea9e332015-04-08 08:57:32 -07001// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp=libiomp5 -ferror-limit 100 -emit-llvm -o - %s
Alexey Bataevc6400582013-03-22 06:34:35 +00002
Alexey Bataev4fa7eab2013-07-19 03:13:43 +00003#pragma omp threadprivate // expected-error {{expected '(' after 'threadprivate'}}
Alexey Bataev6af701f2013-05-13 04:18:18 +00004#pragma omp threadprivate( // expected-error {{expected identifier}} expected-error {{expected ')'}} expected-note {{to match this '('}}
5#pragma omp threadprivate() // expected-error {{expected identifier}}
Alexey Bataevc6400582013-03-22 06:34:35 +00006#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;
Alexey Bataev6af701f2013-05-13 04:18:18 +000014} d; // expected-note {{'d' defined here}}
Alexey Bataevc6400582013-03-22 06:34:35 +000015
Alexey Bataev6af701f2013-05-13 04:18:18 +000016int a; // expected-note {{'a' defined here}}
Alexey Bataevc6400582013-03-22 06:34:35 +000017
18#pragma omp threadprivate(a)
19#pragma omp threadprivate(u) // expected-error {{use of undeclared identifier 'u'}}
Pirama Arumuga Nainar33337ca2015-05-06 11:48:57 -070020#pragma omp threadprivate(d, a)
Alexey Bataevc6400582013-03-22 06:34:35 +000021int foo() { // expected-note {{declared here}}
22 static int l;
Alexey Bataev6af701f2013-05-13 04:18:18 +000023#pragma omp threadprivate(l)) // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}}
Alexey Bataevc6400582013-03-22 06:34:35 +000024 return (a);
25}
26
Stephen Hines651f13c2014-04-23 16:59:28 -070027#pragma omp threadprivate (a) (
Pirama Arumuga Nainar33337ca2015-05-06 11:48:57 -070028// 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 Bataev4fa7eab2013-07-19 03:13:43 +000034#pragma omp threadprivate a // expected-error {{expected '(' after 'threadprivate'}}
Pirama Arumuga Nainar33337ca2015-05-06 11:48:57 -070035#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 Bataevc6400582013-03-22 06:34:35 +000037int x, y;
Alexey Bataev6af701f2013-05-13 04:18:18 +000038#pragma omp threadprivate(x)) // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}}
Stephen Hines651f13c2014-04-23 16:59:28 -070039#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 Bataev6af701f2013-05-13 04:18:18 +000042#pragma omp threadprivate(d.a) // expected-error {{expected identifier}}
Alexey Bataevc6400582013-03-22 06:34:35 +000043#pragma omp threadprivate((float)a) // expected-error {{expected unqualified-id}}
Richard Smith2d670972013-08-17 00:46:16 +000044int foa; // expected-note {{'foa' declared here}}
Alexey Bataevc6400582013-03-22 06:34:35 +000045#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
49struct IncompleteSt; // expected-note {{forward declaration of 'IncompleteSt'}}
50
51extern IncompleteSt e;
Alexey Bataev6af701f2013-05-13 04:18:18 +000052#pragma omp threadprivate (e) // expected-error {{threadprivate variable with incomplete type 'IncompleteSt'}}
Alexey Bataevc6400582013-03-22 06:34:35 +000053
Alexey Bataev6af701f2013-05-13 04:18:18 +000054int &f = a; // expected-note {{'f' defined here}}
Alexey Bataev4fa7eab2013-07-19 03:13:43 +000055#pragma omp threadprivate (f) // expected-error {{arguments of '#pragma omp threadprivate' cannot be of reference type 'int &'}}
Alexey Bataevc6400582013-03-22 06:34:35 +000056
Stephen Hinesc568f1e2014-07-21 00:47:37 -070057class TestClass {
Alexey Bataevc6400582013-03-22 06:34:35 +000058 private:
59 int a; // expected-note {{declared here}}
Alexey Bataev6af701f2013-05-13 04:18:18 +000060 static int b; // expected-note {{'b' declared here}}
Stephen Hinesc568f1e2014-07-21 00:47:37 -070061 TestClass() : a(0){}
Alexey Bataevc6400582013-03-22 06:34:35 +000062 public:
Stephen Hinesc568f1e2014-07-21 00:47:37 -070063 TestClass (int aaa) : a(aaa) {}
Alexey Bataevc6400582013-03-22 06:34:35 +000064#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 Hinesc568f1e2014-07-21 00:47:37 -070067#pragma omp threadprivate (TestClass::b) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'TestClass::b' variable declaration}}
Alexey Bataevc6400582013-03-22 06:34:35 +000068#pragma omp threadprivate (g)
69
70namespace ns {
Alexey Bataevd0dbb7e2013-09-26 03:24:06 +000071 int m;
Alexey Bataevc6400582013-03-22 06:34:35 +000072#pragma omp threadprivate (m)
73}
74#pragma omp threadprivate (m) // expected-error {{use of undeclared identifier 'm'}}
Pirama Arumuga Nainar33337ca2015-05-06 11:48:57 -070075#pragma omp threadprivate (ns::m)
76#pragma omp threadprivate (ns:m) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'?}}
Alexey Bataevc6400582013-03-22 06:34:35 +000077
78const int h = 12;
79const volatile int i = 10;
80#pragma omp threadprivate (h, i)
81
82
83template <class T>
84class 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 Bataev6af701f2013-05-13 04:18:18 +000095static __thread int t; // expected-note {{'t' defined here}}
Alexey Bataevc6400582013-03-22 06:34:35 +000096#pragma omp threadprivate (t) // expected-error {{variable 't' cannot be threadprivate because it is thread-local}}
97
Stephen Hines0e2c34f2015-03-23 12:09:02 -070098register 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 Bataevc6400582013-03-22 06:34:35 +0000101int o; // expected-note {{candidate found by name lookup is 'o'}}
Alexey Bataev6af701f2013-05-13 04:18:18 +0000102#pragma omp threadprivate (o)
Alexey Bataevc6400582013-03-22 06:34:35 +0000103namespace {
Stephen Hines651f13c2014-04-23 16:59:28 -0700104int o; // expected-note {{candidate found by name lookup is '(anonymous namespace)::o'}}
Alexey Bataev6af701f2013-05-13 04:18:18 +0000105#pragma omp threadprivate (o)
Pirama Arumuga Nainar33337ca2015-05-06 11:48:57 -0700106#pragma omp threadprivate (o)
Alexey Bataevc6400582013-03-22 06:34:35 +0000107}
108#pragma omp threadprivate (o) // expected-error {{reference to 'o' is ambiguous}}
Pirama Arumuga Nainar33337ca2015-05-06 11:48:57 -0700109#pragma omp threadprivate (::o)
Alexey Bataevc6400582013-03-22 06:34:35 +0000110
Alexey Bataev6af701f2013-05-13 04:18:18 +0000111int main(int argc, char **argv) { // expected-note {{'argc' defined here}}
Alexey Bataevc6400582013-03-22 06:34:35 +0000112
Stephen Hinesc568f1e2014-07-21 00:47:37 -0700113 int x, y = argc; // expected-note 2 {{'y' defined here}}
Alexey Bataevc6400582013-03-22 06:34:35 +0000114 static double d1;
115 static double d2;
Alexey Bataev6af701f2013-05-13 04:18:18 +0000116 static double d3; // expected-note {{'d3' defined here}}
Stephen Hinesc568f1e2014-07-21 00:47:37 -0700117 static TestClass LocalClass(y); // expected-error {{variable with local storage in initial value of threadprivate variable}}
118#pragma omp threadprivate(LocalClass)
Alexey Bataevc6400582013-03-22 06:34:35 +0000119
120 d.a = a;
121 d2++;
122 ;
Alexey Bataev6af701f2013-05-13 04:18:18 +0000123#pragma omp threadprivate(argc+y) // expected-error {{expected identifier}}
Alexey Bataevc6400582013-03-22 06:34:35 +0000124#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}