mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-22 01:49:11 +00:00
Use C23 [[__fallthrough__]] and [[__noreturn__]] attributes if supported.
If the C23 attributes are not supported, use gcc-style attributes where possible.
This commit is contained in:
parent
cfdcd96b63
commit
16ae61dcd7
29
config.h.in
29
config.h.in
@ -1476,10 +1476,17 @@
|
||||
#endif
|
||||
|
||||
/* For functions that call exit() directly. */
|
||||
#if __GNUC_PREREQ__(2, 5)
|
||||
# define sudo_noreturn __attribute__((__noreturn__))
|
||||
#else
|
||||
# define sudo_noreturn
|
||||
#ifdef __has_c_attribute
|
||||
# if __has_c_attribute(__noreturn__)
|
||||
# define sudo_noreturn [[__noreturn__]]
|
||||
# endif
|
||||
#endif
|
||||
#ifndef sudo_noreturn
|
||||
# if __GNUC_PREREQ__(2, 5)
|
||||
# define sudo_noreturn __attribute__((__noreturn__))
|
||||
# else
|
||||
# define sudo_noreturn
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* For malloc-like functions that return uninitialized or zeroed memory. */
|
||||
@ -1507,6 +1514,20 @@
|
||||
# define sudo_attr_fmt_arg(_f)
|
||||
#endif
|
||||
|
||||
/* C23 defines a fallthrough attribute, gcc 7.0 and clang 10 have their own. */
|
||||
#ifdef __has_c_attribute
|
||||
# if __has_c_attribute(__fallthrough__)
|
||||
# define FALLTHROUGH [[__fallthrough__]]
|
||||
# endif
|
||||
#endif
|
||||
#ifndef FALLTHROUGH
|
||||
# if defined(HAVE_FALLTHROUGH_ATTRIBUTE)
|
||||
# define FALLTHROUGH __attribute__((__fallthrough__))
|
||||
# else
|
||||
# define FALLTHROUGH do { } while (0)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Symbol visibility controls. */
|
||||
#ifdef HAVE_DSO_VISIBILITY
|
||||
# if defined(__GNUC__)
|
||||
|
29
configure.ac
29
configure.ac
@ -5571,10 +5571,17 @@ AH_BOTTOM([#ifndef __GNUC_PREREQ__
|
||||
#endif
|
||||
|
||||
/* For functions that call exit() directly. */
|
||||
#if __GNUC_PREREQ__(2, 5)
|
||||
# define sudo_noreturn __attribute__((__noreturn__))
|
||||
#else
|
||||
# define sudo_noreturn
|
||||
#ifdef __has_c_attribute
|
||||
# if __has_c_attribute(__noreturn__)
|
||||
# define sudo_noreturn [[__noreturn__]]
|
||||
# endif
|
||||
#endif
|
||||
#ifndef sudo_noreturn
|
||||
# if __GNUC_PREREQ__(2, 5)
|
||||
# define sudo_noreturn __attribute__((__noreturn__))
|
||||
# else
|
||||
# define sudo_noreturn
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* For malloc-like functions that return uninitialized or zeroed memory. */
|
||||
@ -5602,6 +5609,20 @@ AH_BOTTOM([#ifndef __GNUC_PREREQ__
|
||||
# define sudo_attr_fmt_arg(_f)
|
||||
#endif
|
||||
|
||||
/* C23 defines a fallthrough attribute, gcc 7.0 and clang 10 have their own. */
|
||||
#ifdef __has_c_attribute
|
||||
# if __has_c_attribute(__fallthrough__)
|
||||
# define FALLTHROUGH [[__fallthrough__]]
|
||||
# endif
|
||||
#endif
|
||||
#ifndef FALLTHROUGH
|
||||
# if defined(HAVE_FALLTHROUGH_ATTRIBUTE)
|
||||
# define FALLTHROUGH __attribute__((__fallthrough__))
|
||||
# else
|
||||
# define FALLTHROUGH do { } while (0)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Symbol visibility controls. */
|
||||
#ifdef HAVE_DSO_VISIBILITY
|
||||
# if defined(__GNUC__)
|
||||
|
@ -37,12 +37,6 @@
|
||||
* Macros and functions that may be missing on some operating systems.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_FALLTHROUGH_ATTRIBUTE
|
||||
# define FALLTHROUGH __attribute__((__fallthrough__))
|
||||
#else
|
||||
# define FALLTHROUGH do { } while (0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Given the pointer x to the member m of the struct s, return
|
||||
* a pointer to the containing structure.
|
||||
|
Loading…
x
Reference in New Issue
Block a user