Skip to content

Commit 3bfeaf4

Browse files
committed
Add nodiscard utility
This just substitutes for `[[nodiscard]]` until we use C++17 -- most modern GNU or GNU-compatible compilers will give us a similar utility in the meantime.
1 parent 467aca9 commit 3bfeaf4

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/util/nodiscard.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*******************************************************************\
2+
3+
Module: No-discard-result macro
4+
5+
Author: Diffblue Ltd.
6+
7+
\*******************************************************************/
8+
9+
/// \file
10+
/// No-discard-result macro
11+
12+
#ifndef CPROVER_TEST_GEN_UTIL_NODISCARD_H
13+
#define CPROVER_TEST_GEN_UTIL_NODISCARD_H
14+
15+
#if __has_cpp_attribute(nodiscard)
16+
#ifdef __clang__
17+
#pragma GCC diagnostic ignored "-Wc++17-extensions"
18+
#endif
19+
#define NODISCARD [[nodiscard]]
20+
#elif __has_cpp_attribute(gnu::warn_unused_result)
21+
#define NODISCARD [[gnu::warn_unused_result]]
22+
#else
23+
#define NODISCARD
24+
#endif
25+
26+
#endif

0 commit comments

Comments
 (0)