aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiodrag Milanovic <mmicko@gmail.com>2018-07-25 11:58:23 +0200
committerMiodrag Milanovic <mmicko@gmail.com>2018-07-25 11:58:23 +0200
commite3ce2f544d8a5ea3e23f6c7b43232bf2dfcee19c (patch)
treeeba361010ec5bbca3b448ea4863cd25a749c7574
parent6b8b067b1a7f0ae165c79e64558f5e0646574457 (diff)
downloadnextpnr-e3ce2f544d8a5ea3e23f6c7b43232bf2dfcee19c.tar.gz
nextpnr-e3ce2f544d8a5ea3e23f6c7b43232bf2dfcee19c.tar.bz2
nextpnr-e3ce2f544d8a5ea3e23f6c7b43232bf2dfcee19c.zip
noreturn have to be void, so there is no UB
-rw-r--r--common/nextpnr.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/common/nextpnr.h b/common/nextpnr.h
index e89512f2..2eb46bd3 100644
--- a/common/nextpnr.h
+++ b/common/nextpnr.h
@@ -79,19 +79,19 @@ class assertion_failure : public std::runtime_error
};
NPNR_NORETURN
-inline bool assert_fail_impl(const char *message, const char *expr_str, const char *filename, int line)
+inline void assert_fail_impl(const char *message, const char *expr_str, const char *filename, int line)
{
throw assertion_failure(message, expr_str, filename, line);
}
NPNR_NORETURN
-inline bool assert_fail_impl_str(std::string message, const char *expr_str, const char *filename, int line)
+inline void assert_fail_impl_str(std::string message, const char *expr_str, const char *filename, int line)
{
throw assertion_failure(message, expr_str, filename, line);
}
-#define NPNR_ASSERT(cond) ((void)((cond) || (assert_fail_impl(#cond, #cond, __FILE__, __LINE__))))
-#define NPNR_ASSERT_MSG(cond, msg) ((void)((cond) || (assert_fail_impl(msg, #cond, __FILE__, __LINE__))))
+#define NPNR_ASSERT(cond) (!(cond) ? assert_fail_impl(#cond, #cond, __FILE__, __LINE__) : (void)true)
+#define NPNR_ASSERT_MSG(cond, msg) (!(cond) ? assert_fail_impl(msg, #cond, __FILE__, __LINE__) : (void)true)
#define NPNR_ASSERT_FALSE(msg) (assert_fail_impl(msg, "false", __FILE__, __LINE__))
#define NPNR_ASSERT_FALSE_STR(msg) (assert_fail_impl_str(msg, "false", __FILE__, __LINE__))