1 // Check no warnings/errors
2 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -fsyntax-only -verify %s
3 // expected-no-diagnostics
5 // Check AST and unparsing
6 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -ast-dump %s | FileCheck %s --check-prefix=DUMP
7 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -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 -fopenmp-version=60 -emit-pch -o %t %s
11 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -include-pch %t -ast-dump-all %s | FileCheck %s --check-prefix=DUMP
12 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -include-pch %t -ast-print %s | FileCheck %s --check-prefix=PRINT
17 // placeholder for loop body code.
18 extern "C" void body(...);
20 // PRINT-LABEL: void foo1(
21 // DUMP-LABEL: FunctionDecl {{.*}} foo1
23 // PRINT: #pragma omp reverse
24 // DUMP: OMPReverseDirective
26 // PRINT: for (int i = 7; i < 17; i += 3)
28 for (int i
= 7; i
< 17; i
+= 3)
35 // PRINT-LABEL: void foo2(
36 // DUMP-LABEL: FunctionDecl {{.*}} foo2
37 void foo2(int start
, int end
, int step
) {
38 // PRINT: #pragma omp reverse
39 // DUMP: OMPReverseDirective
41 // PRINT: for (int i = start; i < end; i += step)
43 for (int i
= start
; i
< end
; i
+= step
)
50 // PRINT-LABEL: void foo3(
51 // DUMP-LABEL: FunctionDecl {{.*}} foo3
53 // PRINT: #pragma omp for
54 // DUMP: OMPForDirective
55 // DUMP-NEXT: CapturedStmt
56 // DUMP-NEXT: CapturedDecl
58 // PRINT: #pragma omp reverse
59 // DUMP-NEXT: OMPReverseDirective
61 for (int i
= 7; i
< 17; i
+= 3)
68 // PRINT-LABEL: void foo4(
69 // DUMP-LABEL: FunctionDecl {{.*}} foo4
71 // PRINT: #pragma omp for collapse(2)
72 // DUMP: OMPForDirective
73 // DUMP-NEXT: OMPCollapseClause
74 // DUMP-NEXT: ConstantExpr
75 // DUMP-NEXT: value: Int 2
76 // DUMP-NEXT: IntegerLiteral {{.*}} 2
77 // DUMP-NEXT: CapturedStmt
78 // DUMP-NEXT: CapturedDecl
79 #pragma omp for collapse(2)
80 // PRINT: #pragma omp reverse
81 // DUMP: OMPReverseDirective
83 // PRINT: for (int i = 7; i < 17; i += 1)
85 for (int i
= 7; i
< 17; i
+= 1)
86 // PRINT: for (int j = 7; j < 17; j += 1)
88 for (int j
= 7; j
< 17; j
+= 1)
95 // PRINT-LABEL: void foo5(
96 // DUMP-LABEL: FunctionDecl {{.*}} foo5
97 void foo5(int start
, int end
, int step
) {
98 // PRINT: #pragma omp for collapse(2)
99 // DUMP: OMPForDirective
100 // DUMP-NEXT: OMPCollapseClause
101 // DUMP-NEXT: ConstantExpr
102 // DUMP-NEXT: value: Int 2
103 // DUMP-NEXT: IntegerLiteral {{.*}} 2
104 // DUMP-NEXT: CapturedStmt
105 // DUMP-NEXT: CapturedDecl
106 #pragma omp for collapse(2)
107 // PRINT: for (int i = 7; i < 17; i += 1)
108 // DUMP-NEXT: ForStmt
109 for (int i
= 7; i
< 17; i
+= 1)
110 // PRINT: #pragma omp reverse
111 // DUMP: OMPReverseDirective
113 // PRINT: for (int j = 7; j < 17; j += 1)
114 // DUMP-NEXT: ForStmt
115 for (int j
= 7; j
< 17; j
+= 1)
116 // PRINT: body(i, j);
122 // PRINT-LABEL: void foo6(
123 // DUMP-LABEL: FunctionTemplateDecl {{.*}} foo6
124 template<typename T
, T Step
>
125 void foo6(T start
, T end
) {
126 // PRINT: #pragma omp reverse
127 // DUMP: OMPReverseDirective
129 // PRINT-NEXT: for (T i = start; i < end; i += Step)
130 // DUMP-NEXT: ForStmt
131 for (T i
= start
; i
< end
; i
+= Step
)
132 // PRINT-NEXT: body(i);
137 // Also test instantiating the template.
143 // PRINT-LABEL: void foo7(
144 // DUMP-LABEL: FunctionDecl {{.*}} foo7
147 // PRINT: #pragma omp reverse
148 // DUMP: OMPReverseDirective
150 // PRINT-NEXT: for (auto &&v : arr)
151 // DUMP-NEXT: CXXForRangeStmt
153 // PRINT-NEXT: body(v);