blob: b8264198079eecd03a92f613dd563f62dadcd0fe [file] [log] [blame]
Alexey Bataevdb390212015-05-20 04:24:19 +00001// RUN: %clang_cc1 -fsyntax-only -fopenmp -verify %s
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00002
Alexey Bataeva8a9153a2017-12-29 18:07:07 +00003// RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -verify %s
4
Alexey Bataevd1e40fb2014-06-26 12:05:45 +00005void foo();
6
7// expected-error@+1 {{unexpected OpenMP directive '#pragma omp single'}}
8#pragma omp single
9
10// expected-error@+1 {{unexpected OpenMP directive '#pragma omp single'}}
11#pragma omp single foo
12
13void test_no_clause() {
14 int i;
15#pragma omp single
16 foo();
17
18#pragma omp single
19 ++i;
20}
21
22void test_branch_protected_scope() {
23 int i = 0;
24L1:
25 ++i;
26
27 int x[24];
28
29#pragma omp parallel
30#pragma omp single
31 {
32 if (i == 5)
33 goto L1; // expected-error {{use of undeclared label 'L1'}}
34 else if (i == 6)
35 return; // expected-error {{cannot return from OpenMP region}}
36 else if (i == 7)
37 goto L2;
38 else if (i == 8) {
39 L2:
40 x[i]++;
41 }
42 }
43
44 if (x[0] == 0)
45 goto L2; // expected-error {{use of undeclared label 'L2'}}
46 else if (x[1] == 1)
47 goto L1;
48}
49
50void test_invalid_clause() {
51 int i;
52#pragma omp parallel
53// expected-warning@+1 {{extra tokens at the end of '#pragma omp single' are ignored}}
54#pragma omp single foo bar
55 foo();
56}
57
58void test_non_identifiers() {
59 int i, x;
60
61#pragma omp parallel
62// expected-warning@+1 {{extra tokens at the end of '#pragma omp single' are ignored}}
63#pragma omp single;
64 foo();
65#pragma omp parallel
66// expected-error@+2 {{unexpected OpenMP clause 'linear' in directive '#pragma omp single'}}
67// expected-warning@+1 {{extra tokens at the end of '#pragma omp single' are ignored}}
68#pragma omp single linear(x);
69 foo();
70
71#pragma omp parallel
72// expected-warning@+1 {{extra tokens at the end of '#pragma omp single' are ignored}}
73#pragma omp single private(x);
74 foo();
75
76#pragma omp parallel
77// expected-warning@+1 {{extra tokens at the end of '#pragma omp single' are ignored}}
78#pragma omp single, private(x);
79 foo();
80}
81
82void test_private() {
83 int i;
84#pragma omp parallel
85// expected-error@+2 {{expected expression}}
86// expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
87#pragma omp single private(
88 foo();
89#pragma omp parallel
90// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
Alexey Bataevc5970622016-04-01 08:43:42 +000091// expected-error@+1 2 {{expected expression}}
Alexey Bataevd1e40fb2014-06-26 12:05:45 +000092#pragma omp single private(,
93 foo();
94#pragma omp parallel
Alexey Bataevc5970622016-04-01 08:43:42 +000095// expected-error@+1 2 {{expected expression}}
Alexey Bataevd1e40fb2014-06-26 12:05:45 +000096#pragma omp single private(, )
97 foo();
98#pragma omp parallel
99// expected-error@+1 {{expected expression}}
100#pragma omp single private()
101 foo();
102#pragma omp parallel
103// expected-error@+1 {{expected expression}}
104#pragma omp single private(int)
105 foo();
106#pragma omp parallel
107// expected-error@+1 {{expected variable name}}
108#pragma omp single private(0)
109 foo();
110
111 int x, y, z;
112#pragma omp parallel
113#pragma omp single private(x)
114 foo();
115#pragma omp parallel
116#pragma omp single private(x, y)
117 foo();
118#pragma omp parallel
119#pragma omp single private(x, y, z)
120 foo();
121}
122
123void test_firstprivate() {
124 int i;
125#pragma omp parallel
126// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
127// expected-error@+1 {{expected expression}}
128#pragma omp single firstprivate(
129 foo();
130
131#pragma omp parallel
132// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
Alexey Bataevc5970622016-04-01 08:43:42 +0000133// expected-error@+1 2 {{expected expression}}
Alexey Bataevd1e40fb2014-06-26 12:05:45 +0000134#pragma omp single firstprivate(,
135 foo();
136#pragma omp parallel
Alexey Bataevc5970622016-04-01 08:43:42 +0000137// expected-error@+1 2 {{expected expression}}
Alexey Bataevd1e40fb2014-06-26 12:05:45 +0000138#pragma omp single firstprivate(, )
139 foo();
140#pragma omp parallel
141// expected-error@+1 {{expected expression}}
142#pragma omp single firstprivate()
143 foo();
144#pragma omp parallel
145// expected-error@+1 {{expected expression}}
146#pragma omp single firstprivate(int)
147 foo();
148#pragma omp parallel
149// expected-error@+1 {{expected variable name}}
150#pragma omp single firstprivate(0)
151 foo();
152}
153
Alexey Bataev4c904ad2014-07-21 02:45:36 +0000154void test_nowait() {
155#pragma omp single nowait nowait // expected-error {{directive '#pragma omp single' cannot contain more than one 'nowait' clause}}
156 for (int i = 0; i < 16; ++i)
157 ;
158}