• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ast-print %s | FileCheck %s
2 // RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -emit-pch -o %t %s
3 // RUN: %clang_cc1 -fopenmp=libiomp5 -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 
foo()9 void foo() {}
10 
11 template <class T>
12 struct S {
operator TS13   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>
tmain(T argc,T * argv)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 parallel
37   a=2;
38 #pragma omp parallel default(none), private(argc,b) firstprivate(argv) shared (d) if (argc > 0) num_threads(C) copyin(S<T>::TS) proc_bind(master) reduction(+:c) reduction(max:e)
39   foo();
40 #pragma omp parallel if (C) num_threads(s) proc_bind(close) reduction(^:e, f) reduction(&& : g)
41   foo();
42   return 0;
43 }
44 
45 // CHECK: template <typename T = int, int C = 5> int tmain(int argc, int *argv) {
46 // CHECK-NEXT: int b = argc, c, d, e, f, g;
47 // CHECK-NEXT: static int a;
48 // CHECK-NEXT: S<int> s;
49 // CHECK-NEXT: #pragma omp parallel
50 // CHECK-NEXT: a = 2;
51 // CHECK-NEXT: #pragma omp parallel default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0) num_threads(5) copyin(S<int>::TS) proc_bind(master) reduction(+: c) reduction(max: e)
52 // CHECK-NEXT: foo()
53 // CHECK-NEXT: #pragma omp parallel if(5) num_threads(s) proc_bind(close) reduction(^: e,f) reduction(&&: g)
54 // CHECK-NEXT: foo()
55 // CHECK: template <typename T = long, int C = 1> long tmain(long argc, long *argv) {
56 // CHECK-NEXT: long b = argc, c, d, e, f, g;
57 // CHECK-NEXT: static long a;
58 // CHECK-NEXT: S<long> s;
59 // CHECK-NEXT: #pragma omp parallel
60 // CHECK-NEXT: a = 2;
61 // CHECK-NEXT: #pragma omp parallel default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0) num_threads(1) copyin(S<long>::TS) proc_bind(master) reduction(+: c) reduction(max: e)
62 // CHECK-NEXT: foo()
63 // CHECK-NEXT: #pragma omp parallel if(1) num_threads(s) proc_bind(close) reduction(^: e,f) reduction(&&: g)
64 // CHECK-NEXT: foo()
65 // CHECK: template <typename T, int C> T tmain(T argc, T *argv) {
66 // CHECK-NEXT: T b = argc, c, d, e, f, g;
67 // CHECK-NEXT: static T a;
68 // CHECK-NEXT: S<T> s;
69 // CHECK-NEXT: #pragma omp parallel
70 // CHECK-NEXT: a = 2;
71 // CHECK-NEXT: #pragma omp parallel default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0) num_threads(C) copyin(S<T>::TS) proc_bind(master) reduction(+: c) reduction(max: e)
72 // CHECK-NEXT: foo()
73 // CHECK-NEXT: #pragma omp parallel if(C) num_threads(s) proc_bind(close) reduction(^: e,f) reduction(&&: g)
74 // CHECK-NEXT: foo()
75 
76 enum Enum { };
77 
main(int argc,char ** argv)78 int main (int argc, char **argv) {
79   long x;
80   int b = argc, c, d, e, f, g;
81   static int a;
82   #pragma omp threadprivate(a)
83   Enum ee;
84 // CHECK: Enum ee;
85 #pragma omp parallel
86 // CHECK-NEXT: #pragma omp parallel
87   a=2;
88 // CHECK-NEXT: a = 2;
89 #pragma omp parallel default(none), private(argc,b) firstprivate(argv) if (argc > 0) num_threads(ee) copyin(a) proc_bind(spread) reduction(| : c, d) reduction(* : e)
90 // CHECK-NEXT: #pragma omp parallel default(none) private(argc,b) firstprivate(argv) if(argc > 0) num_threads(ee) copyin(a) proc_bind(spread) reduction(|: c,d) reduction(*: e)
91   foo();
92 // CHECK-NEXT: foo();
93   return tmain<int, 5>(b, &b) + tmain<long, 1>(x, &x);
94 }
95 
96 #endif
97