blob: 7f88ff38c302490daa328102eeb26dedba2ec9a3 [file] [log] [blame]
Hans Wennborg29e97cb2011-10-27 08:29:09 +00001// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
2
3int printf(char const *, ...);
4
5void test(void) {
6 // size_t
Ted Kremenekce506ae2012-01-20 21:52:58 +00007 printf("%zu", (double)42); // expected-warning {{format specifies type 'size_t' (aka 'unsigned long') but the argument has type 'double'}}
Hans Wennborg29e97cb2011-10-27 08:29:09 +00008
9 // intmax_t / uintmax_t
Ted Kremenekce506ae2012-01-20 21:52:58 +000010 printf("%jd", (double)42); // expected-warning {{format specifies type 'intmax_t' (aka 'long') but the argument has type 'double'}}
11 printf("%ju", (double)42); // expected-warning {{format specifies type 'uintmax_t' (aka 'unsigned long') but the argument has type 'double'}}
Hans Wennborg29e97cb2011-10-27 08:29:09 +000012
13 // ptrdiff_t
Ted Kremenekce506ae2012-01-20 21:52:58 +000014 printf("%td", (double)42); // expected-warning {{format specifies type 'ptrdiff_t' (aka 'long') but the argument has type 'double'}}
Hans Wennborg29e97cb2011-10-27 08:29:09 +000015}