Home | History | Annotate | Download | only in cfenv.syn
      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 // <cfenv>
     11 
     12 #include <cfenv>
     13 #include <type_traits>
     14 
     15 #ifndef FE_DIVBYZERO
     16 #error FE_DIVBYZERO not defined
     17 #endif
     18 
     19 #ifndef FE_INEXACT
     20 #error FE_INEXACT not defined
     21 #endif
     22 
     23 #ifndef FE_INVALID
     24 #error FE_INVALID not defined
     25 #endif
     26 
     27 #ifndef FE_OVERFLOW
     28 #error FE_OVERFLOW not defined
     29 #endif
     30 
     31 #ifndef FE_UNDERFLOW
     32 #error FE_UNDERFLOW not defined
     33 #endif
     34 
     35 #ifndef FE_ALL_EXCEPT
     36 #error FE_ALL_EXCEPT not defined
     37 #endif
     38 
     39 #ifndef FE_DOWNWARD
     40 #error FE_DOWNWARD not defined
     41 #endif
     42 
     43 #ifndef FE_TONEAREST
     44 #error FE_TONEAREST not defined
     45 #endif
     46 
     47 #ifndef FE_TOWARDZERO
     48 #error FE_TOWARDZERO not defined
     49 #endif
     50 
     51 #ifndef FE_UPWARD
     52 #error FE_UPWARD not defined
     53 #endif
     54 
     55 #ifndef FE_DFL_ENV
     56 #error FE_DFL_ENV not defined
     57 #endif
     58 
     59 int main()
     60 {
     61     std::fenv_t fenv = {0};
     62     std::fexcept_t fex = 0;
     63     static_assert((std::is_same<decltype(std::feclearexcept(0)), int>::value), "");
     64     static_assert((std::is_same<decltype(std::fegetexceptflag(&fex, 0)), int>::value), "");
     65     static_assert((std::is_same<decltype(std::feraiseexcept(0)), int>::value), "");
     66     static_assert((std::is_same<decltype(std::fesetexceptflag(&fex, 0)), int>::value), "");
     67     static_assert((std::is_same<decltype(std::fetestexcept(0)), int>::value), "");
     68     static_assert((std::is_same<decltype(std::fegetround()), int>::value), "");
     69     static_assert((std::is_same<decltype(std::fesetround(0)), int>::value), "");
     70     static_assert((std::is_same<decltype(std::fegetenv(&fenv)), int>::value), "");
     71     static_assert((std::is_same<decltype(std::feholdexcept(&fenv)), int>::value), "");
     72     static_assert((std::is_same<decltype(std::fesetenv(&fenv)), int>::value), "");
     73     static_assert((std::is_same<decltype(std::feupdateenv(&fenv)), int>::value), "");
     74 }
     75