// Checker-specific attribute handlers.
//===----------------------------------------------------------------------===//
+static bool isValidSubjectOfNSReturnsRetainedAttribute(Sema &S, QualType type) {
+ return type->isDependentType() ||
+ type->isObjCObjectPointerType() ||
+ type->isBlockPointerType() ||
+ S.Context.isObjCNSObjectType(type);
+}
+
static bool isValidSubjectOfNSAttribute(Sema &S, QualType type) {
return type->isDependentType() ||
type->isObjCObjectPointerType() ||
bool cf;
switch (Attr.getKind()) {
default: llvm_unreachable("invalid ownership attribute");
- case AttributeList::AT_NSReturnsAutoreleased:
case AttributeList::AT_NSReturnsRetained:
+ typeOK = isValidSubjectOfNSReturnsRetainedAttribute(S, returnType);
+ cf = false;
+ break;
+
+ case AttributeList::AT_NSReturnsAutoreleased:
case AttributeList::AT_NSReturnsNotRetained:
typeOK = isValidSubjectOfNSAttribute(S, returnType);
cf = false;
--- /dev/null
+// RUN: %clang_cc1 -fblocks -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -fblocks -fobjc-arc -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fobjc-arc -fsyntax-only -verify -Wno-objc-root-class %s
+// expected-no-diagnostics
+// rdar://17259812
+
+typedef void (^BT) ();
+
+BT foo() __attribute__((ns_returns_retained));
+
+@interface I
+BT foo() __attribute__((ns_returns_retained));
+@end
+
+@implementation I
+BT foo() __attribute__((ns_returns_retained)) {return ^{}; }
+@end