2012-04-14 14:01:31 +00:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
|
2011-02-20 13:06:31 +00:00
|
|
|
// rdar: // 8379892
|
|
|
|
|
|
|
|
struct X {
|
|
|
|
X();
|
|
|
|
X(const X&);
|
|
|
|
~X();
|
|
|
|
|
|
|
|
static int staticData;
|
|
|
|
int data;
|
|
|
|
void method();
|
|
|
|
};
|
|
|
|
|
|
|
|
@interface A {
|
|
|
|
X xval;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (X)x;
|
|
|
|
- (void)setx:(X)x;
|
|
|
|
@end
|
|
|
|
|
|
|
|
void f(A* a) {
|
2012-04-14 14:01:31 +00:00
|
|
|
a.x = X(); // expected-error {{no setter method 'setX:' for assignment to property}}
|
2011-02-20 13:06:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct Y : X { };
|
|
|
|
|
|
|
|
@interface B {
|
|
|
|
@private
|
|
|
|
Y *y;
|
|
|
|
}
|
|
|
|
- (Y)value;
|
|
|
|
- (void)setValue : (Y) arg;
|
|
|
|
@property Y value;
|
|
|
|
@end
|
|
|
|
|
|
|
|
void g(B *b) {
|
|
|
|
b.value.data = 17; // expected-error {{not assignable}}
|
|
|
|
b.value.staticData = 17;
|
|
|
|
b.value.method();
|
|
|
|
}
|
2011-05-02 19:39:53 +00:00
|
|
|
|
|
|
|
@interface C
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation C
|
|
|
|
- (void)method:(B *)b {
|
|
|
|
// <rdar://problem/8985943>
|
|
|
|
b.operator+ = 17; // expected-error{{'operator+' is not a valid property name (accessing an object of type 'B *')}}
|
|
|
|
b->operator+ = 17; // expected-error{{'B' does not have a member named 'operator+'}}
|
|
|
|
}
|
|
|
|
@end
|
2011-10-20 21:14:49 +00:00
|
|
|
|
|
|
|
// PR9759
|
|
|
|
class Forward;
|
2014-11-24 09:15:30 +00:00
|
|
|
@interface D { // expected-note 2 {{'D' declared here}}
|
2011-10-20 21:14:49 +00:00
|
|
|
@public
|
|
|
|
int ivar;
|
|
|
|
}
|
|
|
|
|
|
|
|
@property int property;
|
|
|
|
@end
|
|
|
|
|
|
|
|
void testD(D *d) {
|
|
|
|
d.Forward::property = 17; // expected-error{{property access cannot be qualified with 'Forward::'}}
|
2012-12-02 13:20:44 +00:00
|
|
|
d->Forward::ivar = 12; // expected-error{{instance variable access cannot be qualified with 'Forward::'}}
|
2015-05-27 18:47:56 +00:00
|
|
|
d.D::property = 17; // expected-error{{'D' is not a class, namespace, or enumeration}}
|
|
|
|
d->D::ivar = 12; // expected-error{{'D' is not a class, namespace, or enumeration}}
|
2011-10-20 21:14:49 +00:00
|
|
|
}
|