blob: 92bb71807d00b9e23c76ab870828cfe4abb020fb [file] [log] [blame]
John McCalld1e40d52011-10-02 01:16:38 +00001// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c++ %s.result
2// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s > %t
Argyrios Kyrtzidisb1094a02011-06-23 21:21:33 +00003// RUN: diff %t %s.result
Argyrios Kyrtzidisd8b42162012-01-12 02:34:32 +00004// DISABLE: mingw32
Argyrios Kyrtzidisb1094a02011-06-23 21:21:33 +00005
6#include "Common.h"
7
8@interface NSString : NSObject
9+(id)string;
10@end
11
12struct foo {
13 NSString *s;
14 foo(NSString *s): s([s retain]){
15 NSAutoreleasePool *pool = [NSAutoreleasePool new];
Argyrios Kyrtzidise0e40762011-07-14 21:26:49 +000016 [[[NSString string] retain] release];
Argyrios Kyrtzidisb1094a02011-06-23 21:21:33 +000017 [pool drain];
Argyrios Kyrtzidisaec230d2011-09-01 20:53:18 +000018 if (s)
19 [s release];
Argyrios Kyrtzidisb1094a02011-06-23 21:21:33 +000020 }
21 ~foo(){ [s release]; }
22private:
23 foo(foo const &);
24 foo &operator=(foo const &);
25};
26
27int main(){
28 NSAutoreleasePool *pool = [NSAutoreleasePool new];
29
30 foo f([[NSString string] autorelease]);
31
32 [pool drain];
33 return 0;
34}