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