diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-10-21 04:00:58 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-10-21 04:00:58 +0000 |
commit | 4d8ae4d57ed18d60da4d3786fb740607aa7c3688 (patch) | |
tree | 417e4e11d6a2f8b488e22f6b86d8fe1b6f654864 /test/Sema/format-strings.c | |
parent | 5cca53e5beeb6ec14e03327f0fd4e5ff318834d6 (diff) |
Previously, the printf warnings would say your arguments type was 'int' when it was really a 'char'
or a 'short'. This fixes that and allows the hints to suggest 'h' modifiers for small ints.
Patch by Justin Bogner!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116996 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/format-strings.c')
-rw-r--r-- | test/Sema/format-strings.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c index 1bfab25531..57f087b2e0 100644 --- a/test/Sema/format-strings.c +++ b/test/Sema/format-strings.c @@ -174,7 +174,15 @@ void test10(int x, float f, int i, long long lli) { 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'}} -} +} + +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'}} +} void test11(void *p, char *s) { printf("%p", p); // no-warning |