]> granicus.if.org Git - clang/commitdiff
Add test case to show that Clang now checks the format string
authorTed Kremenek <kremenek@apple.com>
Tue, 16 Feb 2010 02:14:24 +0000 (02:14 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 16 Feb 2010 02:14:24 +0000 (02:14 +0000)
arguments of asprintf (<rdar://problem/6657191>).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96319 91177308-0d34-0410-b5e6-96231b3b80d8

test/Sema/format-strings.c

index 8c2788d3a25c0bb7419467774361c196543779b4..f1fa6580e3b8b296936f8f23d300bd1ab8679bf2 100644 (file)
@@ -183,10 +183,13 @@ void test11(void *p, char *s) {
   printf("%0s", p); // expected-warning{{flag '0' results in undefined behavior in 's' conversion specifier}}
 }
 
-void test12() {
+void test12(char *b) {
   unsigned char buf[4];
   printf ("%.4s\n", buf); // no-warning
   printf ("%.4s\n", &buf); // expected-warning{{conversion specifies type 'char *' but the argument has type 'unsigned char (*)[4]'}}
+  
+  // Verify that we are checking asprintf
+  asprintf(&b, "%d", "asprintf"); // expected-warning{{conversion specifies type 'int' but the argument has type 'char *'}}
 }
 
 typedef struct __aslclient *aslclient;