gcc/
[official-gcc.git] / libgomp / testsuite / libgomp.c / pr64868.c
blobf93caf2091c1714ae55574726ef87cd9c745f011
1 /* PR c/64868 */
2 /* { dg-do run } */
4 float f = 2.0f;
5 double d = 4.0;
6 long double ld = 8.0L;
8 void
9 foo ()
11 #pragma omp atomic
12 f = 1.0f / f;
13 #pragma omp atomic
14 f = 1 / f;
15 #pragma omp atomic
16 f = f / 2.0f;
17 #pragma omp atomic
18 f = f / 2;
19 #pragma omp atomic
20 f /= 2.0f;
21 #pragma omp atomic
22 f /= 2;
23 #pragma omp atomic
24 d = 1.0 / d;
25 #pragma omp atomic
26 d = 1 / d;
27 #pragma omp atomic
28 d = d / 2.0;
29 #pragma omp atomic
30 d = d / 2;
31 #pragma omp atomic
32 d /= 2.0;
33 #pragma omp atomic
34 d /= 2;
35 #pragma omp atomic
36 ld = 1.0L / ld;
37 #pragma omp atomic
38 ld = 1 / ld;
39 #pragma omp atomic
40 ld = ld / 2.0L;
41 #pragma omp atomic
42 ld = ld / 2;
43 #pragma omp atomic
44 ld /= 2.0L;
45 #pragma omp atomic
46 ld /= 2;
47 if (f != 0.125f || d != 0.25 || ld != 0.5L)
48 __builtin_abort ();
51 #ifdef __cplusplus
52 template <typename T, int N1, int N2>
53 void
54 bar ()
56 T v = ::d;
57 #pragma omp atomic
58 v *= 16;
59 #pragma omp atomic
60 v = 1.0 / v;
61 #pragma omp atomic
62 v = N1 / v;
63 #pragma omp atomic
64 v = v / 2.0;
65 #pragma omp atomic
66 v = v / N2;
67 #pragma omp atomic
68 v /= 2.0;
69 #pragma omp atomic
70 v /= N2;
71 if (v != 0.25)
72 __builtin_abort ();
74 #endif
76 int
77 main ()
79 foo ();
80 #ifdef __cplusplus
81 bar<float, 1, 2> ();
82 bar<double, 1, 2> ();
83 bar<long double, 1, 2> ();
84 #endif
85 return 0;