annotate clang/test/SemaObjCXX/references.mm @ 206:f17a3b42b08b

Added tag before-12 for changeset b7591485f4cd
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 07 Jun 2021 21:25:57 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -verify -o - %s
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 __attribute__((objc_root_class))
anatofuz
parents:
diff changeset
4 @interface Root @end
anatofuz
parents:
diff changeset
5
anatofuz
parents:
diff changeset
6 // Test reference binding.
anatofuz
parents:
diff changeset
7
anatofuz
parents:
diff changeset
8 typedef struct {
anatofuz
parents:
diff changeset
9 int f0;
anatofuz
parents:
diff changeset
10 int f1;
anatofuz
parents:
diff changeset
11 } T;
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 @interface A : Root
anatofuz
parents:
diff changeset
14 @property (assign) T p0;
anatofuz
parents:
diff changeset
15 @property (assign) T& p1;
anatofuz
parents:
diff changeset
16 @end
anatofuz
parents:
diff changeset
17
anatofuz
parents:
diff changeset
18 int f0(const T& t) {
anatofuz
parents:
diff changeset
19 return t.f0;
anatofuz
parents:
diff changeset
20 }
anatofuz
parents:
diff changeset
21
anatofuz
parents:
diff changeset
22 int f1(A *a) {
anatofuz
parents:
diff changeset
23 return f0(a.p0);
anatofuz
parents:
diff changeset
24 }
anatofuz
parents:
diff changeset
25
anatofuz
parents:
diff changeset
26 int f2(A *a) {
anatofuz
parents:
diff changeset
27 return f0(a.p1);
anatofuz
parents:
diff changeset
28 }
anatofuz
parents:
diff changeset
29
anatofuz
parents:
diff changeset
30 // PR7740
anatofuz
parents:
diff changeset
31 @class NSString;
anatofuz
parents:
diff changeset
32
anatofuz
parents:
diff changeset
33 void f3(id);
anatofuz
parents:
diff changeset
34 void f4(NSString &tmpstr) {
anatofuz
parents:
diff changeset
35 f3(&tmpstr);
anatofuz
parents:
diff changeset
36 }
anatofuz
parents:
diff changeset
37
anatofuz
parents:
diff changeset
38 // PR7741
anatofuz
parents:
diff changeset
39 @protocol P1 @end
anatofuz
parents:
diff changeset
40 @protocol P2 @end
anatofuz
parents:
diff changeset
41 @protocol P3 @end
anatofuz
parents:
diff changeset
42 @interface foo<P1> {} @end
anatofuz
parents:
diff changeset
43 @interface bar : foo <P1, P2, P3> {} @end
anatofuz
parents:
diff changeset
44 typedef bar baz;
anatofuz
parents:
diff changeset
45
anatofuz
parents:
diff changeset
46 struct ToBar {
anatofuz
parents:
diff changeset
47 operator bar&() const;
anatofuz
parents:
diff changeset
48 };
anatofuz
parents:
diff changeset
49
anatofuz
parents:
diff changeset
50 void f5(foo&);
anatofuz
parents:
diff changeset
51 void f5b(foo<P1>&);
anatofuz
parents:
diff changeset
52 void f5c(foo<P2>&);
anatofuz
parents:
diff changeset
53 void f5d(foo<P3>&);
anatofuz
parents:
diff changeset
54 void f6(baz* x) {
anatofuz
parents:
diff changeset
55 f5(*x);
anatofuz
parents:
diff changeset
56 f5b(*x);
anatofuz
parents:
diff changeset
57 f5c(*x);
anatofuz
parents:
diff changeset
58 f5d(*x);
anatofuz
parents:
diff changeset
59 (void)((foo&)*x);
anatofuz
parents:
diff changeset
60 f5(ToBar());
anatofuz
parents:
diff changeset
61 f5b(ToBar());
anatofuz
parents:
diff changeset
62 f5c(ToBar());
anatofuz
parents:
diff changeset
63 f5d(ToBar());
anatofuz
parents:
diff changeset
64 (void)((foo&)ToBar());
anatofuz
parents:
diff changeset
65 }
anatofuz
parents:
diff changeset
66
anatofuz
parents:
diff changeset
67 // rdar://13794269
anatofuz
parents:
diff changeset
68 @interface B : Root @end
anatofuz
parents:
diff changeset
69 @implementation B {
anatofuz
parents:
diff changeset
70 unsigned bf : 4; // expected-note {{declared here}}
anatofuz
parents:
diff changeset
71 }
anatofuz
parents:
diff changeset
72
anatofuz
parents:
diff changeset
73 - (void) foo {
anatofuz
parents:
diff changeset
74 unsigned &i = bf; // expected-error {{non-const reference cannot bind to bit-field 'bf'}}
anatofuz
parents:
diff changeset
75 }
anatofuz
parents:
diff changeset
76 @end