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