aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/libgomp/testsuite/libgomp.c++/udr-5.C
blob: 91ae2f697c3d48030a0ceeec9c323ba67f2def56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// { dg-do run }

extern "C" void abort ();

struct S
{
  void foo ()
  {
    S s;
    int j = 0;
    #pragma omp declare reduction (bar : int : omp_out += omp_in)
    #pragma omp parallel reduction (bar : s) reduction(S::operator+ : j)
    s.a = 4, j = 1;
    if (s.a != 4 * j) abort ();
  }
  #pragma omp declare reduction (bar : S : baz (omp_out, omp_in))
  static void baz (S &x, S &y) { x.a += y.a; }
  S () : a (0) {}
  int a;
};

template <int N>
struct T
{
  void foo ()
  {
    S s;
    T t;
    int j = 0;
    #pragma omp declare reduction (bar : int : omp_out += omp_in)
    #pragma omp parallel reduction (bar : t) reduction (S::bar : s) \
			 reduction(T<N>::operator+ : j)
    s.a = 4, t.a = 5, j = 1;
    if (s.a != 4 * j || t.a != 5 * j) abort ();
  }
  #pragma omp declare reduction (bar : T<N> : baz (omp_out, omp_in))
  static void baz (T &x, T &y) { x.a += y.a; }
  T () : a (N) {}
  int a;
};

int
main ()
{
  S s;
  s.foo ();
  T<0> t;
  t.foo ();
}