summaryrefslogtreecommitdiffstats
path: root/lib/ccan/typesafe_cb/test/compile_fail-cast_if_type-promotable.c
blob: 11d42f4c6b670bb422949dd5045b3d0bb57b950a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <ccan/typesafe_cb/typesafe_cb.h>
#include <stdbool.h>

static void _set_some_value(void *val)
{
}

#define set_some_value(expr)						\
	_set_some_value(typesafe_cb_cast(void *, long, (expr)))

int main(int argc, char *argv[])
{
#ifdef FAIL
	bool x = 0;
#if !HAVE_TYPEOF||!HAVE_BUILTIN_CHOOSE_EXPR||!HAVE_BUILTIN_TYPES_COMPATIBLE_P
#error "Unfortunately we don't fail if typesafe_cb_cast is a noop."
#endif
#else
	long x = 0;
#endif
	set_some_value(x);
	return 0;
}