forked from OSchip/llvm-project
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 llvm-svn: 203966
This commit is contained in:
parent
f5d65b1ea7
commit
312104a716
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue