summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaObjC/format-strings-objc.m
diff options
context:
space:
mode:
authorJean-Daniel Dupas <devlists@shadowlab.org>2012-01-17 20:03:31 +0000
committerJean-Daniel Dupas <devlists@shadowlab.org>2012-01-17 20:03:31 +0000
commit0ae6e671ccd1d1bd16fe7d360e465dcc56473c9b (patch)
tree7aea0c63b51139d922cac32af24626c1b7ae5f6e /clang/test/SemaObjC/format-strings-objc.m
parentf3bccd77fcbe2c06bc0dd8893d222a19cecb9620 (diff)
downloadbcm5719-llvm-0ae6e671ccd1d1bd16fe7d360e465dcc56473c9b.tar.gz
bcm5719-llvm-0ae6e671ccd1d1bd16fe7d360e465dcc56473c9b.zip
Fix a couples of issues in format strings checking.
PR 10274: format function attribute with the NSString archetype yields no compiler warnings PR 10275: format function attribute isn't checked in Objective-C methods llvm-svn: 148324
Diffstat (limited to 'clang/test/SemaObjC/format-strings-objc.m')
-rw-r--r--clang/test/SemaObjC/format-strings-objc.m19
1 files changed, 19 insertions, 0 deletions
diff --git a/clang/test/SemaObjC/format-strings-objc.m b/clang/test/SemaObjC/format-strings-objc.m
index d89f50afa96..29e3a3f4965 100644
--- a/clang/test/SemaObjC/format-strings-objc.m
+++ b/clang/test/SemaObjC/format-strings-objc.m
@@ -63,3 +63,22 @@ void test_p_conversion_with_objc_pointer(id x, id<Foo> y) {
printf("%p", y); // no-warning
}
+// <rdar://problem/10696348>, PR 10274 - CFString and NSString formats are ignored
+extern void MyNSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
+extern void MyCFStringCreateWithFormat(CFStringRef format, ...) __attribute__((format(__CFString__, 1, 2)));
+
+void check_mylog() {
+ MyNSLog(@"%@"); // expected-warning {{more '%' conversions than data arguments}}
+ // FIXME: find a way to test CFString too, but I don't know how to create constant CFString.
+}
+
+// PR 10275 - format function attribute isn't checked in Objective-C methods
+@interface Foo
++ (id)fooWithFormat:(NSString *)fmt, ... __attribute__((format(__NSString__, 1, 2)));
++ (id)fooWithCStringFormat:(const char *)format, ... __attribute__((format(__printf__, 1, 2)));
+@end
+
+void check_method() {
+ [Foo fooWithFormat:@"%@"]; // expected-warning {{more '%' conversions than data arguments}}
+ [Foo fooWithCStringFormat:"%@"]; // expected-warning {{invalid conversion specifier '@'}}
+}
OpenPOWER on IntegriCloud