From 8342e5776eabf0a6dacffb40eff20dfe35be31ba Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Thu, 18 Mar 2010 18:50:41 +0000 Subject: [PATCH] Some cleanup, change diagnostic when assigning to a property which is not lvalue. llvm-svn: 98848 --- clang/include/clang/AST/Expr.h | 2 -- clang/include/clang/Basic/DiagnosticSemaKinds.td | 6 +----- clang/lib/AST/Expr.cpp | 8 +++----- clang/lib/Sema/SemaExpr.cpp | 3 --- clang/test/SemaObjC/property-not-lvalue.m | 6 +++--- 5 files changed, 7 insertions(+), 18 deletions(-) diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h index 23076b93e13b..6b14e47cbef5 100644 --- a/clang/include/clang/AST/Expr.h +++ b/clang/include/clang/AST/Expr.h @@ -150,7 +150,6 @@ public: LV_InvalidExpression, LV_MemberFunction, LV_SubObjCPropertySetting, - LV_SubObjCPropertyGetterSetting, LV_ClassTemporary }; isLvalueResult isLvalue(ASTContext &Ctx) const; @@ -182,7 +181,6 @@ public: MLV_NoSetterProperty, MLV_MemberFunction, MLV_SubObjCPropertySetting, - MLV_SubObjCPropertyGetterSetting, MLV_ClassTemporary }; isModifiableLvalueResult isModifiableLvalue(ASTContext &Ctx, diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 6e19051ce38f..8322f8f4b63d 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -1952,11 +1952,7 @@ def ext_integer_complement_complex : Extension< def error_nosetter_property_assignment : Error< "setter method is needed to assign to object using property" " assignment syntax">; def error_no_subobject_property_setting : Error< - "cannot assign to a sub-structure of an ivar using property" - " assignment syntax">; -def error_no_subobject_property_getter_setting : Error< - "cannot assign to a sub-structure returned via a getter using property" - " assignment syntax">; + "expression is not assignable using property assignment syntax">; def ext_freestanding_complex : Extension< "complex numbers are an extension in a freestanding C99 implementation">; diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index 1b3202dd4282..a62dbc901264 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -1104,11 +1104,11 @@ Expr::isLvalueResult Expr::isLvalueInternal(ASTContext &Ctx) const { if (m->isArrow()) return LV_Valid; Expr *BaseExp = m->getBase(); - if (BaseExp->getStmtClass() == ObjCPropertyRefExprClass) + if (BaseExp->getStmtClass() == ObjCPropertyRefExprClass || + BaseExp->getStmtClass() == ObjCImplicitSetterGetterRefExprClass) return LV_SubObjCPropertySetting; return - (BaseExp->getStmtClass() == ObjCImplicitSetterGetterRefExprClass) ? - LV_SubObjCPropertyGetterSetting : BaseExp->isLvalue(Ctx); + BaseExp->isLvalue(Ctx); } case UnaryOperatorClass: if (cast(this)->getOpcode() == UnaryOperator::Deref) @@ -1324,8 +1324,6 @@ Expr::isModifiableLvalue(ASTContext &Ctx, SourceLocation *Loc) const { return MLV_InvalidExpression; case LV_MemberFunction: return MLV_MemberFunction; case LV_SubObjCPropertySetting: return MLV_SubObjCPropertySetting; - case LV_SubObjCPropertyGetterSetting: - return MLV_SubObjCPropertyGetterSetting; case LV_ClassTemporary: return MLV_ClassTemporary; } diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index a4846a94633e..6bf8ab90de48 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -5790,9 +5790,6 @@ 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; diff --git a/clang/test/SemaObjC/property-not-lvalue.m b/clang/test/SemaObjC/property-not-lvalue.m index 473ef8649fa0..55eec3e45397 100644 --- a/clang/test/SemaObjC/property-not-lvalue.m +++ b/clang/test/SemaObjC/property-not-lvalue.m @@ -15,8 +15,8 @@ typedef struct NSSize { void foo() { Foo *f; - f.size.width = 2.2; // expected-error {{cannot assign to a sub-structure of an ivar using property assignment syntax}} - f.size.inner.dim = 200; // expected-error {{cannot assign to a sub-structure of an ivar using property assignment syntax}} + f.size.width = 2.2; // expected-error {{expression is not assignable using property assignment syntax}} + f.size.inner.dim = 200; // expected-error {{expression is not assignable using property assignment syntax}} } // radar 7628953 @@ -28,7 +28,7 @@ void foo() { @implementation Gorf - (void)MyView_sharedInit { - self.size.width = 2.2; // expected-error {{cannot assign to a sub-structure returned via a getter using property assignment syntax}} + self.size.width = 2.2; // expected-error {{expression is not assignable using property assignment syntax}} } - (NSSize)size {} @end