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 T arr[argc]; 37 #pragma omp task untied depend(in : argc, argv[b:argc], arr[:]) if (task : argc > 0) 38 a = 2; 39 #pragma omp task default(none), private(argc, b) firstprivate(argv) shared(d) if (argc > 0) final(S<T>::TS > 0) priority(argc) 40 foo(); 41 #pragma omp task if (C) mergeable priority(C) 42 foo(); 43 return 0; 44 } 45 46 // CHECK: template <typename T = int, int C = 5> int tmain(int argc, int *argv) { 47 // CHECK-NEXT: int b = argc, c, d, e, f, g; 48 // CHECK-NEXT: static int a; 49 // CHECK-NEXT: S<int> s; 50 // CHECK-NEXT: int arr[argc]; 51 // CHECK-NEXT: #pragma omp task untied depend(in : argc,argv[b:argc],arr[:]) if(task: argc > 0) 52 // CHECK-NEXT: a = 2; 53 // CHECK-NEXT: #pragma omp task default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0) final(S<int>::TS > 0) priority(argc) 54 // CHECK-NEXT: foo() 55 // CHECK-NEXT: #pragma omp task if(5) mergeable priority(5) 56 // CHECK-NEXT: foo() 57 // CHECK: template <typename T = long, int C = 1> long tmain(long argc, long *argv) { 58 // CHECK-NEXT: long b = argc, c, d, e, f, g; 59 // CHECK-NEXT: static long a; 60 // CHECK-NEXT: S<long> s; 61 // CHECK-NEXT: long arr[argc]; 62 // CHECK-NEXT: #pragma omp task untied depend(in : argc,argv[b:argc],arr[:]) if(task: argc > 0) 63 // CHECK-NEXT: a = 2; 64 // CHECK-NEXT: #pragma omp task default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0) final(S<long>::TS > 0) priority(argc) 65 // CHECK-NEXT: foo() 66 // CHECK-NEXT: #pragma omp task if(1) mergeable priority(1) 67 // CHECK-NEXT: foo() 68 // CHECK: template <typename T, int C> T tmain(T argc, T *argv) { 69 // CHECK-NEXT: T b = argc, c, d, e, f, g; 70 // CHECK-NEXT: static T a; 71 // CHECK-NEXT: S<T> s; 72 // CHECK-NEXT: T arr[argc]; 73 // CHECK-NEXT: #pragma omp task untied depend(in : argc,argv[b:argc],arr[:]) if(task: argc > 0) 74 // CHECK-NEXT: a = 2; 75 // CHECK-NEXT: #pragma omp task default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0) final(S<T>::TS > 0) priority(argc) 76 // CHECK-NEXT: foo() 77 // CHECK-NEXT: #pragma omp task if(C) mergeable priority(C) 78 // CHECK-NEXT: foo() 79 80 enum Enum {}; 81 82 int main(int argc, char **argv) { 83 long x; 84 int b = argc, c, d, e, f, g; 85 static int a; 86 int arr[10]; 87 #pragma omp threadprivate(a) 88 Enum ee; 89 // CHECK: Enum ee; 90 #pragma omp task untied mergeable depend(out:argv[:a][1], (arr)[0:]) if(task: argc > 0) priority(f) 91 // CHECK-NEXT: #pragma omp task untied mergeable depend(out : argv[:a][1],(arr)[0:]) if(task: argc > 0) priority(f) 92 a = 2; 93 // CHECK-NEXT: a = 2; 94 #pragma omp task default(none), private(argc, b) firstprivate(argv) if (argc > 0) final(a > 0) depend(inout : a, argv[:argc],arr[:a]) priority(23) 95 // CHECK-NEXT: #pragma omp task default(none) private(argc,b) firstprivate(argv) if(argc > 0) final(a > 0) depend(inout : a,argv[:argc],arr[:a]) priority(23) 96 foo(); 97 // CHECK-NEXT: foo(); 98 return tmain<int, 5>(b, &b) + tmain<long, 1>(x, &x); 99 } 100 101 #endif 102