summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2010-02-11 01:11:34 +0000
committerFariborz Jahanian <fjahanian@apple.com>2010-02-11 01:11:34 +0000
commit13b9782cc01cb62e749721603d546e73ee569394 (patch)
treef9a0eb227d9b498211e3ab7817efdb0b78172b12 /clang/lib
parente0913883b789913f68cc975a45b31270c1185b24 (diff)
downloadbcm5719-llvm-13b9782cc01cb62e749721603d546e73ee569394.tar.gz
bcm5719-llvm-13b9782cc01cb62e749721603d546e73ee569394.zip
Diagnose when user provided getter is being used as lvalue
using property dot-syntax. Fixes radar 7628953. llvm-svn: 95838
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/Expr.cpp18
-rw-r--r--clang/lib/Sema/SemaExpr.cpp3
2 files changed, 16 insertions, 5 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 4e6cdcab004..1af4bf87732 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/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/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index c12c7776ee3..6f5269a2517 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/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;
OpenPOWER on IntegriCloud