Skip to content

Commit 3296995

Browse files
committed
Only use [[maybe_unused]] with C++17 and later (#73)
1 parent 3f1c9cc commit 3296995

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

test/expected.t.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
#define nsel_CONFIG_CONFIRMS_COMPILATION_ERRORS 0
1616
#endif
1717

18+
#define nsel_HAVE_MAYBE_UNUSED nsel_CPP17_000
19+
20+
#if nsel_HAVE_MAYBE_UNUSED
21+
# define nsel_MAYBE_UNUSED [[maybe_unused]]
22+
#else
23+
# define nsel_MAYBE_UNUSED /*[[maybe_unused]]*/
24+
#endif
25+
1826
// Suppress:
1927
// - unused parameter, for cases without assertions such as [.std...]
2028
#if defined(__clang__)
@@ -607,7 +615,7 @@ CASE( "make_unexpected_from_current_exception(): Allows to create an unexpected_
607615
CASE( "unexpected: C++17 and later provide unexpected_type as unexpected" )
608616
{
609617
#if nsel_CPP17_OR_GREATER || nsel_COMPILER_MSVC_VERSION > 141
610-
[[maybe_unused]] nonstd::unexpected<int> u{7};
618+
nsel_MAYBE_UNUSED nonstd::unexpected<int> u{7};
611619
#else
612620
EXPECT( !!"unexpected is not available (no C++17)." );
613621
#endif
@@ -2281,7 +2289,7 @@ CASE( "invoke" )
22812289

22822290
struct nullopt_t{};
22832291

2284-
[[maybe_unused]] const nullopt_t nullopt{};
2292+
nsel_MAYBE_UNUSED const nullopt_t nullopt{};
22852293

22862294
/// optional expressed in expected
22872295

0 commit comments

Comments
 (0)