brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.3 KiB · b15a764 Raw
153 lines · cpp
1// expected-no-diagnostics2 3//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \4//RUN:   -x c++ -std=c++14 -fexceptions -fcxx-exceptions                   \5//RUN:   -Wno-source-uses-openmp -Wno-openmp-clauses                       \6//RUN:   -ast-print %s | FileCheck %s --check-prefix=PRINT7 8//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \9//RUN:   -x c++ -std=c++14 -fexceptions -fcxx-exceptions                   \10//RUN:   -Wno-source-uses-openmp -Wno-openmp-clauses                       \11//RUN:   -ast-dump %s | FileCheck %s --check-prefix=DUMP12 13//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \14//RUN:   -x c++ -std=c++14 -fexceptions -fcxx-exceptions                   \15//RUN:   -Wno-source-uses-openmp -Wno-openmp-clauses                       \16//RUN:   -emit-pch -o %t %s17 18//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \19//RUN:   -x c++ -std=c++14 -fexceptions -fcxx-exceptions                   \20//RUN:   -Wno-source-uses-openmp -Wno-openmp-clauses                       \21//RUN:   -include-pch %t -ast-print %s | FileCheck %s --check-prefix=PRINT22 23//RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp \24//RUN:   -x c++ -std=c++14 -fexceptions -fcxx-exceptions                   \25//RUN:   -Wno-source-uses-openmp -Wno-openmp-clauses                       \26//RUN:   -include-pch %t -ast-dump-all %s | FileCheck %s --check-prefix=DUMP27 28#ifndef HEADER29#define HEADER30 31struct SomeKernel {32  int targetDev;33  float devPtr;34  SomeKernel();35  ~SomeKernel();36 37  template <unsigned int nRHS>38  void apply() {39#pragma omp parallel default(private)40    {41      targetDev++;42    }43    // PRINT: #pragma omp parallel default(private)44    // PRINT-NEXT: {45    // PRINT-NEXT:  this->targetDev++;46    // CHECK-NEXT: }47    // DUMP: -OMPParallelDirective48    // DUMP->NEXT: -OMPDefaultClause49  }50  // PRINT: template<> void apply<32U>()51  // PRINT: #pragma omp parallel default(private)52  // PRINT-NEXT: {53  // PRINT-NEXT:  this->targetDev++;54  // CHECK-NEXT: }55  // DUMP: -OMPParallelDirective56  // DUMP-NEXT: -OMPDefaultClause57};58 59void use_template() {60  SomeKernel aKern;61  aKern.apply<32>();62}63 64void foo() {65  int a;66#pragma omp parallel default(private)67  a++;68  // PRINT: #pragma omp parallel default(private)69  // PRINT-NEXT: a++;70  // DUMP: -OMPParallelDirective71  // DUMP-NEXT:  -OMPDefaultClause72  // DUMP-NEXT: -OMPPrivateClause {{.*}} <implicit>73  // DUMP-NEXT:  -DeclRefExpr {{.*}} 'a'74}75 76struct St {77  int a, b;78  int y;79  St() : a(0), b(0) {}80  ~St() {}81};82void bar() {83  St a = St();84  static int yy = 0;85#pragma omp parallel default(private)86  {87    a.a += 1;88    a.b += 1;89    a.y++;90    yy++;91  }92  // PRINT: #pragma omp parallel default(private)93  // DUMP: -OMPParallelDirective94  // DUMP-NEXT: -OMPDefaultClause95  // DUMP-NEXT: -OMPPrivateClause {{.*}} <implicit>96  // DUMP-NEXT:  -DeclRefExpr {{.*}} 'a'97  // DUMP-NEXT:  -DeclRefExpr {{.*}} 'yy'98}99 100void zoo(int);101struct A {102  int z;103  int f;104  A();105  ~A();106  void foo() {107#pragma omp parallel private(z) default(private)108    {109      z++;110      f++;111      zoo(z + f);112      f++;113    }114  }115  // PRINT:    #pragma omp parallel private(this->z) default(private)116  // DUMP:     -OMPParallelDirective117  // DUMP-NEXT:  -OMPPrivateClause118  // DUMP-NEXT:    -DeclRefExpr {{.*}} 'z'119  // DUMP-NEXT:  -OMPDefaultClause120  // DUMP-NEXT:  -OMPPrivateClause121  // DUMP-NEXT:    -DeclRefExpr {{.*}} 'f'122  // DUMP:         -CXXThisExpr {{.*}} 'A *' implicit this123  void bar() {124#pragma omp parallel private(z) default(private)125    {126#pragma omp parallel private(z) default(private)127      {128        z++;129        f++;130        zoo(z + f);131        f++;132      }133    }134  }135  // PRINT:    #pragma omp parallel private(this->z) default(private)136  // PRINT:          #pragma omp parallel private(this->z) default(private)137  // DUMP:     -OMPParallelDirective138  // DUMP-NEXT:  -OMPPrivateClause139  // DUMP-NEXT:    -DeclRefExpr {{.*}} 'z'140  // DUMP-NEXT:  -OMPDefaultClause141  // DUMP:           -OMPParallelDirective142  // DUMP-NEXT:        -OMPPrivateClause143  // DUMP-NEXT:           -DeclRefExpr {{.*}} 'z'144  // DUMP-NEXT:        -OMPDefaultClause145  // DUMP-NEXT:        -OMPPrivateClause {{.*}} <implicit>146  // DUMP-NEXT:           -DeclRefExpr {{.*}} 'f'147  // DUMP:             -CXXThisExpr148  // DUMP:         -MemberExpr149  // DUMP-NEXT:       -CXXThisExpr150  // DUMP:         -CXXThisExpr151};152#endif // HEADER153