2013-02-21 06:28:41 +08:00
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
|
2011-10-27 16:29:09 +08:00
|
|
|
|
|
|
|
int printf(char const *, ...);
|
|
|
|
|
|
|
|
void test(void) {
|
|
|
|
// size_t
|
2012-01-21 05:52:58 +08:00
|
|
|
printf("%zu", (double)42); // expected-warning {{format specifies type 'size_t' (aka 'unsigned long') but the argument has type 'double'}}
|
2011-10-27 16:29:09 +08:00
|
|
|
|
|
|
|
// intmax_t / uintmax_t
|
2012-01-21 05:52:58 +08:00
|
|
|
printf("%jd", (double)42); // expected-warning {{format specifies type 'intmax_t' (aka 'long') but the argument has type 'double'}}
|
|
|
|
printf("%ju", (double)42); // expected-warning {{format specifies type 'uintmax_t' (aka 'unsigned long') but the argument has type 'double'}}
|
2011-10-27 16:29:09 +08:00
|
|
|
|
|
|
|
// ptrdiff_t
|
2012-01-21 05:52:58 +08:00
|
|
|
printf("%td", (double)42); // expected-warning {{format specifies type 'ptrdiff_t' (aka 'long') but the argument has type 'double'}}
|
2011-10-27 16:29:09 +08:00
|
|
|
}
|
2012-08-07 17:13:19 +08:00
|
|
|
|
|
|
|
void test_writeback(void) {
|
|
|
|
printf("%jn", (long*)0); // no-warning
|
|
|
|
printf("%jn", (unsigned long*)0); // no-warning
|
|
|
|
printf("%jn", (int*)0); // expected-warning{{format specifies type 'intmax_t *' (aka 'long *') but the argument has type 'int *'}}
|
|
|
|
|
|
|
|
printf("%zn", (long*)0); // no-warning
|
|
|
|
// FIXME: Warn about %zn with non-ssize_t argument.
|
|
|
|
|
|
|
|
printf("%tn", (long*)0); // no-warning
|
|
|
|
printf("%tn", (unsigned long*)0); // no-warning
|
|
|
|
printf("%tn", (int*)0); // expected-warning{{format specifies type 'ptrdiff_t *' (aka 'long *') but the argument has type 'int *'}}
|
|
|
|
}
|