]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/OpenMP/threadprivate_messages.cpp
Vendor import of clang trunk r238337:
[FreeBSD/FreeBSD.git] / test / OpenMP / threadprivate_messages.cpp
1 // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -emit-llvm -o - %s
2
3 #pragma omp threadprivate // expected-error {{expected '(' after 'threadprivate'}}
4 #pragma omp threadprivate( // expected-error {{expected identifier}} expected-error {{expected ')'}} expected-note {{to match this '('}}
5 #pragma omp threadprivate() // expected-error {{expected identifier}}
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;
14 } d; // expected-note {{'d' defined here}}
15
16 int a; // expected-note {{'a' defined here}}
17
18 #pragma omp threadprivate(a)
19 #pragma omp threadprivate(u) // expected-error {{use of undeclared identifier 'u'}}
20 #pragma omp threadprivate(d, a)
21 int foo() { // expected-note {{declared here}}
22   static int l;
23 #pragma omp threadprivate(l)) // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}}
24   return (a);
25 }
26
27 #pragma omp threadprivate (a) (
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}}
34 #pragma omp threadprivate a // expected-error {{expected '(' after 'threadprivate'}}
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}}
37 int x, y;
38 #pragma omp threadprivate(x)) // expected-warning {{extra tokens at the end of '#pragma omp threadprivate' are ignored}}
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)
42 #pragma omp threadprivate(d.a) // expected-error {{expected identifier}}
43 #pragma omp threadprivate((float)a) // expected-error {{expected unqualified-id}}
44 int foa; // expected-note {{'foa' declared here}}
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;
52 #pragma omp threadprivate (e) // expected-error {{threadprivate variable with incomplete type 'IncompleteSt'}}
53
54 int &f = a; // expected-note {{'f' defined here}}
55 #pragma omp threadprivate (f) // expected-error {{arguments of '#pragma omp threadprivate' cannot be of reference type 'int &'}}
56
57 class TestClass {
58   private:
59     int a; // expected-note {{declared here}}
60     static int b; // expected-note {{'b' declared here}}
61     TestClass() : a(0){}
62   public:
63     TestClass (int aaa) : a(aaa) {}
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'}}
67 #pragma omp threadprivate (TestClass::b) // expected-error {{'#pragma omp threadprivate' must appear in the scope of the 'TestClass::b' variable declaration}}
68 #pragma omp threadprivate (g)
69
70 namespace ns {
71   int m;
72 #pragma omp threadprivate (m)
73 }
74 #pragma omp threadprivate (m) // expected-error {{use of undeclared identifier 'm'}}
75 #pragma omp threadprivate (ns::m)
76 #pragma omp threadprivate (ns:m) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'?}}
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
95 static __thread int t; // expected-note {{'t' defined here}}
96 #pragma omp threadprivate (t) // expected-error {{variable 't' cannot be threadprivate because it is thread-local}}
97
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
101 int o; // expected-note {{candidate found by name lookup is 'o'}}
102 #pragma omp threadprivate (o)
103 namespace {
104 int o; // expected-note {{candidate found by name lookup is '(anonymous namespace)::o'}}
105 #pragma omp threadprivate (o)
106 #pragma omp threadprivate (o)
107 }
108 #pragma omp threadprivate (o) // expected-error {{reference to 'o' is ambiguous}}
109 #pragma omp threadprivate (::o)
110
111 int main(int argc, char **argv) { // expected-note {{'argc' defined here}}
112
113   int x, y = argc; // expected-note 2 {{'y' defined here}}
114   static double d1;
115   static double d2;
116   static double d3; // expected-note {{'d3' defined here}}
117   static TestClass LocalClass(y); // expected-error {{variable with local storage in initial value of threadprivate variable}}
118 #pragma omp threadprivate(LocalClass)
119
120   d.a = a;
121   d2++;
122   ;
123 #pragma omp threadprivate(argc+y) // expected-error {{expected identifier}}
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 }