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 T *ptr;
15 static T a;
16 // CHECK: static T a;
17 #pragma omp taskloop simd if(taskloop: argc > N) default(shared) untied priority(N) safelen(N) linear(c) aligned(ptr) grainsize(N)
18 // CHECK-NEXT: #pragma omp taskloop simd if(taskloop: argc > N) default(shared) untied priority(N) safelen(N) linear(c) aligned(ptr) grainsize(N)
19 for (int i = 0; i < 2; ++i)
20 a = 2;
21 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
22 // CHECK-NEXT: a = 2;
23 #pragma omp parallel
24 #pragma omp taskloop simd private(argc, b), firstprivate(c, d), lastprivate(d, f) collapse(N) shared(g) if (c) final(d) mergeable priority(f) simdlen(N) nogroup num_tasks(N)
25 for (int i = 0; i < 2; ++i)
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 j = 0; j < 2; ++j)
30 for (int i = 0; i < 2; ++i)
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 for (int j = 0; j < 2; ++j)
35 foo();
36 // CHECK-NEXT: #pragma omp parallel
37 // CHECK-NEXT: #pragma omp taskloop simd private(argc,b) firstprivate(c,d) lastprivate(d,f) collapse(N) shared(g) if(c) final(d) mergeable priority(f) simdlen(N) nogroup num_tasks(N)
38 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
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 j = 0; j < 2; ++j)
43 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
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: for (int j = 0; j < 2; ++j)
48 // CHECK-NEXT: foo();
49 return T();
50 }
51
main(int argc,char ** argv)52 int main(int argc, char **argv) {
53 int b = argc, c, d, e, f, g;
54 static int a;
55 // CHECK: static int a;
56 #pragma omp taskloop simd if(taskloop: a) default(none) shared(a) final(b) priority(5) safelen(8) linear(b), aligned(argv) nogroup num_tasks(argc)
57 // CHECK-NEXT: #pragma omp taskloop simd if(taskloop: a) default(none) shared(a) final(b) priority(5) safelen(8) linear(b) aligned(argv) nogroup num_tasks(argc)
58 for (int i = 0; i < 2; ++i)
59 a = 2;
60 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
61 // CHECK-NEXT: a = 2;
62 #pragma omp parallel
63 #pragma omp taskloop simd private(argc, b), firstprivate(argv, c), lastprivate(d, f) collapse(2) shared(g) if(argc) mergeable priority(argc) simdlen(16) grainsize(argc)
64 for (int i = 0; i < 10; ++i)
65 for (int j = 0; j < 10; ++j)
66 foo();
67 // CHECK-NEXT: #pragma omp parallel
68 // CHECK-NEXT: #pragma omp taskloop simd private(argc,b) firstprivate(argv,c) lastprivate(d,f) collapse(2) shared(g) if(argc) mergeable priority(argc) simdlen(16) grainsize(argc)
69 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
70 // CHECK-NEXT: for (int j = 0; j < 10; ++j)
71 // CHECK-NEXT: foo();
72 return (tmain<int, 5>(argc) + tmain<char, 1>(argv[0][0]));
73 }
74
75 #endif
76