From a768bc926fd9b4f5747e448071781a29d6b415b2 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Fri, 14 Mar 2014 23:30:18 +0000 Subject: [PATCH] Objective-C. Redo turning 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@203984 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDecl.cpp | 15 ++++++++++----- lib/Sema/SemaDeclObjC.cpp | 7 ++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index eba195386f..f4e0df6d0a 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -9831,14 +9831,19 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body, MD->isDesignatedInitializerForTheInterface(&InitMethod); assert(isDesignated && InitMethod); (void)isDesignated; - Diag(MD->getLocation(), - diag::warn_objc_designated_init_missing_super_call); - Diag(InitMethod->getLocation(), - diag::note_objc_designated_init_marked_here); + // Don't issue this warning for unavaialable inits. + if (!MD->isUnavailable()) { + Diag(MD->getLocation(), + diag::warn_objc_designated_init_missing_super_call); + Diag(InitMethod->getLocation(), + diag::note_objc_designated_init_marked_here); + } getCurFunction()->ObjCWarnForNoDesignatedInitChain = false; } if (getCurFunction()->ObjCWarnForNoInitDelegation) { - Diag(MD->getLocation(), diag::warn_objc_secondary_init_missing_init_call); + // Don't issue this warning for unavaialable inits. + if (!MD->isUnavailable()) + Diag(MD->getLocation(), diag::warn_objc_secondary_init_missing_init_call); getCurFunction()->ObjCWarnForNoInitDelegation = false; } } else { diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index ca4d20c099..3198b01949 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -392,14 +392,11 @@ void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, Decl *D) { if (MDecl->getMethodFamily() == OMF_init) { if (MDecl->isDesignatedInitializerForTheInterface()) { getCurFunction()->ObjCIsDesignatedInit = true; - // Don't issue this warning for unavaialable inits. - if (!MDecl->isUnavailable()) - getCurFunction()->ObjCWarnForNoDesignatedInitChain = + getCurFunction()->ObjCWarnForNoDesignatedInitChain = IC->getSuperClass() != 0; } else if (IC->hasDesignatedInitializers()) { getCurFunction()->ObjCIsSecondaryInit = true; - // Don't issue this warning for unavaialable inits. - getCurFunction()->ObjCWarnForNoInitDelegation = !MDecl->isUnavailable(); + getCurFunction()->ObjCWarnForNoInitDelegation = true; } } -- 2.40.0