1 extern "C" void abort ();
2
3 int a = 18;
4
5 template <typename T>
6 void
f1(T i,T j,T k)7 f1 (T i, T j, T k)
8 {
9 T l = 6, m = 7, n = 8;
10 #pragma omp task private(j, m) shared(k, n)
11 {
12 j = 6;
13 m = 5;
14 if (++a != 19 || ++i != 9 || j != 6 || ++l != 7 || m != 5 || ++n != 9)
15 #pragma omp atomic
16 k++;
17 }
18 #pragma omp taskwait
19 if (a != 19 || i != 8 || j != 26 || k != 0 || l != 6 || m != 7 || n != 9)
20 abort ();
21 }
22
23 int v1 = 1, v2 = 2, v5 = 5;
24 int e;
25
26 template <typename T>
27 void
f2(void)28 f2 (void)
29 {
30 T v3 = 3;
31 #pragma omp sections private (v1) firstprivate (v2)
32 {
33 #pragma omp section
34 {
35 T v4 = 4;
36 v1 = 7;
37 #pragma omp task
38 {
39 if (++v1 != 8 || ++v2 != 3 || ++v3 != 4 || ++v4 != 5 || ++v5 != 6)
40 e = 1;
41 }
42 #pragma omp taskwait
43 if (v1 != 7 || v2 != 2 || v3 != 3 || v4 != 4 || v5 != 6)
44 abort ();
45 if (e)
46 abort ();
47 }
48 }
49 }
50
51 template <typename T>
52 void
f3(T i,T j,T k)53 f3 (T i, T j, T k)
54 {
55 T l = 6, m = 7, n = 8;
56 #pragma omp task private(j, m) shared(k, n) untied
57 {
58 j = 6;
59 m = 5;
60 if (++a != 19 || ++i != 9 || j != 6 || ++l != 7 || m != 5 || ++n != 9)
61 #pragma omp atomic
62 k++;
63 }
64 #pragma omp taskwait
65 if (a != 19 || i != 8 || j != 26 || k != 0 || l != 6 || m != 7 || n != 9)
66 abort ();
67 }
68
69 int
main()70 main ()
71 {
72 f1 <int> (8, 26, 0);
73 f2 <int> ();
74 a = 18;
75 f3 <int> (8, 26, 0);
76 a = 18;
77 #pragma omp parallel num_threads(4)
78 {
79 #pragma omp master
80 {
81 f1 <int> (8, 26, 0);
82 a = 18;
83 f3 <int> (8, 26, 0);
84 }
85 }
86 }
87