This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch main
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=ef97777bbcc4e6d0394909ebbd410186e1114790

commit ef97777bbcc4e6d0394909ebbd410186e1114790
Author: Guillem Jover <[email protected]>
AuthorDate: Thu Feb 23 20:11:11 2023 +0100

    lib: Add an enum flags attribute
    
    This will make it possible to mark enum types that use bitmasks, and be
    able to check that we assign only valid values.
    
    Warned-by: clang-16 -Wassign-enum
---
 lib/compat/compat.h | 7 +++++++
 lib/dpkg/macros.h   | 7 +++++++
 2 files changed, 14 insertions(+)

diff --git a/lib/compat/compat.h b/lib/compat/compat.h
index 17a03259c..b5c054540 100644
--- a/lib/compat/compat.h
+++ b/lib/compat/compat.h
@@ -75,6 +75,13 @@
 #define LIBCOMPAT_ATTR_SENTINEL
 #endif
 
+#if __has_attribute(__enum_extensibility__)
+#define LIBCOMPAT_ATTR_ENUM_FLAGS \
+       __attribute__((__enum_extensibility__(closed),__flag_enum__))
+#else
+#define LIBCOMPAT_ATTR_ENUM_FLAGS
+#endif
+
 /* For C++, define a __func__ fallback in case it's not natively supported. */
 #if defined(__cplusplus) && __cplusplus < 201103L
 # if LIBCOMPAT_GCC_VERSION >= 0x0200
diff --git a/lib/dpkg/macros.h b/lib/dpkg/macros.h
index 491c3a12a..5c609f23f 100644
--- a/lib/dpkg/macros.h
+++ b/lib/dpkg/macros.h
@@ -138,6 +138,13 @@
 #define DPKG_ATTR_NONSTRING
 #endif
 
+#if __has_attribute(__enum_extensibility__)
+#define DPKG_ATTR_ENUM_FLAGS \
+       __attribute__((__enum_extensibility__(closed),__flag_enum__))
+#else
+#define DPKG_ATTR_ENUM_FLAGS
+#endif
+
 #if defined(__cplusplus) && __cplusplus >= 201103L
 #define DPKG_ATTR_THROW(exception)
 #define DPKG_ATTR_NOEXCEPT             noexcept

-- 
Dpkg.Org's dpkg

Reply via email to