fenv_h.pass.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. // XFAIL: newlib
  10. // <fenv.h>
  11. #include <fenv.h>
  12. #include <type_traits>
  13. #ifndef FE_DIVBYZERO
  14. #error FE_DIVBYZERO not defined
  15. #endif
  16. #ifndef FE_INEXACT
  17. #error FE_INEXACT not defined
  18. #endif
  19. #ifndef FE_INVALID
  20. #error FE_INVALID not defined
  21. #endif
  22. #ifndef FE_OVERFLOW
  23. #error FE_OVERFLOW not defined
  24. #endif
  25. #ifndef FE_UNDERFLOW
  26. #error FE_UNDERFLOW not defined
  27. #endif
  28. #ifndef FE_ALL_EXCEPT
  29. #error FE_ALL_EXCEPT not defined
  30. #endif
  31. #ifndef FE_DOWNWARD
  32. #error FE_DOWNWARD not defined
  33. #endif
  34. #ifndef FE_TONEAREST
  35. #error FE_TONEAREST not defined
  36. #endif
  37. #ifndef FE_TOWARDZERO
  38. #error FE_TOWARDZERO not defined
  39. #endif
  40. #ifndef FE_UPWARD
  41. #error FE_UPWARD not defined
  42. #endif
  43. #ifndef FE_DFL_ENV
  44. #error FE_DFL_ENV not defined
  45. #endif
  46. int main(int, char**)
  47. {
  48. fenv_t fenv = {};
  49. fexcept_t fex = 0;
  50. static_assert((std::is_same<decltype(::feclearexcept(0)), int>::value), "");
  51. static_assert((std::is_same<decltype(::fegetexceptflag(&fex, 0)), int>::value), "");
  52. static_assert((std::is_same<decltype(::feraiseexcept(0)), int>::value), "");
  53. static_assert((std::is_same<decltype(::fesetexceptflag(&fex, 0)), int>::value), "");
  54. static_assert((std::is_same<decltype(::fetestexcept(0)), int>::value), "");
  55. static_assert((std::is_same<decltype(::fegetround()), int>::value), "");
  56. static_assert((std::is_same<decltype(::fesetround(0)), int>::value), "");
  57. static_assert((std::is_same<decltype(::fegetenv(&fenv)), int>::value), "");
  58. static_assert((std::is_same<decltype(::feholdexcept(&fenv)), int>::value), "");
  59. static_assert((std::is_same<decltype(::fesetenv(&fenv)), int>::value), "");
  60. static_assert((std::is_same<decltype(::feupdateenv(&fenv)), int>::value), "");
  61. return 0;
  62. }