Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -388,10 +388,13 @@ ]) AC_CHECK_TYPE(max_align_t, [AC_DEFINE(OF_HAVE_MAX_ALIGN_T, 1, [Whether we have max_align_t])]) +AC_CHECK_HEADER(stdnoreturn.h, + [AC_DEFINE(OF_HAVE_STDNORETURN_H, 1, [Whether we have stdnoreturn.h])]) + AC_CHECK_SIZEOF(float) AC_CHECK_SIZEOF(double) AS_IF([test x"$ac_cv_sizeof_float" != x"4" -o x"$ac_cv_sizeof_double" != x"8"], [AC_MSG_ERROR( [Floating point implementation does not conform to IEEE 754!])]) Index: src/OFApplication.h ================================================================== --- src/OFApplication.h +++ src/OFApplication.h @@ -162,18 +162,18 @@ + (OFDictionary*)environment; /*! * @brief Terminates the application. */ -+ (void)terminate OF_NO_RETURN; ++ (void)terminate OF_METHOD_NORETURN; /*! * @brief Terminates the application with the specified status. * * @param status The status with which the application will terminate */ -+ (void)terminateWithStatus: (int)status OF_NO_RETURN; ++ (void)terminateWithStatus: (int)status OF_METHOD_NORETURN; /*! * @brief Gets args and argv. * * @param argc A pointer where a pointer to argc should be stored @@ -218,18 +218,18 @@ - (void)setDelegate: (id )delegate; /*! * @brief Terminates the application. */ -- (void)terminate; +- (void)terminate OF_METHOD_NORETURN; /*! * @brief Terminates the application with the specified status. * * @param status The status with which the application will terminate */ -- (void)terminateWithStatus: (int)status; +- (void)terminateWithStatus: (int)status OF_METHOD_NORETURN; @end @interface OFObject (OFApplicationDelegate) @end Index: src/OFObject.h ================================================================== --- src/OFObject.h +++ src/OFObject.h @@ -44,10 +44,22 @@ #if defined(__GNUC__) # define restrict __restrict__ #elif __STDC_VERSION__ < 199901L # define restrict #endif + +#if __STDC_VERSION__ >= 201112L +# ifdef OF_HAVE_STDNORETURN_H +# include +# else +# define noreturn _Noreturn +# endif +#elif defined(__GNUC__) +# define noreturn __attribute__((noreturn)) +#else +# define noreturn +#endif #if defined(OF_HAVE__THREAD_LOCAL) # define OF_HAVE_COMPILER_TLS # ifdef OF_HAVE_THREADS_H # include @@ -103,14 +115,14 @@ # endif #endif #if defined(__clang__) || __GCC_VERSION__ >= 406 # define OF_SENTINEL __attribute__((__sentinel__)) -# define OF_NO_RETURN __attribute__((__noreturn__)) +# define OF_METHOD_NORETURN __attribute__((__noreturn__)) #else # define OF_SENTINEL -# define OF_NO_RETURN +# define OF_METHOD_NORETURN #endif #if __has_attribute(__objc_requires_super__) # define OF_REQUIRES_SUPER __attribute__((__objc_requires_super__)) #else @@ -959,11 +971,11 @@ * @warning If you override this method, you must make sure that it never * returns. * * @param selector The selector not understood by the receiver */ -- (void)doesNotRecognizeSelector: (SEL)selector OF_NO_RETURN; +- (void)doesNotRecognizeSelector: (SEL)selector OF_METHOD_NORETURN; @end /*! * @protocol OFCopying OFObject.h ObjFW/OFObject.h * Index: src/OFThread.h ================================================================== --- src/OFThread.h +++ src/OFThread.h @@ -143,18 +143,18 @@ #ifdef OF_HAVE_THREADS /*! * @brief Terminates the current thread, letting it return nil. */ -+ (void)terminate OF_NO_RETURN; ++ (void)terminate OF_METHOD_NORETURN; /*! * @brief Terminates the current thread, letting it return the specified object. * * @param object The object which the terminated thread will return */ -+ (void)terminateWithObject: (id)object OF_NO_RETURN; ++ (void)terminateWithObject: (id)object OF_METHOD_NORETURN; # ifdef OF_HAVE_BLOCKS /*! * @brief Initializes an already allocated thread with the specified block. * Index: src/objfw-defs.h.in ================================================================== --- src/objfw-defs.h.in +++ src/objfw-defs.h.in @@ -22,14 +22,15 @@ #undef OF_HAVE_PTHREADS #undef OF_HAVE_PTHREAD_SPINLOCKS #undef OF_HAVE_RECURSIVE_PTHREAD_MUTEXES #undef OF_HAVE_SCHED_YIELD #undef OF_HAVE_SOCKETS +#undef OF_HAVE_STDNORETURN #undef OF_HAVE_SYMLINK #undef OF_HAVE_SYS_SOCKET_H #undef OF_HAVE_THREADS #undef OF_HAVE___THREAD #undef OF_HAVE__THREAD_LOCAL #undef OF_NINTENDO_DS #undef OF_OBJFW_RUNTIME #undef OF_UNIVERSAL #undef SIZE_MAX Index: src/threading.h ================================================================== --- src/threading.h +++ src/threading.h @@ -141,20 +141,21 @@ #else # error of_thread_detach not implemented! #endif } -static OF_INLINE void OF_NO_RETURN +static OF_INLINE void noreturn of_thread_exit(void) { #if defined(OF_HAVE_PTHREADS) pthread_exit(NULL); #elif defined(_WIN32) ExitThread(0); #else # error of_thread_exit not implemented! #endif + OF_UNREACHABLE } static OF_INLINE void of_once(of_once_t *control, void (*func)(void)) {