aboutsummaryrefslogtreecommitdiff
path: root/test/Sema/format-strings-scanf.c
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2012-07-30 17:11:32 +0000
committerHans Wennborg <hans@hanshq.net>2012-07-30 17:11:32 +0000
commitcec9ce49dcf4b4b768043f96c8ef8c1d4cdbb6b9 (patch)
tree9d721b14c3dc15581ba2acee713216b5f103561c /test/Sema/format-strings-scanf.c
parent3ccc173d6f1f9e43566c258289b7581d8aa523ad (diff)
Make -Wformat check the argument type for %n.
This makes Clang check that the corresponding argument for "%n" in a format string is a pointer to int. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160966 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/format-strings-scanf.c')
-rw-r--r--test/Sema/format-strings-scanf.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/test/Sema/format-strings-scanf.c b/test/Sema/format-strings-scanf.c
index e94af5acb1..2ce94840a6 100644
--- a/test/Sema/format-strings-scanf.c
+++ b/test/Sema/format-strings-scanf.c
@@ -121,3 +121,8 @@ void test_quad(int *x, long long *llx) {
scanf("%qd", x); // expected-warning{{format specifies type 'long long *' but the argument has type 'int *'}}
scanf("%qd", llx); // no-warning
}
+
+void test_writeback(int *x) {
+ scanf("%n", (void*)0); // expected-warning{{format specifies type 'int *' but the argument has type 'void *'}}
+ scanf("%n %c", x, x); // expected-warning{{format specifies type 'char *' but the argument has type 'int *'}}
+}