brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.4 KiB · 3ff6d18 Raw
160 lines · cpp
1// Check no warnings/errors2// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -fsyntax-only -verify %s3// expected-no-diagnostics4 5// Check AST and unparsing6// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -ast-dump  %s | FileCheck %s --check-prefix=DUMP7// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -ast-print %s | FileCheck %s --check-prefix=PRINT8 9// Check same results after serialization round-trip10// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -emit-pch -o %t %s11// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -include-pch %t -ast-dump-all %s | FileCheck %s --check-prefix=DUMP12// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -include-pch %t -ast-print    %s | FileCheck %s --check-prefix=PRINT13 14#ifndef HEADER15#define HEADER16 17// placeholder for loop body code.18extern "C" void body(...);19 20// PRINT-LABEL: void foo1(21// DUMP-LABEL:  FunctionDecl {{.*}} foo122void foo1() {23  // PRINT:     #pragma omp reverse24  // DUMP:      OMPReverseDirective25  #pragma omp reverse26  // PRINT: for (int i = 7; i < 17; i += 3)27  // DUMP-NEXT: ForStmt28  for (int i = 7; i < 17; i += 3)29    // PRINT: body(i);30    // DUMP:  CallExpr31      body(i);32}33 34 35// PRINT-LABEL: void foo2(36// DUMP-LABEL:  FunctionDecl {{.*}} foo237void foo2(int start, int end, int step) {38  // PRINT:     #pragma omp reverse39  // DUMP:      OMPReverseDirective40  #pragma omp reverse41  // PRINT: for (int i = start; i < end; i += step)42  // DUMP-NEXT: ForStmt43  for (int i = start; i < end; i += step)44      // PRINT: body(i);45      // DUMP:  CallExpr46      body(i);47}48 49 50// PRINT-LABEL: void foo3(51// DUMP-LABEL:  FunctionDecl {{.*}} foo352void foo3() {53  // PRINT: #pragma omp for54  // DUMP:  OMPForDirective55  // DUMP-NEXT:    CapturedStmt56  // DUMP-NEXT:      CapturedDecl57  #pragma omp for58  // PRINT:     #pragma omp reverse 59  // DUMP-NEXT: OMPReverseDirective60  #pragma omp reverse61  for (int i = 7; i < 17; i += 3)62    // PRINT: body(i);63    // DUMP:  CallExpr64    body(i);65}66 67 68// PRINT-LABEL: void foo4(69// DUMP-LABEL:  FunctionDecl {{.*}} foo470void foo4() {71  // PRINT: #pragma omp for collapse(2)72  // DUMP: OMPForDirective73  // DUMP-NEXT: OMPCollapseClause74  // DUMP-NEXT:  ConstantExpr75  // DUMP-NEXT:    value: Int 276  // DUMP-NEXT:  IntegerLiteral {{.*}} 277  // DUMP-NEXT:    CapturedStmt78  // DUMP-NEXT:      CapturedDecl79  #pragma omp for collapse(2)80  // PRINT:     #pragma omp reverse81  // DUMP:      OMPReverseDirective82  #pragma omp reverse83  // PRINT: for (int i = 7; i < 17; i += 1)84  // DUMP-NEXT: ForStmt85  for (int i = 7; i < 17; i += 1)86    // PRINT: for (int j = 7; j < 17; j += 1)87    // DUMP:  ForStmt88    for (int j = 7; j < 17; j += 1)89      // PRINT: body(i, j);90      // DUMP:  CallExpr91      body(i, j);92}93 94 95// PRINT-LABEL: void foo5(96// DUMP-LABEL:  FunctionDecl {{.*}} foo597void foo5(int start, int end, int step) {98  // PRINT:     #pragma omp for collapse(2)99  // DUMP:      OMPForDirective100  // DUMP-NEXT:   OMPCollapseClause101  // DUMP-NEXT:    ConstantExpr102  // DUMP-NEXT:      value: Int 2103  // DUMP-NEXT:    IntegerLiteral {{.*}} 2104  // DUMP-NEXT:  CapturedStmt105  // DUMP-NEXT:    CapturedDecl106  #pragma omp for collapse(2)107  // PRINT:     for (int i = 7; i < 17; i += 1)108  // DUMP-NEXT: ForStmt109  for (int i = 7; i < 17; i += 1)110    // PRINT: #pragma omp reverse111    // DUMP:  OMPReverseDirective112    #pragma omp reverse 113    // PRINT:     for (int j = 7; j < 17; j += 1)114    // DUMP-NEXT: ForStmt115    for (int j = 7; j < 17; j += 1)116      // PRINT: body(i, j);117      // DUMP:  CallExpr118      body(i, j);119}120 121 122// PRINT-LABEL: void foo6(123// DUMP-LABEL:  FunctionTemplateDecl {{.*}} foo6124template<typename T, T Step>125void foo6(T start, T end) {126  // PRINT: #pragma omp reverse127  // DUMP:  OMPReverseDirective128  #pragma omp reverse129    // PRINT-NEXT: for (T i = start; i < end; i += Step)130    // DUMP-NEXT:  ForStmt131    for (T i = start; i < end; i += Step)132      // PRINT-NEXT: body(i);133      // DUMP:       CallExpr134      body(i);135}136 137// Also test instantiating the template.138void tfoo6() {139  foo6<int,3>(0, 42);140}141 142 143// PRINT-LABEL: void foo7(144// DUMP-LABEL:  FunctionDecl {{.*}} foo7145void foo7() {146  double arr[128];147  // PRINT: #pragma omp reverse148  // DUMP:  OMPReverseDirective149  #pragma omp reverse150  // PRINT-NEXT: for (auto &&v : arr)151  // DUMP-NEXT:  CXXForRangeStmt152  for (auto &&v : arr)153    // PRINT-NEXT: body(v);154    // DUMP:       CallExpr155    body(v);156}157 158#endif159 160