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 | |
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 |
9 | |
10 | #ifndef HEADER |
11 | #define HEADER |
12 | |
13 | void foo() {} |
14 | |
15 | struct S1 { |
16 | S1(): a(0) {} |
17 | S1(int v) : a(v) {} |
18 | int a; |
19 | typedef int type; |
20 | S1& operator +(const S1&); |
21 | S1& operator *(const S1&); |
22 | S1& operator &&(const S1&); |
23 | S1& operator ^(const S1&); |
24 | }; |
25 | |
26 | template <typename T> |
27 | class S7 : public T { |
28 | protected: |
29 | T a; |
30 | T b[100]; |
31 | S7() : a(0) {} |
32 | |
33 | public: |
34 | S7(typename T::type v) : a(v) { |
35 | #pragma omp taskgroup task_reduction(+ : a) task_reduction(*: b[:]) |
36 | for (int k = 0; k < a.a; ++k) |
37 | ++this->a.a; |
38 | } |
39 | S7 &operator=(S7 &s) { |
40 | #pragma omp taskgroup task_reduction(&& : this->a) task_reduction(^: b[s.a.a]) |
41 | for (int k = 0; k < s.a.a; ++k) |
42 | ++s.a.a; |
43 | return *this; |
44 | } |
45 | }; |
46 | |
47 | // CHECK: #pragma omp taskgroup task_reduction(+: this->a) task_reduction(*: this->b[:]) |
48 | // CHECK: #pragma omp taskgroup task_reduction(&&: this->a) task_reduction(^: this->b[s.a.a]) |
49 | // CHECK: #pragma omp taskgroup task_reduction(+: this->a) task_reduction(*: this->b[:]) |
50 | |
51 | class S8 : public S7<S1> { |
52 | S8() {} |
53 | |
54 | public: |
55 | S8(int v) : S7<S1>(v){ |
56 | #pragma omp taskgroup task_reduction(^ : S7 < S1 > ::a) task_reduction(+ : S7 < S1 > ::b[ : S7 < S1 > ::a.a]) |
57 | for (int k = 0; k < a.a; ++k) |
58 | ++this->a.a; |
59 | } |
60 | S8 &operator=(S8 &s) { |
61 | #pragma omp taskgroup task_reduction(* : this->a) task_reduction(&&:this->b[a.a:]) |
62 | for (int k = 0; k < s.a.a; ++k) |
63 | ++s.a.a; |
64 | return *this; |
65 | } |
66 | }; |
67 | |
68 | // CHECK: #pragma omp taskgroup task_reduction(^: this->S7<S1>::a) task_reduction(+: this->S7<S1>::b[:this->S7<S1>::a.a]) |
69 | // CHECK: #pragma omp taskgroup task_reduction(*: this->a) task_reduction(&&: this->b[this->a.a:]) |
70 | |
71 | int main (int argc, char **argv) { |
72 | int b = argc, c, d, e, f, g; |
73 | static int a; |
74 | // CHECK: static int a; |
75 | #pragma omp taskgroup |
76 | a=2; |
77 | // CHECK-NEXT: #pragma omp taskgroup{{$}} |
78 | // CHECK-NEXT: a = 2; |
79 | // CHECK-NEXT: ++a; |
80 | ++a; |
81 | #pragma omp taskgroup task_reduction(min: a) |
82 | foo(); |
83 | // CHECK-NEXT: #pragma omp taskgroup task_reduction(min: a) |
84 | // CHECK-NEXT: foo(); |
85 | // CHECK-NEXT: return 0; |
86 | return 0; |
87 | } |
88 | |
89 | #endif |
90 | |