diff options
| author | Marshall Clow <mclow.lists@gmail.com> | 2019-07-01 23:16:46 +0000 |
|---|---|---|
| committer | Marshall Clow <mclow.lists@gmail.com> | 2019-07-01 23:16:46 +0000 |
| commit | 491ddc00ae7041b01ab00be18dbe7c39d09f94a1 (patch) | |
| tree | 733b5f98d7d9472ed4288a43ea98866a641a9205 /libcxx/test | |
| parent | a7f00941efd740bc6eafc32307b9d92564785f85 (diff) | |
| download | bcm5719-llvm-491ddc00ae7041b01ab00be18dbe7c39d09f94a1.tar.gz bcm5719-llvm-491ddc00ae7041b01ab00be18dbe7c39d09f94a1.zip | |
Add a private call '__libcpp_is_constant_evaluated' which 'works' for old language versions and w/o any compiler support. 'Working', in this case, means that it returns false in those cases.
llvm-svn: 364873
Diffstat (limited to 'libcxx/test')
| -rw-r--r-- | libcxx/test/libcxx/type_traits/is_constant_evaluated.pass.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/libcxx/test/libcxx/type_traits/is_constant_evaluated.pass.cpp b/libcxx/test/libcxx/type_traits/is_constant_evaluated.pass.cpp new file mode 100644 index 00000000000..157d913ccfe --- /dev/null +++ b/libcxx/test/libcxx/type_traits/is_constant_evaluated.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// + +// <type_traits> + +// __libcpp_is_constant_evaluated() + +// returns false when there's no constant evaluation support from the compiler. +// as well as when called not in a constexpr context + +#include <type_traits> +#include <cassert> + +#include "test_macros.h" + +int main (int, char**) { + ASSERT_SAME_TYPE(decltype(std::__libcpp_is_constant_evaluated()), bool); + ASSERT_NOEXCEPT(std::__libcpp_is_constant_evaluated()); + +#if !defined(_LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED) && !defined(_LIBCPP_CXX03_LANG) + static_assert(std::__libcpp_is_constant_evaluated(), ""); +#endif + + bool p = std::__libcpp_is_constant_evaluated(); + assert(!p); + + return 0; + } |

