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