1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
2 | // expected-no-diagnostics |
3 | // rdar: // 7963410 |
4 | |
5 | template<class T> |
6 | class TNSAutoRef |
7 | { |
8 | public: |
9 | TNSAutoRef(T t) |
10 | : fRef(t) |
11 | { } |
12 | |
13 | ~TNSAutoRef() |
14 | { } |
15 | |
16 | operator T() const |
17 | { return fRef; } |
18 | |
19 | T Get() const |
20 | { return fRef; } |
21 | |
22 | private: |
23 | T fRef; |
24 | }; |
25 | |
26 | @interface NSObject |
27 | - (id) alloc; |
28 | - (id)init; |
29 | @end |
30 | |
31 | @interface TFoo : NSObject |
32 | - (void) foo; |
33 | @end |
34 | |
35 | @implementation TFoo |
36 | - (void) foo {} |
37 | @end |
38 | |
39 | @interface TBar : NSObject |
40 | - (void) foo; |
41 | @end |
42 | |
43 | @implementation TBar |
44 | - (void) foo {} |
45 | @end |
46 | |
47 | int main () { |
48 | TNSAutoRef<TBar*> bar([[TBar alloc] init]); |
49 | [bar foo]; |
50 | return 0; |
51 | } |
52 | |