@@ -551,9 +551,23 @@ inline void lwt_init()
551551#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) )
552552#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) )
553553
554+
555+ #if !defined(BOOST_MSVC) || (BOOST_MSVC > 1900)
556+ // The usual idiom for multiline macros. But disabled for MSVC 2025
557+ // and earlier, which would emit a "conditional expression is constant"
558+ // warning that we could not silence with a _Pragma, despite this being
559+ // the same thing described here:
560+ //
561+ // <https://learn.microsoft.com/en-us/cpp/preprocessor/pragma-directives-and-the-pragma-keyword?view=msvc-140>.
562+ //
563+ #define BOOST_LWT_DETAIL_DO_WHILE_FALSE ( x ) do { x } while (false )
564+ #else
565+ #define BOOST_LWT_DETAIL_DO_WHILE_FALSE ( x ) x
566+ #endif
567+
554568#ifndef BOOST_NO_EXCEPTIONS
555569 #define BOOST_TEST_THROWS ( EXPR, EXCEP ) \
556- do { \
570+ BOOST_LWT_DETAIL_DO_WHILE_FALSE ( \
557571 try { \
558572 EXPR; \
559573 ::boost::detail::throw_failed_impl \
@@ -566,15 +580,15 @@ inline void lwt_init()
566580 ::boost::detail::throw_failed_impl \
567581 (#EXPR, #EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
568582 } \
569- } while ( false )
583+ )
570584 //
571585#else
572- #define BOOST_TEST_THROWS ( EXPR, EXCEP ) do {} while ( false )
586+ #define BOOST_TEST_THROWS ( EXPR, EXCEP ) BOOST_LWT_DETAIL_DO_WHILE_FALSE( static_cast < void >( 0 ) )
573587#endif
574588
575589#ifndef BOOST_NO_EXCEPTIONS
576590# define BOOST_TEST_NO_THROW (EXPR ) \
577- do { \
591+ BOOST_LWT_DETAIL_DO_WHILE_FALSE ( \
578592 try { \
579593 EXPR; \
580594 } catch (const std::exception& e) { \
@@ -584,10 +598,10 @@ inline void lwt_init()
584598 ::boost::detail::no_throw_failed_impl \
585599 (#EXPR, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
586600 } \
587- } while ( false )
601+ )
588602 //
589603#else
590- # define BOOST_TEST_NO_THROW (EXPR ) do { EXPR; } while ( false )
604+ # define BOOST_TEST_NO_THROW (EXPR ) BOOST_LWT_DETAIL_DO_WHILE_FALSE( EXPR; )
591605#endif
592606
593607#endif // #ifndef BOOST_CORE_LIGHTWEIGHT_TEST_HPP
0 commit comments