diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2014-08-25 21:27:38 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2014-08-25 21:27:38 +0000 |
commit | 422922838920c21f979845bdb2fa413c52c8377a (patch) | |
tree | e512dc507de1e54e3ef4ca50accc686732e9e2d7 /clang/lib/Sema/SemaExprObjC.cpp | |
parent | 74bd6bc9f9f251f30fd32a890cac4f9164b74204 (diff) | |
download | bcm5719-llvm-422922838920c21f979845bdb2fa413c52c8377a.tar.gz bcm5719-llvm-422922838920c21f979845bdb2fa413c52c8377a.zip |
Objective-C. Allow [super initialize] in an +initialize
implementation but not anywhere else.
rdar://16628028
llvm-svn: 216408
Diffstat (limited to 'clang/lib/Sema/SemaExprObjC.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExprObjC.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index 7ade45d4929..a30eaeae361 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/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(); + } } } |