Add [[nodiscard]] attribute to hipError_t in C++17 mode

This will yield a compiler warning any time you discard an error
return value from an API call.


[ROCm/hip commit: 1d205ab130]
This commit is contained in:
Chris Kitching
2017-10-19 13:34:02 +01:00
parent 65497bfaff
commit 49feb372f5
+10 -1
View File
@@ -143,6 +143,13 @@ typedef struct hipPointerAttribute_t {
*
*/
// Ignoring error-code return values from hip APIs is discouraged. On C++17,
// we can make that yield a warning
#if __cplusplus >= 201703L
#define __HIP_NODISCARD [[nodiscard]]
#else
#define __HIP_NODISCARD
#endif
/*
* @brief hipError_t
@@ -152,7 +159,7 @@ typedef struct hipPointerAttribute_t {
// Developer note - when updating these, update the hipErrorName and hipErrorString functions in NVCC and HCC paths
// Also update the hipCUDAErrorTohipError function in NVCC path.
typedef enum hipError_t {
typedef enum __HIP_NODISCARD hipError_t {
hipSuccess = 0, ///< Successful completion.
hipErrorOutOfMemory = 2,
hipErrorNotInitialized = 3,
@@ -219,6 +226,8 @@ typedef enum hipError_t {
hipErrorTbd ///< Marker that more error codes are needed.
} hipError_t;
#undef __HIP_NODISCARD
/*
* @brief hipDeviceAttribute_t
* @enum