diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2010-02-11 01:11:34 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-02-11 01:11:34 +0000 |
commit | e9ff443040cb571ae2c5c2626c4dc9a9a812d84a (patch) | |
tree | 4ea195507e4594c236c4b4c615edadca9c95ad6e /lib | |
parent | 952b017601f9c82b51119c3a1600f1312a833db9 (diff) |
Diagnose when user provided getter is being used as lvalue
using property dot-syntax. Fixes radar 7628953.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95838 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AST/Expr.cpp | 18 | ||||
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 3 |
2 files changed, 16 insertions, 5 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 4e6cdcab00..1af4bf8773 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -1068,8 +1068,11 @@ Expr::isLvalueResult Expr::isLvalueInternal(ASTContext &Ctx) const { if (m->isArrow()) return LV_Valid; Expr *BaseExp = m->getBase(); - return (BaseExp->getStmtClass() == ObjCPropertyRefExprClass) ? - LV_SubObjCPropertySetting : BaseExp->isLvalue(Ctx); + if (BaseExp->getStmtClass() == ObjCPropertyRefExprClass) + return LV_SubObjCPropertySetting; + return + (BaseExp->getStmtClass() == ObjCImplicitSetterGetterRefExprClass) ? + LV_SubObjCPropertyGetterSetting : BaseExp->isLvalue(Ctx); } // -- If it refers to a static member function [...], then @@ -1092,8 +1095,11 @@ Expr::isLvalueResult Expr::isLvalueInternal(ASTContext &Ctx) const { if (m->isArrow()) return LV_Valid; Expr *BaseExp = m->getBase(); - return (BaseExp->getStmtClass() == ObjCPropertyRefExprClass) ? - LV_SubObjCPropertySetting : BaseExp->isLvalue(Ctx); + if (BaseExp->getStmtClass() == ObjCPropertyRefExprClass) + return LV_SubObjCPropertySetting; + return + (BaseExp->getStmtClass() == ObjCImplicitSetterGetterRefExprClass) ? + LV_SubObjCPropertyGetterSetting : BaseExp->isLvalue(Ctx); } case UnaryOperatorClass: if (cast<UnaryOperator>(this)->getOpcode() == UnaryOperator::Deref) @@ -1283,7 +1289,9 @@ Expr::isModifiableLvalue(ASTContext &Ctx, SourceLocation *Loc) const { } return MLV_InvalidExpression; case LV_MemberFunction: return MLV_MemberFunction; - case LV_SubObjCPropertySetting: return MLV_SubObjCPropertySetting; + case LV_SubObjCPropertySetting: return MLV_SubObjCPropertySetting; + case LV_SubObjCPropertyGetterSetting: + return MLV_SubObjCPropertyGetterSetting; } // The following is illegal: diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index c12c7776ee..6f5269a251 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -5734,6 +5734,9 @@ static bool CheckForModifiableLvalue(Expr *E, SourceLocation Loc, Sema &S) { case Expr::MLV_SubObjCPropertySetting: Diag = diag::error_no_subobject_property_setting; break; + case Expr::MLV_SubObjCPropertyGetterSetting: + Diag = diag::error_no_subobject_property_getter_setting; + break; } SourceRange Assign; |