1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // UNSUPPORTED: newlib
10 
11 // <cfenv>
12 
13 #include <cfenv>
14 #include <type_traits>
15 
16 #include "test_macros.h"
17 
18 #ifndef FE_DIVBYZERO
19 #error FE_DIVBYZERO not defined
20 #endif
21 
22 #ifndef FE_INEXACT
23 #error FE_INEXACT not defined
24 #endif
25 
26 #ifndef FE_INVALID
27 #error FE_INVALID not defined
28 #endif
29 
30 #ifndef FE_OVERFLOW
31 #error FE_OVERFLOW not defined
32 #endif
33 
34 #ifndef FE_UNDERFLOW
35 #error FE_UNDERFLOW not defined
36 #endif
37 
38 #ifndef FE_ALL_EXCEPT
39 #error FE_ALL_EXCEPT not defined
40 #endif
41 
42 #ifndef FE_DOWNWARD
43 #error FE_DOWNWARD not defined
44 #endif
45 
46 #ifndef FE_TONEAREST
47 #error FE_TONEAREST not defined
48 #endif
49 
50 #ifndef FE_TOWARDZERO
51 #error FE_TOWARDZERO not defined
52 #endif
53 
54 #ifndef FE_UPWARD
55 #error FE_UPWARD not defined
56 #endif
57 
58 #ifndef FE_DFL_ENV
59 #error FE_DFL_ENV not defined
60 #endif
61 
62 int main(int, char**)
63 {
64     std::fenv_t fenv;
65     std::fexcept_t fex;
66     ((void)fenv); // Prevent unused warning
67     ((void)fex); // Prevent unused warning
68     static_assert((std::is_same<decltype(std::feclearexcept(0)), int>::value), "");
69     static_assert((std::is_same<decltype(std::fegetexceptflag(&fex, 0)), int>::value), "");
70     static_assert((std::is_same<decltype(std::feraiseexcept(0)), int>::value), "");
71     static_assert((std::is_same<decltype(std::fesetexceptflag(&fex, 0)), int>::value), "");
72     static_assert((std::is_same<decltype(std::fetestexcept(0)), int>::value), "");
73     static_assert((std::is_same<decltype(std::fegetround()), int>::value), "");
74     static_assert((std::is_same<decltype(std::fesetround(0)), int>::value), "");
75     static_assert((std::is_same<decltype(std::fegetenv(&fenv)), int>::value), "");
76     static_assert((std::is_same<decltype(std::feholdexcept(&fenv)), int>::value), "");
77     static_assert((std::is_same<decltype(std::fesetenv(&fenv)), int>::value), "");
78     static_assert((std::is_same<decltype(std::feupdateenv(&fenv)), int>::value), "");
79 
80   return 0;
81 }
82