Add a Q_NORETURN macro to mark a function that never returns

This is implemented for GCC, ICC, Clang and MSVC. With this macro, the
compiler can generate better code because it knows that the function
being called will not return.

Change-Id: Iea2bc7be464606639be65ccb73911d7ed1b29a64
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
This commit is contained in:
Thiago Macieira 2012-03-26 10:31:58 -03:00 committed by Qt by Nokia
parent 2c4845ce33
commit a861463c3c

View File

@ -90,6 +90,7 @@
# define Q_DECL_ALIGN(n) __declspec(align(n))
# define Q_ASSUME(expr) __assume(expr)
# define Q_UNREACHABLE() __assume(0)
# define Q_NORETURN __declspec(noreturn)
/* Intel C++ disguising as Visual C++: the `using' keyword avoids warnings */
# if defined(__INTEL_COMPILER)
# define Q_CC_INTEL
@ -161,6 +162,7 @@
# define Q_DECL_ALIGN(n) __attribute__((__aligned__(n)))
# define Q_LIKELY(expr) __builtin_expect(!!(expr), true)
# define Q_UNLIKELY(expr) __builtin_expect(!!(expr), false)
# define Q_NORETURN __attribute__((__noreturn__))
# if !defined(QT_MOC_CPP)
# define Q_PACKED __attribute__ ((__packed__))
# define Q_NO_PACKED_REFERENCE
@ -395,6 +397,10 @@
# error "Qt has not been tested with this compiler - see http://www.qt-project.org/"
#endif
#ifndef Q_NORETURN
# define Q_NORETURN
#endif
/*
* C++11 support
*