forked from OSchip/llvm-project
Fix crash-on-invalid. <rdar://problem/12765391>.
llvm-svn: 168851
This commit is contained in:
parent
7afe1663e9
commit
fd41aee2f8
|
@ -4182,7 +4182,7 @@ def err_property_not_found : Error<
|
|||
def err_invalid_property_name : Error<
|
||||
"%0 is not a valid property name (accessing an object of type %1)">;
|
||||
def err_getter_not_found : Error<
|
||||
"expected getter method not found on object of type %0">;
|
||||
"no getter method for read from property">;
|
||||
def err_objc_subscript_method_not_found : Error<
|
||||
"expected method to %select{read|write}1 %select{dictionary|array}2 element not "
|
||||
"found on object of type %0">;
|
||||
|
|
|
@ -113,7 +113,7 @@ namespace {
|
|||
Expr *rebuildSpecific(ObjCPropertyRefExpr *refExpr) {
|
||||
// Fortunately, the constraint that we're rebuilding something
|
||||
// with a base limits the number of cases here.
|
||||
assert(refExpr->getBase());
|
||||
assert(refExpr->isObjectReceiver());
|
||||
|
||||
if (refExpr->isExplicitProperty()) {
|
||||
return new (S.Context)
|
||||
|
@ -713,10 +713,9 @@ ExprResult ObjCPropertyOpBuilder::buildSet(Expr *op, SourceLocation opcLoc,
|
|||
ExprResult ObjCPropertyOpBuilder::buildRValueOperation(Expr *op) {
|
||||
// Explicit properties always have getters, but implicit ones don't.
|
||||
// Check that before proceeding.
|
||||
if (RefExpr->isImplicitProperty() &&
|
||||
!RefExpr->getImplicitPropertyGetter()) {
|
||||
if (RefExpr->isImplicitProperty() && !RefExpr->getImplicitPropertyGetter()) {
|
||||
S.Diag(RefExpr->getLocation(), diag::err_getter_not_found)
|
||||
<< RefExpr->getBase()->getType();
|
||||
<< RefExpr->getSourceRange();
|
||||
return ExprError();
|
||||
}
|
||||
|
||||
|
|
|
@ -9,11 +9,34 @@
|
|||
@end
|
||||
|
||||
int func (int arg, Subclass *x) {
|
||||
if (x.setterOnly) { // expected-error {{expected getter method not found on object of type 'Subclass *'}}
|
||||
if (x.setterOnly) { // expected-error {{no getter method for read from property}}
|
||||
x.setterOnly = 1;
|
||||
}
|
||||
func(x.setterOnly + 1, x); // expected-error {{expected getter method not found on object of type 'Subclass *'}}
|
||||
int i = x.setterOnly + 1; // expected-error {{expected getter method not found on object of type 'Subclass *'}}
|
||||
return x.setterOnly + 1; // expected-error {{expected getter method not found on object of type 'Subclass *'}}
|
||||
func(x.setterOnly + 1, x); // expected-error {{no getter method for read from property}}
|
||||
int i = x.setterOnly + 1; // expected-error {{no getter method for read from property}}
|
||||
return x.setterOnly + 1; // expected-error {{no getter method for read from property}}
|
||||
}
|
||||
|
||||
// <rdar://problem/12765391>
|
||||
|
||||
@interface TestClass
|
||||
+ (void) setSetterOnly : (int) arg;
|
||||
@end
|
||||
|
||||
int func2 (int arg) {
|
||||
if (TestClass.setterOnly) { // expected-error {{no getter method for read from property}}
|
||||
TestClass.setterOnly = 1;
|
||||
}
|
||||
func(TestClass.setterOnly + 1, x); // expected-error {{no getter method for read from property}}
|
||||
int i = TestClass.setterOnly + 1; // expected-error {{no getter method for read from property}}
|
||||
return TestClass.setterOnly + 1; // expected-error {{no getter method for read from property}}
|
||||
}
|
||||
|
||||
@interface Sub : Subclass
|
||||
- (int) func3;
|
||||
@end
|
||||
@implementation Sub
|
||||
- (int) func3 {
|
||||
return super.setterOnly; // expected-error {{no getter method for read from property}}
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -89,7 +89,7 @@ void g(int); // expected-note {{passing argument to parameter here}}
|
|||
|
||||
void f(C *c) {
|
||||
c.Foo = 17; // OK
|
||||
g(c.Foo); // expected-error {{expected getter method not found on object of type 'C *'}}
|
||||
g(c.Foo); // expected-error {{no getter method for read from property}}
|
||||
}
|
||||
|
||||
|
||||
|
@ -132,7 +132,7 @@ int main (void) {
|
|||
self.Pxyz = 0; // expected-error {{synthesized properties 'Pxyz' and 'pxyz' both claim setter 'setPxyz:'}}
|
||||
self.pxyz = 0; // expected-error {{synthesized properties 'pxyz' and 'Pxyz' both claim setter 'setPxyz:'}}
|
||||
self.R = 0;
|
||||
return self.R; // expected-error {{expected getter method not found on object of type 'rdar11363363 *'}}
|
||||
return self.R; // expected-error {{no getter method for read from property}}
|
||||
}
|
||||
@end
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ struct X {
|
|||
- (int) z;
|
||||
@end
|
||||
void test2(Test2 *a) {
|
||||
auto y = a.y; // expected-error {{expected getter method not found on object of type 'Test2 *'}}
|
||||
auto y = a.y; // expected-error {{no getter method for read from property}}
|
||||
auto z = a.z;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue