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 // CHECK: static T a;
16 #pragma omp for schedule(dynamic) linear(a)
17 // CHECK-NEXT: #pragma omp for schedule(dynamic) linear(a)
18 for (int i = 0; i < 2; ++i)
19 a = 2;
20 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
21 // CHECK-NEXT: a = 2;
22 #pragma omp parallel
23 #pragma omp for private(argc, b), firstprivate(c, d), lastprivate(d, f) collapse(N) schedule(static, N) ordered(N) nowait linear(a : N)
24 for (int i = 0; i < 2; ++i)
25 for (int j = 0; j < 2; ++j)
26 for (int j = 0; j < 2; ++j)
27 for (int j = 0; j < 2; ++j)
28 for (int j = 0; j < 2; ++j)
29 for (int i = 0; i < 2; ++i)
30 for (int j = 0; j < 2; ++j)
31 for (int j = 0; j < 2; ++j)
32 for (int j = 0; j < 2; ++j)
33 for (int j = 0; j < 2; ++j)
34 foo();
35 // CHECK-NEXT: #pragma omp parallel
36 // CHECK-NEXT: #pragma omp for private(argc,b) firstprivate(c,d) lastprivate(d,f) collapse(N) schedule(static, N) ordered(N) nowait linear(a: N)
37 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
38 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
39 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
40 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
41 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
42 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
43 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
44 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
45 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
46 // CHECK-NEXT: for (int j = 0; j < 2; ++j)
47 // CHECK-NEXT: foo();
48 return T();
49 }
50
main(int argc,char ** argv)51 int main(int argc, char **argv) {
52 int b = argc, c, d, e, f, g;
53 static int a;
54 // CHECK: static int a;
55 #pragma omp for schedule(guided, argc)
56 // CHECK-NEXT: #pragma omp for schedule(guided, argc)
57 for (int i = 0; i < 2; ++i)
58 a = 2;
59 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
60 // CHECK-NEXT: a = 2;
61 #pragma omp parallel
62 #pragma omp for private(argc, b), firstprivate(argv, c), lastprivate(d, f) collapse(2) schedule(auto) ordered nowait linear(g:-1)
63 for (int i = 0; i < 10; ++i)
64 for (int j = 0; j < 10; ++j)
65 foo();
66 // CHECK-NEXT: #pragma omp parallel
67 // CHECK-NEXT: #pragma omp for private(argc,b) firstprivate(argv,c) lastprivate(d,f) collapse(2) schedule(auto) ordered nowait linear(g: -1)
68 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
69 // CHECK-NEXT: for (int j = 0; j < 10; ++j)
70 // CHECK-NEXT: foo();
71 return (tmain<int, 5>(argc) + tmain<char, 1>(argv[0][0]));
72 }
73
74 #endif
75