summaryrefslogtreecommitdiffstats
path: root/lib/Sema/SemaExprObjC.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2014-08-25 21:27:38 +0000
committerFariborz Jahanian <fjahanian@apple.com>2014-08-25 21:27:38 +0000
commiteffffaae3b5ebab5f3ee676e68f58cbd3ce9856a (patch)
treeb9ce798ab06001375a98f737de7516d1f84dddb4 /lib/Sema/SemaExprObjC.cpp
parent884375bafb4cf93ede134791758eb02a4e91455f (diff)
Objective-C. Allow [super initialize] in an +initialize
implementation but not anywhere else. rdar://16628028 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216408 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExprObjC.cpp')
-rw-r--r--lib/Sema/SemaExprObjC.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp
index 7ade45d492..a30eaeae36 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -2237,14 +2237,25 @@ ExprResult Sema::BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo,
return ExprError();
// Warn about explicit call of +initialize on its own class. But not on 'super'.
- if (Method && Method->getMethodFamily() == OMF_initialize &&
- !SuperLoc.isValid()) {
- const ObjCInterfaceDecl *ID =
- dyn_cast<ObjCInterfaceDecl>(Method->getDeclContext());
- if (ID == Class) {
- Diag(Loc, diag::warn_direct_initialize_call);
- Diag(Method->getLocation(), diag::note_method_declared_at)
- << Method->getDeclName();
+ if (Method && Method->getMethodFamily() == OMF_initialize) {
+ if (!SuperLoc.isValid()) {
+ const ObjCInterfaceDecl *ID =
+ dyn_cast<ObjCInterfaceDecl>(Method->getDeclContext());
+ if (ID == Class) {
+ Diag(Loc, diag::warn_direct_initialize_call);
+ Diag(Method->getLocation(), diag::note_method_declared_at)
+ << Method->getDeclName();
+ }
+ }
+ else if (ObjCMethodDecl *CurMeth = getCurMethodDecl()) {
+ // [super initialize] is allowed only within an +initialize implementation
+ if (CurMeth->getMethodFamily() != OMF_initialize) {
+ Diag(Loc, diag::warn_direct_super_initialize_call);
+ Diag(Method->getLocation(), diag::note_method_declared_at)
+ << Method->getDeclName();
+ Diag(CurMeth->getLocation(), diag::note_method_declared_at)
+ << CurMeth->getDeclName();
+ }
}
}