xref: /minix3/external/bsd/llvm/dist/clang/test/SemaObjCXX/property-reference.mm (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fsyntax-only -verify -Wno-objc-root-class %s
2*f4a2713aSLionel Sambuc// rdar://9070460
3*f4a2713aSLionel Sambuc
4*f4a2713aSLionel Sambucclass TCPPObject
5*f4a2713aSLionel Sambuc{
6*f4a2713aSLionel Sambucpublic:
7*f4a2713aSLionel Sambuc	TCPPObject(const TCPPObject& inObj);
8*f4a2713aSLionel Sambuc	TCPPObject();
9*f4a2713aSLionel Sambuc	~TCPPObject();
10*f4a2713aSLionel Sambuc
11*f4a2713aSLionel Sambuc	TCPPObject& operator=(const TCPPObject& inObj)const ; // expected-note {{'operator=' declared here}}
12*f4a2713aSLionel Sambuc
13*f4a2713aSLionel Sambuc	void* Data();
14*f4a2713aSLionel Sambuc
15*f4a2713aSLionel Sambucprivate:
16*f4a2713aSLionel Sambuc	void* fData;
17*f4a2713aSLionel Sambuc};
18*f4a2713aSLionel Sambuc
19*f4a2713aSLionel Sambuc
20*f4a2713aSLionel Sambuctypedef const TCPPObject& CREF_TCPPObject;
21*f4a2713aSLionel Sambuc
22*f4a2713aSLionel Sambuc@interface TNSObject
23*f4a2713aSLionel Sambuc@property (assign, readwrite, nonatomic) CREF_TCPPObject cppObjectNonAtomic;
24*f4a2713aSLionel Sambuc@property (assign, readwrite) CREF_TCPPObject cppObjectAtomic;
25*f4a2713aSLionel Sambuc@property (assign, readwrite, nonatomic) const TCPPObject& cppObjectDynamic;
26*f4a2713aSLionel Sambuc@end
27*f4a2713aSLionel Sambuc
28*f4a2713aSLionel Sambuc
29*f4a2713aSLionel Sambuc@implementation TNSObject
30*f4a2713aSLionel Sambuc
31*f4a2713aSLionel Sambuc@synthesize cppObjectNonAtomic;
32*f4a2713aSLionel Sambuc@synthesize cppObjectAtomic; // expected-error{{atomic property of reference type 'CREF_TCPPObject' (aka 'const TCPPObject &') cannot have non-trivial assignment operator}}
33*f4a2713aSLionel Sambuc@dynamic cppObjectDynamic;
34*f4a2713aSLionel Sambuc
35*f4a2713aSLionel Sambuc- (const TCPPObject&) cppObjectNonAtomic
36*f4a2713aSLionel Sambuc{
37*f4a2713aSLionel Sambuc	return cppObjectNonAtomic;
38*f4a2713aSLionel Sambuc}
39*f4a2713aSLionel Sambuc
40*f4a2713aSLionel Sambuc- (void) setCppObjectNonAtomic: (const TCPPObject&)cppObject
41*f4a2713aSLionel Sambuc{
42*f4a2713aSLionel Sambuc	cppObjectNonAtomic = cppObject;
43*f4a2713aSLionel Sambuc}
44*f4a2713aSLionel Sambuc@end
45*f4a2713aSLionel Sambuc
46*f4a2713aSLionel Sambuc
47*f4a2713aSLionel Sambuc// <rdar://problem/11052352>
48*f4a2713aSLionel Sambuc@interface NSObject
49*f4a2713aSLionel Sambuc+ alloc;
50*f4a2713aSLionel Sambuc- init;
51*f4a2713aSLionel Sambuc- class;
52*f4a2713aSLionel Sambuc@end
53*f4a2713aSLionel Sambuc
54*f4a2713aSLionel Sambuctemplate<typename T> void f() {
55*f4a2713aSLionel Sambuc  NSObject *o = [NSObject.alloc init];
56*f4a2713aSLionel Sambuc  [o class];
57*f4a2713aSLionel Sambuc}
58*f4a2713aSLionel Sambuc
59*f4a2713aSLionel Sambuctemplate void f<int>();
60*f4a2713aSLionel Sambuc
61*f4a2713aSLionel Sambuc// rdar://13602832
62*f4a2713aSLionel Sambuc//
63*f4a2713aSLionel Sambuc// Make sure that the default-argument checker looks through
64*f4a2713aSLionel Sambuc// pseudo-object expressions correctly.  The default argument
65*f4a2713aSLionel Sambuc// needs to force l2r to test this effectively because the checker
66*f4a2713aSLionel Sambuc// is syntactic and runs before placeholders are handled.
67*f4a2713aSLionel Sambuc@interface Test13602832
68*f4a2713aSLionel Sambuc- (int) x;
69*f4a2713aSLionel Sambuc@end
70*f4a2713aSLionel Sambucnamespace test13602832 {
71*f4a2713aSLionel Sambuc  template <int N> void foo(Test13602832 *a, int limit = a.x + N) {} // expected-error {{default argument references parameter 'a'}}
72*f4a2713aSLionel Sambuc
73*f4a2713aSLionel Sambuc  void test(Test13602832 *a) {
74*f4a2713aSLionel Sambuc    // FIXME: this is a useless cascade error.
75*f4a2713aSLionel Sambuc    foo<1024>(a); // expected-error {{no matching function}}
76*f4a2713aSLionel Sambuc  }
77*f4a2713aSLionel Sambuc}
78