LWG 3035. std::allocator's constructors should be constexpr
[official-gcc.git] / gcc / testsuite / gcc.dg / nextafter-1.c
bloba768574b3422aeeb8c34dfca63fb1e8f9c22061f
1 /* PR libstdc++/85466 */
2 /* { dg-do run } */
3 /* { dg-options "-O2 -fno-math-errno -fno-trapping-math -fdump-tree-optimized" } */
4 /* { dg-add-options ieee } */
5 /* { dg-final { scan-tree-dump-not "nextafter" "optimized" } } */
6 /* { dg-final { scan-tree-dump-not "nexttoward" "optimized" } } */
8 float nextafterf (float, float);
9 double nextafter (double, double);
10 long double nextafterl (long double, long double);
11 float nexttowardf (float, long double);
12 double nexttoward (double, long double);
13 long double nexttowardl (long double, long double);
15 #define CHECK(x) if (!(x)) __builtin_abort ()
17 #ifndef NEED_ERRNO
18 #define NEED_ERRNO 0
19 #endif
20 #ifndef NEED_EXC
21 #define NEED_EXC 0
22 #endif
23 #ifndef NO_LONG_DOUBLE
24 #define NO_LONG_DOUBLE (__LDBL_MANT_DIG__ == 106)
25 #endif
27 #define TEST(name, fn, type, L1, L2, l1, l2, MIN1, \
28 MAX1, DENORM_MIN1, EPSILON1, MIN2, MAX2, DENORM_MIN2) \
29 void \
30 name (void) \
31 { \
32 const type a = fn (0.0##L1, 0.0##L2); \
33 CHECK (a == 0.0##L1 && !__builtin_signbit (a)); \
34 const type b = fn (0.0##L1, -0.0##L2); \
35 CHECK (b == 0.0##L1 && __builtin_signbit (b)); \
36 const type c = fn (__builtin_nan##l1 (""), 0.0##L2); \
37 CHECK (__builtin_isnan##l1 (c)); \
38 const type d = fn (2.0##L1, __builtin_nan##l2 ("")); \
39 CHECK (__builtin_isnan##l1 (d)); \
40 const type e = NEED_EXC ? DENORM_MIN1 : fn (0.0##L1, 8.0##L2); \
41 CHECK (e == DENORM_MIN1); \
42 const type f = fn (1.0##L1, 8.0##L2); \
43 CHECK (f == 1.0##L1 + EPSILON1); \
44 const type g = fn (1.0##L1, -8.0##L2); \
45 CHECK (g == 1.0##L1 - EPSILON1 / 2.0##L1); \
46 const type h = fn (__builtin_inf (), 0.0##L2); \
47 CHECK (h == MAX1); \
48 const type i = fn (-1.0##L1, -__builtin_inf ()); \
49 CHECK (i == -1.0##L1 - EPSILON1); \
50 const type j = fn (1.5##L1, __builtin_inf ()); \
51 CHECK (j == 1.5##L1 + EPSILON1); \
52 const type k = fn (1.5##L1 - EPSILON1, 100.0##L2); \
53 CHECK (k == 1.5##L1); \
54 const type l \
55 = (NEED_EXC || NEED_ERRNO) ? 0.0##L1 : fn (DENORM_MIN1, 0.0##L2); \
56 CHECK (l == 0.0##L1 && !__builtin_signbit (l)); \
57 const type m \
58 = (NEED_EXC || NEED_ERRNO) ? __builtin_inf##l1 () \
59 : fn (MAX1, __builtin_inf ()); \
60 CHECK (__builtin_isinf##l1 (m) && !__builtin_signbit (m)); \
61 const type n = fn (DENORM_MIN1, 12.0##L2); \
62 CHECK (n == 2.0##L1 * DENORM_MIN1); \
63 const type o = fn (n, 24.0##L2); \
64 CHECK (o == 3.0##L1 * DENORM_MIN1); \
65 const type p = fn (o, 132.0##L2); \
66 CHECK (p == 4.0##L1 * DENORM_MIN1); \
67 const type q = fn (2.0##L1 * DENORM_MIN1, -__builtin_inf ()); \
68 CHECK (q == DENORM_MIN1); \
69 const type r = fn (3.0##L1 * DENORM_MIN1, DENORM_MIN2); \
70 CHECK (r == 2.0##L1 * DENORM_MIN1); \
71 const type s = fn (4.0##L1 * DENORM_MIN1, 2.0##L2 * DENORM_MIN2); \
72 CHECK (s == 3.0##L1 * DENORM_MIN1); \
73 const type t = fn (MIN1, 0.0##L2); \
74 CHECK (t == MIN1 - DENORM_MIN1); \
75 const type u = fn (MIN1 - DENORM_MIN1, -MIN2); \
76 CHECK (u == MIN1 - 2.0##L1 * DENORM_MIN1); \
77 const type v = fn (MIN1 - 2.0##L1 * DENORM_MIN1, 100.0##L2); \
78 CHECK (v == MIN1 - DENORM_MIN1); \
79 const type w = fn (MIN1 - DENORM_MIN1, MAX2); \
80 CHECK (w == MIN1); \
81 const type x = fn (MIN1, 17.0##L2); \
82 CHECK (x == MIN1 + DENORM_MIN1); \
83 const type y = fn (MIN1 + DENORM_MIN1, __builtin_inf##l2 ()); \
84 CHECK (y == MIN1 + 2.0##L1 * DENORM_MIN1); \
85 const type z = fn (MIN1 / 2.0##L1, -MIN2); \
86 CHECK (z == MIN1 / 2.0##L1 - DENORM_MIN1); \
87 const type aa = fn (-MIN1 / 4.0##L1, MIN2); \
88 CHECK (aa == -MIN1 / 4.0##L1 + DENORM_MIN1); \
89 const type ab = fn (MIN1 * 2.0##L1, -MIN2); \
90 CHECK (ab == MIN1 * 2.0##L1 - DENORM_MIN1); \
91 const type ac = fn (MIN1 * 4.0##L1, MIN2); \
92 CHECK (ac == MIN1 * 4.0##L1 - DENORM_MIN1 * 2.0##L1); \
93 const type ad = fn (MIN1 * 64.0##L1, MIN2); \
94 CHECK (ad == MIN1 * 64.0##L1 - DENORM_MIN1 * 32.0##L1); \
95 const type ae = fn (MIN1 / 2.0##L1 - DENORM_MIN1, 100.0##L2); \
96 CHECK (ae == MIN1 / 2.0##L1); \
97 const type af = fn (-MIN1 / 4 + DENORM_MIN1, -100.0##L2); \
98 CHECK (af == -MIN1 / 4.0##L1); \
99 const type ag = fn (MIN1 * 2.0##L1 - DENORM_MIN1, 100.0##L2); \
100 CHECK (ag == MIN1 * 2.0##L1); \
101 const type ah = fn (MIN1 * 4.0##L1 - 2.0##L1 * DENORM_MIN1, 100.0##L2); \
102 CHECK (ah == MIN1 * 4.0##L1); \
103 const type ai = fn (MIN1 * 64.0##L1 - 32.0##L1 * DENORM_MIN1, 100.0##L2); \
104 CHECK (ai == MIN1 * 64.0##L1); \
105 const type aj = fn (MIN1 * 64.0##L1, 100.0##L2); \
106 CHECK (aj == MIN1 * 64.0##L1 + 64.0##L1 * DENORM_MIN1); \
107 const type ak = fn (MIN1 * 64.0##L1 + DENORM_MIN1 * 64.0##L1, 1024.0##L2); \
108 CHECK (ak == MIN1 * 64.0##L1 + 128.0##L1 * DENORM_MIN1); \
109 const type al = fn (128.0##L1, 128.0##L2); \
110 CHECK (al == 128.0##L1); \
111 const type am = fn (128.0##L1, 129.0##L2); \
112 CHECK (am == 128.0##L1 + 128.0##L1 * EPSILON1); \
113 const type an = fn (-128.0##L1 + -128.0##L1 * EPSILON1, -130.0##L2); \
114 CHECK (an == -128.0##L1 - 256.0##L1 * EPSILON1); \
115 const type ao = fn (128.0##L1 + 256.0##L1 * EPSILON1, 256.0##L2); \
116 CHECK (ao == 128.0##L1 + 384.0##L1 * EPSILON1); \
117 const type ap = fn (128.0##L1 + 384.0##L1 * EPSILON1, -0.0##L2); \
118 CHECK (ap == 128.0##L1 + 256.0##L1 * EPSILON1); \
119 const type aq = fn (128.0##L1 + 256.0##L1 * EPSILON1, 1.0##L2); \
120 CHECK (aq == 128.0##L1 + 128.0##L1 * EPSILON1); \
121 const type ar = fn (128.0##L1 + 128.0##L1 * EPSILON1, 0.0##L2); \
122 CHECK (ar == 128.0##L1); \
123 const type as = fn (128.0##L1, 0.0##L2); \
124 CHECK (as == 128.0##L1 - 64.0##L1 * EPSILON1); \
125 const type at = fn (128.0##L1 - 64.0##L1 * EPSILON1, 5.0##L2); \
126 CHECK (at == 128.0##L1 - 128.0##L1 * EPSILON1); \
129 TEST (test1, nextafterf, float, F, F, f, f, __FLT_MIN__, __FLT_MAX__,
130 __FLT_DENORM_MIN__, __FLT_EPSILON__, __FLT_MIN__, __FLT_MAX__,
131 __FLT_DENORM_MIN__)
132 TEST (test2, nextafter, double, , , , , __DBL_MIN__, __DBL_MAX__,
133 __DBL_DENORM_MIN__, __DBL_EPSILON__, __DBL_MIN__, __DBL_MAX__,
134 __DBL_DENORM_MIN__)
135 #if !NO_LONG_DOUBLE
136 TEST (test3, nextafterl, long double, L, L, l, l, __LDBL_MIN__, __LDBL_MAX__,
137 __LDBL_DENORM_MIN__, __LDBL_EPSILON__, __LDBL_MIN__, __LDBL_MAX__,
138 __LDBL_DENORM_MIN__)
139 TEST (test4, nexttowardf, float, F, L, f, l, __FLT_MIN__, __FLT_MAX__,
140 __FLT_DENORM_MIN__, __FLT_EPSILON__, __LDBL_MIN__, __LDBL_MAX__,
141 __LDBL_DENORM_MIN__)
142 TEST (test5, nexttoward, double, , L, , l, __DBL_MIN__, __DBL_MAX__,
143 __DBL_DENORM_MIN__, __DBL_EPSILON__, __LDBL_MIN__, __LDBL_MAX__,
144 __LDBL_DENORM_MIN__)
145 TEST (test6, nexttowardl, long double, L, L, l, l, __LDBL_MIN__, __LDBL_MAX__,
146 __LDBL_DENORM_MIN__, __LDBL_EPSILON__, __LDBL_MIN__, __LDBL_MAX__,
147 __LDBL_DENORM_MIN__)
148 #endif
151 main ()
153 test1 ();
154 test2 ();
155 #if !NO_LONG_DOUBLE
156 test3 ();
157 test4 ();
158 test5 ();
159 test6 ();
160 #endif
161 return 0;