Argyrios Kyrtzidis | b1094a0 | 2011-06-23 21:21:33 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fsyntax-only -fobjc-arc -x objective-c++ %s.result |
| 2 | // RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fsyntax-only -x objective-c++ %s > %t |
| 3 | // RUN: diff %t %s.result |
| 4 | |
| 5 | #include "Common.h" |
| 6 | |
| 7 | @interface NSString : NSObject |
| 8 | +(id)string; |
| 9 | @end |
| 10 | |
| 11 | struct foo { |
| 12 | NSString *s; |
| 13 | foo(NSString *s): s([s retain]){ |
| 14 | NSAutoreleasePool *pool = [NSAutoreleasePool new]; |
Argyrios Kyrtzidis | e0e4076 | 2011-07-14 21:26:49 +0000 | [diff] [blame] | 15 | [[[NSString string] retain] release]; |
Argyrios Kyrtzidis | b1094a0 | 2011-06-23 21:21:33 +0000 | [diff] [blame] | 16 | [pool drain]; |
Argyrios Kyrtzidis | aec230d | 2011-09-01 20:53:18 +0000 | [diff] [blame^] | 17 | if (s) |
| 18 | [s release]; |
Argyrios Kyrtzidis | b1094a0 | 2011-06-23 21:21:33 +0000 | [diff] [blame] | 19 | } |
| 20 | ~foo(){ [s release]; } |
| 21 | private: |
| 22 | foo(foo const &); |
| 23 | foo &operator=(foo const &); |
| 24 | }; |
| 25 | |
| 26 | int main(){ |
| 27 | NSAutoreleasePool *pool = [NSAutoreleasePool new]; |
| 28 | |
| 29 | foo f([[NSString string] autorelease]); |
| 30 | |
| 31 | [pool drain]; |
| 32 | return 0; |
| 33 | } |