From 78512b16ea19063fe2f5918de7d6e22bea0d2d76 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Sat, 26 Apr 2014 21:28:41 +0000 Subject: [PATCH] [SemaObjC] Fix ObjCInterfaceDecl::inheritsDesignatedInitializers(), if there are no designated initializers in the super class hierarchy then it should return false. rdar://16692535 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207332 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/DeclObjC.cpp | 16 +++++++++++++--- test/SemaObjC/attr-designated-init.m | 22 ++++++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index 357c1ec529..aedb097bee 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -385,11 +385,21 @@ bool ObjCInterfaceDecl::inheritsDesignatedInitializers() const { // misleading warnings. if (isIntroducingInitializers(this)) { data().InheritedDesignatedInitializers = DefinitionData::IDI_NotInherited; - return false; } else { - data().InheritedDesignatedInitializers = DefinitionData::IDI_Inherited; - return true; + if (auto SuperD = getSuperClass()) { + data().InheritedDesignatedInitializers = + SuperD->declaresOrInheritsDesignatedInitializers() ? + DefinitionData::IDI_Inherited : + DefinitionData::IDI_NotInherited; + } else { + data().InheritedDesignatedInitializers = + DefinitionData::IDI_NotInherited; + } } + assert(data().InheritedDesignatedInitializers + != DefinitionData::IDI_Unknown); + return data().InheritedDesignatedInitializers == + DefinitionData::IDI_Inherited; } } diff --git a/test/SemaObjC/attr-designated-init.m b/test/SemaObjC/attr-designated-init.m index 3dbc2cab12..b52e5c5d4a 100644 --- a/test/SemaObjC/attr-designated-init.m +++ b/test/SemaObjC/attr-designated-init.m @@ -388,3 +388,25 @@ __attribute__((objc_root_class)) return self; } @end + +__attribute__((objc_root_class)) +@interface RootNoDI +-(id)init; +@end + +@interface Base : RootNoDI +@end + +@implementation Base +@end + +@interface Derived : Base +- (instancetype)initWithInt:(int)n NS_DESIGNATED_INITIALIZER; +@end + +@implementation Derived +- (instancetype)initWithInt:(int)n +{ + return [super init]; +} +@end -- 2.40.0