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(firstprivate) 40 { 41 targetDev++; 42 } 43 // PRINT: #pragma omp parallel default(firstprivate) 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(firstprivate) 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(firstprivate) 67 a++; 68 // PRINT: #pragma omp parallel default(firstprivate) 69 // PRINT-NEXT: a++; 70 // DUMP: -OMPParallelDirective 71 // DUMP-NEXT: -OMPDefaultClause 72 // DUMP-NEXT: -OMPFirstprivateClause {{.*}} <implicit> 73 // DUMP-NEXT: -DeclRefExpr {{.*}} 'a' 74 } 75 76 struct St { 77 int a, b; 78 static int y; 79 St() : a(0), b(0) {} 80 ~St() {} 81 }; 82 int St::y = 0; 83 void bar() { 84 St a = St(); 85 static int yy = 0; 86 #pragma omp parallel default(firstprivate) 87 { 88 a.a += 1; 89 a.b += 1; 90 a.y++; 91 yy++; 92 St::y++; 93 } 94 // PRINT: #pragma omp parallel default(firstprivate) 95 // DUMP: -OMPParallelDirective 96 // DUMP-NEXT: -OMPDefaultClause 97 // DUMP-NEXT: -OMPFirstprivateClause {{.*}} <implicit> 98 // DUMP-NEXT: -DeclRefExpr {{.*}} 'a' 99 // DUMP-NEXT: -DeclRefExpr {{.*}} 'yy' 100 // DUMP-NEXT: -DeclRefExpr {{.*}} 'y' 101 } 102 #endif // HEADER 103