1 // expected-no-diagnostics 2 3 //RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 \ 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=PRINT 7 8 //RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 \ 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=DUMP 12 13 //RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 \ 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 %s 17 18 //RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 \ 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=PRINT 22 23 //RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=51 \ 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=DUMP 27 28 #ifndef HEADER 29 #define HEADER 30 31 struct 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: -OMPParallelDirective 48 // DUMP->NEXT: -OMPDefaultClause 49 } 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: -OMPParallelDirective 56 // DUMP-NEXT: -OMPDefaultClause 57 }; 58 59 void use_template() { 60 SomeKernel aKern; 61 aKern.apply<32>(); 62 } 63 64 void 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: -OMPParallelDirective 71 // DUMP-NEXT: -OMPDefaultClause 72 // DUMP-NEXT: -OMPPrivateClause {{.*}} <implicit> 73 // DUMP-NEXT: -DeclRefExpr {{.*}} 'a' 74 } 75 76 struct St { 77 int a, b; 78 int y; 79 St() : a(0), b(0) {} 80 ~St() {} 81 }; 82 void 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: -OMPParallelDirective 94 // DUMP-NEXT: -OMPDefaultClause 95 // DUMP-NEXT: -OMPPrivateClause {{.*}} <implicit> 96 // DUMP-NEXT: -DeclRefExpr {{.*}} 'a' 97 // DUMP-NEXT: -DeclRefExpr {{.*}} 'yy' 98 } 99 100 void zoo(int); 101 struct 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: -OMPParallelDirective 117 // DUMP-NEXT: -OMPPrivateClause 118 // DUMP-NEXT: -DeclRefExpr {{.*}} 'z' 119 // DUMP-NEXT: -OMPDefaultClause 120 // DUMP-NEXT: -OMPPrivateClause 121 // DUMP-NEXT: -DeclRefExpr {{.*}} 'f' 122 // DUMP: -CXXThisExpr {{.*}} 'A *' implicit this 123 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: -OMPParallelDirective 138 // DUMP-NEXT: -OMPPrivateClause 139 // DUMP-NEXT: -DeclRefExpr {{.*}} 'z' 140 // DUMP-NEXT: -OMPDefaultClause 141 // DUMP: -OMPParallelDirective 142 // DUMP-NEXT: -OMPPrivateClause 143 // DUMP-NEXT: -DeclRefExpr {{.*}} 'z' 144 // DUMP-NEXT: -OMPDefaultClause 145 // DUMP-NEXT: -OMPPrivateClause {{.*}} <implicit> 146 // DUMP-NEXT: -DeclRefExpr {{.*}} 'f' 147 // DUMP: -CXXThisExpr 148 // DUMP: -MemberExpr 149 // DUMP-NEXT: -CXXThisExpr 150 // DUMP: -CXXThisExpr 151 }; 152 #endif // HEADER 153