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:
parent
5cdaeaaa1d
commit
e89d03f619
|
@ -420,7 +420,8 @@ static Cl::ModifiableType IsModifiable(ASTContext &Ctx, const Expr *E,
|
|||
|
||||
// Records with any const fields (recursively) are not modifiable.
|
||||
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 "
|
||||
"copy assignment operator.");
|
||||
if (R->hasConstFields())
|
||||
|
|
|
@ -6685,6 +6685,8 @@ ExprResult Sema::BuildBinOp(Scope *S, SourceLocation OpLoc,
|
|||
BinaryOperatorKind Opc,
|
||||
Expr *lhs, Expr *rhs) {
|
||||
if (getLangOptions().CPlusPlus &&
|
||||
(!isa<ObjCImplicitSetterGetterRefExpr>(lhs) ||
|
||||
rhs->isTypeDependent()) &&
|
||||
(lhs->getType()->isOverloadableType() ||
|
||||
rhs->getType()->isOverloadableType())) {
|
||||
// Find all of the overloaded operators visible from this
|
||||
|
|
|
@ -57,3 +57,22 @@ int main() {
|
|||
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();
|
||||
}
|
||||
|
|
|
@ -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}}
|
||||
}
|
||||
|
Loading…
Reference in New Issue