[libcxx] r280777 - Improve constexpr tests for std::any
Eric Fiselier via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 6 19:38:48 PDT 2016
Author: ericwf
Date: Tue Sep 6 21:38:48 2016
New Revision: 280777
URL: http://llvm.org/viewvc/llvm-project?rev=280777&view=rev
Log:
Improve constexpr tests for std::any
Modified:
libcxx/trunk/test/std/utilities/any/any.class/any.cons/default.pass.cpp
Modified: libcxx/trunk/test/std/utilities/any/any.class/any.cons/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/any/any.class/any.cons/default.pass.cpp?rev=280777&r1=280776&r2=280777&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/any/any.class/any.cons/default.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/any/any.class/any.cons/default.pass.cpp Tue Sep 6 21:38:48 2016
@@ -21,15 +21,6 @@
#include "any_helpers.h"
#include "count_new.hpp"
-#if TEST_HAS_BUILTIN_IDENTIFIER(__has_constant_initializer)
-// std::any must have a constexpr default constructor, but it's a non-literal
-// type so we can't create a constexpr variable. This tests that we actually
-// get 'constant initialization'.
-std::any a;
-static_assert(__has_constant_initializer(a),
- "any must be constant initializable");
-#endif
-
int main()
{
using std::any;
@@ -40,6 +31,15 @@ int main()
);
}
{
+ struct TestConstexpr : public std::any {
+ constexpr TestConstexpr() : std::any() {}
+ };
+#ifdef _LIBCPP_SAFE_STATIC
+ _LIBCPP_SAFE_STATIC static std::any a;
+ ((void)a);
+#endif
+ }
+ {
DisableAllocationGuard g; ((void)g);
any const a;
assertEmpty(a);
More information about the cfe-commits
mailing list