1 // Check no warnings/errors
2 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fsyntax-only -verify %s
3 // expected-no-diagnostics
5 // Check AST and unparsing
6 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -ast-dump %s | FileCheck %s --check-prefix=DUMP
7 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -ast-print %s | FileCheck %s --check-prefix=PRINT
9 // Check same results after serialization round-trip
10 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -emit-pch -o %t %s
11 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -include-pch %t -ast-dump-all %s | FileCheck %s --check-prefix=DUMP
12 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -include-pch %t -ast-print %s | FileCheck %s --check-prefix=PRINT
17 // placeholder for loop body code.
18 extern "C" void body(...);
21 // PRINT-LABEL: void foo1(
22 // DUMP-LABEL: FunctionDecl {{.*}} foo1
24 // PRINT: #pragma omp tile sizes(5, 5)
25 // DUMP: OMPTileDirective
26 // DUMP-NEXT: OMPSizesClause
27 // DUMP-NEXT: IntegerLiteral {{.*}} 5
28 // DUMP-NEXT: IntegerLiteral {{.*}} 5
29 #pragma omp tile sizes(5,5)
30 // PRINT: for (int i = 7; i < 17; i += 3)
32 for (int i
= 7; i
< 17; i
+= 3)
33 // PRINT: for (int j = 7; j < 17; j += 3)
35 for (int j
= 7; j
< 17; j
+= 3)
42 // PRINT-LABEL: void foo2(
43 // DUMP-LABEL: FunctionDecl {{.*}} foo2
44 void foo2(int start1
, int start2
, int end1
, int end2
) {
45 // PRINT: #pragma omp tile sizes(5, 5)
46 // DUMP: OMPTileDirective
47 // DUMP-NEXT: OMPSizesClause
48 // DUMP-NEXT: IntegerLiteral {{.*}} 5
49 // DUMP-NEXT: IntegerLiteral {{.*}} 5
50 #pragma omp tile sizes(5,5)
51 // PRINT: for (int i = start1; i < end1; i += 1)
53 for (int i
= start1
; i
< end1
; i
+= 1)
54 // PRINT: for (int j = start2; j < end2; j += 1)
56 for (int j
= start2
; j
< end2
; j
+= 1)
63 // PRINT-LABEL: void foo3(
64 // DUMP-LABEL: FunctionDecl {{.*}} foo3
66 // PRINT: #pragma omp for
67 // DUMP: OMPForDirective
68 // DUMP-NEXT: CapturedStmt
69 // DUMP-NEXT: CapturedDecl
71 // PRINT: #pragma omp tile sizes(5)
72 // DUMP-NEXT: OMPTileDirective
73 // DUMP-NEXT: OMPSizesClause
74 // DUMP-NEXT: IntegerLiteral {{.*}} 5
75 #pragma omp tile sizes(5)
76 for (int i
= 7; i
< 17; i
+= 3)
83 // PRINT-LABEL: void foo4(
84 // DUMP-LABEL: FunctionDecl {{.*}} foo4
86 // PRINT: #pragma omp for collapse(3)
87 // DUMP: OMPForDirective
88 // DUMP-NEXT: OMPCollapseClause
89 // DUMP-NEXT: ConstantExpr
90 // DUMP-NEXT: value: Int 3
91 // DUMP-NEXT: IntegerLiteral {{.*}} 3
92 // DUMP-NEXT: CapturedStmt
93 // DUMP-NEXT: CapturedDecl
94 #pragma omp for collapse(3)
95 // PRINT: #pragma omp tile sizes(5, 5)
96 // DUMP: OMPTileDirective
97 // DUMP-NEXT: OMPSizesClause
98 // DUMP-NEXT: IntegerLiteral {{.*}} 5
99 // DUMP-NEXT: IntegerLiteral {{.*}} 5
100 #pragma omp tile sizes(5, 5)
101 // PRINT: for (int i = 7; i < 17; i += 1)
102 // DUMP-NEXT: ForStmt
103 for (int i
= 7; i
< 17; i
+= 1)
104 // PRINT: for (int j = 7; j < 17; j += 1)
106 for (int j
= 7; j
< 17; j
+= 1)
107 // PRINT: body(i, j);
113 // PRINT-LABEL: void foo5(
114 // DUMP-LABEL: FunctionDecl {{.*}} foo5
115 void foo5(int start
, int end
, int step
) {
116 // PRINT: #pragma omp for collapse(2)
117 // DUMP: OMPForDirective
118 // DUMP-NEXT: OMPCollapseClause
119 // DUMP-NEXT: ConstantExpr
120 // DUMP-NEXT: value: Int 2
121 // DUMP-NEXT: IntegerLiteral {{.*}} 2
122 // DUMP-NEXT: CapturedStmt
123 // DUMP-NEXT: CapturedDecl
124 #pragma omp for collapse(2)
125 // PRINT: for (int i = 7; i < 17; i += 1)
126 // DUMP-NEXT: ForStmt
127 for (int i
= 7; i
< 17; i
+= 1)
128 // PRINT: #pragma omp tile sizes(5)
129 // DUMP: OMPTileDirective
130 // DUMP-NEXT: OMPSizesClause
131 // DUMP-NEXT: IntegerLiteral {{.*}} 5
132 #pragma omp tile sizes(5)
133 // PRINT: for (int j = 7; j < 17; j += 1)
134 // DUMP-NEXT: ForStmt
135 for (int j
= 7; j
< 17; j
+= 1)
136 // PRINT: body(i, j);
142 // PRINT-LABEL: void foo6(
143 // DUMP-LABEL: FunctionTemplateDecl {{.*}} foo6
144 template<typename T
, T Step
, T Tile
>
145 void foo6(T start
, T end
) {
146 // PRINT: #pragma omp tile sizes(Tile)
147 // DUMP: OMPTileDirective
148 // DUMP-NEXT: OMPSizesClause
149 // DUMP-NEXT: DeclRefExpr {{.*}} 'Tile' 'T'
150 #pragma omp tile sizes(Tile)
151 // PRINT-NEXT: for (T i = start; i < end; i += Step)
152 // DUMP-NEXT: ForStmt
153 for (T i
= start
; i
< end
; i
+= Step
)
154 // PRINT-NEXT: body(i);
159 // Also test instantiating the template.
161 foo6
<int,3,5>(0, 42);
165 // PRINT-LABEL: template <int Tile> void foo7(int start, int stop, int step) {
166 // DUMP-LABEL: FunctionTemplateDecl {{.*}} foo7
168 void foo7(int start
, int stop
, int step
) {
169 // PRINT: #pragma omp tile sizes(Tile)
170 // DUMP: OMPTileDirective
171 // DUMP-NEXT: OMPSizesClause
172 // DUMP-NEXT: DeclRefExpr {{.*}} 'Tile' 'int'
173 #pragma omp tile sizes(Tile)
174 // PRINT-NEXT: for (int i = start; i < stop; i += step)
175 // DUMP-NEXT: ForStmt
176 for (int i
= start
; i
< stop
; i
+= step
)
177 // PRINT-NEXT: body(i);