From ce506ae231703a23ea95335cd4de19c60082f361 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Fri, 20 Jan 2012 21:52:58 +0000 Subject: [PATCH] Tighten format string diagnostic and make it a bit clearer (and a bit closer to GCC's). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148579 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/DiagnosticSemaKinds.td | 2 +- test/Analysis/taint-generic.c | 2 +- test/Sema/block-printf-attribute-1.c | 2 +- test/Sema/format-strings-c90.c | 6 +-- test/Sema/format-strings-int-typedefs.c | 40 ++++++++++---------- test/Sema/format-strings-scanf.c | 24 ++++++------ test/Sema/format-strings-size_t.c | 8 ++-- test/Sema/format-strings.c | 44 +++++++++++----------- test/Sema/no-format-y2k-turnsoff-format.c | 2 +- test/SemaCXX/format-strings-0x.cpp | 2 +- test/SemaObjC/format-strings-objc.m | 4 +- 11 files changed, 68 insertions(+), 68 deletions(-) diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 41e723722f..f685c9f2b7 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -4791,7 +4791,7 @@ def warn_scanf_nonzero_width : Warning< "zero field width in scanf format string is unused">, InGroup; def warn_printf_conversion_argument_type_mismatch : Warning< - "conversion specifies type %0 but the argument has type %1">, + "format specifies type %0 but the argument has type %1">, InGroup; def warn_printf_positional_arg_exceeds_data_args : Warning < "data argument position '%0' exceeds the number of data arguments (%1)">, diff --git a/test/Analysis/taint-generic.c b/test/Analysis/taint-generic.c index 65e519e6ae..be20f2c24f 100644 --- a/test/Analysis/taint-generic.c +++ b/test/Analysis/taint-generic.c @@ -65,7 +65,7 @@ void bufferScanfAssignment(int x) { void scanfArg() { int t = 0; - scanf("%d", t); // expected-warning {{conversion specifies type 'int *' but the argument has type 'int'}} + scanf("%d", t); // expected-warning {{format specifies type 'int *' but the argument has type 'int'}} } void bufferGetchar(int x) { diff --git a/test/Sema/block-printf-attribute-1.c b/test/Sema/block-printf-attribute-1.c index c19b3788a3..8188ba5b55 100644 --- a/test/Sema/block-printf-attribute-1.c +++ b/test/Sema/block-printf-attribute-1.c @@ -6,6 +6,6 @@ int main() { void (^z) (int arg, const char * format, ...) __attribute__ ((__format__ (__printf__, 2, 3))) = ^ __attribute__ ((__format__ (__printf__, 2, 3))) (int arg, const char * format, ...) {}; - z(1, "%s", 1); // expected-warning{{conversion specifies type 'char *' but the argument has type 'int'}} + z(1, "%s", 1); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}} z(1, "%s", "HELLO"); // no-warning } diff --git a/test/Sema/format-strings-c90.c b/test/Sema/format-strings-c90.c index 678a6ef373..0b32e82d87 100644 --- a/test/Sema/format-strings-c90.c +++ b/test/Sema/format-strings-c90.c @@ -21,7 +21,7 @@ void foo(char **sp, float *fp, int *ip) { scanf("%da", ip); /* Test argument type check for the 'a' length modifier. */ - scanf("%as", fp); /* expected-warning{{conversion specifies type 'char **' but the argument has type 'float *'}} */ - scanf("%aS", fp); /* expected-warning{{conversion specifies type 'wchar_t **' (aka 'int **') but the argument has type 'float *'}} */ - scanf("%a[abc]", fp); /* expected-warning{{conversion specifies type 'char **' but the argument has type 'float *'}} */ + scanf("%as", fp); /* expected-warning{{format specifies type 'char **' but the argument has type 'float *'}} */ + scanf("%aS", fp); /* expected-warning{{format specifies type 'wchar_t **' (aka 'int **') but the argument has type 'float *'}} */ + scanf("%a[abc]", fp); /* expected-warning{{format specifies type 'char **' but the argument has type 'float *'}} */ } diff --git a/test/Sema/format-strings-int-typedefs.c b/test/Sema/format-strings-int-typedefs.c index 8d5dff1523..341d49c500 100644 --- a/test/Sema/format-strings-int-typedefs.c +++ b/test/Sema/format-strings-int-typedefs.c @@ -4,23 +4,23 @@ 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')}} - printf("%ju", 42.0); // expected-warning {{conversion specifies type 'uintmax_t' (aka 'unsigned long long')}} - printf("%zu", 42.0); // expected-warning {{conversion specifies type 'size_t' (aka 'unsigned long')}} - printf("%td", 42.0); // expected-warning {{conversion specifies type 'ptrdiff_t' (aka 'int')}} - printf("%lc", 42.0); // expected-warning {{conversion specifies type 'wint_t' (aka 'int')}} - printf("%ls", 42.0); // expected-warning {{conversion specifies type 'wchar_t *' (aka 'int *')}} - 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')}} + printf("%jd", 42.0); // expected-warning {{format specifies type 'intmax_t' (aka 'long long')}} + printf("%ju", 42.0); // expected-warning {{format specifies type 'uintmax_t' (aka 'unsigned long long')}} + printf("%zu", 42.0); // expected-warning {{format specifies type 'size_t' (aka 'unsigned long')}} + printf("%td", 42.0); // expected-warning {{format specifies type 'ptrdiff_t' (aka 'int')}} + printf("%lc", 42.0); // expected-warning {{format specifies type 'wint_t' (aka 'int')}} + printf("%ls", 42.0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}} + printf("%S", 42.0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}} + printf("%C", 42.0); // expected-warning {{format 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 *')}} + scanf("%jd", 0); // expected-warning {{format specifies type 'intmax_t *' (aka 'long long *')}} + scanf("%ju", 0); // expected-warning {{format specifies type 'uintmax_t *' (aka 'unsigned long long *')}} + scanf("%zu", 0); // expected-warning {{format specifies type 'size_t *' (aka 'unsigned long *')}} + scanf("%td", 0); // expected-warning {{format specifies type 'ptrdiff_t *' (aka 'int *')}} + scanf("%lc", 0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}} + scanf("%ls", 0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}} + scanf("%S", 0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}} + scanf("%C", 0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}} // typedef size_t et al. to something crazy. @@ -30,8 +30,8 @@ void test(void) { typedef void *ptrdiff_t; // The warning still fires, because it checks the underlying type. - printf("%jd", (intmax_t)42); // expected-warning {{conversion specifies type 'intmax_t' (aka 'long long') but the argument has type 'intmax_t' (aka 'void *')}} - printf("%ju", (uintmax_t)42); // expected-warning {{conversion specifies type 'uintmax_t' (aka 'unsigned long long') but the argument has type 'uintmax_t' (aka 'void *')}} - printf("%zu", (size_t)42); // expected-warning {{conversion specifies type 'size_t' (aka 'unsigned long') but the argument has type 'size_t' (aka 'void *')}} - printf("%td", (ptrdiff_t)42); // expected-warning {{conversion specifies type 'ptrdiff_t' (aka 'int') but the argument has type 'ptrdiff_t' (aka 'void *')}} + printf("%jd", (intmax_t)42); // expected-warning {{format specifies type 'intmax_t' (aka 'long long') but the argument has type 'intmax_t' (aka 'void *')}} + printf("%ju", (uintmax_t)42); // expected-warning {{format specifies type 'uintmax_t' (aka 'unsigned long long') but the argument has type 'uintmax_t' (aka 'void *')}} + printf("%zu", (size_t)42); // expected-warning {{format specifies type 'size_t' (aka 'unsigned long') but the argument has type 'size_t' (aka 'void *')}} + printf("%td", (ptrdiff_t)42); // expected-warning {{format specifies type 'ptrdiff_t' (aka 'int') but the argument has type 'ptrdiff_t' (aka 'void *')}} } diff --git a/test/Sema/format-strings-scanf.c b/test/Sema/format-strings-scanf.c index be70357560..e954958c52 100644 --- a/test/Sema/format-strings-scanf.c +++ b/test/Sema/format-strings-scanf.c @@ -59,9 +59,9 @@ void test_variants(int *i, const char *s, ...) { FILE *f = 0; char buf[100]; - fscanf(f, "%ld", i); // expected-warning{{conversion specifies type 'long *' but the argument has type 'int *'}} - sscanf(buf, "%ld", i); // expected-warning{{conversion specifies type 'long *' but the argument has type 'int *'}} - my_scanf("%ld", i); // expected-warning{{conversion specifies type 'long *' but the argument has type 'int *'}} + fscanf(f, "%ld", i); // expected-warning{{format specifies type 'long *' but the argument has type 'int *'}} + sscanf(buf, "%ld", i); // expected-warning{{format specifies type 'long *' but the argument has type 'int *'}} + my_scanf("%ld", i); // expected-warning{{format specifies type 'long *' but the argument has type 'int *'}} va_list ap; va_start(ap, s); @@ -72,7 +72,7 @@ void test_variants(int *i, const char *s, ...) { } void test_scanlist(int *ip, char *sp) { - scanf("%[abc]", ip); // expected-warning{{conversion specifies type 'char *' but the argument has type 'int *'}} + scanf("%[abc]", ip); // expected-warning{{format specifies type 'char *' but the argument has type 'int *'}} scanf("%h[abc]", sp); // expected-warning{{length modifier 'h' results in undefined behavior or no effect with '[' conversion specifier}} } @@ -80,9 +80,9 @@ void test_alloc_extension(char **sp, wchar_t **lsp, float *fp) { /* Make sure "%a" gets parsed as a conversion specifier for float, * even when followed by an 's', 'S' or '[', which would cause it to be * parsed as a length modifier in C90. */ - scanf("%as", sp); // expected-warning{{conversion specifies type 'float *' but the argument has type 'char **'}} - scanf("%aS", lsp); // expected-warning{{conversion specifies type 'float *' but the argument has type 'wchar_t **'}} - scanf("%a[bcd]", sp); // expected-warning{{conversion specifies type 'float *' but the argument has type 'char **'}} + scanf("%as", sp); // expected-warning{{format specifies type 'float *' but the argument has type 'char **'}} + scanf("%aS", lsp); // expected-warning{{format specifies type 'float *' but the argument has type 'wchar_t **'}} + scanf("%a[bcd]", sp); // expected-warning{{format specifies type 'float *' but the argument has type 'char **'}} // Test that the 'm' length modifier is only allowed with s, S, c, C or [. // TODO: Warn that 'm' is an extension. @@ -94,9 +94,9 @@ void test_alloc_extension(char **sp, wchar_t **lsp, float *fp) { scanf("%md", sp); // expected-warning{{length modifier 'm' results in undefined behavior or no effect with 'd' conversion specifier}} // Test argument type check for the 'm' length modifier. - scanf("%ms", fp); // expected-warning{{conversion specifies type 'char **' but the argument has type 'float *'}} - scanf("%mS", fp); // expected-warning{{conversion specifies type 'wchar_t **' (aka 'int **') but the argument has type 'float *'}} - scanf("%mc", fp); // expected-warning{{conversion specifies type 'char **' but the argument has type 'float *'}} - scanf("%mC", fp); // expected-warning{{conversion specifies type 'wchar_t **' (aka 'int **') but the argument has type 'float *'}} - scanf("%m[abc]", fp); // expected-warning{{conversion specifies type 'char **' but the argument has type 'float *'}} + scanf("%ms", fp); // expected-warning{{format specifies type 'char **' but the argument has type 'float *'}} + scanf("%mS", fp); // expected-warning{{format specifies type 'wchar_t **' (aka 'int **') but the argument has type 'float *'}} + scanf("%mc", fp); // expected-warning{{format specifies type 'char **' but the argument has type 'float *'}} + scanf("%mC", fp); // expected-warning{{format specifies type 'wchar_t **' (aka 'int **') but the argument has type 'float *'}} + scanf("%m[abc]", fp); // expected-warning{{format specifies type 'char **' but the argument has type 'float *'}} } diff --git a/test/Sema/format-strings-size_t.c b/test/Sema/format-strings-size_t.c index 2f6a25f66e..7f88ff38c3 100644 --- a/test/Sema/format-strings-size_t.c +++ b/test/Sema/format-strings-size_t.c @@ -4,12 +4,12 @@ int printf(char const *, ...); void test(void) { // size_t - printf("%zu", (double)42); // expected-warning {{conversion specifies type 'size_t' (aka 'unsigned long') but the argument has type 'double'}} + printf("%zu", (double)42); // expected-warning {{format specifies type 'size_t' (aka 'unsigned long') but the argument has type 'double'}} // intmax_t / uintmax_t - printf("%jd", (double)42); // expected-warning {{conversion specifies type 'intmax_t' (aka 'long') but the argument has type 'double'}} - printf("%ju", (double)42); // expected-warning {{conversion specifies type 'uintmax_t' (aka 'unsigned long') but the argument has type 'double'}} + printf("%jd", (double)42); // expected-warning {{format specifies type 'intmax_t' (aka 'long') but the argument has type 'double'}} + printf("%ju", (double)42); // expected-warning {{format specifies type 'uintmax_t' (aka 'unsigned long') but the argument has type 'double'}} // ptrdiff_t - printf("%td", (double)42); // expected-warning {{conversion specifies type 'ptrdiff_t' (aka 'long') but the argument has type 'double'}} + printf("%td", (double)42); // expected-warning {{format specifies type 'ptrdiff_t' (aka 'long') but the argument has type 'double'}} } diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c index c4bbc836d4..e32ad245e3 100644 --- a/test/Sema/format-strings.c +++ b/test/Sema/format-strings.c @@ -71,8 +71,8 @@ void check_invalid_specifier(FILE* fp, char *buf) { printf("%s%lb%d","unix",10,20); // expected-warning {{invalid conversion specifier 'b'}} fprintf(fp,"%%%l"); // expected-warning {{incomplete format specifier}} - sprintf(buf,"%%%%%ld%d%d", 1, 2, 3); // expected-warning{{conversion specifies type 'long' but the argument has type 'int'}} - snprintf(buf, 2, "%%%%%ld%;%d", 1, 2, 3); // expected-warning{{conversion specifies type 'long' but the argument has type 'int'}} expected-warning {{invalid conversion specifier ';'}} + sprintf(buf,"%%%%%ld%d%d", 1, 2, 3); // expected-warning{{format specifies type 'long' but the argument has type 'int'}} + snprintf(buf, 2, "%%%%%ld%;%d", 1, 2, 3); // expected-warning{{format specifies type 'long' but the argument has type 'int'}} expected-warning {{invalid conversion specifier ';'}} } void check_null_char_string(char* b) @@ -166,33 +166,33 @@ void test10(int x, float f, int i, long long lli) { printf("%"); // expected-warning{{incomplete format specifier}} printf("%.d", x); // no-warning printf("%.", x); // expected-warning{{incomplete format specifier}} - printf("%f", 4); // expected-warning{{conversion specifies type 'double' but the argument has type 'int'}} + printf("%f", 4); // expected-warning{{format specifies type 'double' but the argument has type 'int'}} printf("%qd", lli); printf("hhX %hhX", (unsigned char)10); // no-warning printf("llX %llX", (long long) 10); // no-warning // This is fine, because there is an implicit conversion to an int. printf("%d", (unsigned char) 10); // no-warning - printf("%d", (long long) 10); // expected-warning{{conversion specifies type 'int' but the argument has type 'long long'}} + printf("%d", (long long) 10); // expected-warning{{format specifies type 'int' but the argument has type 'long long'}} printf("%Lf\n", (long double) 1.0); // no-warning - printf("%f\n", (long double) 1.0); // expected-warning{{conversion specifies type 'double' but the argument has type 'long double'}} + printf("%f\n", (long double) 1.0); // expected-warning{{format specifies type 'double' but the argument has type 'long double'}} // The man page says that a zero precision is okay. printf("%.0Lf", (long double) 1.0); // no-warning - printf("%c\n", "x"); // expected-warning{{conversion specifies type 'int' but the argument has type 'char *'}} - printf("%c\n", 1.23); // expected-warning{{conversion specifies type 'int' but the argument has type 'double'}} + printf("%c\n", "x"); // expected-warning{{format specifies type 'int' but the argument has type 'char *'}} + printf("%c\n", 1.23); // expected-warning{{format specifies type 'int' but the argument has type 'double'}} printf("Format %d, is %! %f", 1, 2, 4.4); // expected-warning{{invalid conversion specifier '!'}} } typedef unsigned char uint8_t; void should_understand_small_integers() { - printf("%hhu", (short) 10); // expected-warning{{conversion specifies type 'unsigned char' but the argument has type 'short'}} - printf("%hu\n", (unsigned char) 1); // expected-warning{{conversion specifies type 'unsigned short' but the argument has type 'unsigned char'}} - printf("%hu\n", (uint8_t)1); // expected-warning{{conversion specifies type 'unsigned short' but the argument has type 'uint8_t'}} + printf("%hhu", (short) 10); // expected-warning{{format specifies type 'unsigned char' but the argument has type 'short'}} + printf("%hu\n", (unsigned char) 1); // expected-warning{{format specifies type 'unsigned short' but the argument has type 'unsigned char'}} + printf("%hu\n", (uint8_t)1); // expected-warning{{format specifies type 'unsigned short' but the argument has type 'uint8_t'}} } void test11(void *p, char *s) { printf("%p", p); // no-warning - printf("%p", 123); // expected-warning{{conversion specifies type 'void *' but the argument has type 'int'}} + printf("%p", 123); // expected-warning{{format specifies type 'void *' but the argument has type 'int'}} printf("%.4p", p); // expected-warning{{precision used with 'p' conversion specifier, resulting in undefined behavior}} printf("%+p", p); // expected-warning{{flag '+' results in undefined behavior with 'p' conversion specifier}} printf("% p", p); // expected-warning{{flag ' ' results in undefined behavior with 'p' conversion specifier}} @@ -206,16 +206,16 @@ void test11(void *p, char *s) { 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]'}} + printf ("%.4s\n", &buf); // expected-warning{{format 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 *'}} + asprintf(&b, "%d", "asprintf"); // expected-warning{{format specifies type 'int' but the argument has type 'char *'}} } void test13(short x) { char bel = 007; printf("bel: '0%hhd'\n", bel); // no-warning - printf("x: '0%hhd'\n", x); // expected-warning {{conversion specifies type 'char' but the argument has type 'short'}} + printf("x: '0%hhd'\n", x); // expected-warning {{format specifies type 'char' but the argument has type 'short'}} } typedef struct __aslclient *aslclient; @@ -237,7 +237,7 @@ typedef __WCHAR_TYPE__ wchar_t; void test_unicode_conversions(wchar_t *s) { printf("%S", s); // no-warning - printf("%s", s); // expected-warning{{conversion specifies type 'char *' but the argument has type 'wchar_t *'}} + printf("%s", s); // expected-warning{{format specifies type 'char *' but the argument has type 'wchar_t *'}} printf("%C", s[0]); // no-warning printf("%c", s[0]); // FIXME: This test reports inconsistent results. On Windows, '%C' expects @@ -255,7 +255,7 @@ void test_positional_arguments() { printf("%1$*0$d", (int) 2); // expected-warning{{position arguments in format strings start counting at 1 (not 0)}} printf("%1$d", (int) 2); // no-warning printf("%1$d", (int) 2, 2); // expected-warning{{data argument not used by format string}} - printf("%1$d%1$f", (int) 2); // expected-warning{{conversion specifies type 'double' but the argument has type 'int'}} + printf("%1$d%1$f", (int) 2); // expected-warning{{format specifies type 'double' but the argument has type 'int'}} printf("%1$2.2d", (int) 2); // no-warning printf("%2$*1$.2d", (int) 2, (int) 3); // no-warning printf("%2$*8$d", (int) 2, (int) 3); // expected-warning{{specified field width is missing a matching 'int' argument}} @@ -267,13 +267,13 @@ void test_positional_arguments() { void myprintf_PR_6697(const char *format, int x, ...) __attribute__((__format__(printf,1, 3))); void test_pr_6697() { myprintf_PR_6697("%s\n", 1, "foo"); // no-warning - myprintf_PR_6697("%s\n", 1, (int)0); // expected-warning{{conversion specifies type 'char *' but the argument has type 'int'}} + myprintf_PR_6697("%s\n", 1, (int)0); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}} // FIXME: Not everything should clearly support positional arguments, // but we need a way to identify those cases. myprintf_PR_6697("%1$s\n", 1, "foo"); // no-warning myprintf_PR_6697("%2$s\n", 1, "foo"); // expected-warning{{data argument position '2' exceeds the number of data arguments (1)}} myprintf_PR_6697("%18$s\n", 1, "foo"); // expected-warning{{data argument position '18' exceeds the number of data arguments (1)}} - myprintf_PR_6697("%1$s\n", 1, (int) 0); // expected-warning{{conversion specifies type 'char *' but the argument has type 'int'}} + myprintf_PR_6697("%1$s\n", 1, (int) 0); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}} } void rdar8026030(FILE *fp) { @@ -359,7 +359,7 @@ void posix_extensions() { #pragma GCC diagnostic ignored "-Wformat-security" void pr8486() { - printf("%s", 1); // expected-warning{{conversion specifies type 'char *' but the argument has type 'int'}} + printf("%s", 1); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}} } // PR9314 @@ -372,7 +372,7 @@ void pr9314() { int printf(const char * restrict, ...) __attribute__((__format__ (__printf__, 1, 2))); void rdar9612060(void) { - printf("%s", 2); // expected-warning{{conversion specifies type 'char *' but the argument has type 'int'}} + printf("%s", 2); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}} } void check_char(unsigned char x, signed char y) { @@ -421,8 +421,8 @@ void pr9751() { printf("%.", 5); // expected-warning{{incomplete format specifier}} const char kFormat6[] = "%s"; // expected-note{{format string is defined here}} - printf(kFormat6, 5); // expected-warning{{conversion specifies type 'char *' but the argument has type 'int'}} - printf("%s", 5); // expected-warning{{conversion specifies type 'char *' but the argument has type 'int'}} + printf(kFormat6, 5); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}} + printf("%s", 5); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}} const char kFormat7[] = "%0$"; // expected-note{{format string is defined here}} printf(kFormat7, 5); // expected-warning{{position arguments in format strings start counting at 1 (not 0)}} diff --git a/test/Sema/no-format-y2k-turnsoff-format.c b/test/Sema/no-format-y2k-turnsoff-format.c index bd06e506ce..b206ecdfc1 100644 --- a/test/Sema/no-format-y2k-turnsoff-format.c +++ b/test/Sema/no-format-y2k-turnsoff-format.c @@ -4,6 +4,6 @@ void foo(const char *, ...) __attribute__((__format__ (__printf__, 1, 2))); void bar(unsigned int a) { - foo("%s", a); // expected-warning {{conversion specifies type 'char *' but the argument has type 'unsigned int'}} + foo("%s", a); // expected-warning {{format specifies type 'char *' but the argument has type 'unsigned int'}} } diff --git a/test/SemaCXX/format-strings-0x.cpp b/test/SemaCXX/format-strings-0x.cpp index 61bdbe188d..9359c7b1f9 100644 --- a/test/SemaCXX/format-strings-0x.cpp +++ b/test/SemaCXX/format-strings-0x.cpp @@ -6,7 +6,7 @@ extern int printf(const char *restrict, ...); } void f(char **sp, float *fp) { - scanf("%as", sp); // expected-warning{{conversion specifies type 'float *' but the argument has type 'char **'}} + scanf("%as", sp); // expected-warning{{format specifies type 'float *' but the argument has type 'char **'}} printf("%a", 1.0); scanf("%afoobar", fp); diff --git a/test/SemaObjC/format-strings-objc.m b/test/SemaObjC/format-strings-objc.m index 29e3a3f496..3fb7c9e435 100644 --- a/test/SemaObjC/format-strings-objc.m +++ b/test/SemaObjC/format-strings-objc.m @@ -47,8 +47,8 @@ extern void CFStringCreateWithFormat2(int *format, ...) __attribute__((format(CF // - Catch use of long long with int arguments. void rdar_7068334() { long long test = 500; - printf("%i ",test); // expected-warning{{conversion specifies type 'int' but the argument has type 'long long'}} - NSLog(@"%i ",test); // expected-warning{{conversion specifies type 'int' but the argument has type 'long long'}} + printf("%i ",test); // expected-warning{{format specifies type 'int' but the argument has type 'long long'}} + NSLog(@"%i ",test); // expected-warning{{format specifies type 'int' but the argument has type 'long long'}} } // -- 2.40.0