summaryrefslogtreecommitdiffstats
path: root/src/corelib/global
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-03-26 10:31:58 -0300
committerQt by Nokia <qt-info@nokia.com>2012-03-27 16:51:30 +0200
commita861463c3c7a216632ae81a90e085fb99579d544 (patch)
tree98718cfe73d65cfcd6375027f1cb29b89793e30b /src/corelib/global
parent2c4845ce331e5dfaf5e106f74871ce16721a1358 (diff)
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>
Diffstat (limited to 'src/corelib/global')
-rw-r--r--src/corelib/global/qcompilerdetection.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index c9f59454b2..a043e5e072 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -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
*