brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · e6244c7 Raw
84 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// Picolibc does not define some of the floating point environment macros for10// arm platforms without hardware floating point support.11// UNSUPPORTED: LIBCXX-PICOLIBC-FIXME12 13// <cfenv>14 15#include <cfenv>16#include <type_traits>17 18#include "test_macros.h"19 20#ifndef FE_DIVBYZERO21#error FE_DIVBYZERO not defined22#endif23 24#ifndef FE_INEXACT25#error FE_INEXACT not defined26#endif27 28#ifndef FE_INVALID29#error FE_INVALID not defined30#endif31 32#ifndef FE_OVERFLOW33#error FE_OVERFLOW not defined34#endif35 36#ifndef FE_UNDERFLOW37#error FE_UNDERFLOW not defined38#endif39 40#ifndef FE_ALL_EXCEPT41#error FE_ALL_EXCEPT not defined42#endif43 44#ifndef FE_DOWNWARD45#error FE_DOWNWARD not defined46#endif47 48#ifndef FE_TONEAREST49#error FE_TONEAREST not defined50#endif51 52#ifndef FE_TOWARDZERO53#error FE_TOWARDZERO not defined54#endif55 56#ifndef FE_UPWARD57#error FE_UPWARD not defined58#endif59 60#ifndef FE_DFL_ENV61#error FE_DFL_ENV not defined62#endif63 64int main(int, char**)65{66    std::fenv_t fenv;67    std::fexcept_t fex;68    ((void)fenv); // Prevent unused warning69    ((void)fex); // Prevent unused warning70    static_assert((std::is_same<decltype(std::feclearexcept(0)), int>::value), "");71    static_assert((std::is_same<decltype(std::fegetexceptflag(&fex, 0)), int>::value), "");72    static_assert((std::is_same<decltype(std::feraiseexcept(0)), int>::value), "");73    static_assert((std::is_same<decltype(std::fesetexceptflag(&fex, 0)), int>::value), "");74    static_assert((std::is_same<decltype(std::fetestexcept(0)), int>::value), "");75    static_assert((std::is_same<decltype(std::fegetround()), int>::value), "");76    static_assert((std::is_same<decltype(std::fesetround(0)), int>::value), "");77    static_assert((std::is_same<decltype(std::fegetenv(&fenv)), int>::value), "");78    static_assert((std::is_same<decltype(std::feholdexcept(&fenv)), int>::value), "");79    static_assert((std::is_same<decltype(std::fesetenv(&fenv)), int>::value), "");80    static_assert((std::is_same<decltype(std::feupdateenv(&fenv)), int>::value), "");81 82  return 0;83}84