aboutsummaryrefslogtreecommitdiff
path: root/test/Sema/format-strings.c
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2007-10-12 20:51:52 +0000
committerTed Kremenek <kremenek@apple.com>2007-10-12 20:51:52 +0000
commit580b664e9c2acd3bffddfea79b1ce2863cfd9dd0 (patch)
tree787c494c41ab1c4186a0df6d69eecf70463b9c0e /test/Sema/format-strings.c
parent3457e8cbaa8a6fec5d69173450655fe0bc38634b (diff)
Added notion of '*' specified format width/specifiers when checking
printf format strings. Added type checking to see if the matching width/precision argument was of type 'int'. Thanks to Anders Carlsson for reporting this missing feature. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42933 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/format-strings.c')
-rw-r--r--test/Sema/format-strings.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c
index 8b3be6856b..2222f79608 100644
--- a/test/Sema/format-strings.c
+++ b/test/Sema/format-strings.c
@@ -61,3 +61,11 @@ void check_wide_string(char* b, ...)
printf(L"foo %d",2); // expected-warning {{should not be a wide string}}
vasprintf(&b,L"bar %d",2); // expected-warning {{should not be a wide string}}
}
+
+void check_asterisk_precision_width(int x) {
+ printf("%*d"); // expected-warning {{'*' specified field width is missing a matching 'int' argument}}
+ printf("%.*d"); // expected-warning {{'.*' specified field precision is missing a matching 'int' argument}}
+ printf("%*d",12,x); // no-warning
+ printf("%*d","foo",x); // expected-warning {{field width should have type 'int', but argument has type 'char *'}}
+ printf("%.*d","foo",x); // expected-warning {{field precision should have type 'int', but argument has type 'char *'}}
+} \ No newline at end of file