1 // RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
2 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
3 // RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
4
5 // RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s | FileCheck %s
6 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s
7 // RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
8 // expected-no-diagnostics
9
10 #ifndef HEADER
11 #define HEADER
12
foo()13 void foo() {}
14
15 template <class T, int N>
tmain(T argc)16 T tmain (T argc) {
17 T b = argc, c, d, e, f, g;
18 static T a;
19 #pragma omp for ordered
20 for (int i =0 ; i < argc; ++i)
21 #pragma omp ordered
22 {
23 a=2;
24 }
25 #pragma omp for ordered
26 for (int i =0 ; i < argc; ++i)
27 #pragma omp ordered threads
28 {
29 a=2;
30 }
31 #pragma omp simd
32 for (int i =0 ; i < argc; ++i)
33 #pragma omp ordered simd
34 {
35 a=2;
36 }
37 #pragma omp for simd
38 for (int i =0 ; i < argc; ++i)
39 #pragma omp ordered simd
40 {
41 a=2;
42 }
43 #pragma omp parallel for simd
44 for (int i =0 ; i < argc; ++i)
45 #pragma omp ordered simd
46 {
47 a=2;
48 }
49 #pragma omp parallel for ordered(1)
50 for (int i =0 ; i < argc; ++i) {
51 #pragma omp ordered depend(source)
52 #pragma omp ordered depend(sink:i+N)
53 a = 2;
54 }
55 return (0);
56 }
57
58 // CHECK: static T a;
59 // CHECK-NEXT: #pragma omp for ordered
60 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
61 // CHECK-NEXT: #pragma omp ordered{{$}}
62 // CHECK-NEXT: {
63 // CHECK-NEXT: a = 2;
64 // CHECK-NEXT: }
65 // CHECK-NEXT: #pragma omp for ordered
66 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
67 // CHECK-NEXT: #pragma omp ordered threads
68 // CHECK-NEXT: {
69 // CHECK-NEXT: a = 2;
70 // CHECK-NEXT: }
71 // CHECK-NEXT: #pragma omp simd
72 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
73 // CHECK-NEXT: #pragma omp ordered simd
74 // CHECK-NEXT: {
75 // CHECK-NEXT: a = 2;
76 // CHECK-NEXT: }
77 // CHECK-NEXT: #pragma omp for simd
78 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
79 // CHECK-NEXT: #pragma omp ordered simd
80 // CHECK-NEXT: {
81 // CHECK-NEXT: a = 2;
82 // CHECK-NEXT: }
83 // CHECK-NEXT: #pragma omp parallel for simd
84 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
85 // CHECK-NEXT: #pragma omp ordered simd
86 // CHECK-NEXT: {
87 // CHECK-NEXT: a = 2;
88 // CHECK-NEXT: }
89 // CHECK-NEXT: #pragma omp parallel for ordered(1)
90 // CHECK-NEXT: for (int i = 0; i < argc; ++i) {
91 // CHECK-NEXT: #pragma omp ordered depend(source)
92 // CHECK-NEXT: #pragma omp ordered depend(sink : i + N)
93 // CHECK-NEXT: a = 2;
94 // CHECK-NEXT: }
95 // CHECK: static int a;
96 // CHECK-NEXT: #pragma omp for ordered
97 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
98 // CHECK-NEXT: #pragma omp ordered
99 // CHECK-NEXT: {
100 // CHECK-NEXT: a = 2;
101 // CHECK-NEXT: }
102 // CHECK-NEXT: #pragma omp for ordered
103 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
104 // CHECK-NEXT: #pragma omp ordered threads
105 // CHECK-NEXT: {
106 // CHECK-NEXT: a = 2;
107 // CHECK-NEXT: }
108 // CHECK-NEXT: #pragma omp simd
109 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
110 // CHECK-NEXT: #pragma omp ordered simd
111 // CHECK-NEXT: {
112 // CHECK-NEXT: a = 2;
113 // CHECK-NEXT: }
114 // CHECK-NEXT: #pragma omp for simd
115 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
116 // CHECK-NEXT: #pragma omp ordered simd
117 // CHECK-NEXT: {
118 // CHECK-NEXT: a = 2;
119 // CHECK-NEXT: }
120 // CHECK-NEXT: #pragma omp parallel for simd
121 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
122 // CHECK-NEXT: #pragma omp ordered simd
123 // CHECK-NEXT: {
124 // CHECK-NEXT: a = 2;
125 // CHECK-NEXT: }
126 // CHECK-NEXT: #pragma omp parallel for ordered(1)
127 // CHECK-NEXT: for (int i = 0; i < argc; ++i) {
128 // CHECK-NEXT: #pragma omp ordered depend(source)
129 // CHECK-NEXT: #pragma omp ordered depend(sink : i + 3)
130 // CHECK-NEXT: a = 2;
131 // CHECK-NEXT: }
132
133 // CHECK-LABEL: int main(
main(int argc,char ** argv)134 int main (int argc, char **argv) {
135 int b = argc, c, d, e, f, g;
136 static int a;
137 // CHECK: static int a;
138 #pragma omp for ordered
139 for (int i =0 ; i < argc; ++i)
140 #pragma omp ordered
141 {
142 a=2;
143 }
144 #pragma omp for ordered
145 for (int i =0 ; i < argc; ++i)
146 #pragma omp ordered threads
147 {
148 a=2;
149 }
150 #pragma omp simd
151 for (int i =0 ; i < argc; ++i)
152 #pragma omp ordered simd
153 {
154 a=2;
155 }
156 #pragma omp for simd
157 for (int i =0 ; i < argc; ++i)
158 #pragma omp ordered simd
159 {
160 a=2;
161 }
162 #pragma omp parallel for simd
163 for (int i =0 ; i < argc; ++i)
164 #pragma omp ordered simd
165 {
166 a=2;
167 }
168 #pragma omp parallel for ordered(1)
169 for (int i =0 ; i < argc; ++i) {
170 #pragma omp ordered depend(source)
171 #pragma omp ordered depend(sink: i - 5)
172 a = 2;
173 }
174 // CHECK-NEXT: #pragma omp for ordered
175 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
176 // CHECK-NEXT: #pragma omp ordered
177 // CHECK-NEXT: {
178 // CHECK-NEXT: a = 2;
179 // CHECK-NEXT: }
180 // CHECK-NEXT: #pragma omp for ordered
181 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
182 // CHECK-NEXT: #pragma omp ordered threads
183 // CHECK-NEXT: {
184 // CHECK-NEXT: a = 2;
185 // CHECK-NEXT: }
186 // CHECK-NEXT: #pragma omp simd
187 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
188 // CHECK-NEXT: #pragma omp ordered simd
189 // CHECK-NEXT: {
190 // CHECK-NEXT: a = 2;
191 // CHECK-NEXT: }
192 // CHECK-NEXT: #pragma omp for simd
193 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
194 // CHECK-NEXT: #pragma omp ordered simd
195 // CHECK-NEXT: {
196 // CHECK-NEXT: a = 2;
197 // CHECK-NEXT: }
198 // CHECK-NEXT: #pragma omp parallel for simd
199 // CHECK-NEXT: for (int i = 0; i < argc; ++i)
200 // CHECK-NEXT: #pragma omp ordered simd
201 // CHECK-NEXT: {
202 // CHECK-NEXT: a = 2;
203 // CHECK-NEXT: }
204 // CHECK-NEXT: #pragma omp parallel for ordered(1)
205 // CHECK-NEXT: for (int i = 0; i < argc; ++i) {
206 // CHECK-NEXT: #pragma omp ordered depend(source)
207 // CHECK-NEXT: #pragma omp ordered depend(sink : i - 5)
208 // CHECK-NEXT: a = 2;
209 // CHECK-NEXT: }
210 return tmain<int, 3>(argc);
211 }
212
213 #endif
214