sections_private_messages.cpp revision c568f1e98938584c0ef0b12ae5018ff7d90a4072
1// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
2
3void foo() {
4}
5
6bool foobool(int argc) {
7  return argc;
8}
9
10struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
11extern S1 a;
12class S2 {
13  mutable int a;
14
15public:
16  S2() : a(0) {}
17};
18const S2 b;
19const S2 ba[5];
20class S3 {
21  int a;
22
23public:
24  S3() : a(0) {}
25};
26const S3 ca[5];
27class S4 { // expected-note {{'S4' declared here}}
28  int a;
29  S4();
30
31public:
32  S4(int v) : a(v) {}
33};
34class S5 { // expected-note {{'S5' declared here}}
35  int a;
36  S5() : a(0) {}
37
38public:
39  S5(int v) : a(v) {}
40};
41
42S3 h;
43#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
44
45template <class I, class C>
46int foomain(I argc, C **argv) {
47  I e(4);
48  I g(5);
49  int i;
50  int &j = i;                // expected-note {{'j' defined here}}
51#pragma omp sections private // expected-error {{expected '(' after 'private'}}
52  {
53    foo();
54  }
55#pragma omp sections private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
56  {
57    foo();
58  }
59#pragma omp sections private() // expected-error {{expected expression}}
60  {
61    foo();
62  }
63#pragma omp sections private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
64  {
65    foo();
66  }
67#pragma omp sections private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
68  {
69    foo();
70  }
71#pragma omp sections private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
72  {
73    foo();
74  }
75#pragma omp sections private(argc)
76  {
77    foo();
78  }
79#pragma omp sections private(S1) // expected-error {{'S1' does not refer to a value}}
80  {
81    foo();
82  }
83#pragma omp sections private(a, b) // expected-error {{private variable with incomplete type 'S1'}}
84  {
85    foo();
86  }
87#pragma omp sections private(argv[1]) // expected-error {{expected variable name}}
88  {
89    foo();
90  }
91#pragma omp sections private(e, g)
92  {
93    foo();
94  }
95#pragma omp sections private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
96  {
97    foo();
98  }
99#pragma omp sections shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp sections'}}
100  {
101    foo();
102  }
103#pragma omp parallel
104  {
105    int v = 0;
106    int i;
107#pragma omp sections private(i)
108    {
109      foo();
110    }
111    v += i;
112  }
113#pragma omp parallel shared(i)
114#pragma omp parallel private(i)
115#pragma omp sections private(j) // expected-error {{arguments of OpenMP clause 'private' cannot be of reference type}}
116  {
117    foo();
118  }
119#pragma omp sections private(i)
120  {
121    foo();
122  }
123  return 0;
124}
125
126int main(int argc, char **argv) {
127  S4 e(4); // expected-note {{'e' defined here}}
128  S5 g(5); // expected-note {{'g' defined here}}
129  int i;
130  int &j = i;                // expected-note {{'j' defined here}}
131#pragma omp sections private // expected-error {{expected '(' after 'private'}}
132  {
133    foo();
134  }
135#pragma omp sections private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
136  {
137    foo();
138  }
139#pragma omp sections private() // expected-error {{expected expression}}
140  {
141    foo();
142  }
143#pragma omp sections private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
144  {
145    foo();
146  }
147#pragma omp sections private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
148  {
149    foo();
150  }
151#pragma omp sections private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
152  {
153    foo();
154  }
155#pragma omp sections private(argc)
156  {
157    foo();
158  }
159#pragma omp sections private(S1) // expected-error {{'S1' does not refer to a value}}
160  {
161    foo();
162  }
163#pragma omp sections private(a, b) // expected-error {{private variable with incomplete type 'S1'}}
164  {
165    foo();
166  }
167#pragma omp sections private(argv[1]) // expected-error {{expected variable name}}
168  {
169    foo();
170  }
171#pragma omp sections private(e, g) // expected-error 2 {{private variable must have an accessible, unambiguous default constructor}}
172  {
173    foo();
174  }
175#pragma omp sections private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
176  {
177    foo();
178  }
179#pragma omp sections shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp sections'}}
180  {
181    foo();
182  }
183#pragma omp parallel
184  {
185    int i;
186#pragma omp sections private(i)
187    {
188      foo();
189    }
190  }
191#pragma omp parallel shared(i)
192#pragma omp parallel private(i)
193#pragma omp sections private(j) // expected-error {{arguments of OpenMP clause 'private' cannot be of reference type}}
194  {
195    foo();
196  }
197#pragma omp sections private(i)
198  {
199    foo();
200  }
201
202  return 0;
203}
204
205