| 1 |
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s |
| 2 |
|
| 3 |
struct X { |
| 4 |
X(); |
| 5 |
X(const X&); |
| 6 |
~X(); |
| 7 |
|
| 8 |
static int staticData; |
| 9 |
int data; |
| 10 |
void method(); |
| 11 |
}; |
| 12 |
|
| 13 |
@interface A { |
| 14 |
X xval; |
| 15 |
} |
| 16 |
|
| 17 |
- (X)x; |
| 18 |
- (void)setx:(X)x; |
| 19 |
@end |
| 20 |
|
| 21 |
void f(A* a) { |
| 22 |
a.x = X(); // expected-error {{no setter method 'setX:' for assignment to property}} |
| 23 |
} |
| 24 |
|
| 25 |
struct Y : X { }; |
| 26 |
|
| 27 |
@interface B { |
| 28 |
@private |
| 29 |
Y *y; |
| 30 |
} |
| 31 |
- (Y)value; |
| 32 |
- (void)setValue : (Y) arg; |
| 33 |
@property Y value; |
| 34 |
@end |
| 35 |
|
| 36 |
void g(B *b) { |
| 37 |
b.value.data = 17; // expected-error {{not assignable}} |
| 38 |
b.value.staticData = 17; |
| 39 |
b.value.method(); |
| 40 |
} |
| 41 |
|
| 42 |
@interface C |
| 43 |
@end |
| 44 |
|
| 45 |
@implementation C |
| 46 |
- (void)method:(B *)b { |
| 47 |
b.operator+ = 17; // expected-error{{'operator+' is not a valid property name (accessing an object of type 'B *')}} |
| 48 |
b->operator+ = 17; // expected-error{{'B' does not have a member named 'operator+'}} |
| 49 |
} |
| 50 |
@end |
| 51 |
|
| 52 |
// PR9759 |
| 53 |
class Forward; |
| 54 |
@interface D { // expected-note 2 {{'D' declared here}} |
| 55 |
@public |
| 56 |
int ivar; |
| 57 |
} |
| 58 |
|
| 59 |
@property int property; |
| 60 |
@end |
| 61 |
|
| 62 |
void testD(D *d) { |
| 63 |
d.Forward::property = 17; // expected-error{{property access cannot be qualified with 'Forward'}} |
| 64 |
d->Forward::ivar = 12; // expected-error{{instance variable access cannot be qualified with 'Forward'}} |
| 65 |
d.D::property = 17; // expected-error{{'D' is not a class, namespace, or enumeration}} |
| 66 |
d->D::ivar = 12; // expected-error{{'D' is not a class, namespace, or enumeration}} |
| 67 |
} |