expand support for noreturn declarations
Although gcc specifies support for declaring a function as noreturn after the function name and parameters, other compilers do so via an attribute at the start of the declaration. Add some macro support for the attribute-at-the-beginning method: o MS Visual Studio compiler o Upcoming C23 standard (untested at this point)
This commit is contained in:
@@ -784,12 +784,12 @@ extern void done_in_by(struct monst *, int);
|
||||
extern void done_object_cleanup(void);
|
||||
#endif /* !MAKEDEFS_C && MDLIB_C && !CPPREGEX_C */
|
||||
#if !defined(CPPREGEX_C)
|
||||
extern void panic(const char *, ...) PRINTF_F(1, 2) NORETURN;
|
||||
ATTRNORETURN extern void panic(const char *, ...) PRINTF_F(1, 2) NORETURN;
|
||||
#endif
|
||||
#if !defined(MAKEDEFS_C) && !defined(MDLIB_C) && !defined(CPPREGEX_C)
|
||||
extern void done(int);
|
||||
extern void container_contents(struct obj *, boolean, boolean, boolean);
|
||||
extern void nh_terminate(int) NORETURN;
|
||||
ATTRNORETURN extern void nh_terminate(int) NORETURN;
|
||||
extern void delayed_killer(int, int, const char *);
|
||||
extern struct kinfo *find_delayed_killer(int);
|
||||
extern void dealloc_killer(struct kinfo *);
|
||||
@@ -1830,7 +1830,7 @@ extern void nhl_done(lua_State *);
|
||||
extern boolean nhl_loadlua(lua_State *, const char *);
|
||||
extern int nhl_pcall(lua_State *, int, int);
|
||||
extern boolean load_lua(const char *, nhl_sandbox_info *);
|
||||
extern void nhl_error(lua_State *, const char *) NORETURN;
|
||||
ATTRNORETURN extern void nhl_error(lua_State *, const char *) NORETURN;
|
||||
extern void lcheck_param_table(lua_State *);
|
||||
extern schar get_table_mapchr(lua_State *, const char *);
|
||||
extern schar get_table_mapchr_opt(lua_State *, const char *, schar);
|
||||
@@ -2072,7 +2072,7 @@ extern void msmsg(const char *, ...) PRINTF_F(1, 2);
|
||||
extern void gettty(void);
|
||||
extern void settty(const char *);
|
||||
extern void setftty(void);
|
||||
extern void error(const char *, ...) PRINTF_F(1, 2) NORETURN;
|
||||
ATTRNORETURN extern void error(const char *, ...) PRINTF_F(1, 2) NORETURN;
|
||||
#if defined(TIMED_DELAY) && defined(_MSC_VER)
|
||||
extern void msleep(unsigned);
|
||||
#endif
|
||||
@@ -3000,7 +3000,7 @@ extern void settty(const char *);
|
||||
extern void setftty(void);
|
||||
extern void intron(void);
|
||||
extern void introff(void);
|
||||
extern void error (const char *, ...) PRINTF_F(1, 2) NORETURN;
|
||||
ATTRNORETURN extern void error(const char *, ...) PRINTF_F(1, 2) NORETURN;
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
extern void tty_utf8graphics_fixup(void);
|
||||
#endif
|
||||
@@ -3152,8 +3152,8 @@ extern boolean authorize_wizard_mode(void);
|
||||
|
||||
/* ### vmsmisc.c ### */
|
||||
|
||||
extern void vms_abort(void) NORETURN;
|
||||
extern void vms_exit(int) NORETURN;
|
||||
ATTRNORETURN extern void vms_abort(void) NORETURN;
|
||||
ATTRNORETURN extern void vms_exit(int) NORETURN;
|
||||
#ifdef PANICTRACE
|
||||
extern void vms_traceback(int);
|
||||
#endif
|
||||
@@ -3167,7 +3167,7 @@ extern void shuttty(const char *);
|
||||
extern void setftty(void);
|
||||
extern void intron(void);
|
||||
extern void introff(void);
|
||||
extern void error (const char *, ...) PRINTF_F(1, 2) NORETURN;
|
||||
ATTRNORETURN extern void error (const char *, ...) PRINTF_F(1, 2) NORETURN;
|
||||
#ifdef TIMED_DELAY
|
||||
extern void msleep(unsigned);
|
||||
#endif
|
||||
|
||||
@@ -393,6 +393,17 @@ typedef genericptr genericptr_t; /* (void *) or (char *) */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Give first priority to standard
|
||||
*/
|
||||
#ifndef ATTRNORETURN
|
||||
#if defined(__STDC_VERSION__) || defined(__cplusplus)
|
||||
#if (__STDC_VERSION__ > 202300L) || defined(__cplusplus)
|
||||
#define ATTRNORETURN [[noreturn]]
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Allow gcc2 to check parameters of printf-like calls with -Wformat;
|
||||
* append this to a prototype declaration (see pline() in extern.h).
|
||||
@@ -406,7 +417,11 @@ typedef genericptr genericptr_t; /* (void *) or (char *) */
|
||||
#endif
|
||||
#if __GNUC__ >= 3
|
||||
#define UNUSED __attribute__((unused))
|
||||
#ifndef ATTRNORETURN
|
||||
#ifndef NORETURN
|
||||
#define NORETURN __attribute__((noreturn))
|
||||
#endif
|
||||
#endif
|
||||
#if (!defined(__linux__) && !defined(MACOS)) || defined(GCC_URWARN)
|
||||
/* disable gcc's __attribute__((__warn_unused_result__)) since explicitly
|
||||
discarding the result by casting to (void) is not accepted as a 'use' */
|
||||
@@ -419,6 +434,12 @@ typedef genericptr genericptr_t; /* (void *) or (char *) */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifndef ATTRNORETURN
|
||||
#define ATTRNORETURN __declspec(noreturn)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef PRINTF_F
|
||||
#define PRINTF_F(f, v)
|
||||
#endif
|
||||
@@ -428,6 +449,9 @@ typedef genericptr genericptr_t; /* (void *) or (char *) */
|
||||
#ifndef UNUSED
|
||||
#define UNUSED
|
||||
#endif
|
||||
#ifndef ATTRNORETURN
|
||||
#define ATTRNORETURN
|
||||
#endif
|
||||
#ifndef NORETURN
|
||||
#define NORETURN
|
||||
#endif
|
||||
@@ -435,4 +459,5 @@ typedef genericptr genericptr_t; /* (void *) or (char *) */
|
||||
#define NONNULL
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* TRADSTDC_H */
|
||||
|
||||
Reference in New Issue
Block a user