r207332 - [SemaObjC] Fix ObjCInterfaceDecl::inheritsDesignatedInitializers(), if there are no
Argyrios Kyrtzidis
akyrtzi at gmail.com
Sat Apr 26 14:28:42 PDT 2014
Author: akirtzidis
Date: Sat Apr 26 16:28:41 2014
New Revision: 207332
URL: http://llvm.org/viewvc/llvm-project?rev=207332&view=rev
Log:
[SemaObjC] Fix ObjCInterfaceDecl::inheritsDesignatedInitializers(), if there are no
designated initializers in the super class hierarchy then it should return false.
rdar://16692535
Modified:
cfe/trunk/lib/AST/DeclObjC.cpp
cfe/trunk/test/SemaObjC/attr-designated-init.m
Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=207332&r1=207331&r2=207332&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Sat Apr 26 16:28:41 2014
@@ -385,11 +385,21 @@ bool ObjCInterfaceDecl::inheritsDesignat
// 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;
}
}
Modified: cfe/trunk/test/SemaObjC/attr-designated-init.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/attr-designated-init.m?rev=207332&r1=207331&r2=207332&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/attr-designated-init.m (original)
+++ cfe/trunk/test/SemaObjC/attr-designated-init.m Sat Apr 26 16:28:41 2014
@@ -388,3 +388,25 @@ __attribute__((objc_root_class))
return self;
}
@end
+
+__attribute__((objc_root_class))
+ at interface RootNoDI
+-(id)init;
+ at end
+
+ at interface Base : RootNoDI
+ at end
+
+ at implementation Base
+ at end
+
+ at interface Derived : Base
+- (instancetype)initWithInt:(int)n NS_DESIGNATED_INITIALIZER;
+ at end
+
+ at implementation Derived
+- (instancetype)initWithInt:(int)n
+{
+ return [super init];
+}
+ at end
More information about the cfe-commits
mailing list