125ed0c07SAlexey Bataev // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -fnoopenmp-use-tls -ferror-limit 100 -emit-llvm -o - %s
225ed0c07SAlexey Bataev // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -emit-llvm -o - %s
325ed0c07SAlexey Bataev
425ed0c07SAlexey Bataev // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp-simd -fnoopenmp-use-tls -ferror-limit 100 -emit-llvm -o - %s
525ed0c07SAlexey Bataev // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp-simd -ferror-limit 100 -emit-llvm -o - %s
625ed0c07SAlexey Bataev
725ed0c07SAlexey Bataev #pragma omp allocate // expected-error {{expected '(' after 'allocate'}}
825ed0c07SAlexey Bataev #pragma omp allocate( // expected-error {{expected identifier}} expected-error {{expected ')'}} expected-note {{to match this '('}}
925ed0c07SAlexey Bataev #pragma omp allocate() // expected-error {{expected identifier}}
1025ed0c07SAlexey Bataev #pragma omp allocate(1) // expected-error {{expected unqualified-id}}
1125ed0c07SAlexey Bataev struct CompleteSt {
1225ed0c07SAlexey Bataev int a;
1325ed0c07SAlexey Bataev };
1425ed0c07SAlexey Bataev
1525ed0c07SAlexey Bataev struct CompleteSt1 {
1625ed0c07SAlexey Bataev #pragma omp allocate(1) // expected-error {{expected unqualified-id}}
1725ed0c07SAlexey Bataev int a;
1825ed0c07SAlexey Bataev } d; // expected-note {{'d' defined here}}
1925ed0c07SAlexey Bataev
2025ed0c07SAlexey Bataev int a; // expected-note {{'a' defined here}}
2125ed0c07SAlexey Bataev
2225ed0c07SAlexey Bataev #pragma omp allocate(a)
2325ed0c07SAlexey Bataev #pragma omp allocate(u) // expected-error {{use of undeclared identifier 'u'}}
2425ed0c07SAlexey Bataev #pragma omp allocate(d, a)
foo()2525ed0c07SAlexey Bataev int foo() { // expected-note {{declared here}}
2625ed0c07SAlexey Bataev static int l;
2725ed0c07SAlexey Bataev #pragma omp allocate(l)) // expected-warning {{extra tokens at the end of '#pragma omp allocate' are ignored}}
2825ed0c07SAlexey Bataev return (a);
2925ed0c07SAlexey Bataev }
3025ed0c07SAlexey Bataev
3125ed0c07SAlexey Bataev #pragma omp allocate(a)(
3225ed0c07SAlexey Bataev // expected-warning@-1 {{extra tokens at the end of '#pragma omp allocate' are ignored}}
3325ed0c07SAlexey Bataev #pragma omp allocate(a)[ // expected-warning {{extra tokens at the end of '#pragma omp allocate' are ignored}}
3425ed0c07SAlexey Bataev #pragma omp allocate(a) { // expected-warning {{extra tokens at the end of '#pragma omp allocate' are ignored}}
3525ed0c07SAlexey Bataev #pragma omp allocate(a)) // expected-warning {{extra tokens at the end of '#pragma omp allocate' are ignored}}
3625ed0c07SAlexey Bataev #pragma omp allocate(a)] // expected-warning {{extra tokens at the end of '#pragma omp allocate' are ignored}}
3725ed0c07SAlexey Bataev #pragma omp allocate(a) } // expected-warning {{extra tokens at the end of '#pragma omp allocate' are ignored}}
3825ed0c07SAlexey Bataev #pragma omp allocate a // expected-error {{expected '(' after 'allocate'}}
3925ed0c07SAlexey Bataev #pragma omp allocate(d // expected-error {{expected ')'}} expected-note {{to match this '('}}
4025ed0c07SAlexey Bataev #pragma omp allocate(d)) // expected-warning {{extra tokens at the end of '#pragma omp allocate' are ignored}}
4125ed0c07SAlexey Bataev int x, y;
4225ed0c07SAlexey Bataev #pragma omp allocate(x)) // expected-warning {{extra tokens at the end of '#pragma omp allocate' are ignored}}
4325ed0c07SAlexey Bataev #pragma omp allocate(y)),
4425ed0c07SAlexey Bataev // expected-warning@-1 {{extra tokens at the end of '#pragma omp allocate' are ignored}}
4525ed0c07SAlexey Bataev #pragma omp allocate(a, d)
4625ed0c07SAlexey Bataev #pragma omp allocate(d.a) // expected-error {{expected identifier}}
4725ed0c07SAlexey Bataev #pragma omp allocate((float)a) // expected-error {{expected unqualified-id}}
4825ed0c07SAlexey Bataev int foa; // expected-note {{'foa' declared here}}
4925ed0c07SAlexey Bataev #pragma omp allocate(faa) // expected-error {{use of undeclared identifier 'faa'; did you mean 'foa'?}}
5025ed0c07SAlexey Bataev #pragma omp allocate(foo) // expected-error {{'foo' is not a global variable, static local variable or static data member}}
5125ed0c07SAlexey Bataev #pragma omp allocate(int a = 2) // expected-error {{expected unqualified-id}}
5225ed0c07SAlexey Bataev
5325ed0c07SAlexey Bataev struct IncompleteSt;
5425ed0c07SAlexey Bataev
5525ed0c07SAlexey Bataev extern IncompleteSt e;
5625ed0c07SAlexey Bataev #pragma omp allocate(e)
5725ed0c07SAlexey Bataev
5825ed0c07SAlexey Bataev int &f = a;
5925ed0c07SAlexey Bataev #pragma omp allocate(f)
6025ed0c07SAlexey Bataev
6125ed0c07SAlexey Bataev class TestClass {
6225ed0c07SAlexey Bataev private:
6325ed0c07SAlexey Bataev int a; // expected-note {{declared here}}
6425ed0c07SAlexey Bataev static int b; // expected-note {{'b' declared here}}
TestClass()6525ed0c07SAlexey Bataev TestClass() : a(0) {}
6625ed0c07SAlexey Bataev
6725ed0c07SAlexey Bataev public:
TestClass(int aaa)6825ed0c07SAlexey Bataev TestClass(int aaa) : a(aaa) {}
6925ed0c07SAlexey Bataev #pragma omp allocate(b, a) // expected-error {{'a' is not a global variable, static local variable or static data member}}
7025ed0c07SAlexey Bataev } g(10);
7125ed0c07SAlexey Bataev #pragma omp allocate(b) // expected-error {{use of undeclared identifier 'b'}}
7225ed0c07SAlexey Bataev #pragma omp allocate(TestClass::b) // expected-error {{'#pragma omp allocate' must appear in the scope of the 'TestClass::b' variable declaration}}
7325ed0c07SAlexey Bataev #pragma omp allocate(g)
7425ed0c07SAlexey Bataev
7525ed0c07SAlexey Bataev namespace ns {
7625ed0c07SAlexey Bataev int m;
7725ed0c07SAlexey Bataev #pragma omp allocate(m, m)
7825ed0c07SAlexey Bataev } // namespace ns
7925ed0c07SAlexey Bataev #pragma omp allocate(m) // expected-error {{use of undeclared identifier 'm'}}
8025ed0c07SAlexey Bataev #pragma omp allocate(ns::m)
8125ed0c07SAlexey Bataev #pragma omp allocate(ns \
8225ed0c07SAlexey Bataev : m) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'?}}
8325ed0c07SAlexey Bataev
8425ed0c07SAlexey Bataev const int h = 12;
8525ed0c07SAlexey Bataev const volatile int i = 10;
8625ed0c07SAlexey Bataev #pragma omp allocate(h, i)
8725ed0c07SAlexey Bataev
8825ed0c07SAlexey Bataev template <class T>
8925ed0c07SAlexey Bataev class TempClass {
9025ed0c07SAlexey Bataev private:
9125ed0c07SAlexey Bataev T a;
TempClass()9225ed0c07SAlexey Bataev TempClass() : a() {}
9325ed0c07SAlexey Bataev
9425ed0c07SAlexey Bataev public:
TempClass(T aaa)9525ed0c07SAlexey Bataev TempClass(T aaa) : a(aaa) {}
9625ed0c07SAlexey Bataev static T s;
9725ed0c07SAlexey Bataev #pragma omp allocate(s)
9825ed0c07SAlexey Bataev };
9925ed0c07SAlexey Bataev #pragma omp allocate(s) // expected-error {{use of undeclared identifier 's'}}
10025ed0c07SAlexey Bataev
10125ed0c07SAlexey Bataev static __thread int t;
10225ed0c07SAlexey Bataev #pragma omp allocate(t)
10325ed0c07SAlexey Bataev
10425ed0c07SAlexey Bataev // Register "0" is currently an invalid register for global register variables.
10525ed0c07SAlexey Bataev // Use "esp" instead of "0".
10625ed0c07SAlexey Bataev // register int reg0 __asm__("0");
10725ed0c07SAlexey Bataev register int reg0 __asm__("esp");
10825ed0c07SAlexey Bataev #pragma omp allocate(reg0)
10925ed0c07SAlexey Bataev
11025ed0c07SAlexey Bataev int o; // expected-note {{candidate found by name lookup is 'o'}}
11125ed0c07SAlexey Bataev #pragma omp allocate(o)
11225ed0c07SAlexey Bataev namespace {
11325ed0c07SAlexey Bataev int o; // expected-note {{candidate found by name lookup is '(anonymous namespace)::o'}}
11425ed0c07SAlexey Bataev #pragma omp allocate(o)
11525ed0c07SAlexey Bataev #pragma omp allocate(o)
11625ed0c07SAlexey Bataev } // namespace
11725ed0c07SAlexey Bataev #pragma omp allocate(o) // expected-error {{reference to 'o' is ambiguous}}
11825ed0c07SAlexey Bataev #pragma omp allocate(::o)
11925ed0c07SAlexey Bataev
main(int argc,char ** argv)12025ed0c07SAlexey Bataev int main(int argc, char **argv) {
12125ed0c07SAlexey Bataev
12225ed0c07SAlexey Bataev int x, y = argc;
12325ed0c07SAlexey Bataev static double d1;
12425ed0c07SAlexey Bataev static double d2;
12525ed0c07SAlexey Bataev static double d3; // expected-note {{'d3' defined here}}
12625ed0c07SAlexey Bataev static double d4;
12725ed0c07SAlexey Bataev static TestClass LocalClass(y);
12825ed0c07SAlexey Bataev #pragma omp allocate(LocalClass)
12925ed0c07SAlexey Bataev
13025ed0c07SAlexey Bataev d.a = a;
13125ed0c07SAlexey Bataev d2++;
13225ed0c07SAlexey Bataev ;
13325ed0c07SAlexey Bataev #pragma omp allocate(argc + y) // expected-error {{expected identifier}}
13425ed0c07SAlexey Bataev #pragma omp allocate(argc, y)
13525ed0c07SAlexey Bataev #pragma omp allocate(d2)
13625ed0c07SAlexey Bataev #pragma omp allocate(d1)
13725ed0c07SAlexey Bataev {
13825ed0c07SAlexey Bataev ++a;
13925ed0c07SAlexey Bataev d2 = 0;
14025ed0c07SAlexey Bataev #pragma omp allocate(d3) // expected-error {{'#pragma omp allocate' must appear in the scope of the 'd3' variable declaration}}
14125ed0c07SAlexey Bataev }
14225ed0c07SAlexey Bataev #pragma omp allocate(d3)
14325ed0c07SAlexey Bataev label:
14425ed0c07SAlexey Bataev #pragma omp allocate(d4) // expected-error {{'#pragma omp allocate' cannot be an immediate substatement}}
14525ed0c07SAlexey Bataev
14625ed0c07SAlexey Bataev #pragma omp allocate(a) // expected-error {{'#pragma omp allocate' must appear in the scope of the 'a' variable declaration}}
14725ed0c07SAlexey Bataev return (y);
14825ed0c07SAlexey Bataev #pragma omp allocate(d) // expected-error {{'#pragma omp allocate' must appear in the scope of the 'd' variable declaration}}
149*e106f25fSAlexey Bataev #pragma omp parallel allocate(d) // expected-error {{the referenced item is not found in any private clause on the same directive}}
150*e106f25fSAlexey Bataev ;
15125ed0c07SAlexey Bataev }
152