* private.h (ATTRIBUTE_NORETURN): Rename from _Noreturn, which C23 says is obsolescent, and use C23-style [[noreturn]] if available. All uses of _Noreturn changed. --- date.c | 2 +- private.h | 15 +++++++++++---- zdump.c | 2 +- zic.c | 8 ++++---- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/date.c b/date.c index 13194629..11c5e5fe 100644 --- a/date.c +++ b/date.c @@ -42,7 +42,7 @@ static void display(const char *, time_t); static void dogmt(void); static void errensure(void); static void timeout(FILE *, const char *, const struct tm *); -static _Noreturn void usage(void); +static ATTRIBUTE_NORETURN void usage(void); int main(const int argc, char *argv[]) diff --git a/private.h b/private.h index 84facded..fa46094b 100644 --- a/private.h +++ b/private.h @@ -446,11 +446,18 @@ typedef unsigned long uintmax_t; # endif #endif -#if !defined _Noreturn && __STDC_VERSION__ < 201112 -# if 2 < __GNUC__ + (8 <= __GNUC_MINOR__) -# define _Noreturn __attribute__((noreturn)) +#ifdef __has_c_attribute +# if __has_c_attribute(noreturn) +# define ATTRIBUTE_NORETURN [[noreturn]] +# endif +#endif +#ifndef ATTRIBUTE_NORETURN +# if 201112 <= __STDC_VERSION__ +# define ATTRIBUTE_NORETURN _Noreturn +# elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) +# define ATTRIBUTE_NORETURN __attribute__((noreturn)) # else -# define _Noreturn +# define ATTRIBUTE_NORETURN /* empty */ # endif #endif diff --git a/zdump.c b/zdump.c index de1e1116..99723ac0 100644 --- a/zdump.c +++ b/zdump.c @@ -125,7 +125,7 @@ is_alpha(char a) } } -static _Noreturn void +static ATTRIBUTE_NORETURN void size_overflow(void) { fprintf(stderr, _("%s: size overflow\n"), progname); diff --git a/zic.c b/zic.c index 7a7a5094..bd0cf4cd 100644 --- a/zic.c +++ b/zic.c @@ -459,14 +459,14 @@ static char roll[TZ_MAX_LEAPS]; ** Memory allocation. */ -static _Noreturn void +static ATTRIBUTE_NORETURN void memory_exhausted(const char *msg) { fprintf(stderr, _("%s: Memory exhausted: %s\n"), progname, msg); exit(EXIT_FAILURE); } -static _Noreturn void +static ATTRIBUTE_NORETURN void size_overflow(void) { memory_exhausted(_("size overflow")); @@ -666,7 +666,7 @@ close_file(FILE *stream, char const *dir, char const *name, } } -static _Noreturn void +static ATTRIBUTE_NORETURN void usage(FILE *stream, int status) { fprintf(stream, @@ -3725,7 +3725,7 @@ getfields(char *cp, char **array, int arrayelts) return nsubs; } -static _Noreturn void +static ATTRIBUTE_NORETURN void time_overflow(void) { error(_("time overflow")); -- 2.37.2