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 
9 void foo() {}
10 
11 template <class T, int N>
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 distribute dist_schedule(static,10)
17 // CHECK-NEXT: #pragma omp distribute dist_schedule(static, 10)
18   for (int i=0; i < 2; ++i)a=2;
19 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
20 // CHECK-NEXT: a = 2;
21 #pragma omp distribute dist_schedule(static,a)
22 // CHECK-NEXT: #pragma omp distribute dist_schedule(static, a)
23   for (int i=0; i < 2; ++i)a=2;
24 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
25 // CHECK-NEXT: a = 2;
26 #pragma omp target
27 #pragma omp teams
28 #pragma omp distribute dist_schedule(static,2)
29   for (int i = 0; i < 10; ++i)
30   for (int j = 0; j < 10; ++j)foo();
31 // CHECK-NEXT: #pragma omp target
32 // CHECK-NEXT: #pragma omp teams
33 // CHECK-NEXT: #pragma omp distribute dist_schedule(static, 2)
34 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
35 // CHECK-NEXT: for (int j = 0; j < 10; ++j)
36 // CHECK-NEXT: foo();
37 #pragma omp target
38 #pragma omp teams
39 #pragma omp distribute dist_schedule(static,a)
40   for (int i = 0; i < 10; ++i)
41   for (int j = 0; j < 10; ++j)foo();
42 // CHECK-NEXT: #pragma omp target
43 // CHECK-NEXT: #pragma omp teams
44 // CHECK-NEXT: #pragma omp distribute dist_schedule(static, a)
45 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
46 // CHECK-NEXT: for (int j = 0; j < 10; ++j)
47 // CHECK-NEXT: foo();
48   for (int i = 0; i < 10; ++i)foo();
49 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
50 // CHECK-NEXT: foo();
51 #pragma omp distribute
52 // CHECK: #pragma omp distribute
53   for (int i = 0; i < 10; ++i)foo();
54 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
55 // CHECK-NEXT: foo();
56   return T();
57 }
58 
59 int main (int argc, char **argv) {
60   int b = argc, c, d, e, f, g;
61   static int a;
62 // CHECK: static int a;
63 #pragma omp distribute dist_schedule(static,10)
64 // CHECK-NEXT: #pragma omp distribute dist_schedule(static, 10)
65   for (int i=0; i < 2; ++i)a=2;
66 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
67 // CHECK-NEXT: a = 2;
68 #pragma omp distribute dist_schedule(static,b)
69 // CHECK-NEXT: #pragma omp distribute dist_schedule(static, b)
70   for (int i=0; i < 2; ++i)a=2;
71 // CHECK-NEXT: for (int i = 0; i < 2; ++i)
72 // CHECK-NEXT: a = 2;
73 #pragma omp target
74 #pragma omp teams
75 #pragma omp distribute dist_schedule(static,2)
76   for (int i = 0; i < 10; ++i)
77   for (int j = 0; j < 10; ++j)foo();
78 // CHECK-NEXT: #pragma omp target
79 // CHECK-NEXT: #pragma omp teams
80 // CHECK-NEXT: #pragma omp distribute dist_schedule(static, 2)
81 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
82 // CHECK-NEXT: for (int j = 0; j < 10; ++j)
83 // CHECK-NEXT: foo();
84 #pragma omp target
85 #pragma omp teams
86 #pragma omp distribute dist_schedule(static,a)
87   for (int i = 0; i < 10; ++i)
88   for (int j = 0; j < 10; ++j)foo();
89 // CHECK-NEXT: #pragma omp target
90 // CHECK-NEXT: #pragma omp teams
91 // CHECK-NEXT: #pragma omp distribute dist_schedule(static, a)
92 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
93 // CHECK-NEXT: for (int j = 0; j < 10; ++j)
94 // CHECK-NEXT: foo();
95   for (int i = 0; i < 10; ++i)foo();
96 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
97 // CHECK-NEXT: foo();
98 #pragma omp distribute
99 // CHECK: #pragma omp distribute
100   for (int i = 0; i < 10; ++i)foo();
101 // CHECK-NEXT: for (int i = 0; i < 10; ++i)
102 // CHECK-NEXT: foo();
103   return (tmain<int, 5>(argc) + tmain<char, 1>(argv[0][0]));
104 }
105 
106 #endif
107