libgomp/testsuite/libgomp.c++/single-2.C
raw| 1 | extern "C" void abort (void); |
| 2 | |
| 3 | struct X |
| 4 | { |
| 5 | int a; |
| 6 | char b; |
| 7 | int c; |
| 8 | }; |
| 9 | |
| 10 | int |
| 11 | main() |
| 12 | { |
| 13 | int i = 0; |
| 14 | struct X x; |
| 15 | int bad = 0; |
| 16 | |
| 17 | #pragma omp parallel private (i, x) shared (bad) |
| 18 | { |
| 19 | i = 5; |
| 20 | |
| 21 | #pragma omp single copyprivate (i, x) |
| 22 | { |
| 23 | i++; |
| 24 | x.a = 23; |
| 25 | x.b = 42; |
| 26 | x.c = 26; |
| 27 | } |
| 28 | |
| 29 | if (i != 6 || x.a != 23 || x.b != 42 || x.c != 26) |
| 30 | bad = 1; |
| 31 | } |
| 32 | |
| 33 | if (bad) |
| 34 | abort (); |
| 35 | |
| 36 | return 0; |
| 37 | } |