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