diff options
Diffstat (limited to 'src/mongo/platform')
-rw-r--r-- | src/mongo/platform/compiler.h | 7 | ||||
-rw-r--r-- | src/mongo/platform/compiler_gcc.h | 3 | ||||
-rw-r--r-- | src/mongo/platform/compiler_msvc.h | 1 |
3 files changed, 11 insertions, 0 deletions
diff --git a/src/mongo/platform/compiler.h b/src/mongo/platform/compiler.h index af3e0b20dc3..713cb11379d 100644 --- a/src/mongo/platform/compiler.h +++ b/src/mongo/platform/compiler.h @@ -150,6 +150,13 @@ * Tells the compiler that a class defines a type for which checking results is necessary. Types * thus defined turn functions returning them into "must check results" style functions. Preview * of the `[[nodiscard]]` C++17 attribute. + * + * + * MONGO_WARN_UNUSED_RESULT_FUNCTION + * + * Tells the compiler that a function returns a value for which consuming the result is + * necessary. Functions thus defined are "must check results" style functions. Preview of the + * `[[nodiscard]]` C++17 attribute. */ diff --git a/src/mongo/platform/compiler_gcc.h b/src/mongo/platform/compiler_gcc.h index a58a72a2d11..913dace45a0 100644 --- a/src/mongo/platform/compiler_gcc.h +++ b/src/mongo/platform/compiler_gcc.h @@ -45,6 +45,7 @@ // MONGO_WARN_UNUSED_RESULT is only supported in the semantics we want for classes in Clang, not in // GCC < 7. #define MONGO_WARN_UNUSED_RESULT_CLASS [[gnu::warn_unused_result]] +#define MONGO_WARN_UNUSED_RESULT_FUNCTION [[gnu::warn_unused_result]] #else #define MONGO_COMPILER_COLD_FUNCTION __attribute__((__cold__)) #define MONGO_COMPILER_NORETURN __attribute__((__noreturn__, __cold__)) @@ -52,8 +53,10 @@ // GCC 7 added support for [[nodiscard]] with the semantics we want. #if defined(__has_cpp_attribute) && __has_cpp_attribute(nodiscard) #define MONGO_WARN_UNUSED_RESULT_CLASS [[nodiscard]] +#define MONGO_WARN_UNUSED_RESULT_FUNCTION [[nodiscard]] #else #define MONGO_WARN_UNUSED_RESULT_CLASS +#define MONGO_WARN_UNUSED_RESULT_FUNCTION [[gnu::warn_unused_result]] #endif #endif diff --git a/src/mongo/platform/compiler_msvc.h b/src/mongo/platform/compiler_msvc.h index e9e2bfa86ef..9c872256d4d 100644 --- a/src/mongo/platform/compiler_msvc.h +++ b/src/mongo/platform/compiler_msvc.h @@ -51,6 +51,7 @@ #define MONGO_COMPILER_API_IMPORT __declspec(dllimport) #define MONGO_WARN_UNUSED_RESULT_CLASS +#define MONGO_WARN_UNUSED_RESULT_FUNCTION #ifdef _M_IX86 // 32-bit x86 supports multiple of calling conventions. We build supporting the cdecl convention |