Переглянути джерело

Use C23 [[noreturn]] if available

* private.h (ATTRIBUTE_NORETURN): Rename from _Noreturn, which
C23 says is obsolescent, and use C23-style [[noreturn]] if available.
All uses of _Noreturn changed.
Paul Eggert 3 роки тому
батько
коміт
dbfcefe0c1
4 змінених файлів з 17 додано та 10 видалено
  1. 1 1
      date.c
  2. 11 4
      private.h
  3. 1 1
      zdump.c
  4. 4 4
      zic.c

+ 1 - 1
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[])

+ 11 - 4
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
 

+ 1 - 1
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);

+ 4 - 4
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"));