aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2012-03-15 21:22:27 +0000
committerTed Kremenek <kremenek@apple.com>2012-03-15 21:22:27 +0000
commitafcd1954be90965d832ae56f1413beae836c3346 (patch)
treee437f741176377cf9e1c8c5460c212e63f909ae0
parentaea3ece6d2ef7810d3c6296d7f46dc453caf40e3 (diff)
Support '%p' format specifier with block pointers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152839 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Analysis/FormatString.cpp2
-rw-r--r--test/SemaObjC/format-strings-objc.m12
2 files changed, 12 insertions, 2 deletions
diff --git a/lib/Analysis/FormatString.cpp b/lib/Analysis/FormatString.cpp
index dd2f2406d4..ba45865af8 100644
--- a/lib/Analysis/FormatString.cpp
+++ b/lib/Analysis/FormatString.cpp
@@ -337,7 +337,7 @@ bool ArgTypeResult::matchesType(ASTContext &C, QualType argTy) const {
case CPointerTy:
return argTy->isPointerType() || argTy->isObjCObjectPointerType() ||
- argTy->isNullPtrType();
+ argTy->isBlockPointerType() || argTy->isNullPtrType();
case ObjCPointerTy: {
if (argTy->getAs<ObjCObjectPointerType>() ||
diff --git a/test/SemaObjC/format-strings-objc.m b/test/SemaObjC/format-strings-objc.m
index a2a926c7d0..b9c2241399 100644
--- a/test/SemaObjC/format-strings-objc.m
+++ b/test/SemaObjC/format-strings-objc.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -Wformat-nonliteral -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -Wformat-nonliteral -fsyntax-only -fblocks -verify %s
//===----------------------------------------------------------------------===//
// The following code is reduced using delta-debugging from
@@ -176,3 +176,13 @@ void test_toll_free_bridging(CFStringRef x) {
}
@end
+
+
+// Test that it is okay to use %p with the address of a block.
+void rdar11049844_aux();
+int rdar11049844() {
+ typedef void (^MyBlock)(void);
+ MyBlock x = ^void() { rdar11049844_aux(); };
+ printf("%p", x); // no-warning
+}
+