summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorDaniel Gröber <dxld@darkboxed.org>2021-02-15 04:07:23 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-07-29 13:12:47 -0400
commite6731578246b6e6959026d4a9da9971b097c83aa (patch)
treeb187c46fc1d10b17a1f7d2a5952582269921b73a /includes
parent296ed7395c9a45352cf2e03ef9ff0b3b1f5a1a80 (diff)
downloadhaskell-e6731578246b6e6959026d4a9da9971b097c83aa.tar.gz
Add configure flag to enable ASSERTs in all ways
Running the test suite with asserts enabled is somewhat tricky at the moment as running it with a GHC compiled the DEBUG way has some hundred failures from the start. These seem to be unrelated to assertions though. So this provides a toggle to make it easier to debug failing assertions using the test suite.
Diffstat (limited to 'includes')
-rw-r--r--includes/Cmm.h8
-rw-r--r--includes/Rts.h24
2 files changed, 25 insertions, 7 deletions
diff --git a/includes/Cmm.h b/includes/Cmm.h
index b1b8680e99..9b17e9f400 100644
--- a/includes/Cmm.h
+++ b/includes/Cmm.h
@@ -211,7 +211,13 @@
Assertions and Debuggery
-------------------------------------------------------------------------- */
-#if defined(DEBUG)
+#if defined(DEBUG) || defined(USE_ASSERTS_ALL_WAYS)
+#define ASSERTS_ENABLED 1
+#else
+#undef ASSERTS_ENABLED
+#endif
+
+#if ASSERTS_ENABLED
#define ASSERT(predicate) \
if (predicate) { \
/*null*/; \
diff --git a/includes/Rts.h b/includes/Rts.h
index 5e657e07ce..82fd48fcbf 100644
--- a/includes/Rts.h
+++ b/includes/Rts.h
@@ -112,7 +112,9 @@ extern "C" {
Assertions and Debuggery
CHECK(p) evaluates p and terminates with an error if p is false
- ASSERT(p) like CHECK(p) if DEBUG is on, otherwise a no-op
+ ASSERT(p) like CHECK(p) a no-op, unless ASSERTS_ENABLED is on. Either
+ because we're building in the DEBUG way or USE_ASSERTS_ALL_WAYS
+ (aka --enable-asserts-all-ways) was enabled at ./configure time.
-------------------------------------------------------------------------- */
void _assertFail(const char *filename, unsigned int linenum)
@@ -130,12 +132,22 @@ void _assertFail(const char *filename, unsigned int linenum)
else \
barf(msg, ##__VA_ARGS__)
-#if !defined(DEBUG)
-#define ASSERT(predicate) /* nothing */
-#define ASSERTM(predicate,msg,...) /* nothing */
+#if defined(DEBUG) || defined(USE_ASSERTS_ALL_WAYS)
+#define ASSERTS_ENABLED 1
#else
-#define ASSERT(predicate) CHECK(predicate)
-#define ASSERTM(predicate,msg,...) CHECKM(predicate,msg,##__VA_ARGS__)
+#undef ASSERTS_ENABLED
+#endif
+
+#if ASSERTS_ENABLED
+#define ASSERT(predicate) \
+ do { CHECK(predicate); } while(0)
+#define ASSERTM(predicate,msg,...) \
+ do { CHECKM(predicate, msg, ##__VA_ARGS__); } while(0)
+#else
+#define ASSERT(predicate) \
+ do { (void) sizeof(predicate); } while(0)
+#define ASSERTM(predicate,msg,...) \
+ do { (void) sizeof(predicate); (void) sizeof(msg); } while(0)
#endif /* DEBUG */
/*