xref: /minix3/external/bsd/llvm/dist/clang/test/SemaObjCXX/conversion-to-objc-pointer.mm (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc// expected-no-diagnostics
3*f4a2713aSLionel Sambuc// rdar: // 7963410
4*f4a2713aSLionel Sambuc
5*f4a2713aSLionel Sambuctemplate<class T>
6*f4a2713aSLionel Sambucclass TNSAutoRef
7*f4a2713aSLionel Sambuc{
8*f4a2713aSLionel Sambucpublic:
9*f4a2713aSLionel Sambuc	TNSAutoRef(T t)
10*f4a2713aSLionel Sambuc		:	fRef(t)
11*f4a2713aSLionel Sambuc		{ }
12*f4a2713aSLionel Sambuc
13*f4a2713aSLionel Sambuc	~TNSAutoRef()
14*f4a2713aSLionel Sambuc		{  }
15*f4a2713aSLionel Sambuc
16*f4a2713aSLionel Sambuc	operator T() const
17*f4a2713aSLionel Sambuc		{ return fRef; }
18*f4a2713aSLionel Sambuc
19*f4a2713aSLionel Sambuc	T Get() const
20*f4a2713aSLionel Sambuc		{ return fRef; }
21*f4a2713aSLionel Sambuc
22*f4a2713aSLionel Sambucprivate:
23*f4a2713aSLionel Sambuc	T fRef;
24*f4a2713aSLionel Sambuc};
25*f4a2713aSLionel Sambuc
26*f4a2713aSLionel Sambuc@interface NSObject
27*f4a2713aSLionel Sambuc- (id) alloc;
28*f4a2713aSLionel Sambuc- (id)init;
29*f4a2713aSLionel Sambuc@end
30*f4a2713aSLionel Sambuc
31*f4a2713aSLionel Sambuc@interface TFoo : NSObject
32*f4a2713aSLionel Sambuc- (void) foo;
33*f4a2713aSLionel Sambuc@end
34*f4a2713aSLionel Sambuc
35*f4a2713aSLionel Sambuc@implementation TFoo
36*f4a2713aSLionel Sambuc- (void) foo {}
37*f4a2713aSLionel Sambuc@end
38*f4a2713aSLionel Sambuc
39*f4a2713aSLionel Sambuc@interface TBar : NSObject
40*f4a2713aSLionel Sambuc- (void) foo;
41*f4a2713aSLionel Sambuc@end
42*f4a2713aSLionel Sambuc
43*f4a2713aSLionel Sambuc@implementation TBar
44*f4a2713aSLionel Sambuc- (void) foo {}
45*f4a2713aSLionel Sambuc@end
46*f4a2713aSLionel Sambuc
47*f4a2713aSLionel Sambucint main () {
48*f4a2713aSLionel Sambuc	TNSAutoRef<TBar*> bar([[TBar alloc] init]);
49*f4a2713aSLionel Sambuc	[bar foo];
50*f4a2713aSLionel Sambuc	return 0;
51*f4a2713aSLionel Sambuc}
52