c++, coroutines: Simplify separation of the user function body and ramp.
[official-gcc.git] / gcc / testsuite / g++.dg / cpp1y / constexpr-50060.C
blob4ac27a349a0168b11f3adcad39e79cb8cbcb13ea
1 // PR c++/50060
2 // { dg-do compile { target c++14 } }
4 // sincos and lgamma_r aren't available in -std=c++14,
5 // only in -std=gnu++14.  Use __builtin_* in that case.
6 extern "C" void sincos (double, double *, double *);
7 extern "C" double frexp (double, int *);
8 extern "C" double modf (double, double *);
9 extern "C" double remquo (double, double, int *);
10 extern "C" double lgamma_r (double, int *);
12 constexpr double
13 f0 (double x)
15   double y {};
16   double z {};
17   __builtin_sincos (x, &y, &z);
18   return y;
21 constexpr double
22 f1 (double x)
24   double y {};
25   double z {};
26   __builtin_sincos (x, &y, &z);
27   return z;
30 constexpr double
31 f2 (double x)
33   int y {};
34   return frexp (x, &y);
37 constexpr int
38 f3 (double x)
40   int y {};
41   frexp (x, &y);
42   return y;
45 constexpr double
46 f4 (double x)
48   double y {};
49   return modf (x, &y);
52 constexpr double
53 f5 (double x)
55   double y {};
56   modf (x, &y);
57   return y;
60 constexpr double
61 f6 (double x, double y)
63   int z {};
64   return remquo (x, y, &z);
67 constexpr int
68 f7 (double x, double y)
70   int z {};
71   remquo (x, y, &z);
72   return z;
75 constexpr double
76 f8 (double x)
78   int y {};
79   return __builtin_lgamma_r (x, &y);
82 constexpr int
83 f9 (double x)
85   int y {};
86   __builtin_lgamma_r (x, &y);
87   return y;
90 static_assert (f0 (0.0) == 0.0, "");
91 static_assert (f1 (0.0) == 1.0, "");
92 static_assert (f2 (6.5) == 0.8125, "");
93 static_assert (f3 (6.5) == 3, "");
94 static_assert (f4 (-7.25) == -0.25, "");
95 static_assert (f5 (-7.25) == -7.0, "");
96 static_assert (f6 (3.0, 2.0) == -1.0, "");
97 static_assert (f7 (3.0, 2.0) == 2, "");
98 static_assert (f8 (0.75) >= 0.20 && f8 (0.75) <= 0.21, "");
99 static_assert (f8 (0.75) >= 0.20 && f8 (0.75) <= 0.21, "");
100 static_assert (f9 (0.75) == 1, "");