Mesa (main): util: tune signatures of generated enum operators

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri May 14 11:24:37 UTC 2021


Module: Mesa
Branch: main
Commit: a50d5b13be6adbc1a1058d52f49fe5503ab30ff9
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a50d5b13be6adbc1a1058d52f49fe5503ab30ff9

Author: Tony Wasserka <tony.wasserka at gmx.de>
Date:   Thu May 13 12:04:11 2021 +0200

util: tune signatures of generated enum operators

This allows use of these operators in a constexpr context and silences
a clang -Wunused-function warning.

Reviewed-by: Jesse Natalie <jenatali at microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10784>

---

 src/util/enum_operators.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/util/enum_operators.h b/src/util/enum_operators.h
index 3a2bb53c060..8d7d37a4e1b 100644
--- a/src/util/enum_operators.h
+++ b/src/util/enum_operators.h
@@ -23,12 +23,13 @@
 
 #ifdef __cplusplus
 
+#include "macros.h"
 #include <type_traits>
 
 // some enum helpers
 #define MESA_DEFINE_CPP_ENUM_BINARY_OPERATOR(Enum, op) \
 extern "C++" {                                         \
-static inline                                          \
+UNUSED static constexpr                                \
 Enum operator op (Enum a, Enum b)                      \
 {                                                      \
    using IntType = std::underlying_type_t<Enum>;       \
@@ -37,7 +38,7 @@ Enum operator op (Enum a, Enum b)                      \
    return static_cast<Enum>(ua op ub);                 \
 }                                                      \
                                                        \
-static inline                                          \
+UNUSED static constexpr                                \
 Enum& operator op##= (Enum &a, Enum b)                 \
 {                                                      \
    using IntType = std::underlying_type_t<Enum>;       \
@@ -51,7 +52,7 @@ Enum& operator op##= (Enum &a, Enum b)                 \
 
 #define MESA_DEFINE_CPP_ENUM_UNARY_OPERATOR(Enum, op) \
 extern "C++" {                                        \
-static inline                                         \
+UNUSED static constexpr                               \
 Enum operator op (Enum a)                             \
 {                                                     \
    using IntType = std::underlying_type_t<Enum>;      \



More information about the mesa-commit mailing list