From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- .../obj-c++.dg/property/at-property-13.mm | 72 ++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 gcc/testsuite/obj-c++.dg/property/at-property-13.mm (limited to 'gcc/testsuite/obj-c++.dg/property/at-property-13.mm') diff --git a/gcc/testsuite/obj-c++.dg/property/at-property-13.mm b/gcc/testsuite/obj-c++.dg/property/at-property-13.mm new file mode 100644 index 000000000..6786c3aa8 --- /dev/null +++ b/gcc/testsuite/obj-c++.dg/property/at-property-13.mm @@ -0,0 +1,72 @@ +/* Contributed by Nicola Pero , October 2010. */ +/* { dg-do run } */ +/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */ + +/* Test retain and copy synthesized methods. */ + +#include +#include +#include + +@interface MyRootClass +{ + Class isa; + int copy_count; + id a; + id b; +} +@property (copy) id a; +@property (retain) id b; ++ (id) initialize; ++ (id) alloc; +- (id) init; +- (id) copyWithZone: (void *)zone; +- (int) copyCount; +- (id) autorelease; +- (oneway void) release; +- (id) retain; +@end + +/* This class implements copyWithZone, which doesn't do anything other + than increasing a counter of how many copies were made. */ +@implementation MyRootClass ++ (id) initialize { return self; } ++ (id) alloc { return class_createInstance (self, 0); } +- (id) init { return self; } +- (id) copyWithZone: (void *)zone { copy_count++; return self; } +- (int) copyCount { return copy_count; } +- (id) autorelease { return self; } +- (oneway void) release { return; } +- (id) retain { return self; } +@synthesize a; +@synthesize b; +@end + +int main (void) +{ + MyRootClass *object = [[MyRootClass alloc] init]; + MyRootClass *argument = [[MyRootClass alloc] init]; + + /* This should copy argument. */ + object.a = argument; + if (object.a != argument) + abort (); + + /* Test that it was copied. */ + if ([object.a copyCount] != 1) + abort (); + + /* We just test that the retain accessors seem to work and that they + don't copy. We don't test that retain was actually called, + because if garbage collection is enabled, it may never be + called! */ + object.b = argument; + if (object.b != argument) + abort (); + + /* Test that it was not copied. */ + if ([object.b copyCount] != 1) + abort (); + + return (0); +} -- cgit v1.2.3