property reference expression used on lhs of assignment

follows objective's semantics and is not overload'able
with an assignment operator. Fixes a crash and a missing
diagnostics. Radar 8379892.

llvm-svn: 113555
This commit is contained in:
Fariborz Jahanian 2010-09-09 23:01:10 +00:00
parent 5cdaeaaa1d
commit e89d03f619
4 changed files with 44 additions and 1 deletions

View File

@ -420,7 +420,8 @@ static Cl::ModifiableType IsModifiable(ASTContext &Ctx, const Expr *E,
// Records with any const fields (recursively) are not modifiable. // Records with any const fields (recursively) are not modifiable.
if (const RecordType *R = CT->getAs<RecordType>()) { if (const RecordType *R = CT->getAs<RecordType>()) {
assert(!Ctx.getLangOptions().CPlusPlus && assert((isa<ObjCImplicitSetterGetterRefExpr>(E) ||
!Ctx.getLangOptions().CPlusPlus) &&
"C++ struct assignment should be resolved by the " "C++ struct assignment should be resolved by the "
"copy assignment operator."); "copy assignment operator.");
if (R->hasConstFields()) if (R->hasConstFields())

View File

@ -6685,6 +6685,8 @@ ExprResult Sema::BuildBinOp(Scope *S, SourceLocation OpLoc,
BinaryOperatorKind Opc, BinaryOperatorKind Opc,
Expr *lhs, Expr *rhs) { Expr *lhs, Expr *rhs) {
if (getLangOptions().CPlusPlus && if (getLangOptions().CPlusPlus &&
(!isa<ObjCImplicitSetterGetterRefExpr>(lhs) ||
rhs->isTypeDependent()) &&
(lhs->getType()->isOverloadableType() || (lhs->getType()->isOverloadableType() ||
rhs->getType()->isOverloadableType())) { rhs->getType()->isOverloadableType())) {
// Find all of the overloaded operators visible from this // Find all of the overloaded operators visible from this

View File

@ -57,3 +57,22 @@ int main() {
return 0; return 0;
} }
// rdar://8379892
// CHECK: define void @_Z1fP1A
// CHECK: @objc_msgSend to void
struct X {
X();
X(const X&);
~X();
};
@interface A {
X xval;
}
- (X)x;
- (void)setX:(X)x;
@end
void f(A* a) {
a.x = X();
}

View File

@ -0,0 +1,21 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// rdar: // 8379892
struct X {
X();
X(const X&);
~X();
};
@interface A {
X xval;
}
- (X)x;
- (void)setx:(X)x;
@end
void f(A* a) {
a.x = X(); // expected-error {{setter method is needed to assign to object using property assignment syntax}}
}