From: Fariborz Jahanian Date: Fri, 14 Mar 2014 20:35:00 +0000 (+0000) Subject: Objective-C. Turn off designated initialization warnings on X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=65477082fee4881b636d1abc8a56ef5ed1fb7a52;p=clang Objective-C. Turn off designated initialization warnings on 'init' methods which are unavailable. Subclasses of NSObject have to implement such methods as a common pattern to prevent user's own implementation. // rdar://16305460 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203966 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 3198b01949..ca4d20c099 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -392,11 +392,14 @@ void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, Decl *D) { if (MDecl->getMethodFamily() == OMF_init) { if (MDecl->isDesignatedInitializerForTheInterface()) { getCurFunction()->ObjCIsDesignatedInit = true; - getCurFunction()->ObjCWarnForNoDesignatedInitChain = + // Don't issue this warning for unavaialable inits. + if (!MDecl->isUnavailable()) + getCurFunction()->ObjCWarnForNoDesignatedInitChain = IC->getSuperClass() != 0; } else if (IC->hasDesignatedInitializers()) { getCurFunction()->ObjCIsSecondaryInit = true; - getCurFunction()->ObjCWarnForNoInitDelegation = true; + // Don't issue this warning for unavaialable inits. + getCurFunction()->ObjCWarnForNoInitDelegation = !MDecl->isUnavailable(); } } diff --git a/test/SemaObjC/attr-designated-init.m b/test/SemaObjC/attr-designated-init.m index 916be5d3bc..fccf21536c 100644 --- a/test/SemaObjC/attr-designated-init.m +++ b/test/SemaObjC/attr-designated-init.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s +// RUN: %clang_cc1 -fsyntax-only -Wno-incomplete-implementation -verify -fblocks %s #define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) @@ -248,3 +248,17 @@ __attribute__((objc_root_class)) return ((void*)0); } @end + +// rdar://16305460 +__attribute__((objc_root_class)) +@interface MyObject +- (instancetype)initWithStuff:(id)stuff __attribute__((objc_designated_initializer)); +- (instancetype)init __attribute__((unavailable)); +@end + +@implementation MyObject +- (instancetype)init +{ + return ((void*)0); +} +@end