libcxx

libcxx mirror with random patches
git clone https://git.neptards.moe/neptards/libcxx.git
Log | Files | Refs

constexpr-fns.pass.cpp (1173B)


      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 // Check that the overloads of std::__libcpp_{isnan,isinf,isfinite} that take
     11 // floating-point values are evaluatable from constexpr contexts.
     12 //
     13 // These functions need to be constexpr in order to be called from CUDA, see
     14 // https://reviews.llvm.org/D25403.  They don't actually need to be
     15 // constexpr-evaluatable, but that's what we check here, since we can't check
     16 // true constexpr-ness.
     17 //
     18 // This fails with gcc because __builtin_isnan and friends, which libcpp_isnan
     19 // and friends call, are not themselves constexpr-evaluatable.
     20 //
     21 // UNSUPPORTED: c++98, c++03
     22 // XFAIL: gcc
     23 
     24 #include <cmath>
     25 
     26 static_assert(std::__libcpp_isnan_or_builtin(0.) == false, "");
     27 static_assert(std::__libcpp_isinf_or_builtin(0.0) == false, "");
     28 static_assert(std::__libcpp_isfinite_or_builtin(0.0) == true, "");
     29 
     30 int main()
     31 {
     32 }