aboutsummaryrefslogtreecommitdiff
path: root/test/Sema/format-strings-scanf.c
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2012-08-07 09:13:19 +0000
committerHans Wennborg <hans@hanshq.net>2012-08-07 09:13:19 +0000
commitf7158fa034174d2756736d1032b75d01d9deeb4c (patch)
treedaae3b86a7aa65825f39d4d279ac4fa52cb99661 /test/Sema/format-strings-scanf.c
parent58e1e54476d610d6c33ef483f216ed8a1282d35c (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-scanf.c')
-rw-r--r--test/Sema/format-strings-scanf.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/Sema/format-strings-scanf.c b/test/Sema/format-strings-scanf.c
index 49c97149a7..235ac11faa 100644
--- a/test/Sema/format-strings-scanf.c
+++ b/test/Sema/format-strings-scanf.c
@@ -131,6 +131,32 @@ void test_quad(int *x, long long *llx) {
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 *'}}
+
+ scanf("%hhn", (signed char*)0); // no-warning
+ scanf("%hhn", (char*)0); // no-warning
+ scanf("%hhn", (unsigned char*)0); // no-warning
+ scanf("%hhn", (int*)0); // expected-warning{{format specifies type 'signed char *' but the argument has type 'int *'}}
+
+ scanf("%hn", (short*)0); // no-warning
+ scanf("%hn", (unsigned short*)0); // no-warning
+ scanf("%hn", (int*)0); // expected-warning{{format specifies type 'short *' but the argument has type 'int *'}}
+
+ scanf("%n", (int*)0); // no-warning
+ scanf("%n", (unsigned int*)0); // no-warning
+ scanf("%n", (char*)0); // expected-warning{{format specifies type 'int *' but the argument has type 'char *'}}
+
+ scanf("%ln", (long*)0); // no-warning
+ scanf("%ln", (unsigned long*)0); // no-warning
+ scanf("%ln", (int*)0); // expected-warning{{format specifies type 'long *' but the argument has type 'int *'}}
+
+ scanf("%lln", (long long*)0); // no-warning
+ scanf("%lln", (unsigned long long*)0); // no-warning
+ scanf("%lln", (int*)0); // expected-warning{{format specifies type 'long long *' but the argument has type 'int *'}}
+
+ scanf("%qn", (long long*)0); // no-warning
+ scanf("%qn", (unsigned long long*)0); // no-warning
+ scanf("%qn", (int*)0); // expected-warning{{format specifies type 'long long *' but the argument has type 'int *'}}
+
}
void test_qualifiers(const int *cip, volatile int* vip,