[libcxx] r304883 - Fix test with exceptions disabled

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 7 02:06:05 PDT 2017


Author: ericwf
Date: Wed Jun  7 04:06:05 2017
New Revision: 304883

URL: http://llvm.org/viewvc/llvm-project?rev=304883&view=rev
Log:
Fix test with exceptions disabled

Modified:
    libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp

Modified: libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp?rev=304883&r1=304882&r2=304883&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp Wed Jun  7 04:06:05 2017
@@ -107,35 +107,6 @@ struct CopyDoesThrow {
   CopyDoesThrow &operator=(const CopyDoesThrow &) noexcept(false);
 };
 
-#ifndef TEST_HAS_NO_EXCEPTIONS
-struct CopyThrows {
-  CopyThrows() = default;
-  CopyThrows(const CopyThrows &) { throw 42; }
-  CopyThrows &operator=(const CopyThrows &) { throw 42; }
-};
-
-struct CopyCannotThrow {
-  static int alive;
-  CopyCannotThrow() { ++alive; }
-  CopyCannotThrow(const CopyCannotThrow &) noexcept { ++alive; }
-  CopyCannotThrow(CopyCannotThrow &&) noexcept { assert(false); }
-  CopyCannotThrow &operator=(const CopyCannotThrow &) noexcept = default;
-  CopyCannotThrow &operator=(CopyCannotThrow &&) noexcept { assert(false); return *this; }
-};
-
-int CopyCannotThrow::alive = 0;
-
-struct MoveThrows {
-  static int alive;
-  MoveThrows() { ++alive; }
-  MoveThrows(const MoveThrows &) { ++alive; }
-  MoveThrows(MoveThrows &&) { throw 42; }
-  MoveThrows &operator=(const MoveThrows &) { return *this; }
-  MoveThrows &operator=(MoveThrows &&) { throw 42; }
-  ~MoveThrows() { --alive; }
-};
-
-int MoveThrows::alive = 0;
 
 struct NTCopyAssign {
   constexpr NTCopyAssign(int v) : value(v) {}
@@ -178,6 +149,36 @@ struct TCopyAssignNTMoveAssign {
 
 static_assert(std::is_trivially_copy_assignable_v<TCopyAssignNTMoveAssign>, "");
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
+struct CopyThrows {
+  CopyThrows() = default;
+  CopyThrows(const CopyThrows &) { throw 42; }
+  CopyThrows &operator=(const CopyThrows &) { throw 42; }
+};
+
+struct CopyCannotThrow {
+  static int alive;
+  CopyCannotThrow() { ++alive; }
+  CopyCannotThrow(const CopyCannotThrow &) noexcept { ++alive; }
+  CopyCannotThrow(CopyCannotThrow &&) noexcept { assert(false); }
+  CopyCannotThrow &operator=(const CopyCannotThrow &) noexcept = default;
+  CopyCannotThrow &operator=(CopyCannotThrow &&) noexcept { assert(false); return *this; }
+};
+
+int CopyCannotThrow::alive = 0;
+
+struct MoveThrows {
+  static int alive;
+  MoveThrows() { ++alive; }
+  MoveThrows(const MoveThrows &) { ++alive; }
+  MoveThrows(MoveThrows &&) { throw 42; }
+  MoveThrows &operator=(const MoveThrows &) { return *this; }
+  MoveThrows &operator=(MoveThrows &&) { throw 42; }
+  ~MoveThrows() { --alive; }
+};
+
+int MoveThrows::alive = 0;
+
 struct MakeEmptyT {
   static int alive;
   MakeEmptyT() { ++alive; }




More information about the cfe-commits mailing list