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