Debian Codegraph @

libgomp/testsuite/libgomp.c++/udr-8.C

raw
1 // { dg-do run }
2
3 extern "C" void abort ();
4
5 struct S;
6 void foo (S *, S *);
7 void bar (S &, S &);
8 #pragma omp declare reduction (+:S:foo (&omp_out, &omp_in))
9 #pragma omp declare reduction (*:S:bar (omp_out, omp_in))
10 struct S { int s; S () : s (0) {} };
11
12 void
13 foo (S *x, S *y)
14 {
15 x->s += y->s;
16 }
17
18 void
19 bar (S &x, S &y)
20 {
21 x.s += y.s;
22 }
23
24 int
25 main ()
26 {
27 S s, t;
28 int i = 0;
29 #pragma omp parallel reduction (+:s, i) reduction (*:t)
30 {
31 if (s.s != 0 || t.s != 0)
32 abort ();
33 s.s = 2;
34 t.s = 3;
35 i = 1;
36 }
37 if (s.s != 2 * i || t.s != 3 * i)
38 abort ();
39 }