|
From: <sv...@va...> - 2015-03-28 18:36:09
|
Author: florian
Date: Sat Mar 28 18:36:01 2015
New Revision: 15047
Log:
Add STATIC_ASSERT and use it.
Modified:
trunk/include/pub_tool_basics.h
trunk/memcheck/tests/vbit-test/irops.c
Modified: trunk/include/pub_tool_basics.h
==============================================================================
--- trunk/include/pub_tool_basics.h (original)
+++ trunk/include/pub_tool_basics.h Sat Mar 28 18:36:01 2015
@@ -367,6 +367,9 @@
} var = { .in = x }; var.out; \
})
+// Poor man's static assert
+#define STATIC_ASSERT(x) extern int VG_(VG_(VG_(unused)))[(x) ? 1 : -1]
+
#endif /* __PUB_TOOL_BASICS_H */
/*--------------------------------------------------------------------*/
Modified: trunk/memcheck/tests/vbit-test/irops.c
==============================================================================
--- trunk/memcheck/tests/vbit-test/irops.c (original)
+++ trunk/memcheck/tests/vbit-test/irops.c Sat Mar 28 18:36:01 2015
@@ -2,6 +2,7 @@
#include <stdio.h> // fprintf
#include <stdlib.h> // exit
+#include "pub_tool_basics.h" // STATIC_ASSERT
#include "vtest.h"
#define DEFOP(op,ukind) op, #op, ukind
@@ -1050,9 +1051,8 @@
/* Force compile time failure in case libvex_ir.h::IROp was updated
and the irops array is out of synch */
-extern int ensure_complete[
- (sizeof irops / sizeof *irops == Iop_LAST - Iop_INVALID - 1) ? 1 : -1
- ];
+STATIC_ASSERT \
+ (sizeof irops / sizeof *irops == Iop_LAST - Iop_INVALID - 1);
/* Return a descriptor for OP, iff it exists and it is implemented
for the current architecture. */
|