| John McCall | d5c98ae | 2011-11-15 01:35:18 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s |
| Douglas Gregor | a57a66e | 2011-02-08 02:14:35 +0000 | [diff] [blame] | 2 | |
| 3 | struct X { |
| 4 | void f() const; |
| 5 | ~X(); |
| 6 | }; |
| 7 | |
| 8 | @interface A { |
| 9 | X x_; |
| 10 | } |
| 11 | |
| 12 | - (const X&)x; |
| 13 | - (void)setx:(const X&)other; |
| 14 | @end |
| 15 | |
| 16 | @implementation A |
| 17 | |
| 18 | - (const X&)x { return x_; } |
| 19 | - (void)setx:(const X&)other { x_ = other; } |
| 20 | - (void)method { |
| 21 | self.x.f(); |
| John McCall | d5c98ae | 2011-11-15 01:35:18 +0000 | [diff] [blame] | 22 | } |
| Douglas Gregor | a57a66e | 2011-02-08 02:14:35 +0000 | [diff] [blame] | 23 | @end |
| 24 | |
| John McCall | d5c98ae | 2011-11-15 01:35:18 +0000 | [diff] [blame] | 25 | // rdar://problem/10444030 |
| 26 | @interface Test2 |
| 27 | - (void) setY: (int) y; |
| 28 | - (int) z; |
| 29 | @end |
| 30 | void test2(Test2 *a) { |
| 31 | auto y = a.y; // expected-error {{expected getter method not found on object of type 'Test2 *'}} expected-error {{variable 'y' with type 'auto' has incompatible initializer of type}} |
| 32 | auto z = a.z; |
| 33 | } |
| John McCall | 9b80c21 | 2012-01-11 00:14:46 +0000 | [diff] [blame] | 34 | |
| 35 | // rdar://problem/10672108 |
| 36 | @interface Test3 |
| 37 | - (int) length; |
| 38 | @end |
| 39 | void test3(Test3 *t) { |
| John McCall | fd3b664 | 2012-01-11 01:35:55 +0000 | [diff] [blame] | 40 | char vla[t.length] = {}; // expected-error {{variable-sized object may not be initialized}} |
| 41 | char *heaparray = new char[t.length]; |
| John McCall | 9b80c21 | 2012-01-11 00:14:46 +0000 | [diff] [blame] | 42 | } |
| Eli Friedman | 42b199c | 2012-01-12 00:44:34 +0000 | [diff] [blame] | 43 | |
| Douglas Gregor | bf3a826 | 2012-01-12 16:11:24 +0000 | [diff] [blame] | 44 | // <rdar://problem/10672501> |
| 45 | namespace std { |
| 46 | template<typename T> void count(); |
| Eli Friedman | 42b199c | 2012-01-12 00:44:34 +0000 | [diff] [blame] | 47 | } |
| Douglas Gregor | bf3a826 | 2012-01-12 16:11:24 +0000 | [diff] [blame] | 48 | |
| Douglas Gregor | ccff301 | 2012-01-13 16:56:26 +0000 | [diff] [blame^] | 49 | @interface Test4 |
| 50 | - (X&) prop; |
| 51 | @end |
| 52 | |
| 53 | void test4(Test4 *t) { |
| 54 | (void)const_cast<const X&>(t.prop); |
| 55 | (void)dynamic_cast<X&>(t.prop); |
| 56 | (void)reinterpret_cast<int&>(t.prop); |
| 57 | } |
| 58 | |
| 59 | @interface Test5 { |
| Douglas Gregor | bf3a826 | 2012-01-12 16:11:24 +0000 | [diff] [blame] | 60 | @public |
| 61 | int count; |
| 62 | } |
| 63 | @property int count; |
| 64 | @end |
| 65 | |
| Douglas Gregor | ccff301 | 2012-01-13 16:56:26 +0000 | [diff] [blame^] | 66 | void test5(Test5* t5) { |
| 67 | if (t5.count < 2) { } |
| 68 | if (t5->count < 2) { } |
| Douglas Gregor | bf3a826 | 2012-01-12 16:11:24 +0000 | [diff] [blame] | 69 | } |
| 70 | |