xref: /minix3/external/bsd/llvm/dist/clang/test/OpenMP/simd_private_messages.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
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 2 {{declared here}} expected-note 2 {{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 };
17*0a6a1f1dSLionel Sambuc const S2 b;
18*0a6a1f1dSLionel Sambuc const S2 ba[5];
19*0a6a1f1dSLionel Sambuc class S3 {
20*0a6a1f1dSLionel Sambuc   int a;
21*0a6a1f1dSLionel Sambuc public:
S3()22*0a6a1f1dSLionel Sambuc   S3():a(0) { }
23*0a6a1f1dSLionel Sambuc };
24*0a6a1f1dSLionel Sambuc const S3 ca[5];
25*0a6a1f1dSLionel Sambuc class S4 {
26*0a6a1f1dSLionel Sambuc   int a;
27*0a6a1f1dSLionel Sambuc   S4(); // expected-note {{implicitly declared private here}}
28*0a6a1f1dSLionel Sambuc public:
S4(int v)29*0a6a1f1dSLionel Sambuc   S4(int v):a(v) { }
30*0a6a1f1dSLionel Sambuc };
31*0a6a1f1dSLionel Sambuc class S5 {
32*0a6a1f1dSLionel Sambuc   int a;
S5()33*0a6a1f1dSLionel Sambuc   S5():a(0) {} // expected-note {{implicitly declared private here}}
34*0a6a1f1dSLionel Sambuc public:
S5(int v)35*0a6a1f1dSLionel Sambuc   S5(int v):a(v) { }
36*0a6a1f1dSLionel Sambuc };
37*0a6a1f1dSLionel Sambuc 
38*0a6a1f1dSLionel Sambuc S3 h;
39*0a6a1f1dSLionel Sambuc #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
40*0a6a1f1dSLionel Sambuc 
foomain(I argc,C ** argv)41*0a6a1f1dSLionel Sambuc template<class I, class C> int foomain(I argc, C **argv) {
42*0a6a1f1dSLionel Sambuc   I e(4);
43*0a6a1f1dSLionel Sambuc   I g(5);
44*0a6a1f1dSLionel Sambuc   int i;
45*0a6a1f1dSLionel Sambuc   int &j = i; // expected-note {{'j' defined here}}
46*0a6a1f1dSLionel Sambuc   #pragma omp simd private // expected-error {{expected '(' after 'private'}}
47*0a6a1f1dSLionel Sambuc   for (int k = 0; k < argc; ++k) ++k;
48*0a6a1f1dSLionel Sambuc   #pragma omp simd private ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
49*0a6a1f1dSLionel Sambuc   for (int k = 0; k < argc; ++k) ++k;
50*0a6a1f1dSLionel Sambuc   #pragma omp simd private () // expected-error {{expected expression}}
51*0a6a1f1dSLionel Sambuc   for (int k = 0; k < argc; ++k) ++k;
52*0a6a1f1dSLionel Sambuc   #pragma omp simd private (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
53*0a6a1f1dSLionel Sambuc   for (int k = 0; k < argc; ++k) ++k;
54*0a6a1f1dSLionel Sambuc   #pragma omp simd private (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
55*0a6a1f1dSLionel Sambuc   for (int k = 0; k < argc; ++k) ++k;
56*0a6a1f1dSLionel Sambuc   #pragma omp simd private (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
57*0a6a1f1dSLionel Sambuc   for (int k = 0; k < argc; ++k) ++k;
58*0a6a1f1dSLionel Sambuc   #pragma omp simd private (argc)
59*0a6a1f1dSLionel Sambuc   for (int k = 0; k < argc; ++k) ++k;
60*0a6a1f1dSLionel Sambuc   #pragma omp simd private (S1) // expected-error {{'S1' does not refer to a value}}
61*0a6a1f1dSLionel Sambuc   for (int k = 0; k < argc; ++k) ++k;
62*0a6a1f1dSLionel Sambuc   #pragma omp simd private (a, b) // expected-error {{private variable with incomplete type 'S1'}}
63*0a6a1f1dSLionel Sambuc   for (int k = 0; k < argc; ++k) ++k;
64*0a6a1f1dSLionel Sambuc   #pragma omp simd private (argv[1]) // expected-error {{expected variable name}}
65*0a6a1f1dSLionel Sambuc   for (int k = 0; k < argc; ++k) ++k;
66*0a6a1f1dSLionel Sambuc   #pragma omp simd private(e, g)
67*0a6a1f1dSLionel Sambuc   for (int k = 0; k < argc; ++k) ++k;
68*0a6a1f1dSLionel Sambuc   #pragma omp simd private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
69*0a6a1f1dSLionel Sambuc   for (int k = 0; k < argc; ++k) ++k;
70*0a6a1f1dSLionel Sambuc   #pragma omp simd shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp simd'}}
71*0a6a1f1dSLionel Sambuc   for (int k = 0; k < argc; ++k) ++k;
72*0a6a1f1dSLionel Sambuc   #pragma omp parallel
73*0a6a1f1dSLionel Sambuc   {
74*0a6a1f1dSLionel Sambuc     int v = 0;
75*0a6a1f1dSLionel Sambuc     int i;
76*0a6a1f1dSLionel Sambuc     #pragma omp simd private(i)
77*0a6a1f1dSLionel Sambuc     for (int k = 0; k < argc; ++k) { i = k; v += i; }
78*0a6a1f1dSLionel Sambuc   }
79*0a6a1f1dSLionel Sambuc   #pragma omp parallel shared(i)
80*0a6a1f1dSLionel Sambuc   #pragma omp parallel private(i)
81*0a6a1f1dSLionel Sambuc   #pragma omp simd private(j) // expected-error {{arguments of OpenMP clause 'private' cannot be of reference type}}
82*0a6a1f1dSLionel Sambuc   for (int k = 0; k < argc; ++k) ++k;
83*0a6a1f1dSLionel Sambuc   #pragma omp simd private(i)
84*0a6a1f1dSLionel Sambuc   for (int k = 0; k < argc; ++k) ++k;
85*0a6a1f1dSLionel Sambuc   return 0;
86*0a6a1f1dSLionel Sambuc }
87*0a6a1f1dSLionel Sambuc 
main(int argc,char ** argv)88*0a6a1f1dSLionel Sambuc int main(int argc, char **argv) {
89*0a6a1f1dSLionel Sambuc   S4 e(4);
90*0a6a1f1dSLionel Sambuc   S5 g(5);
91*0a6a1f1dSLionel Sambuc   int i;
92*0a6a1f1dSLionel Sambuc   int &j = i; // expected-note {{'j' defined here}}
93*0a6a1f1dSLionel Sambuc   #pragma omp simd private // expected-error {{expected '(' after 'private'}}
94*0a6a1f1dSLionel Sambuc   for (int k = 0; k < argc; ++k) ++k;
95*0a6a1f1dSLionel Sambuc   #pragma omp simd private ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
96*0a6a1f1dSLionel Sambuc   for (int k = 0; k < argc; ++k) ++k;
97*0a6a1f1dSLionel Sambuc   #pragma omp simd private () // expected-error {{expected expression}}
98*0a6a1f1dSLionel Sambuc   for (int k = 0; k < argc; ++k) ++k;
99*0a6a1f1dSLionel Sambuc   #pragma omp simd private (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
100*0a6a1f1dSLionel Sambuc   for (int k = 0; k < argc; ++k) ++k;
101*0a6a1f1dSLionel Sambuc   #pragma omp simd private (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
102*0a6a1f1dSLionel Sambuc   for (int k = 0; k < argc; ++k) ++k;
103*0a6a1f1dSLionel Sambuc   #pragma omp simd private (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
104*0a6a1f1dSLionel Sambuc   for (int k = 0; k < argc; ++k) ++k;
105*0a6a1f1dSLionel Sambuc   #pragma omp simd private (argc)
106*0a6a1f1dSLionel Sambuc   for (int k = 0; k < argc; ++k) ++k;
107*0a6a1f1dSLionel Sambuc   #pragma omp simd private (S1) // expected-error {{'S1' does not refer to a value}}
108*0a6a1f1dSLionel Sambuc   for (int k = 0; k < argc; ++k) ++k;
109*0a6a1f1dSLionel Sambuc   #pragma omp simd private (a, b) // expected-error {{private variable with incomplete type 'S1'}}
110*0a6a1f1dSLionel Sambuc   for (int k = 0; k < argc; ++k) ++k;
111*0a6a1f1dSLionel Sambuc   #pragma omp simd private (argv[1]) // expected-error {{expected variable name}}
112*0a6a1f1dSLionel Sambuc   for (int k = 0; k < argc; ++k) ++k;
113*0a6a1f1dSLionel Sambuc   #pragma omp simd private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
114*0a6a1f1dSLionel Sambuc   for (int k = 0; k < argc; ++k) ++k;
115*0a6a1f1dSLionel Sambuc   #pragma omp simd private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
116*0a6a1f1dSLionel Sambuc   for (int k = 0; k < argc; ++k) ++k;
117*0a6a1f1dSLionel Sambuc   #pragma omp simd shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp simd'}}
118*0a6a1f1dSLionel Sambuc   for (int k = 0; k < argc; ++k) ++k;
119*0a6a1f1dSLionel Sambuc   #pragma omp parallel
120*0a6a1f1dSLionel Sambuc   {
121*0a6a1f1dSLionel Sambuc     int i;
122*0a6a1f1dSLionel Sambuc     #pragma omp simd private(i)
123*0a6a1f1dSLionel Sambuc     for (int k = 0; k < argc; ++k) ++k;
124*0a6a1f1dSLionel Sambuc   }
125*0a6a1f1dSLionel Sambuc   #pragma omp parallel shared(i)
126*0a6a1f1dSLionel Sambuc   #pragma omp parallel private(i)
127*0a6a1f1dSLionel Sambuc   #pragma omp simd private(j) // expected-error {{arguments of OpenMP clause 'private' cannot be of reference type}}
128*0a6a1f1dSLionel Sambuc   for (int k = 0; k < argc; ++k) ++k;
129*0a6a1f1dSLionel Sambuc   #pragma omp simd private(i)
130*0a6a1f1dSLionel Sambuc   for (int k = 0; k < argc; ++k) ++k;
131*0a6a1f1dSLionel Sambuc 
132*0a6a1f1dSLionel Sambuc   return 0;
133*0a6a1f1dSLionel Sambuc }
134*0a6a1f1dSLionel Sambuc 
135