diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2011-04-12 23:39:33 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-04-12 23:39:33 +0000 |
commit | b8f17abf30a9aab6382c84a758fd6679a8b5583a (patch) | |
tree | 99d0c7b95bea9c596b049ab11e345591dc46b9c8 /lib/Sema/SemaExpr.cpp | |
parent | f7e903d7a30891083420c07ebeed281726a101d6 (diff) |
Redeclaration of 'self' should be flagged in
objective-c instead of crashing in IRgen.
// rdar://9154582.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129412 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index be1d666c3a..96b2e56b41 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -1915,6 +1915,17 @@ Sema::LookupInObjCMethod(LookupResult &Lookup, Scope *S, return ExprError(); MarkDeclarationReferenced(Loc, IV); + Expr *base = SelfExpr.take(); + base = base->IgnoreParenImpCasts(); + if (const DeclRefExpr *DE = dyn_cast<DeclRefExpr>(base)) { + const NamedDecl *ND = DE->getDecl(); + if (!isa<ImplicitParamDecl>(ND)) { + Diag(Loc, diag::error_implicit_ivar_access) + << IV->getDeclName(); + Diag(ND->getLocation(), diag::note_declared_at); + return ExprError(); + } + } return Owned(new (Context) ObjCIvarRefExpr(IV, IV->getType(), Loc, SelfExpr.take(), true, true)); |