Switch to portable noreturn attributes

This commit is contained in:
Lassi Kortela 2019-08-18 00:07:46 +03:00
parent edf7c991f4
commit baea23ab29
3 changed files with 23 additions and 8 deletions

View File

@ -1327,7 +1327,8 @@ int numeric_compare(value_t a, value_t b, int eq, int eqnans, char *fname)
return 1; return 1;
} }
static void DivideByZeroError() __attribute__((__noreturn__)); STATIC_NORETURN(void, DivideByZeroError());
static void DivideByZeroError(void) static void DivideByZeroError(void)
{ {
lerror(DivideError, "/: division by zero"); lerror(DivideError, "/: division by zero");

View File

@ -16,6 +16,22 @@
#undef BITS32 // TODO #undef BITS32 // TODO
#define BITS64 // TODO #define BITS64 // TODO
#ifdef __GNUC__
#define EXTERN_NORETURN(ret, args) extern ret args __attribute__((__noreturn__))
#define STATIC_NORETURN(ret, args) static ret args __attribute__((__noreturn__))
#endif
#ifdef _MSC_VER
#define EXTERN_NORETURN(ret, args) __declspec(noreturn) extern ret args
#define STATIC_NORETURN(ret, args) __declspec(noreturn) static ret args
#endif
#ifdef __WATCOMC__
#pragma aux noreturn aborts;
#define EXTERN_NORETURN(ret, args) extern ret __pragma("noreturn") args
#define STATIC_NORETURN(ret, args) static ret __pragma("noreturn") args
#endif
#define LLT_ALLOC(n) malloc(n) #define LLT_ALLOC(n) malloc(n)
#define LLT_REALLOC(p, n) realloc((p), (n)) #define LLT_REALLOC(p, n) realloc((p), (n))
#define LLT_FREE(x) free(x) #define LLT_FREE(x) free(x)

View File

@ -190,15 +190,13 @@ extern value_t fl_lasterror;
#define FL_CATCH_EXTERN \ #define FL_CATCH_EXTERN \
else for (l__ca = 1; l__ca; l__ca = 0, fl_restorestate(&_ctx)) else for (l__ca = 1; l__ca; l__ca = 0, fl_restorestate(&_ctx))
void lerrorf(value_t e, char *format, ...) __attribute__((__noreturn__)); EXTERN_NORETURN(void, lerrorf(value_t e, char *format, ...));
void lerror(value_t e, const char *msg) __attribute__((__noreturn__)); EXTERN_NORETURN(void, lerror(value_t e, const char *msg));
void fl_savestate(struct fl_exception_context *_ctx); void fl_savestate(struct fl_exception_context *_ctx);
void fl_restorestate(struct fl_exception_context *_ctx); void fl_restorestate(struct fl_exception_context *_ctx);
void fl_raise(value_t e) __attribute__((__noreturn__)); EXTERN_NORETURN(void, fl_raise(value_t e));
void type_error(char *fname, char *expected, value_t got) EXTERN_NORETURN(void, type_error(char *fname, char *expected, value_t got));
__attribute__((__noreturn__)); EXTERN_NORETURN(void, bounds_error(char *fname, value_t arr, value_t ind));
void bounds_error(char *fname, value_t arr, value_t ind)
__attribute__((__noreturn__));
extern value_t ArgError, IOError, KeyError, MemoryError, EnumerationError; extern value_t ArgError, IOError, KeyError, MemoryError, EnumerationError;
extern value_t UnboundError; extern value_t UnboundError;