summaryrefslogtreecommitdiff
path: root/compiler/HsVersions.h
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2007-09-07 23:33:24 +0000
committerIan Lynagh <igloo@earth.li>2007-09-07 23:33:24 +0000
commitcd14f4675f2ba7a2354a8b1bad3e68dd4ba61642 (patch)
treeac2e35119a76de48e47f47e8c2bc6760d20ed1b1 /compiler/HsVersions.h
parent0fcdfcf6cc0cb7a894559ba1ba5c7fe2adc61862 (diff)
downloadhaskell-cd14f4675f2ba7a2354a8b1bad3e68dd4ba61642.tar.gz
In ASSERT and friends, use all the expressions we are passed even if !DEBUG
Otherwise we may get unused variable warnings. GHC should optimise them all out for us.
Diffstat (limited to 'compiler/HsVersions.h')
-rw-r--r--compiler/HsVersions.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/compiler/HsVersions.h b/compiler/HsVersions.h
index 0c41fa521e..fb47f7cba5 100644
--- a/compiler/HsVersions.h
+++ b/compiler/HsVersions.h
@@ -43,11 +43,13 @@ name = Util.global (value) :: IORef (ty); \
#define ASSERTM(mbool) do { bool <- mbool; ASSERT(bool) return () }
#define ASSERTM2(mbool,msg) do { bool <- mbool; ASSERT2(bool,msg) return () }
#else
-#define ASSERT(e) if False then error "ASSERT" else
-#define ASSERT2(e,msg) if False then error "ASSERT2" else
-#define ASSERTM(e)
-#define ASSERTM2(e,msg)
-#define WARN(e,msg) if False then error "WARN" else
+-- We have to actually use all the variables we are given or we may get
+-- unused variable warnings when DEBUG is off.
+#define ASSERT(e) if False && (not (e)) then panic "ASSERT" else
+#define ASSERT2(e,msg) if False && (not (e)) then pprPanic "ASSERT2" (msg) else
+#define ASSERTM(e) do { let { _mbool = (e) } }
+#define ASSERTM2(e,msg) do { let { _mbool = (e) }; when False (panic "ASSERTM2") }
+#define WARN(e,msg) if False && (e) then pprPanic "WARN" msg else
#endif
-- This #ifndef lets us switch off the "import FastString"