blob: 1bfba6d8643c305dcdb96da22e49af92ff3a6a3d [file] [log] [blame]
Alexey Bataevc6400582013-03-22 06:34:35 +00001// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 %s
2
Alexey Bataev6af701f2013-05-13 04:18:18 +00003#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 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'}}
20#pragma omp threadprivate(d, a) // expected-error {{'#pragma omp threadprivate' must precede all references to variable 'a'}}
21int 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
Alexey Bataev6af701f2013-05-13 04:18:18 +000027#pragma omp threadprivate a // expected-error {{expected '(' after 'threadprivate'}} expected-error {{'#pragma omp threadprivate' must precede all references to variable 'a'}}
Alexey Bataevc6400582013-03-22 06:34:35 +000028#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 Bataev6af701f2013-05-13 04:18:18 +000029#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 Bataevc6400582013-03-22 06:34:35 +000030int x, y;
Alexey Bataev6af701f2013-05-13 04:18:18 +000031#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 Bataevc6400582013-03-22 06:34:35 +000033#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 Bataev6af701f2013-05-13 04:18:18 +000034#pragma omp threadprivate(d.a) // expected-error {{expected identifier}}
Alexey Bataevc6400582013-03-22 06:34:35 +000035#pragma omp threadprivate((float)a) // expected-error {{expected unqualified-id}}
36int 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
41struct IncompleteSt; // expected-note {{forward declaration of 'IncompleteSt'}}
42
43extern IncompleteSt e;
Alexey Bataev6af701f2013-05-13 04:18:18 +000044#pragma omp threadprivate (e) // expected-error {{threadprivate variable with incomplete type 'IncompleteSt'}}
Alexey Bataevc6400582013-03-22 06:34:35 +000045
Alexey Bataev6af701f2013-05-13 04:18:18 +000046int &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 Bataevc6400582013-03-22 06:34:35 +000048
49class Class {
50 private:
51 int a; // expected-note {{declared here}}
Alexey Bataev6af701f2013-05-13 04:18:18 +000052 static int b; // expected-note {{'b' declared here}}
Alexey Bataevc6400582013-03-22 06:34:35 +000053 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 Bataev6af701f2013-05-13 04:18:18 +000059#pragma omp threadprivate (Class::b) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'Class::b' variable declaration}}
Alexey Bataevc6400582013-03-22 06:34:35 +000060#pragma omp threadprivate (g)
61
62namespace ns {
Alexey Bataev6af701f2013-05-13 04:18:18 +000063 int m; // expected-note 2 {{'m' defined here}}
Alexey Bataevc6400582013-03-22 06:34:35 +000064#pragma omp threadprivate (m)
65}
66#pragma omp threadprivate (m) // expected-error {{use of undeclared identifier 'm'}}
Alexey Bataev6af701f2013-05-13 04:18:18 +000067#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 Bataevc6400582013-03-22 06:34:35 +000069
70const int h = 12;
71const volatile int i = 10;
72#pragma omp threadprivate (h, i)
73
74
75template <class T>
76class 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 Bataev6af701f2013-05-13 04:18:18 +000087static __thread int t; // expected-note {{'t' defined here}}
Alexey Bataevc6400582013-03-22 06:34:35 +000088#pragma omp threadprivate (t) // expected-error {{variable 't' cannot be threadprivate because it is thread-local}}
89
90int o; // expected-note {{candidate found by name lookup is 'o'}}
Alexey Bataev6af701f2013-05-13 04:18:18 +000091#pragma omp threadprivate (o)
Alexey Bataevc6400582013-03-22 06:34:35 +000092namespace {
93int o; // expected-note {{candidate found by name lookup is '<anonymous namespace>::o'}}
Alexey Bataev6af701f2013-05-13 04:18:18 +000094#pragma omp threadprivate (o)
95#pragma omp threadprivate (o) // expected-error {{'#pragma omp threadprivate' must precede all references to variable '<anonymous namespace>::o'}}
Alexey Bataevc6400582013-03-22 06:34:35 +000096}
97#pragma omp threadprivate (o) // expected-error {{reference to 'o' is ambiguous}}
Alexey Bataev6af701f2013-05-13 04:18:18 +000098#pragma omp threadprivate (::o) // expected-error {{'#pragma omp threadprivate' must precede all references to variable 'o'}}
Alexey Bataevc6400582013-03-22 06:34:35 +000099
Alexey Bataev6af701f2013-05-13 04:18:18 +0000100int main(int argc, char **argv) { // expected-note {{'argc' defined here}}
Alexey Bataevc6400582013-03-22 06:34:35 +0000101
Alexey Bataev6af701f2013-05-13 04:18:18 +0000102 int x, y = argc; // expected-note {{'y' defined here}}
Alexey Bataevc6400582013-03-22 06:34:35 +0000103 static double d1;
104 static double d2;
Alexey Bataev6af701f2013-05-13 04:18:18 +0000105 static double d3; // expected-note {{'d3' defined here}}
Alexey Bataevc6400582013-03-22 06:34:35 +0000106
107 d.a = a;
108 d2++;
109 ;
Alexey Bataev6af701f2013-05-13 04:18:18 +0000110#pragma omp threadprivate(argc+y) // expected-error {{expected identifier}}
Alexey Bataevc6400582013-03-22 06:34:35 +0000111#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}