* config/i386/i386.c (ix86_legitimize_address): Declare
[official-gcc.git] / libgomp / testsuite / libgomp.c++ / udr-7.C
blob6f661895a379308cb8244cb41a1d8e405d44f00e
1 // { dg-do run }
3 extern "C" void abort ();
5 struct S
7   int s;
8   void foo (S &x) { s += x.s; }
9   S (const S &x) { s = x.s + 1; }
10   S () { s = 6; }
11   ~S () {}
14 void
15 bar (S &x, S &y)
17   if (x.s != 6 || y.s != 6)
18     abort ();
19   x.s = 8;
22 #pragma omp declare reduction (foo: S: omp_out.foo (omp_in)) \
23         initializer (omp_priv (omp_orig))
24 #pragma omp declare reduction (bar : S: omp_out.foo (omp_in)) \
25         initializer (bar (omp_priv, omp_orig))
28 baz (S x)
30   S r;
31   int i = 0;
32   if (x.s != 7 || r.s != 6)
33     abort ();
34   #pragma omp parallel reduction (foo: x) reduction (bar: r) \
35                        reduction (+: i)
36   {
37     if (x.s != 8 || r.s != 8)
38       abort ();
39     x.s = 12;
40     r.s = 14;
41     i = 1;
42   }
43   if (x.s != 7 + 12 * i || r.s != 6 + 14 * i)
44     abort ();
45   return r;
48 void
49 baz (S &x, S &y)
51   int i = 0, &j = i;
52   #pragma omp parallel reduction (foo: x) reduction (bar: y) \
53                        reduction (+: i)
54   {
55     if (x.s != 7 || y.s != 8)
56       abort ();
57     x.s = 12;
58     y.s = 14;
59     i = 1;
60   }
61   if (x.s != 6 + 12 * j || y.s != 6 + 14 * j)
62     abort ();
65 int
66 main ()
68   S s;
69   baz (s);
70   S t, u;
71   baz (t, u);