blob: 69551ff96cc0e6d254b9a7879401055f036c281f [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}} expected-note{{forward declaration of 'S1'}}
11extern S1 a;
12class S2 {
13 mutable int a;
14public:
15 S2():a(0) { }
16 static float S2s; // expected-note {{static data member is predetermined as shared}}
17};
18const S2 b;
19const S2 ba[5];
20class S3 {
21 int a;
22public:
23 S3():a(0) { }
24};
25const S3 c; // expected-note {{global variable is predetermined as shared}}
26const S3 ca[5]; // expected-note {{global variable is predetermined as shared}}
27extern const int f; // expected-note {{global variable is predetermined as shared}}
28class S4 {
29 int a;
30 S4(); // expected-note {{implicitly declared private here}}
31public:
32 S4(int v):a(v) { }
33};
34class S5 {
35 int a;
36 S5():a(0) {} // expected-note {{implicitly declared private here}}
37public:
38 S5(int v):a(v) { }
39};
40
41int threadvar;
42#pragma omp threadprivate(threadvar) // expected-note {{defined as threadprivate or thread local}}
43
44namespace A {
45double x;
46#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
47}
48namespace B {
49using A::x;
50}
51
52int main(int argc, char **argv) {
53 const int d = 5; // expected-note {{constant variable is predetermined as shared}}
54 const int da[5] = { 0 }; // expected-note {{constant variable is predetermined as shared}}
55 S4 e(4);
56 S5 g(5);
57 int i;
58 int &j = i;
59#pragma omp target teams private // expected-error {{expected '(' after 'private'}}
60 foo();
61#pragma omp target teams private ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
62 foo();
63#pragma omp target teams private () // expected-error {{expected expression}}
64 foo();
65#pragma omp target teams private (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
66 foo();
67#pragma omp target teams private (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
68 foo();
69#pragma omp target teams private (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
70 foo();
71#pragma omp target teams private (argc argv) // expected-error {{expected ',' or ')' in 'private' clause}}
72 foo();
73#pragma omp target teams private (S1) // expected-error {{'S1' does not refer to a value}}
74 foo();
75#pragma omp target teams private (a, b, c, d, f) // expected-error {{a private variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be private}}
76 foo();
77#pragma omp target teams private (argv[1]) // expected-error {{expected variable name}}
78 foo();
79#pragma omp target teams private(ba)
80 foo();
81#pragma omp target teams private(ca) // expected-error {{shared variable cannot be private}}
82 foo();
83#pragma omp target teams private(da) // expected-error {{shared variable cannot be private}}
84 foo();
85#pragma omp target teams private(S2::S2s) // expected-error {{shared variable cannot be private}}
86 foo();
87#pragma omp target teams private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
88 foo();
89#pragma omp target teams private(threadvar, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be private}}
90 foo();
91#pragma omp target teams shared(i), private(i) // expected-error {{shared variable cannot be private}} expected-note {{defined as shared}}
92 foo();
93#pragma omp target teams firstprivate(i) private(i) // expected-error {{firstprivate variable cannot be private}} expected-note {{defined as firstprivate}}
94 foo();
95#pragma omp target teams private(i)
96 foo();
97#pragma omp target teams private(j)
98 foo();
99#pragma omp target teams firstprivate(i)
100 for (int k = 0; k < 10; ++k) {
101#pragma omp parallel private(i)
102 foo();
103 }
104 static int m;
105#pragma omp target teams private(m) // OK
106 foo();
107
108 return 0;
109}