Hans Wennborg | a792aff | 2011-12-07 10:33:11 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s |
| 2 | |
| 3 | int printf(char const *, ...); |
| 4 | |
| 5 | void test(void) { |
| 6 | printf("%jd", 42.0); // expected-warning {{conversion specifies type 'intmax_t' (aka 'long long')}} |
| 7 | printf("%ju", 42.0); // expected-warning {{conversion specifies type 'uintmax_t' (aka 'unsigned long long')}} |
| 8 | printf("%zu", 42.0); // expected-warning {{conversion specifies type 'size_t' (aka 'unsigned long')}} |
| 9 | printf("%td", 42.0); // expected-warning {{conversion specifies type 'ptrdiff_t' (aka 'int')}} |
| 10 | |
| 11 | // typedef size_t et al. to something crazy. |
| 12 | typedef void *size_t; |
| 13 | typedef void *intmax_t; |
| 14 | typedef void *uintmax_t; |
| 15 | typedef void *ptrdiff_t; |
| 16 | |
| 17 | // The warning still fires, because it checks the underlying type. |
| 18 | printf("%jd", (intmax_t)42); // expected-warning {{conversion specifies type 'intmax_t' (aka 'long long') but the argument has type 'intmax_t' (aka 'void *')}} |
| 19 | printf("%ju", (uintmax_t)42); // expected-warning {{conversion specifies type 'uintmax_t' (aka 'unsigned long long') but the argument has type 'uintmax_t' (aka 'void *')}} |
| 20 | printf("%zu", (size_t)42); // expected-warning {{conversion specifies type 'size_t' (aka 'unsigned long') but the argument has type 'size_t' (aka 'void *')}} |
| 21 | printf("%td", (ptrdiff_t)42); // expected-warning {{conversion specifies type 'ptrdiff_t' (aka 'int') but the argument has type 'ptrdiff_t' (aka 'void *')}} |
| 22 | } |