1 // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -fnoopenmp-use-tls -ferror-limit 100 -emit-llvm -o - %s
2 // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -emit-llvm -o - %s
3
4 // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp-simd -fnoopenmp-use-tls -ferror-limit 100 -emit-llvm -o - %s
5 // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp-simd -ferror-limit 100 -emit-llvm -o - %s
6
7 #pragma omp allocate // expected-error {{expected '(' after 'allocate'}}
8 #pragma omp allocate( // expected-error {{expected identifier}} expected-error {{expected ')'}} expected-note {{to match this '('}}
9 #pragma omp allocate() // expected-error {{expected identifier}}
10 #pragma omp allocate(1) // expected-error {{expected unqualified-id}}
11 struct CompleteSt {
12 int a;
13 };
14
15 struct CompleteSt1 {
16 #pragma omp allocate(1) // expected-error {{expected unqualified-id}}
17 int a;
18 } d; // expected-note {{'d' defined here}}
19
20 int a; // expected-note {{'a' defined here}}
21
22 #pragma omp allocate(a)
23 #pragma omp allocate(u) // expected-error {{use of undeclared identifier 'u'}}
24 #pragma omp allocate(d, a)
foo()25 int foo() { // expected-note {{declared here}}
26 static int l;
27 #pragma omp allocate(l)) // expected-warning {{extra tokens at the end of '#pragma omp allocate' are ignored}}
28 return (a);
29 }
30
31 #pragma omp allocate(a)(
32 // expected-warning@-1 {{extra tokens at the end of '#pragma omp allocate' are ignored}}
33 #pragma omp allocate(a)[ // expected-warning {{extra tokens at the end of '#pragma omp allocate' are ignored}}
34 #pragma omp allocate(a) { // expected-warning {{extra tokens at the end of '#pragma omp allocate' are ignored}}
35 #pragma omp allocate(a)) // expected-warning {{extra tokens at the end of '#pragma omp allocate' are ignored}}
36 #pragma omp allocate(a)] // expected-warning {{extra tokens at the end of '#pragma omp allocate' are ignored}}
37 #pragma omp allocate(a) } // expected-warning {{extra tokens at the end of '#pragma omp allocate' are ignored}}
38 #pragma omp allocate a // expected-error {{expected '(' after 'allocate'}}
39 #pragma omp allocate(d // expected-error {{expected ')'}} expected-note {{to match this '('}}
40 #pragma omp allocate(d)) // expected-warning {{extra tokens at the end of '#pragma omp allocate' are ignored}}
41 int x, y;
42 #pragma omp allocate(x)) // expected-warning {{extra tokens at the end of '#pragma omp allocate' are ignored}}
43 #pragma omp allocate(y)),
44 // expected-warning@-1 {{extra tokens at the end of '#pragma omp allocate' are ignored}}
45 #pragma omp allocate(a, d)
46 #pragma omp allocate(d.a) // expected-error {{expected identifier}}
47 #pragma omp allocate((float)a) // expected-error {{expected unqualified-id}}
48 int foa; // expected-note {{'foa' declared here}}
49 #pragma omp allocate(faa) // expected-error {{use of undeclared identifier 'faa'; did you mean 'foa'?}}
50 #pragma omp allocate(foo) // expected-error {{'foo' is not a global variable, static local variable or static data member}}
51 #pragma omp allocate(int a = 2) // expected-error {{expected unqualified-id}}
52
53 struct IncompleteSt;
54
55 extern IncompleteSt e;
56 #pragma omp allocate(e)
57
58 int &f = a;
59 #pragma omp allocate(f)
60
61 class TestClass {
62 private:
63 int a; // expected-note {{declared here}}
64 static int b; // expected-note {{'b' declared here}}
TestClass()65 TestClass() : a(0) {}
66
67 public:
TestClass(int aaa)68 TestClass(int aaa) : a(aaa) {}
69 #pragma omp allocate(b, a) // expected-error {{'a' is not a global variable, static local variable or static data member}}
70 } g(10);
71 #pragma omp allocate(b) // expected-error {{use of undeclared identifier 'b'}}
72 #pragma omp allocate(TestClass::b) // expected-error {{'#pragma omp allocate' must appear in the scope of the 'TestClass::b' variable declaration}}
73 #pragma omp allocate(g)
74
75 namespace ns {
76 int m;
77 #pragma omp allocate(m, m)
78 } // namespace ns
79 #pragma omp allocate(m) // expected-error {{use of undeclared identifier 'm'}}
80 #pragma omp allocate(ns::m)
81 #pragma omp allocate(ns \
82 : m) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'?}}
83
84 const int h = 12;
85 const volatile int i = 10;
86 #pragma omp allocate(h, i)
87
88 template <class T>
89 class TempClass {
90 private:
91 T a;
TempClass()92 TempClass() : a() {}
93
94 public:
TempClass(T aaa)95 TempClass(T aaa) : a(aaa) {}
96 static T s;
97 #pragma omp allocate(s)
98 };
99 #pragma omp allocate(s) // expected-error {{use of undeclared identifier 's'}}
100
101 static __thread int t;
102 #pragma omp allocate(t)
103
104 // Register "0" is currently an invalid register for global register variables.
105 // Use "esp" instead of "0".
106 // register int reg0 __asm__("0");
107 register int reg0 __asm__("esp");
108 #pragma omp allocate(reg0)
109
110 int o; // expected-note {{candidate found by name lookup is 'o'}}
111 #pragma omp allocate(o)
112 namespace {
113 int o; // expected-note {{candidate found by name lookup is '(anonymous namespace)::o'}}
114 #pragma omp allocate(o)
115 #pragma omp allocate(o)
116 } // namespace
117 #pragma omp allocate(o) // expected-error {{reference to 'o' is ambiguous}}
118 #pragma omp allocate(::o)
119
main(int argc,char ** argv)120 int main(int argc, char **argv) {
121
122 int x, y = argc;
123 static double d1;
124 static double d2;
125 static double d3; // expected-note {{'d3' defined here}}
126 static double d4;
127 static TestClass LocalClass(y);
128 #pragma omp allocate(LocalClass)
129
130 d.a = a;
131 d2++;
132 ;
133 #pragma omp allocate(argc + y) // expected-error {{expected identifier}}
134 #pragma omp allocate(argc, y)
135 #pragma omp allocate(d2)
136 #pragma omp allocate(d1)
137 {
138 ++a;
139 d2 = 0;
140 #pragma omp allocate(d3) // expected-error {{'#pragma omp allocate' must appear in the scope of the 'd3' variable declaration}}
141 }
142 #pragma omp allocate(d3)
143 label:
144 #pragma omp allocate(d4) // expected-error {{'#pragma omp allocate' cannot be an immediate substatement}}
145
146 #pragma omp allocate(a) // expected-error {{'#pragma omp allocate' must appear in the scope of the 'a' variable declaration}}
147 return (y);
148 #pragma omp allocate(d) // expected-error {{'#pragma omp allocate' must appear in the scope of the 'd' variable declaration}}
149 #pragma omp parallel allocate(d) // expected-error {{the referenced item is not found in any private clause on the same directive}}
150 ;
151 }
152