diff options
| author | Ted Kremenek <kremenek@apple.com> | 2010-06-16 21:23:04 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2010-06-16 21:23:04 +0000 |
| commit | 64c235e4c68a8f2bad5d26ea429b91b4e83f1de6 (patch) | |
| tree | 403e50b67fd807a6203dcbee447acce287419b42 /clang/test | |
| parent | fd3b4e739012b95bf981bbe79702a6a955578ca3 (diff) | |
| download | bcm5719-llvm-64c235e4c68a8f2bad5d26ea429b91b4e83f1de6.tar.gz bcm5719-llvm-64c235e4c68a8f2bad5d26ea429b91b4e83f1de6.zip | |
Extend format string type-checking to include '%p'. Fixes remaining cases PR 4468.
llvm-svn: 106151
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/Sema/format-strings-fixit.c | 1 | ||||
| -rw-r--r-- | clang/test/Sema/format-strings.c | 1 | ||||
| -rw-r--r-- | clang/test/SemaObjC/format-strings-objc.m | 8 |
3 files changed, 10 insertions, 0 deletions
diff --git a/clang/test/Sema/format-strings-fixit.c b/clang/test/Sema/format-strings-fixit.c index 9a1fef0401a..bbdd4d81059 100644 --- a/clang/test/Sema/format-strings-fixit.c +++ b/clang/test/Sema/format-strings-fixit.c @@ -14,6 +14,7 @@ void test() { printf("%s", (int) 123); printf("abc%0f", "testing testing 123"); printf("%u", (long) -12); + printf("%p", 123); // Larger types printf("%+.2d", (unsigned long long) 123456); diff --git a/clang/test/Sema/format-strings.c b/clang/test/Sema/format-strings.c index d6d37961d92..72aa5927c30 100644 --- a/clang/test/Sema/format-strings.c +++ b/clang/test/Sema/format-strings.c @@ -176,6 +176,7 @@ void test10(int x, float f, int i, long long lli) { 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("%.4p", p); // expected-warning{{precision used in 'p' conversion specifier (where it has no meaning)}} printf("%+p", p); // expected-warning{{flag '+' results in undefined behavior in 'p' conversion specifier}} printf("% p", p); // expected-warning{{flag ' ' results in undefined behavior in 'p' conversion specifier}} diff --git a/clang/test/SemaObjC/format-strings-objc.m b/clang/test/SemaObjC/format-strings-objc.m index 1fcc34f695d..d89f50afa96 100644 --- a/clang/test/SemaObjC/format-strings-objc.m +++ b/clang/test/SemaObjC/format-strings-objc.m @@ -55,3 +55,11 @@ void rdar_7068334() { void rdar_7697748() { NSLog(@"%@!"); // expected-warning{{more '%' conversions than data arguments}} } + +@protocol Foo; + +void test_p_conversion_with_objc_pointer(id x, id<Foo> y) { + printf("%p", x); // no-warning + printf("%p", y); // no-warning +} + |

