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