1 // RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s 2 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s 3 // RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s 4 // expected-no-diagnostics 5 6 #ifndef HEADER 7 #define HEADER 8 9 void foo() {} 10 11 template <class T> 12 struct S { 13 operator T() {return T();} 14 static T TS; 15 #pragma omp threadprivate(TS) 16 }; 17 18 // CHECK: template <class T = int> struct S { 19 // CHECK: static int TS; 20 // CHECK-NEXT: #pragma omp threadprivate(S<int>::TS) 21 // CHECK-NEXT: } 22 // CHECK: template <class T = long> struct S { 23 // CHECK: static long TS; 24 // CHECK-NEXT: #pragma omp threadprivate(S<long>::TS) 25 // CHECK-NEXT: } 26 // CHECK: template <class T> struct S { 27 // CHECK: static T TS; 28 // CHECK-NEXT: #pragma omp threadprivate(S::TS) 29 // CHECK: }; 30 31 template <typename T, int C> 32 T tmain(T argc, T *argv) { 33 T b = argc, c, d, e, f, g; 34 static T a; 35 S<T> s; 36 #pragma omp target 37 #pragma omp teams 38 a=2; 39 #pragma omp target 40 #pragma omp teams default(none), private(argc,b) firstprivate(argv) shared (d) reduction(+:c) reduction(max:e) num_teams(C) thread_limit(d*C) 41 foo(); 42 #pragma omp target 43 #pragma omp teams reduction(^:e, f) reduction(&& : g) 44 foo(); 45 return 0; 46 } 47 48 // CHECK: template <typename T = int, int C = 5> int tmain(int argc, int *argv) { 49 // CHECK-NEXT: int b = argc, c, d, e, f, g; 50 // CHECK-NEXT: static int a; 51 // CHECK-NEXT: S<int> s; 52 // CHECK-NEXT: #pragma omp target 53 // CHECK-NEXT: #pragma omp teams 54 // CHECK-NEXT: a = 2; 55 // CHECK-NEXT: #pragma omp target 56 // CHECK-NEXT: #pragma omp teams default(none) private(argc,b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(5) thread_limit(d * 5) 57 // CHECK-NEXT: foo() 58 // CHECK-NEXT: #pragma omp target 59 // CHECK-NEXT: #pragma omp teams reduction(^: e,f) reduction(&&: g) 60 // CHECK-NEXT: foo() 61 // CHECK: template <typename T = long, int C = 1> long tmain(long argc, long *argv) { 62 // CHECK-NEXT: long b = argc, c, d, e, f, g; 63 // CHECK-NEXT: static long a; 64 // CHECK-NEXT: S<long> s; 65 // CHECK-NEXT: #pragma omp target 66 // CHECK-NEXT: #pragma omp teams 67 // CHECK-NEXT: a = 2; 68 // CHECK-NEXT: #pragma omp target 69 // CHECK-NEXT: #pragma omp teams default(none) private(argc,b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(1) thread_limit(d * 1) 70 // CHECK-NEXT: foo() 71 // CHECK-NEXT: #pragma omp target 72 // CHECK-NEXT: #pragma omp teams reduction(^: e,f) reduction(&&: g) 73 // CHECK-NEXT: foo() 74 // CHECK: template <typename T, int C> T tmain(T argc, T *argv) { 75 // CHECK-NEXT: T b = argc, c, d, e, f, g; 76 // CHECK-NEXT: static T a; 77 // CHECK-NEXT: S<T> s; 78 // CHECK-NEXT: #pragma omp target 79 // CHECK-NEXT: #pragma omp teams 80 // CHECK-NEXT: a = 2; 81 // CHECK-NEXT: #pragma omp target 82 // CHECK-NEXT: #pragma omp teams default(none) private(argc,b) firstprivate(argv) shared(d) reduction(+: c) reduction(max: e) num_teams(C) thread_limit(d * C) 83 // CHECK-NEXT: foo() 84 // CHECK-NEXT: #pragma omp target 85 // CHECK-NEXT: #pragma omp teams reduction(^: e,f) reduction(&&: g) 86 // CHECK-NEXT: foo() 87 88 enum Enum { }; 89 90 int main (int argc, char **argv) { 91 long x; 92 int b = argc, c, d, e, f, g; 93 static int a; 94 #pragma omp threadprivate(a) 95 Enum ee; 96 // CHECK: Enum ee; 97 #pragma omp target 98 #pragma omp teams 99 // CHECK-NEXT: #pragma omp target 100 // CHECK-NEXT: #pragma omp teams 101 a=2; 102 // CHECK-NEXT: a = 2; 103 #pragma omp target 104 #pragma omp teams default(none), private(argc,b) num_teams(f) firstprivate(argv) reduction(| : c, d) reduction(* : e) thread_limit(f+g) 105 // CHECK-NEXT: #pragma omp target 106 // CHECK-NEXT: #pragma omp teams default(none) private(argc,b) num_teams(f) firstprivate(argv) reduction(|: c,d) reduction(*: e) thread_limit(f + g) 107 foo(); 108 // CHECK-NEXT: foo(); 109 return tmain<int, 5>(b, &b) + tmain<long, 1>(x, &x); 110 } 111 112 extern template int S<int>::TS; 113 extern template long S<long>::TS; 114 #endif 115