diff options
author | Eric Fiselier <eric@efcs.ca> | 2016-10-12 09:48:44 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2016-10-12 09:48:44 +0000 |
commit | 1c3203a2c15ceef01765c47ae910a6d61f8286c8 (patch) | |
tree | 9132b406a43e28337959f4cfd00c7ce4edd2113f | |
parent | 757a69b76017994e9f049c70c42a88f07ff15917 (diff) | |
download | bcm5719-llvm-1c3203a2c15ceef01765c47ae910a6d61f8286c8.tar.gz bcm5719-llvm-1c3203a2c15ceef01765c47ae910a6d61f8286c8.zip |
Fix more C++11 constexpr issues in the tests
llvm-svn: 283996
-rw-r--r-- | libcxx/test/support/archetypes.hpp | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/libcxx/test/support/archetypes.hpp b/libcxx/test/support/archetypes.hpp index b9b2853dc6b..96933fa4882 100644 --- a/libcxx/test/support/archetypes.hpp +++ b/libcxx/test/support/archetypes.hpp @@ -138,27 +138,42 @@ struct ValueBase { explicit constexpr ValueBase(std::initializer_list<int>& il, int y = 0) : value(il.size()) {} template <bool Dummy = true, typename std::enable_if<Dummy && !Explicit, bool>::type = true> constexpr ValueBase(std::initializer_list<int>& il, int y = 0) : value(il.size()) {} - constexpr ValueBase& operator=(int xvalue) noexcept { + TEST_CONSTEXPR_CXX14 ValueBase& operator=(int xvalue) noexcept { value = xvalue; return *this; } //~ValueBase() { assert(value != -999); value = -999; } int value; protected: - constexpr ValueBase() noexcept : value(0) {} - constexpr ValueBase(ValueBase const& o) noexcept : value(o.value) { - assert(o.value != -1); assert(o.value != -999); + constexpr static int check_value(int const& val) { +#if TEST_STD_VER < 14 + return val == -1 || val == 999 ? TEST_THROW(42) : val; +#else + assert(val != -1); assert(val != 999); + return val; +#endif } - constexpr ValueBase(ValueBase && o) noexcept : value(o.value) { - assert(o.value != -1); assert(o.value != -999); - o.value = -1; + constexpr static int check_value(int& val, int val_cp = 0) { +#if TEST_STD_VER < 14 + return val_cp = val, val = -1, (val_cp == -1 || val_cp == 999 ? TEST_THROW(42) : val_cp); +#else + assert(val != -1); assert(val != 999); + val_cp = val; + val = -1; + return val_cp; +#endif + } + constexpr ValueBase() noexcept : value(0) {} + constexpr ValueBase(ValueBase const& o) noexcept : value(check_value(o.value)) { + } + constexpr ValueBase(ValueBase && o) noexcept : value(check_value(o.value)) { } - constexpr ValueBase& operator=(ValueBase const& o) noexcept { + TEST_CONSTEXPR_CXX14 ValueBase& operator=(ValueBase const& o) noexcept { assert(o.value != -1); assert(o.value != -999); value = o.value; return *this; } - constexpr ValueBase& operator=(ValueBase&& o) noexcept { + TEST_CONSTEXPR_CXX14 ValueBase& operator=(ValueBase&& o) noexcept { assert(o.value != -1); assert(o.value != -999); value = o.value; o.value = -1; |