Mesa (master): mesa: Add unreachable() macro.
Matt Turner
mattst88 at kemper.freedesktop.org
Wed Nov 6 19:39:41 UTC 2013
Module: Mesa
Branch: master
Commit: 3a5223c24cc30b3d8698352782ad9130ee2407ae
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3a5223c24cc30b3d8698352782ad9130ee2407ae
Author: Matt Turner <mattst88 at gmail.com>
Date: Mon Nov 4 16:24:35 2013 -0800
mesa: Add unreachable() macro.
Reviewed-by: Brian Paul <brianp at vmware.com>
Reviewed-by: Francisco Jerez <currojerez at riseup.net>
---
src/mesa/main/compiler.h | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h
index 2820913..dceea02 100644
--- a/src/mesa/main/compiler.h
+++ b/src/mesa/main/compiler.h
@@ -248,6 +248,21 @@ static INLINE GLuint CPU_TO_LE32(GLuint x)
(void) sizeof(char [1 - 2*!(COND)]); \
} while (0)
+/**
+ * Unreachable macro. Useful for suppressing "control reaches end of non-void
+ * function" warnings.
+ */
+#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 5
+#define unreachable() __builtin_unreachable()
+#elif (defined(__clang__) && defined(__has_builtin))
+# if __has_builtin(__builtin_unreachable)
+# define unreachable() __builtin_unreachable()
+# endif
+#endif
+
+#ifndef unreachable
+#define unreachable()
+#endif
#if (__GNUC__ >= 3)
#define PRINTFLIKE(f, a) __attribute__ ((format(__printf__, f, a)))
More information about the mesa-commit
mailing list