summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2017-01-22 21:06:05 -0800
committerH. Peter Anvin <hpa@zytor.com>2017-01-22 21:06:05 -0800
commitfc427c6fab29c0af1441e5c2f80602d6ebd6c49b (patch)
tree698d8e113bc5d3a580c9e0286f56e051dc69c09e
parentcd0c7ddc40f6e12f80f122284f68fe835449e176 (diff)
downloadnasm-fc427c6fab29c0af1441e5c2f80602d6ebd6c49b.tar.gz
nasmlib.h: slightly tidy up the definition of nasm_build_assert()
"Assertion failed" is likely to be redundant with static_assert(). __attribute__((error)) is only guaranteed to work while optimizing, so do not use it unless __OPTIMIZE__ is defined. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--include/nasmlib.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/include/nasmlib.h b/include/nasmlib.h
index ea297b5d..3738e3b7 100644
--- a/include/nasmlib.h
+++ b/include/nasmlib.h
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------- *
*
- * Copyright 1996-2016 The NASM Authors - All Rights Reserved
+ * Copyright 1996-2017 The NASM Authors - All Rights Reserved
* See the file AUTHORS included with the NASM distribution for
* the specific copyright holders.
*
@@ -176,13 +176,13 @@ no_return nasm_assert_failed(const char *, int, const char *);
* NASM failure at build time if x != 0
*/
#ifdef static_assert
-# define nasm_build_assert(x) static_assert(x, "assertion " #x " failed")
-#elif defined(HAVE_FUNC_ATTRIBUTE_ERROR)
+# define nasm_build_assert(x) static_assert(x, #x)
+#elif defined(HAVE_FUNC_ATTRIBUTE_ERROR) && defined(__OPTIMIZE__)
# define nasm_build_assert(x) \
if (!(x)) { \
- extern void __attribute__((error("assertion " #x " failed"))) \
- fail(void); \
- fail(); \
+ extern void __attribute__((error("assertion " #x " failed"))) \
+ _nasm_static_fail(void); \
+ _nasm_static_fail(); \
}
#else
# define nasm_build_assert(x) (void)(sizeof(char[1-2*!(x)]))