Xfuncproto: define _X_FALLTHROUGH for modern compilers

Can be used to tell the compiler that fallthrough between cases in
a switch statement is intentional.  Handles gcc >= 7 and clang >= 12
as well as all C23-compliant compilers.

Bumps xproto version to 7.0.34.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/proto/xorgproto/-/merge_requests/96>
This commit is contained in:
Alan Coopersmith 2025-04-21 15:59:24 -07:00
parent 9d5e1d1dc1
commit 1914233e66
2 changed files with 19 additions and 4 deletions

View file

@ -78,13 +78,16 @@ in this Software without prior written authorization from The Open Group.
/* http://clang.llvm.org/docs/LanguageExtensions.html#has-attribute */ /* http://clang.llvm.org/docs/LanguageExtensions.html#has-attribute */
#ifndef __has_attribute #ifndef __has_attribute
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */ # define __has_attribute(x) 0 /* Compatibility with older compilers. */
#endif #endif
#ifndef __has_feature #ifndef __has_feature
# define __has_feature(x) 0 /* Compatibility with non-clang compilers. */ # define __has_feature(x) 0 /* Compatibility with older compilers. */
#endif #endif
#ifndef __has_extension #ifndef __has_extension
# define __has_extension(x) 0 /* Compatibility with non-clang compilers. */ # define __has_extension(x) 0 /* Compatibility with older compilers. */
#endif
#ifndef __has_c_attribute
# define __has_c_attribute(x) 0 /* Compatibility with pre-C23 compilers. */
#endif #endif
/* Added in X11R6.9, so available in any version of modular xproto */ /* Added in X11R6.9, so available in any version of modular xproto */
@ -213,4 +216,16 @@ in this Software without prior written authorization from The Open Group.
# define _X_NONSTRING # define _X_NONSTRING
#endif #endif
/* Mark a fallthrough in a switch statement as intentional
Handles C23 compilers, as well as gcc >= 7 and clang >= 12
For older compilers/linters, pair with a fallthrough comment. */
/* requires xproto >= 7.0.34 */
#if __has_c_attribute(fallthrough)
#define _X_FALLTHROUGH [[fallthrough]]
#elif __has_attribute(fallthrough)
#define _X_FALLTHROUGH __attribute__((fallthrough))
#else
#define _X_FALLTHROUGH (void)0
#endif
#endif /* _XFUNCPROTO_H_ */ #endif /* _XFUNCPROTO_H_ */

View file

@ -4,5 +4,5 @@ includex11dir=@includedir@/X11
Name: Xproto Name: Xproto
Description: Xproto headers Description: Xproto headers
Version: 7.0.33 Version: 7.0.34
Cflags: -I${includedir} Cflags: -I${includedir}