philsquared/Catch — pull request #262 by bendiken (2014-03-20 03:22:58+00:00)
Title: Fix -Wunused-value warnings from Clang 3.4 in THROWS/NOTHROW use

This commit fixes annoying `-Wall` compiler warnings that will be emitted when compiling test suites that include any test cases for `std::bad_cast` exceptions being thrown or not thrown, as per the following pattern:

REQUIRE_THROWS_AS((bool)my_object, std::bad_cast);

For example, [these test cases](https://github.com/datagraph/libxsd/blob/master/test/check_boolean.cc#L86) of mine would result in numerous spurious Clang warnings of the kind:

CXX check_boolean.o
check_boolean.cc:86:21: warning: expression result unused [-Wunused-value]
REQUIRE_THROWS_AS((bool)xsd::boolean(""), std::bad_cast);
^ ~~~~~~~~~~~~~~~~
./catch.hpp:8353:76: note: expanded from macro 'REQUIRE_THROWS_AS'
#define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::Normal, "REQUIRE_THROWS_AS" )
^
./catch.hpp:1655:37: note: expanded from macro 'INTERNAL_CATCH_THROWS_AS'
INTERNAL_CATCH_THROWS_IMPL( expr, exceptionType, resultDisposition ) \
^
./catch.hpp:1633:13: note: expanded from macro 'INTERNAL_CATCH_THROWS_IMPL'
expr; \
^

These types of spurious warnings are easily eliminated by just ensuring that Catch casts `expr` to `void`.