1 extern
2 #ifdef __cplusplus
3 "C"
4 #endif
5 void abort (void);
6 int a, b[3] = { 1, 1, 1 };
7 unsigned long int c[2] = { ~0UL, ~0UL };
8
9 void
10 bar (int i)
11 {
12 #pragma omp task in_reduction (*: b[:3]) in_reduction (&: c[1:]) \
13 in_reduction (+: a)
14 {
15 a += 4;
16 b[1] *= 4;
17 c[1] &= ~(1UL << (i + 16));
18 }
19 }
20
21 void
22 foo (int x)
23 {
24 #pragma omp scope reduction (task, +: a)
25 {
26 #pragma omp scope reduction (task, *: b)
27 {
28 #pragma omp scope reduction (task, &: c[1:1])
29 {
30 #pragma omp barrier
31 #pragma omp sections
32 {
33 {
34 a++; b[0] *= 2; bar (2); b[2] *= 3; c[1] &= ~(1UL << 2);
35 }
36 #pragma omp section
37 { b[0] *= 2; bar (4); b[2] *= 3; c[1] &= ~(1UL << 4); a++; }
38 #pragma omp section
39 { bar (6); b[2] *= 3; c[1] &= ~(1UL << 6); a++; b[0] *= 2; }
40 #pragma omp section
41 { b[2] *= 3; c[1] &= ~(1UL << 8); a++; b[0] *= 2; bar (8); }
42 #pragma omp section
43 { c[1] &= ~(1UL << 10); a++; b[0] *= 2; bar (10); b[2] *= 3; }
44 #pragma omp section
45 { a++; b[0] *= 2; b[2] *= 3; c[1] &= ~(1UL << 12); bar (12); }
46 #pragma omp section
47 if (x)
48 {
49 a++; b[0] *= 2; b[2] *= 3; bar (14); c[1] &= ~(1UL << 14);
50 }
51 }
52 }
53 }
54 }
55 }
56
57 int
58 main ()
59 {
60 volatile int one = 1;
61 foo (!one);
62 if (a != 30 || b[0] != 64 || b[1] != (1 << 12) || b[2] != 3 * 3 * 3 * 3 * 3 * 3
63 || c[0] != ~0UL || c[1] != ~0x15541554UL)
64 abort ();
65 a = 0;
66 b[0] = 1;
67 b[1] = 1;
68 b[2] = 1;
69 c[1] = ~0UL;
70 #pragma omp parallel
71 foo (one);
72 if (a != 35 || b[0] != 128 || b[1] != (1 << 14) || b[2] != 3 * 3 * 3 * 3 * 3 * 3 * 3
73 || c[0] != ~0UL || c[1] != ~0x55545554UL)
74 abort ();
75 return 0;
76 }