From: Ted Kremenek Date: Tue, 16 Feb 2010 02:14:24 +0000 (+0000) Subject: Add test case to show that Clang now checks the format string X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0da9e9582832ee776030a38420fc851b0118b598;p=clang Add test case to show that Clang now checks the format string arguments of asprintf (). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96319 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c index 8c2788d3a2..f1fa6580e3 100644 --- a/test/Sema/format-strings.c +++ b/test/Sema/format-strings.c @@ -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;