Commit cd14f467 authored by Ian Lynagh's avatar Ian Lynagh
Browse files

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.
parent 0fcdfcf6
......@@ -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"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment