John McCall | 993f43f | 2013-05-06 21:39:12 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -verify -o - %s |
| 2 | |
| 3 | __attribute__((objc_root_class)) |
| 4 | @interface Root @end |
Daniel Dunbar | fcf3de3 | 2009-06-05 06:03:19 +0000 | [diff] [blame] | 5 | |
| 6 | // Test reference binding. |
| 7 | |
| 8 | typedef struct { |
| 9 | int f0; |
| 10 | int f1; |
| 11 | } T; |
| 12 | |
John McCall | 993f43f | 2013-05-06 21:39:12 +0000 | [diff] [blame] | 13 | @interface A : Root |
Daniel Dunbar | fcf3de3 | 2009-06-05 06:03:19 +0000 | [diff] [blame] | 14 | @property (assign) T p0; |
Fariborz Jahanian | 1408676 | 2011-03-28 23:47:18 +0000 | [diff] [blame] | 15 | @property (assign) T& p1; |
Daniel Dunbar | fcf3de3 | 2009-06-05 06:03:19 +0000 | [diff] [blame] | 16 | @end |
| 17 | |
| 18 | int f0(const T& t) { |
| 19 | return t.f0; |
| 20 | } |
| 21 | |
| 22 | int f1(A *a) { |
| 23 | return f0(a.p0); |
| 24 | } |
| 25 | |
| 26 | int f2(A *a) { |
Fariborz Jahanian | 1408676 | 2011-03-28 23:47:18 +0000 | [diff] [blame] | 27 | return f0(a.p1); |
Daniel Dunbar | fcf3de3 | 2009-06-05 06:03:19 +0000 | [diff] [blame] | 28 | } |
| 29 | |
Douglas Gregor | 8f70ddb | 2010-07-29 16:05:45 +0000 | [diff] [blame] | 30 | // PR7740 |
| 31 | @class NSString; |
| 32 | |
| 33 | void f3(id); |
| 34 | void f4(NSString &tmpstr) { |
| 35 | f3(&tmpstr); |
| 36 | } |
Douglas Gregor | 569c316 | 2010-08-07 11:51:51 +0000 | [diff] [blame] | 37 | |
| 38 | // PR7741 |
| 39 | @protocol P1 @end |
| 40 | @protocol P2 @end |
| 41 | @protocol P3 @end |
| 42 | @interface foo<P1> {} @end |
Fariborz Jahanian | b7bc34a | 2011-04-08 18:25:29 +0000 | [diff] [blame] | 43 | @interface bar : foo <P1, P2, P3> {} @end |
Douglas Gregor | 569c316 | 2010-08-07 11:51:51 +0000 | [diff] [blame] | 44 | typedef bar baz; |
Douglas Gregor | aaa3713 | 2010-08-07 11:56:45 +0000 | [diff] [blame] | 45 | |
| 46 | struct ToBar { |
| 47 | operator bar&() const; |
| 48 | }; |
| 49 | |
Douglas Gregor | 569c316 | 2010-08-07 11:51:51 +0000 | [diff] [blame] | 50 | void f5(foo&); |
| 51 | void f5b(foo<P1>&); |
| 52 | void f5c(foo<P2>&); |
| 53 | void f5d(foo<P3>&); |
| 54 | void f6(baz* x) { |
| 55 | f5(*x); |
| 56 | f5b(*x); |
| 57 | f5c(*x); |
| 58 | f5d(*x); |
Douglas Gregor | aaa3713 | 2010-08-07 11:56:45 +0000 | [diff] [blame] | 59 | (void)((foo&)*x); |
| 60 | f5(ToBar()); |
| 61 | f5b(ToBar()); |
| 62 | f5c(ToBar()); |
| 63 | f5d(ToBar()); |
| 64 | (void)((foo&)ToBar()); |
Douglas Gregor | 569c316 | 2010-08-07 11:51:51 +0000 | [diff] [blame] | 65 | } |
John McCall | 993f43f | 2013-05-06 21:39:12 +0000 | [diff] [blame] | 66 | |
| 67 | // rdar://13794269 |
| 68 | @interface B : Root @end |
| 69 | @implementation B { |
| 70 | unsigned bf : 4; // expected-note {{declared here}} |
| 71 | } |
| 72 | |
| 73 | - (void) foo { |
| 74 | unsigned &i = bf; // expected-error {{non-const reference cannot bind to bit-field 'bf'}} |
| 75 | } |
| 76 | @end |