diff options
Diffstat (limited to 'test/CodeGenCXX/builtin-constant-p.cpp')
-rw-r--r-- | test/CodeGenCXX/builtin-constant-p.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/CodeGenCXX/builtin-constant-p.cpp b/test/CodeGenCXX/builtin-constant-p.cpp new file mode 100644 index 000000000000..6d853e8a6828 --- /dev/null +++ b/test/CodeGenCXX/builtin-constant-p.cpp @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -triple=x86_64-linux-gnu -emit-llvm -o - %s + +// Don't crash if the argument to __builtin_constant_p isn't scalar. +template <typename T> +constexpr bool is_constant(const T v) { + return __builtin_constant_p(v); +} + +template <typename T> +class numeric { + public: + using type = T; + + template <typename S> + constexpr numeric(S value) + : value_(static_cast<T>(value)) {} + + private: + const T value_; +}; + +bool bcp() { + return is_constant(numeric<int>(1)); +} |