1 | // RUN: %clang_cc1 -fsyntax-only -fopenmp -verify %s |
2 | |
3 | // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -verify %s |
4 | |
5 | void 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 | |
13 | void test_no_clause() { |
14 | int i; |
15 | #pragma omp single |
16 | foo(); |
17 | |
18 | #pragma omp single |
19 | ++i; |
20 | } |
21 | |
22 | void test_branch_protected_scope() { |
23 | int i = 0; |
24 | L1: |
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 | |
50 | void 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 | |
58 | void 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 | |
82 | void 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 '('}} |
91 | // expected-error@+1 2 {{expected expression}} |
92 | #pragma omp single private(, |
93 | foo(); |
94 | #pragma omp parallel |
95 | // expected-error@+1 2 {{expected expression}} |
96 | #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 | |
123 | void 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 '('}} |
133 | // expected-error@+1 2 {{expected expression}} |
134 | #pragma omp single firstprivate(, |
135 | foo(); |
136 | #pragma omp parallel |
137 | // expected-error@+1 2 {{expected expression}} |
138 | #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 | |
154 | void 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 | } |
159 | |