PR target/81988
[official-gcc.git] / libgomp / testsuite / libgomp.c++ / udr-8.C
blob81c4beb8b6eb76e2c021db73918b5cce23a68776
1 // { dg-do run }
3 extern "C" void abort ();
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) {} };
12 void
13 foo (S *x, S *y)
15   x->s += y->s;
18 void
19 bar (S &x, S &y)
21   x.s += y.s;
24 int
25 main ()
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 ();