blob: 84e412eb4c4bfa7152ced281eb18bb3e4a0e9f87 [file] [log] [blame]
Kelvin Libf594a52016-12-17 05:48:59 +00001// RUN: %clang_cc1 -verify -fopenmp %s
2
3void foo() {
4}
5
6bool foobool(int argc) {
7 return argc;
8}
9
10struct S1; // expected-note {{declared here}}
11extern S1 a;
12class S2 {
13 mutable int a;
14public:
15 S2():a(0) { }
16 S2(S2 &s2):a(s2.a) { }
17};
18const S2 b;
19const S2 ba[5];
20class S3 {
21 int a;
22public:
23 S3():a(0) { }
24 S3(S3 &s3):a(s3.a) { }
25};
26const S3 c;
27const S3 ca[5];
28extern const int f;
29class S4 {
30 int a;
31 S4();
32 S4(const S4 &s4);
33public:
34 S4(int v):a(v) { }
35};
36class S5 {
37 int a;
38 S5():a(0) {}
39 S5(const S5 &s5):a(s5.a) { }
40public:
41 S5(int v):a(v) { }
42};
43
44S3 h;
45#pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
46
47namespace A {
48double x;
49#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
50}
51namespace B {
52using A::x;
53}
54
55int main(int argc, char **argv) {
56 const int d = 5;
57 const int da[5] = { 0 };
58 S4 e(4);
59 S5 g(5);
60 int i;
61 int &j = i;
62#pragma omp target teams shared // expected-error {{expected '(' after 'shared'}}
63 foo();
64#pragma omp target teams shared ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
65 foo();
66#pragma omp target teams shared () // expected-error {{expected expression}}
67 foo();
68#pragma omp target teams shared (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
69 foo();
70#pragma omp target teams shared (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
71 foo();
72#pragma omp target teams shared (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
73 foo();
74#pragma omp target teams shared (argc)
75 foo();
76#pragma omp target teams shared (S1) // expected-error {{'S1' does not refer to a value}}
77 foo();
78#pragma omp target teams shared (a, b, c, d, f)
79 foo();
80#pragma omp target teams shared (argv[1]) // expected-error {{expected variable name}}
81 foo();
82#pragma omp target teams shared(ba)
83 foo();
84#pragma omp target teams shared(ca)
85 foo();
86#pragma omp target teams shared(da)
87 foo();
88#pragma omp target teams shared(e, g)
89 foo();
90#pragma omp target teams shared(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be shared}}
91 foo();
92#pragma omp target teams private(i), shared(i) // expected-error {{private variable cannot be shared}} expected-note {{defined as private}}
93 foo();
94#pragma omp target teams firstprivate(i), shared(i) // expected-error {{firstprivate variable cannot be shared}} expected-note {{defined as firstprivate}}
95 foo();
96#pragma omp target teams private(i)
97 foo();
98#pragma omp target teams shared(i)
99 foo();
100#pragma omp target teams shared(j)
101 foo();
102#pragma omp target teams firstprivate(i)
103 foo();
104#pragma omp target teams shared(i)
105 foo();
106#pragma omp target teams shared(j)
107 foo();
108
109 return 0;
110}