summaryrefslogtreecommitdiffstats
path: root/clang/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
commit41362cea7b4eca2248cdc3fd36b534d17624cecc (patch)
treeac80f734d283293b1a82150b99f2d883599d4e7d /clang/test/Sema/format-strings.c
parente0ad9ea7cd85a2329d28eb40d3aad39267c9832a (diff)
downloadbcm5719-llvm-41362cea7b4eca2248cdc3fd36b534d17624cecc.tar.gz
bcm5719-llvm-41362cea7b4eca2248cdc3fd36b534d17624cecc.zip
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. llvm-svn: 42933
Diffstat (limited to 'clang/test/Sema/format-strings.c')
-rw-r--r--clang/test/Sema/format-strings.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/test/Sema/format-strings.c b/clang/test/Sema/format-strings.c
index 8b3be6856b5..2222f796086 100644
--- a/clang/test/Sema/format-strings.c
+++ b/clang/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
OpenPOWER on IntegriCloud