Skip to content

Commit

Permalink
Only use [[maybe_unused]] with C++17 and later (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinmoene committed Dec 10, 2024
1 parent 3f1c9cc commit 3296995
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions test/expected.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
#define nsel_CONFIG_CONFIRMS_COMPILATION_ERRORS 0
#endif

#define nsel_HAVE_MAYBE_UNUSED nsel_CPP17_000

#if nsel_HAVE_MAYBE_UNUSED
# define nsel_MAYBE_UNUSED [[maybe_unused]]
#else
# define nsel_MAYBE_UNUSED /*[[maybe_unused]]*/
#endif

// Suppress:
// - unused parameter, for cases without assertions such as [.std...]
#if defined(__clang__)
Expand Down Expand Up @@ -607,7 +615,7 @@ CASE( "make_unexpected_from_current_exception(): Allows to create an unexpected_
CASE( "unexpected: C++17 and later provide unexpected_type as unexpected" )
{
#if nsel_CPP17_OR_GREATER || nsel_COMPILER_MSVC_VERSION > 141
[[maybe_unused]] nonstd::unexpected<int> u{7};
nsel_MAYBE_UNUSED nonstd::unexpected<int> u{7};
#else
EXPECT( !!"unexpected is not available (no C++17)." );
#endif
Expand Down Expand Up @@ -2281,7 +2289,7 @@ CASE( "invoke" )

struct nullopt_t{};

[[maybe_unused]] const nullopt_t nullopt{};
nsel_MAYBE_UNUSED const nullopt_t nullopt{};

/// optional expressed in expected

Expand Down

0 comments on commit 3296995

Please sign in to comment.