diff options
Diffstat (limited to 'test/libcxx/numerics/c.math/constexpr-fns.pass.cpp')
-rw-r--r-- | test/libcxx/numerics/c.math/constexpr-fns.pass.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/libcxx/numerics/c.math/constexpr-fns.pass.cpp b/test/libcxx/numerics/c.math/constexpr-fns.pass.cpp new file mode 100644 index 0000000000000..9123be1f09907 --- /dev/null +++ b/test/libcxx/numerics/c.math/constexpr-fns.pass.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// Check that the overloads of std::__libcpp_{isnan,isinf,isfinite} that take +// floating-point values are evaluatable from constexpr contexts. +// +// These functions need to be constexpr in order to be called from CUDA, see +// https://reviews.llvm.org/D25403. They don't actually need to be +// constexpr-evaluatable, but that's what we check here, since we can't check +// true constexpr-ness. +// +// This fails with gcc because __builtin_isnan and friends, which libcpp_isnan +// and friends call, are not themselves constexpr-evaluatable. +// +// UNSUPPORTED: c++98, c++03 +// XFAIL: gcc + +#include <cmath> + +static_assert(std::__libcpp_isnan(0.) == false, ""); +static_assert(std::__libcpp_isinf(0.0) == false, ""); +static_assert(std::__libcpp_isfinite(0.0) == true, ""); + +int main() +{ +} |