X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fcast%2Ftest%2Fcompile_fail-cast_const.c;h=277f3de1c442b21fd9a8953b560a97d5bbb80e58;hp=bb8de94f4c2212e0a5e1a27d41b0d2cb0d01017f;hb=6569a707d169a629e25e10710c760c8dc84525c7;hpb=118ace351b789dfaca8866f84a8cd4b924941268 diff --git a/ccan/cast/test/compile_fail-cast_const.c b/ccan/cast/test/compile_fail-cast_const.c index bb8de94f..277f3de1 100644 --- a/ccan/cast/test/compile_fail-cast_const.c +++ b/ccan/cast/test/compile_fail-cast_const.c @@ -1,17 +1,29 @@ #include #include +/* Note: this *isn't* sizeof(char) on all platforms. */ +struct char_struct { + char c; +}; + int main(int argc, char *argv[]) { char *uc; - const + const #ifdef FAIL - int + struct char_struct #else char #endif *p = NULL; uc = cast_const(char *, p); + (void) uc; /* Suppress unused-but-set-variable warning. */ return 0; } + +#ifdef FAIL +#if !HAVE_TYPEOF||!HAVE_BUILTIN_CHOOSE_EXPR||!HAVE_BUILTIN_TYPES_COMPATIBLE_P +#error "Unfortunately we don't fail if cast_const can only use size" +#endif +#endif