From 0dabd951ba115f682e387d72f7f9866de824db0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Tue, 31 Jan 2017 18:02:11 +0100 Subject: [PATCH] expr is now cast to void in THROWS family of assertions. This prevents Clang from complaining about unused value in expressions containing explicit casts used in the THROW assertion macro family. Example: `REQUIRE_THROWS_AS(static_cast(object), std::bad_cast);` would trigger `-Wunused-value` warning. Now it does not. Credits to Arto Bendiken, who submitted a PR almost 3 years ago, but his branch has since died and I was unable to merge it. --- include/internal/catch_capture.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp index 5d6a97ae..04be7016 100644 --- a/include/internal/catch_capture.hpp +++ b/include/internal/catch_capture.hpp @@ -58,7 +58,7 @@ do { \ Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \ try { \ - expr; \ + static_cast(expr); \ __catchResult.captureResult( Catch::ResultWas::Ok ); \ } \ catch( ... ) { \ @@ -73,7 +73,7 @@ Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition, #matcher ); \ if( __catchResult.allowThrows() ) \ try { \ - expr; \ + static_cast(expr); \ __catchResult.captureResult( Catch::ResultWas::DidntThrowException ); \ } \ catch( ... ) { \ @@ -90,7 +90,7 @@ Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \ if( __catchResult.allowThrows() ) \ try { \ - expr; \ + static_cast(expr); \ __catchResult.captureResult( Catch::ResultWas::DidntThrowException ); \ } \ catch( exceptionType ) { \