xref: /aosp_15_r20/external/libcxx/test/libcxx/numerics/c.math/constexpr-fns.pass.cpp (revision 58b9f456b02922dfdb1fad8a988d5fd8765ecb80)
1*58b9f456SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
2*58b9f456SAndroid Build Coastguard Worker //
3*58b9f456SAndroid Build Coastguard Worker //                     The LLVM Compiler Infrastructure
4*58b9f456SAndroid Build Coastguard Worker //
5*58b9f456SAndroid Build Coastguard Worker // This file is dual licensed under the MIT and the University of Illinois Open
6*58b9f456SAndroid Build Coastguard Worker // Source Licenses. See LICENSE.TXT for details.
7*58b9f456SAndroid Build Coastguard Worker //
8*58b9f456SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
9*58b9f456SAndroid Build Coastguard Worker 
10*58b9f456SAndroid Build Coastguard Worker // Check that the overloads of std::__libcpp_{isnan,isinf,isfinite} that take
11*58b9f456SAndroid Build Coastguard Worker // floating-point values are evaluatable from constexpr contexts.
12*58b9f456SAndroid Build Coastguard Worker //
13*58b9f456SAndroid Build Coastguard Worker // These functions need to be constexpr in order to be called from CUDA, see
14*58b9f456SAndroid Build Coastguard Worker // https://reviews.llvm.org/D25403.  They don't actually need to be
15*58b9f456SAndroid Build Coastguard Worker // constexpr-evaluatable, but that's what we check here, since we can't check
16*58b9f456SAndroid Build Coastguard Worker // true constexpr-ness.
17*58b9f456SAndroid Build Coastguard Worker //
18*58b9f456SAndroid Build Coastguard Worker // This fails with gcc because __builtin_isnan and friends, which libcpp_isnan
19*58b9f456SAndroid Build Coastguard Worker // and friends call, are not themselves constexpr-evaluatable.
20*58b9f456SAndroid Build Coastguard Worker //
21*58b9f456SAndroid Build Coastguard Worker // UNSUPPORTED: c++98, c++03
22*58b9f456SAndroid Build Coastguard Worker // XFAIL: gcc
23*58b9f456SAndroid Build Coastguard Worker 
24*58b9f456SAndroid Build Coastguard Worker #include <cmath>
25*58b9f456SAndroid Build Coastguard Worker 
26*58b9f456SAndroid Build Coastguard Worker static_assert(std::__libcpp_isnan_or_builtin(0.) == false, "");
27*58b9f456SAndroid Build Coastguard Worker static_assert(std::__libcpp_isinf_or_builtin(0.0) == false, "");
28*58b9f456SAndroid Build Coastguard Worker static_assert(std::__libcpp_isfinite_or_builtin(0.0) == true, "");
29*58b9f456SAndroid Build Coastguard Worker 
main()30*58b9f456SAndroid Build Coastguard Worker int main()
31*58b9f456SAndroid Build Coastguard Worker {
32*58b9f456SAndroid Build Coastguard Worker }
33