Skip gnat.dg/prot7.adb on hppa.
[official-gcc.git] / libgomp / testsuite / libgomp.c-c++-common / lastprivate-conditional-6.c
blobd21379358590af59d525d5429c29ec2e53d7ef71
1 #include <stdlib.h>
3 int x;
4 long long y;
5 int r, s, t;
7 void
8 foo (const char *a)
10 #pragma omp parallel sections lastprivate (conditional: x, y)
12 if (a[0])
13 x = a[0];
14 #pragma omp section
16 if (a[1])
17 x = a[1];
18 if (a[2])
19 y = a[2];
21 #pragma omp section
22 if (a[3])
23 y = a[3];
24 #pragma omp section
25 if (a[4])
26 x = a[4];
27 #pragma omp section
29 if (a[5])
30 x = a[5];
31 if (a[6])
32 y = a[6];
37 void
38 bar (const char *a)
40 #pragma omp parallel sections lastprivate (conditional: x, y) reduction (task, +: t)
42 if (a[0])
43 x = a[0];
44 #pragma omp section
46 if (a[1])
47 x = a[1];
48 if (a[2])
49 y = a[2];
50 #pragma omp task in_reduction (+: t)
51 t++;
53 #pragma omp section
54 if (a[3])
55 y = a[3];
56 #pragma omp section
57 if (a[4])
58 x = a[4];
59 #pragma omp section
61 #pragma omp task in_reduction (+: t)
62 ++t;
63 if (a[5])
64 x = a[5];
65 if (a[6])
66 y = a[6];
71 void
72 baz (const char *a)
74 #pragma omp parallel sections lastprivate (conditional: x, y) reduction (+: r, s)
76 if (a[0])
77 x = a[0];
78 #pragma omp section
80 if (a[1])
81 x = a[1];
82 ++r;
83 ++s;
84 if (a[2])
85 y = a[2];
87 #pragma omp section
88 if (a[3])
89 y = a[3];
90 #pragma omp section
92 ++s;
93 if (a[4])
94 x = a[4];
96 #pragma omp section
98 if (a[5])
99 x = a[5];
100 if (a[6])
101 y = a[6];
102 ++s;
108 main ()
110 foo ("\0\1\2\3\0\5");
111 if (x != 5 || y != 3)
112 abort ();
114 foo ("\6\0\0\0\0\0\7");
115 if (x != 6 || y != 7)
116 abort ();
118 foo ("\7\6\5\4\3\2\1");
119 if (x != 2 || y != 1)
120 abort ();
122 foo ("\0\0\4\3\0\7");
123 if (x != 7 || y != 3)
124 abort ();
126 bar ("\0\1\2\4\0\5");
127 if (x != 5 || y != 4 || t != 2)
128 abort ();
130 bar ("\6\0\0\0\0\0\7");
131 if (x != 6 || y != 7 || t != 4)
132 abort ();
134 bar ("\7\6\5\4\3\2\1");
135 if (x != 2 || y != 1 || t != 6)
136 abort ();
138 bar ("\0\0\4\3\0\7");
139 if (x != 7 || y != 3 || t != 8)
140 abort ();
142 baz ("\0\1\2\4\0\5");
143 if (x != 5 || y != 4 || r != 1 || s != 3)
144 abort ();
146 baz ("\6\0\0\0\0\0\7");
147 if (x != 6 || y != 7 || r != 2 || s != 6)
148 abort ();
150 baz ("\7\6\5\4\3\2\1");
151 if (x != 2 || y != 1 || r != 3 || s != 9)
152 abort ();
154 baz ("\0\0\4\3\0\7");
155 if (x != 7 || y != 3 || r != 4 || s != 12)
156 abort ();
158 return 0;