diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-12-15 23:59:41 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-12-15 23:59:41 +0000 |
commit | e8d28904b096d72a108fdf1f07ea7546b22f8102 (patch) | |
tree | e50e1db18963d69f50aee8c2659eba8188b67a6e /clang/lib/AST/Expr.cpp | |
parent | 9158fb748cd7ebee26e47bb67825a7494049ff62 (diff) | |
download | bcm5719-llvm-e8d28904b096d72a108fdf1f07ea7546b22f8102.tar.gz bcm5719-llvm-e8d28904b096d72a108fdf1f07ea7546b22f8102.zip |
Diagnose attempting to assign to a sub-structure of an ivar
using objective-c property. (fixes radar 7449707)
llvm-svn: 91474
Diffstat (limited to 'clang/lib/AST/Expr.cpp')
-rw-r--r-- | clang/lib/AST/Expr.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index 139e04b2ed5..dcf4411d854 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -1047,8 +1047,13 @@ Expr::isLvalueResult Expr::isLvalueInternal(ASTContext &Ctx) const { // -- If E2 is a non-static data member [...]. If E1 is an // lvalue, then E1.E2 is an lvalue. - if (isa<FieldDecl>(Member)) - return m->isArrow() ? LV_Valid : m->getBase()->isLvalue(Ctx); + if (isa<FieldDecl>(Member)) { + if (m->isArrow()) + return LV_Valid; + Expr *BaseExp = m->getBase(); + return (BaseExp->getStmtClass() == ObjCPropertyRefExprClass) ? + LV_SubObjCPropertySetting : BaseExp->isLvalue(Ctx); + } // -- If it refers to a static member function [...], then // E1.E2 is an lvalue. @@ -1065,9 +1070,13 @@ Expr::isLvalueResult Expr::isLvalueInternal(ASTContext &Ctx) const { // Not an lvalue. return LV_InvalidExpression; } - + // C99 6.5.2.3p4 - return m->isArrow() ? LV_Valid : m->getBase()->isLvalue(Ctx); + if (m->isArrow()) + return LV_Valid; + Expr *BaseExp = m->getBase(); + return (BaseExp->getStmtClass() == ObjCPropertyRefExprClass) ? + LV_SubObjCPropertySetting : BaseExp->isLvalue(Ctx); } case UnaryOperatorClass: if (cast<UnaryOperator>(this)->getOpcode() == UnaryOperator::Deref) @@ -1244,6 +1253,7 @@ Expr::isModifiableLvalue(ASTContext &Ctx, SourceLocation *Loc) const { } return MLV_InvalidExpression; case LV_MemberFunction: return MLV_MemberFunction; + case LV_SubObjCPropertySetting: return MLV_SubObjCPropertySetting; } // The following is illegal: |