From 8549ec2604f3896eece840d27d7661052c8d394a Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Tue, 28 Jan 2014 22:46:29 +0000 Subject: [PATCH] Objective-C. Fixes a bug where "new" family attribute was not being overridden in the category method implementation resulting in bogus warning. // rdar://15919775 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200342 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDeclObjC.cpp | 3 ++- test/SemaObjC/dealloc.m | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index c91ce37711..8337c1f7e5 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -3165,7 +3165,8 @@ Decl *Sema::ActOnMethodDeclaration( ObjCMethod->getLocation())); } if (isa(ImpDecl)) { - ObjCMethodFamily family = ObjCMethod->getMethodFamily(); + ObjCMethodFamily family = + ObjCMethod->getSelector().getMethodFamily(); if (family == OMF_dealloc && IMD && IMD->isOverriding()) Diag(ObjCMethod->getLocation(), diag::warn_dealloc_in_category) << ObjCMethod->getDeclName(); diff --git a/test/SemaObjC/dealloc.m b/test/SemaObjC/dealloc.m index db89b20f5a..c1bd0b5ed4 100644 --- a/test/SemaObjC/dealloc.m +++ b/test/SemaObjC/dealloc.m @@ -39,3 +39,17 @@ - (void)dealloc { // expected-warning {{-dealloc is being overridden in a category}} } @end + +// rdar://15919775 +@interface NSObject @end +@interface NSError:NSObject +@end + +@interface NSError(CAT) +- (NSError *)MCCopyAsPrimaryError __attribute__((objc_method_family(new))); +@end +@implementation NSError(CAT) +- (NSError *)MCCopyAsPrimaryError { + return 0; +} +@end -- 2.40.0