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