X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fstr%2Ftest%2Fcompile_fail-isalpha.c;fp=ccan%2Fstr%2Ftest%2Fcompile_fail-isalpha.c;h=76de15041ce537a876ce8bd15c32a07b5e33af02;hb=ecea073699c60fd5aab9e3955f59a7042d637b68;hp=0000000000000000000000000000000000000000;hpb=3f4e83d8ac847d6bf0c20e88cdbca535e842a97b;p=ccan diff --git a/ccan/str/test/compile_fail-isalpha.c b/ccan/str/test/compile_fail-isalpha.c new file mode 100644 index 00000000..76de1504 --- /dev/null +++ b/ccan/str/test/compile_fail-isalpha.c @@ -0,0 +1,23 @@ +#define CCAN_STR_DEBUG 1 +#include + +int main(int argc, char *argv[]) +{ +#ifdef FAIL +#if !HAVE_BUILTIN_TYPES_COMPATIBLE_P || !HAVE_TYPEOF +#error We need typeof to check isalpha. +#endif + char +#else + unsigned char +#endif + c = argv[0][0]; + +#ifdef FAIL + /* Fake fail on unsigned char platforms. */ + c = 255; + BUILD_ASSERT(c < 0); +#endif + + return isalpha(c); +}