]> git.ozlabs.org Git - ccan/blobdiff - ccan/tlist2/test/compile_fail-tlist_tail_2.c
tlist2: a alternate to tlist that encodes the member offset into the container type
[ccan] / ccan / tlist2 / test / compile_fail-tlist_tail_2.c
diff --git a/ccan/tlist2/test/compile_fail-tlist_tail_2.c b/ccan/tlist2/test/compile_fail-tlist_tail_2.c
new file mode 100644 (file)
index 0000000..e30e1cd
--- /dev/null
@@ -0,0 +1,29 @@
+#include <ccan/tlist2/tlist2.h>
+
+struct child {
+       const char *name;
+       struct list_node list;
+};
+
+struct cousin {
+       const char *name;
+       struct list_node list;
+};
+
+int main(int argc, char *argv[])
+{
+       TLIST2(struct child, list) children;
+       struct child child = { "child" };
+#ifdef FAIL
+       struct cousin *c;
+#else
+       struct child *c;
+#endif
+
+       tlist2_init(&children);
+       tlist2_add(&children, &child);
+
+       c = tlist2_tail(&children);
+       (void) c; /* Suppress unused-but-set-variable warning. */
+       return 0;
+}