aboutsummaryrefslogtreecommitdiff
path: root/test/Sema/format-strings-int-typedefs.c
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2011-12-10 13:20:11 +0000
committerHans Wennborg <hans@hanshq.net>2011-12-10 13:20:11 +0000
commit6fcd932dfd6835f70cc00d6f7c6789793f6d7b66 (patch)
tree2ee0188182bc788b5a2ad7707914e8850c36ac83 /test/Sema/format-strings-int-typedefs.c
parente7edf30143e565574c9bed0f1dbeaa47bb9a0891 (diff)
Check that arguments to a scanf call match the format specifier,
and offer fixits when there is a mismatch. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146326 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/format-strings-int-typedefs.c')
-rw-r--r--test/Sema/format-strings-int-typedefs.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/Sema/format-strings-int-typedefs.c b/test/Sema/format-strings-int-typedefs.c
index 2568b8d69f..8d5dff1523 100644
--- a/test/Sema/format-strings-int-typedefs.c
+++ b/test/Sema/format-strings-int-typedefs.c
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
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')}}
@@ -12,6 +13,15 @@ void test(void) {
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')}}
+ 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 *')}}
+
// typedef size_t et al. to something crazy.
typedef void *size_t;