diff options
author | Ted Kremenek <kremenek@apple.com> | 2012-01-20 21:52:58 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2012-01-20 21:52:58 +0000 |
commit | ce506ae231703a23ea95335cd4de19c60082f361 (patch) | |
tree | 4f354d3fe0d049a3d9948bc0774814e0d8b5f03c /test/Sema/format-strings-int-typedefs.c | |
parent | 3026348bd4c13a0f83b59839f64065e0fcbea253 (diff) |
Tighten format string diagnostic and make it a bit clearer (and a bit closer to GCC's).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148579 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/format-strings-int-typedefs.c')
-rw-r--r-- | test/Sema/format-strings-int-typedefs.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/test/Sema/format-strings-int-typedefs.c b/test/Sema/format-strings-int-typedefs.c index 8d5dff1523..341d49c500 100644 --- a/test/Sema/format-strings-int-typedefs.c +++ b/test/Sema/format-strings-int-typedefs.c @@ -4,23 +4,23 @@ int printf(char const *, ...); int scanf(char const *, ...); void test(void) { - printf("%jd", 42.0); // expected-warning {{conversion specifies type 'intmax_t' (aka 'long long')}} - printf("%ju", 42.0); // expected-warning {{conversion specifies type 'uintmax_t' (aka 'unsigned long long')}} - printf("%zu", 42.0); // expected-warning {{conversion specifies type 'size_t' (aka 'unsigned long')}} - printf("%td", 42.0); // expected-warning {{conversion specifies type 'ptrdiff_t' (aka 'int')}} - printf("%lc", 42.0); // expected-warning {{conversion specifies type 'wint_t' (aka 'int')}} - printf("%ls", 42.0); // expected-warning {{conversion specifies type 'wchar_t *' (aka 'int *')}} - printf("%S", 42.0); // expected-warning {{conversion specifies type 'wchar_t *' (aka 'int *')}} - printf("%C", 42.0); // expected-warning {{conversion specifies type 'wchar_t' (aka 'int')}} + printf("%jd", 42.0); // expected-warning {{format specifies type 'intmax_t' (aka 'long long')}} + printf("%ju", 42.0); // expected-warning {{format specifies type 'uintmax_t' (aka 'unsigned long long')}} + printf("%zu", 42.0); // expected-warning {{format specifies type 'size_t' (aka 'unsigned long')}} + printf("%td", 42.0); // expected-warning {{format specifies type 'ptrdiff_t' (aka 'int')}} + printf("%lc", 42.0); // expected-warning {{format specifies type 'wint_t' (aka 'int')}} + printf("%ls", 42.0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}} + printf("%S", 42.0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}} + printf("%C", 42.0); // expected-warning {{format specifies type 'wchar_t' (aka 'int')}} - scanf("%jd", 0); // expected-warning {{conversion specifies type 'intmax_t *' (aka 'long long *')}} - scanf("%ju", 0); // expected-warning {{conversion specifies type 'uintmax_t *' (aka 'unsigned long long *')}} - scanf("%zu", 0); // expected-warning {{conversion specifies type 'size_t *' (aka 'unsigned long *')}} - scanf("%td", 0); // expected-warning {{conversion specifies type 'ptrdiff_t *' (aka 'int *')}} - scanf("%lc", 0); // expected-warning {{conversion specifies type 'wchar_t *' (aka 'int *')}} - scanf("%ls", 0); // expected-warning {{conversion specifies type 'wchar_t *' (aka 'int *')}} - scanf("%S", 0); // expected-warning {{conversion specifies type 'wchar_t *' (aka 'int *')}} - scanf("%C", 0); // expected-warning {{conversion specifies type 'wchar_t *' (aka 'int *')}} + scanf("%jd", 0); // expected-warning {{format specifies type 'intmax_t *' (aka 'long long *')}} + scanf("%ju", 0); // expected-warning {{format specifies type 'uintmax_t *' (aka 'unsigned long long *')}} + scanf("%zu", 0); // expected-warning {{format specifies type 'size_t *' (aka 'unsigned long *')}} + scanf("%td", 0); // expected-warning {{format specifies type 'ptrdiff_t *' (aka 'int *')}} + scanf("%lc", 0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}} + scanf("%ls", 0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}} + scanf("%S", 0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}} + scanf("%C", 0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}} // typedef size_t et al. to something crazy. @@ -30,8 +30,8 @@ void test(void) { typedef void *ptrdiff_t; // The warning still fires, because it checks the underlying type. - printf("%jd", (intmax_t)42); // expected-warning {{conversion specifies type 'intmax_t' (aka 'long long') but the argument has type 'intmax_t' (aka 'void *')}} - 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 *')}} - printf("%zu", (size_t)42); // expected-warning {{conversion specifies type 'size_t' (aka 'unsigned long') but the argument has type 'size_t' (aka 'void *')}} - printf("%td", (ptrdiff_t)42); // expected-warning {{conversion specifies type 'ptrdiff_t' (aka 'int') but the argument has type 'ptrdiff_t' (aka 'void *')}} + printf("%jd", (intmax_t)42); // expected-warning {{format specifies type 'intmax_t' (aka 'long long') but the argument has type 'intmax_t' (aka 'void *')}} + printf("%ju", (uintmax_t)42); // expected-warning {{format specifies type 'uintmax_t' (aka 'unsigned long long') but the argument has type 'uintmax_t' (aka 'void *')}} + printf("%zu", (size_t)42); // expected-warning {{format specifies type 'size_t' (aka 'unsigned long') but the argument has type 'size_t' (aka 'void *')}} + printf("%td", (ptrdiff_t)42); // expected-warning {{format specifies type 'ptrdiff_t' (aka 'int') but the argument has type 'ptrdiff_t' (aka 'void *')}} } |