summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/format-strings.c
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-10-21 04:00:58 +0000
committerTed Kremenek <kremenek@apple.com>2010-10-21 04:00:58 +0000
commit12a37de0039f79649a2758f7c9d67e925ca8f4a3 (patch)
tree724c11b18e821ba2deb11dac323c52edd471d5ba /clang/test/Sema/format-strings.c
parent6377965efbaabdb2188aa58b2a444531538c871f (diff)
downloadbcm5719-llvm-12a37de0039f79649a2758f7c9d67e925ca8f4a3.tar.gz
bcm5719-llvm-12a37de0039f79649a2758f7c9d67e925ca8f4a3.zip
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! llvm-svn: 116996
Diffstat (limited to 'clang/test/Sema/format-strings.c')
-rw-r--r--clang/test/Sema/format-strings.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/clang/test/Sema/format-strings.c b/clang/test/Sema/format-strings.c
index 1bfab255313..57f087b2e0c 100644
--- a/clang/test/Sema/format-strings.c
+++ b/clang/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
OpenPOWER on IntegriCloud