blob: 3a522005abee44c66b222d464637b5aaa7542419 [file] [log] [blame]
Fariborz Jahaniandd69aae2009-12-16 18:03:30 +00001// RUN: %clang_cc1 -verify -emit-llvm -o - %s
Daniel Dunbarfcf3de32009-06-05 06:03:19 +00002
3// Test reference binding.
4
5typedef struct {
6 int f0;
7 int f1;
8} T;
9
10@interface A
11@property (assign) T p0;
Fariborz Jahanian14086762011-03-28 23:47:18 +000012@property (assign) T& p1;
Daniel Dunbarfcf3de32009-06-05 06:03:19 +000013@end
14
15int f0(const T& t) {
16 return t.f0;
17}
18
19int f1(A *a) {
20 return f0(a.p0);
21}
22
23int f2(A *a) {
Fariborz Jahanian14086762011-03-28 23:47:18 +000024 return f0(a.p1);
Daniel Dunbarfcf3de32009-06-05 06:03:19 +000025}
26
Douglas Gregor8f70ddb2010-07-29 16:05:45 +000027// PR7740
28@class NSString;
29
30void f3(id);
31void f4(NSString &tmpstr) {
32 f3(&tmpstr);
33}
Douglas Gregor569c3162010-08-07 11:51:51 +000034
35// PR7741
36@protocol P1 @end
37@protocol P2 @end
38@protocol P3 @end
39@interface foo<P1> {} @end
Fariborz Jahanianb7bc34a2011-04-08 18:25:29 +000040@interface bar : foo <P1, P2, P3> {} @end
Douglas Gregor569c3162010-08-07 11:51:51 +000041typedef bar baz;
Douglas Gregoraaa37132010-08-07 11:56:45 +000042
43struct ToBar {
44 operator bar&() const;
45};
46
Douglas Gregor569c3162010-08-07 11:51:51 +000047void f5(foo&);
48void f5b(foo<P1>&);
49void f5c(foo<P2>&);
50void f5d(foo<P3>&);
51void f6(baz* x) {
52 f5(*x);
53 f5b(*x);
54 f5c(*x);
55 f5d(*x);
Douglas Gregoraaa37132010-08-07 11:56:45 +000056 (void)((foo&)*x);
57 f5(ToBar());
58 f5b(ToBar());
59 f5c(ToBar());
60 f5d(ToBar());
61 (void)((foo&)ToBar());
Douglas Gregor569c3162010-08-07 11:51:51 +000062}