return FunctionScopes.back();
}
+ sema::FunctionScopeInfo *getEnclosingFunction() const {
+ if (FunctionScopes.empty())
+ return 0;
+
+ for (int e = FunctionScopes.size()-1; e >= 0; --e) {
+ if (isa<sema::BlockScopeInfo>(FunctionScopes[e]))
+ continue;
+ return FunctionScopes[e];
+ }
+ return 0;
+ }
+
template <typename ExprT>
void recordUseOfEvaluatedWeak(const ExprT *E, bool IsRead=true) {
if (!isUnevaluatedContext())
}
}
- if (Method && Method->getMethodFamily() == OMF_init &&
- getCurFunction()->ObjCIsDesignatedInit &&
+ FunctionScopeInfo *DIFunctionScopeInfo =
+ (Method && Method->getMethodFamily() == OMF_init)
+ ? getEnclosingFunction() : 0;
+
+ if (DIFunctionScopeInfo &&
+ DIFunctionScopeInfo->ObjCIsDesignatedInit &&
(SuperLoc.isValid() || isSelfExpr(Receiver))) {
bool isDesignatedInitChain = false;
if (SuperLoc.isValid()) {
if (!ID->declaresOrInheritsDesignatedInitializers() ||
ID->isDesignatedInitializer(Sel)) {
isDesignatedInitChain = true;
- getCurFunction()->ObjCWarnForNoDesignatedInitChain = false;
+ DIFunctionScopeInfo->ObjCWarnForNoDesignatedInitChain = false;
}
}
}
}
}
- if (Method && Method->getMethodFamily() == OMF_init &&
- getCurFunction()->ObjCIsSecondaryInit &&
+ if (DIFunctionScopeInfo &&
+ DIFunctionScopeInfo->ObjCIsSecondaryInit &&
(SuperLoc.isValid() || isSelfExpr(Receiver))) {
if (SuperLoc.isValid()) {
Diag(SelLoc, diag::warn_objc_secondary_init_super_init_call);
} else {
- getCurFunction()->ObjCWarnForNoInitDelegation = false;
+ DIFunctionScopeInfo->ObjCWarnForNoInitDelegation = false;
}
}
@interface B1
-(id)initB1 NS_DESIGNATED_INITIALIZER; // expected-note 6 {{method marked as designated initializer of the class here}}
-(id)initB2;
--(id)initB3 NS_DESIGNATED_INITIALIZER; // expected-note 3 {{method marked as designated initializer of the class here}}
+-(id)initB3 NS_DESIGNATED_INITIALIZER; // expected-note 4 {{method marked as designated initializer of the class here}}
@end
@implementation B1
[s initB1];
[self meth];
void (^blk)(void) = ^{
- [self initB1];
+ [self initB1]; // expected-warning {{designated initializer should only invoke a designated initializer on 'super'}}
};
return [super initB3];
}
-(id)initS5 {
[super initB1]; // expected-warning {{secondary initializer should not invoke an initializer on 'super'}}
void (^blk)(void) = ^{
- [super initB1];
+ [super initB1]; // expected-warning {{secondary initializer should not invoke an initializer on 'super'}}
};
return [self initS1];
}
return ((void*)0);
}
@end
+
+// rdar://16323233
+__attribute__((objc_root_class))
+@interface B4
+-(id)initB4 NS_DESIGNATED_INITIALIZER;
+@end
+
+@interface rdar16323233 : B4
+-(id)initS4 NS_DESIGNATED_INITIALIZER;
+@end
+
+@implementation rdar16323233
+-(id)initS4 {
+ static id sSharedObject = (void*)0;
+ (void)^(void) {
+ sSharedObject = [super initB4];
+ };
+ return 0;
+}
+-(id)initB4 {
+ return [self initS4];
+}
+@end