]> granicus.if.org Git - clang/commitdiff
Support '%p' format specifier with block pointers.
authorTed Kremenek <kremenek@apple.com>
Thu, 15 Mar 2012 21:22:27 +0000 (21:22 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 15 Mar 2012 21:22:27 +0000 (21:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152839 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/FormatString.cpp
test/SemaObjC/format-strings-objc.m

index dd2f2406d464ad489e7b659559dc5517bb7a4af5..ba45865af875237c5adadcd87514ca30684c7c39 100644 (file)
@@ -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>() ||
index a2a926c7d010f7f13ee9ae3b86fdd61198d6f2d9..b9c224139998d34349c5f750bbe696a40d3e77fb 100644 (file)
@@ -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
+}
+