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 4 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 8 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 13 14 #ifndef HEADER 15 #define HEADER 16 17 // placeholder for loop body code. 18 extern "C" void body(...); 19 20 // PRINT-LABEL: void foo1( 21 // DUMP-LABEL: FunctionDecl {{.*}} foo1 22 void foo1() { 23 // PRINT: #pragma omp reverse 24 // DUMP: OMPReverseDirective 25 #pragma omp reverse 26 // PRINT: for (int i = 7; i < 17; i += 3) 27 // DUMP-NEXT: ForStmt 28 for (int i = 7; i < 17; i += 3) 29 // PRINT: body(i); 30 // DUMP: CallExpr 31 body(i); 32 } 33 34 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 40 #pragma omp reverse 41 // PRINT: for (int i = start; i < end; i += step) 42 // DUMP-NEXT: ForStmt 43 for (int i = start; i < end; i += step) 44 // PRINT: body(i); 45 // DUMP: CallExpr 46 body(i); 47 } 48 49 50 // PRINT-LABEL: void foo3( 51 // DUMP-LABEL: FunctionDecl {{.*}} foo3 52 void foo3() { 53 // PRINT: #pragma omp for 54 // DUMP: OMPForDirective 55 // DUMP-NEXT: CapturedStmt 56 // DUMP-NEXT: CapturedDecl 57 #pragma omp for 58 // PRINT: #pragma omp reverse 59 // DUMP-NEXT: OMPReverseDirective 60 #pragma omp reverse 61 for (int i = 7; i < 17; i += 3) 62 // PRINT: body(i); 63 // DUMP: CallExpr 64 body(i); 65 } 66 67 68 // PRINT-LABEL: void foo4( 69 // DUMP-LABEL: FunctionDecl {{.*}} foo4 70 void 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 82 #pragma omp reverse 83 // PRINT: for (int i = 7; i < 17; i += 1) 84 // DUMP-NEXT: ForStmt 85 for (int i = 7; i < 17; i += 1) 86 // PRINT: for (int j = 7; j < 17; j += 1) 87 // DUMP: ForStmt 88 for (int j = 7; j < 17; j += 1) 89 // PRINT: body(i, j); 90 // DUMP: CallExpr 91 body(i, j); 92 } 93 94 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 112 #pragma omp reverse 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); 117 // DUMP: CallExpr 118 body(i, j); 119 } 120 121 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 128 #pragma omp reverse 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); 133 // DUMP: CallExpr 134 body(i); 135 } 136 137 // Also test instantiating the template. 138 void tfoo6() { 139 foo6<int,3>(0, 42); 140 } 141 142 143 // PRINT-LABEL: void foo7( 144 // DUMP-LABEL: FunctionDecl {{.*}} foo7 145 void foo7() { 146 double arr[128]; 147 // PRINT: #pragma omp reverse 148 // DUMP: OMPReverseDirective 149 #pragma omp reverse 150 // PRINT-NEXT: for (auto &&v : arr) 151 // DUMP-NEXT: CXXForRangeStmt 152 for (auto &&v : arr) 153 // PRINT-NEXT: body(v); 154 // DUMP: CallExpr 155 body(v); 156 } 157 158 #endif 159 160