From d08ff53e612c18e7cc3622b0ffb9476353b9d9d9 Mon Sep 17 00:00:00 2001 From: Roelf-Jilling Date: Tue, 14 Jan 2020 17:38:42 +0100 Subject: [PATCH] Use [[maybe_unused]] with C++17 --- tests/CMakeLists.txt | 18 +++++++++++++----- tests/span_tests.cpp | 12 ++++++++++-- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1d74c45..973403f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -57,9 +57,11 @@ if(MSVC) # MSVC or simulating MSVC -Wno-missing-prototypes -Wno-shift-sign-overflow # GTest gtest-port.h -Wno-undef # GTest - -Wno-unused-variable -Wno-used-but-marked-unused # GTest EXPECT_DEATH - $<$:-Wno-unused-member-function> + $<$: # no support for [[maybe_unused]] + -Wno-unused-member-function + -Wno-unused-variable + > > ) else() @@ -85,16 +87,22 @@ else() -Wno-missing-prototypes -Wno-padded -Wno-unknown-attributes - -Wno-unused-variable -Wno-used-but-marked-unused # GTest EXPECT_DEATH - $<$:-Wno-unused-member-function> -Wno-weak-vtables + $<$: # no support for [[maybe_unused]] + -Wno-unused-member-function + -Wno-unused-variable + > > $<$: $<$:-Wno-undefined-func-template> > $<$: - -Wno-unused-variable + $<$,6>>: + $<$: # no support for [[maybe_unused]] + -Wno-unused-variable + > + > > ) endif(MSVC) diff --git a/tests/span_tests.cpp b/tests/span_tests.cpp index d0da49d..20c8bc0 100644 --- a/tests/span_tests.cpp +++ b/tests/span_tests.cpp @@ -1287,7 +1287,11 @@ TEST(span_test, from_array_constructor) auto beyond = s.rend(); EXPECT_TRUE(it != beyond); - EXPECT_DEATH(auto _ = *beyond , deathstring); +#if (__cplusplus > 201402L) + EXPECT_DEATH([[maybe_unused]] auto _ = *beyond , deathstring); +#else + EXPECT_DEATH(auto _ = *beyond , deathstring); +#endif EXPECT_TRUE(beyond - first == 4); EXPECT_TRUE(first - first == 0); @@ -1332,7 +1336,11 @@ TEST(span_test, from_array_constructor) auto beyond = s.crend(); EXPECT_TRUE(it != beyond); - EXPECT_DEATH(auto _ = *beyond, deathstring); +#if (__cplusplus > 201402L) + EXPECT_DEATH([[maybe_unused]] auto _ = *beyond, deathstring); +#else + EXPECT_DEATH(auto _ = *beyond, deathstring); +#endif EXPECT_TRUE(beyond - first == 4); EXPECT_TRUE(first - first == 0);