diff options
author | Hans Wennborg <hans@hanshq.net> | 2012-08-07 09:13:19 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2012-08-07 09:13:19 +0000 |
commit | f7158fa034174d2756736d1032b75d01d9deeb4c (patch) | |
tree | daae3b86a7aa65825f39d4d279ac4fa52cb99661 /test/Sema/format-strings-size_t.c | |
parent | 58e1e54476d610d6c33ef483f216ed8a1282d35c (diff) |
Properly check length modfiers for %n in format strings.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161408 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/format-strings-size_t.c')
-rw-r--r-- | test/Sema/format-strings-size_t.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/Sema/format-strings-size_t.c b/test/Sema/format-strings-size_t.c index 7f88ff38c3..5058a76218 100644 --- a/test/Sema/format-strings-size_t.c +++ b/test/Sema/format-strings-size_t.c @@ -13,3 +13,16 @@ void test(void) { // ptrdiff_t printf("%td", (double)42); // expected-warning {{format specifies type 'ptrdiff_t' (aka 'long') but the argument has type 'double'}} } + +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 *'}} +} |