From cd83106151285041c4e5f492bb80e9cb22276db2 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Mon, 1 Feb 2010 19:28:15 +0000 Subject: Format string checking: selectively ignore implicit casts to 'int' when checking if the format specifier matches the type of the data argument and the length modifier indicates the data type is 'char' or 'short'. llvm-svn: 94992 --- clang/test/Sema/format-strings.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'clang/test/Sema/format-strings.c') diff --git a/clang/test/Sema/format-strings.c b/clang/test/Sema/format-strings.c index 02e39a426be..a055bfe1822 100644 --- a/clang/test/Sema/format-strings.c +++ b/clang/test/Sema/format-strings.c @@ -162,6 +162,11 @@ void test10(int x, float f, int i, long long lli) { printf("%.", x); // expected-warning{{incomplete format specifier}} printf("%f", 4); // expected-warning{{conversion 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'}} } typedef struct __aslclient *aslclient; -- cgit v1.2.3