From 4777321ff2bb4e1a9115ea5e406aa15edb897a45 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 20 Oct 2025 20:27:17 +0300 Subject: [PATCH] Revert "Omit do {} while (false) for MSVC versions prior to 2015" This reverts commit 40fda50ae1d421eab3e45608f019cc81eaee908b. --- include/boost/core/lightweight_test.hpp | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/include/boost/core/lightweight_test.hpp b/include/boost/core/lightweight_test.hpp index 267ba66..b6fba35 100644 --- a/include/boost/core/lightweight_test.hpp +++ b/include/boost/core/lightweight_test.hpp @@ -551,22 +551,9 @@ inline void lwt_init() #define BOOST_TEST_ALL_EQ(begin1, end1, begin2, end2) ( ::boost::detail::test_all_eq_impl(BOOST_LIGHTWEIGHT_TEST_OSTREAM, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, begin1, end1, begin2, end2) ) #define BOOST_TEST_ALL_WITH(begin1, end1, begin2, end2, predicate) ( ::boost::detail::test_all_with_impl(BOOST_LIGHTWEIGHT_TEST_OSTREAM, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, begin1, end1, begin2, end2, predicate) ) -#if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1900) -// The usual idiom for multiline macros. But disabled for MSVC versions -// prior to 2015, which would emit a "conditional expression is constant" -// warning that we could not silence with a _Pragma, despite this being -// the same thing described here: -// -// . -// - #define BOOST_LWT_DETAIL_DO_WHILE_FALSE( x ) do { x } while (false) -#else - #define BOOST_LWT_DETAIL_DO_WHILE_FALSE( x ) x -#endif - #ifndef BOOST_NO_EXCEPTIONS #define BOOST_TEST_THROWS( EXPR, EXCEP ) \ - BOOST_LWT_DETAIL_DO_WHILE_FALSE( \ + do { \ try { \ EXPR; \ ::boost::detail::throw_failed_impl \ @@ -579,15 +566,15 @@ inline void lwt_init() ::boost::detail::throw_failed_impl \ (#EXPR, #EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \ } \ - ) + } while (false) // #else - #define BOOST_TEST_THROWS( EXPR, EXCEP ) BOOST_LWT_DETAIL_DO_WHILE_FALSE((void)0;) + #define BOOST_TEST_THROWS( EXPR, EXCEP ) do {} while (false) #endif #ifndef BOOST_NO_EXCEPTIONS # define BOOST_TEST_NO_THROW(EXPR) \ - BOOST_LWT_DETAIL_DO_WHILE_FALSE( \ + do { \ try { \ EXPR; \ } catch (const std::exception& e) { \ @@ -597,10 +584,10 @@ inline void lwt_init() ::boost::detail::no_throw_failed_impl \ (#EXPR, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \ } \ - ) + } while (false) // #else -# define BOOST_TEST_NO_THROW(EXPR) BOOST_LWT_DETAIL_DO_WHILE_FALSE(EXPR;) +# define BOOST_TEST_NO_THROW(EXPR) do { EXPR; } while (false) #endif #endif // #ifndef BOOST_CORE_LIGHTWEIGHT_TEST_HPP