summaryrefslogtreecommitdiff
path: root/lib/ccan/cast/test/compile_fail-cast_static-2.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ccan/cast/test/compile_fail-cast_static-2.c')
-rw-r--r--lib/ccan/cast/test/compile_fail-cast_static-2.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/ccan/cast/test/compile_fail-cast_static-2.c b/lib/ccan/cast/test/compile_fail-cast_static-2.c
new file mode 100644
index 0000000000..8a12025384
--- /dev/null
+++ b/lib/ccan/cast/test/compile_fail-cast_static-2.c
@@ -0,0 +1,23 @@
+#include <ccan/cast/cast.h>
+#include <stdlib.h>
+
+int main(int argc, char *argv[])
+{
+ char *c;
+#ifdef FAIL
+ long
+#else
+ char
+#endif
+ *p = 0;
+
+ c = cast_static(char *, p);
+ (void) c; /* Suppress unused-but-set-variable warning. */
+ return 0;
+}
+
+#ifdef FAIL
+#if !HAVE_COMPOUND_LITERALS
+#error "Unfortunately we don't fail if cast_static is a noop"
+#endif
+#endif