Make noreturn attribute valid only for GNUC implementations

.. with an `exit` call to make the declaration clearly true to the
compiler.
This commit is contained in:
Matthew Flatt 2019-02-17 07:13:14 -07:00
parent 6117d8aff4
commit f14d7e06bb
4 changed files with 13 additions and 2 deletions

View File

@ -252,6 +252,15 @@ extern "C"
{ {
#endif #endif
/* The reason we need two preprocessor variables is that, in gcc/clang the
function attribute comes after the function declaration. However,
in MSVC the function attribute comes before the function declaration. */
#ifdef __GNUC__
#define NORETURN __attribute__((__noreturn__))
#else
#define NORETURN
#endif
/* Allowed by all configurations, currently: */ /* Allowed by all configurations, currently: */
#define MZ_CAN_ACCESS_THREAD_LOCAL_DIRECTLY #define MZ_CAN_ACCESS_THREAD_LOCAL_DIRECTLY

View File

@ -4412,6 +4412,8 @@ scheme_raise_exn(int id, ...)
#else #else
call_error(buffer, alen, scheme_false); call_error(buffer, alen, scheme_false);
#endif #endif
exit(0); /* should not get here, but makes NORETURN clearly true */
} }
#ifndef NO_SCHEME_EXNS #ifndef NO_SCHEME_EXNS

View File

@ -198,7 +198,7 @@ MZ_EXTERN Scheme_On_Atomic_Timeout_Proc scheme_set_on_atomic_timeout(Scheme_On_A
/*========================================================================*/ /*========================================================================*/
MZ_EXTERN void scheme_signal_error(const char *msg, ...); MZ_EXTERN void scheme_signal_error(const char *msg, ...);
MZ_EXTERN void scheme_raise_exn(int exnid, ...) __attribute__ ((noreturn)); MZ_EXTERN void scheme_raise_exn(int exnid, ...) NORETURN;
MZ_EXTERN void scheme_warning(char *msg, ...); MZ_EXTERN void scheme_warning(char *msg, ...);
MZ_EXTERN void scheme_raise(Scheme_Object *exn); MZ_EXTERN void scheme_raise(Scheme_Object *exn);

View File

@ -139,7 +139,7 @@ Scheme_On_Atomic_Timeout_Proc (*scheme_set_on_atomic_timeout)(Scheme_On_Atomic_T
/* error handling */ /* error handling */
/*========================================================================*/ /*========================================================================*/
void (*scheme_signal_error)(const char *msg, ...); void (*scheme_signal_error)(const char *msg, ...);
void (*scheme_raise_exn)(int exnid, ...) __attribute__ ((noreturn)); void (*scheme_raise_exn)(int exnid, ...) NORETURN;
void (*scheme_warning)(char *msg, ...); void (*scheme_warning)(char *msg, ...);
void (*scheme_raise)(Scheme_Object *exn); void (*scheme_raise)(Scheme_Object *exn);
int (*scheme_log_level_p)(Scheme_Logger *logger, int level); int (*scheme_log_level_p)(Scheme_Logger *logger, int level);