Skip to content

Commit bc01ebc

Browse files
Intro TEST_MAYBE_UNUSED macro for tests
1 parent 6de976a commit bc01ebc

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

libcxx/test/support/test_macros.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,16 @@ inline Tp const& DoNotOptimize(Tp const& value) {
508508
#define TEST_NO_UNIQUE_ADDRESS
509509
#endif
510510

511+
#if TEST_STD_VER >= 17 && __has_cpp_attribute(maybe_unused)
512+
# define TEST_MAYBE_UNUSED [[maybe_unused]]
513+
#elif __has_cpp_attribute(__maybe_unused__)
514+
# define TEST_MAYBE_UNUSED [[__maybe_unused__]]
515+
#elif __has_cpp_attribute(gnu::unused)
516+
# define TEST_MAYBE_UNUSED [[gnu::unused]]
517+
#else
518+
# define TEST_MAYBE_UNUSED
519+
#endif
520+
511521
#ifdef _LIBCPP_SHORT_WCHAR
512522
# define TEST_SHORT_WCHAR
513523
#endif

0 commit comments

Comments
 (0)