Imported Upstream version 4.0.0+dfsg1
[abartlet/samba-debian.git] / lib / ccan / cast / test / compile_fail-cast_static-3.c
diff --git a/lib/ccan/cast/test/compile_fail-cast_static-3.c b/lib/ccan/cast/test/compile_fail-cast_static-3.c
new file mode 100644 (file)
index 0000000..6296b75
--- /dev/null
@@ -0,0 +1,21 @@
+#include <ccan/cast/cast.h>
+#include <stdlib.h>
+
+int main(int argc, char *argv[])
+{
+       char *c;
+#ifdef FAIL
+       const
+#endif
+               char *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