Patrick Beard | b2f6820 | 2012-04-06 18:12:22 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s |
Fariborz Jahanian | 4088ec0 | 2010-09-09 23:01:10 +0000 | [diff] [blame] | 2 | // rdar: // 8379892 |
| 3 | |
| 4 | struct X { |
| 5 | X(); |
| 6 | X(const X&); |
| 7 | ~X(); |
John McCall | 0943168 | 2010-11-18 19:01:18 +0000 | [diff] [blame] | 8 | |
| 9 | static int staticData; |
| 10 | int data; |
| 11 | void method(); |
Fariborz Jahanian | 4088ec0 | 2010-09-09 23:01:10 +0000 | [diff] [blame] | 12 | }; |
| 13 | |
| 14 | @interface A { |
| 15 | X xval; |
| 16 | } |
| 17 | |
| 18 | - (X)x; |
| 19 | - (void)setx:(X)x; |
| 20 | @end |
| 21 | |
| 22 | void f(A* a) { |
John McCall | 3c3b7f9 | 2011-10-25 17:37:35 +0000 | [diff] [blame] | 23 | a.x = X(); // expected-error {{no setter method 'setX:' for assignment to property}} |
Fariborz Jahanian | 4088ec0 | 2010-09-09 23:01:10 +0000 | [diff] [blame] | 24 | } |
| 25 | |
John McCall | 0943168 | 2010-11-18 19:01:18 +0000 | [diff] [blame] | 26 | struct Y : X { }; |
| 27 | |
| 28 | @interface B { |
| 29 | @private |
| 30 | Y *y; |
| 31 | } |
| 32 | - (Y)value; |
| 33 | - (void)setValue : (Y) arg; |
| 34 | @property Y value; |
| 35 | @end |
| 36 | |
| 37 | void g(B *b) { |
| 38 | b.value.data = 17; // expected-error {{not assignable}} |
| 39 | b.value.staticData = 17; |
| 40 | b.value.method(); |
| 41 | } |
Douglas Gregor | 109ec1b | 2011-04-20 18:19:55 +0000 | [diff] [blame] | 42 | |
| 43 | @interface C |
| 44 | @end |
| 45 | |
| 46 | @implementation C |
| 47 | - (void)method:(B *)b { |
| 48 | // <rdar://problem/8985943> |
| 49 | b.operator+ = 17; // expected-error{{'operator+' is not a valid property name (accessing an object of type 'B *')}} |
Douglas Gregor | cbec959 | 2011-04-20 18:20:33 +0000 | [diff] [blame] | 50 | b->operator+ = 17; // expected-error{{'B' does not have a member named 'operator+'}} |
Douglas Gregor | 109ec1b | 2011-04-20 18:19:55 +0000 | [diff] [blame] | 51 | } |
| 52 | @end |
Douglas Gregor | b5ae92f | 2011-10-09 23:22:49 +0000 | [diff] [blame] | 53 | |
| 54 | // PR9759 |
| 55 | class Forward; |
| 56 | @interface D { |
| 57 | @public |
| 58 | int ivar; |
| 59 | } |
| 60 | |
| 61 | @property int property; |
| 62 | @end |
| 63 | |
| 64 | void testD(D *d) { |
| 65 | d.Forward::property = 17; // expected-error{{property access cannot be qualified with 'Forward::'}} |
| 66 | d->Forward::ivar = 12; // expected-error{{ivar access cannot be qualified with 'Forward::'}} |
Douglas Gregor | 5a706dc | 2011-10-10 16:09:49 +0000 | [diff] [blame] | 67 | d.D::property = 17; // expected-error{{expected a class or namespace}} |
| 68 | d->D::ivar = 12; // expected-error{{expected a class or namespace}} |
Douglas Gregor | b5ae92f | 2011-10-09 23:22:49 +0000 | [diff] [blame] | 69 | } |