[llvm-commits] [llvm-gcc-4.2] r55730 - /llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/
Bill Wendling
isanbard at gmail.com
Wed Sep 3 13:53:27 PDT 2008
Author: void
Date: Wed Sep 3 15:53:26 2008
New Revision: 55730
URL: http://llvm.org/viewvc/llvm-project?rev=55730&view=rev
Log:
Add new tests, remove empty tests, and fix formatting issues.
Syncs up with Apple's GCC r150332.
Added:
llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/method-bad-return-type.mm
llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-1.mm
llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-2.mm
llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-3.mm
llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-32-5.mm
llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-4.mm
llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-5.mm
llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-6.mm
llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-7.mm
llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-8.mm
llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-9.mm
llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/type-nsobject-attribute-2.mm
llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/type-nsobject-attribute.mm
Removed:
llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/objc2-const-str-64bit-1.mm
llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/objc2-protocol-3.mm
Modified:
llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/const-str-3.mm
llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/objc-foreach-11.mm
llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/objc-gc-assign-ivar-1.mm
llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/objc2-ivar-offset.mm
Modified: llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/const-str-3.mm
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/obj-c%2B%2B.dg/const-str-3.mm?rev=55730&r1=55729&r2=55730&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/const-str-3.mm (original)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/const-str-3.mm Wed Sep 3 15:53:26 2008
@@ -2,7 +2,7 @@
runtime. */
/* Developed by Markus Hitter <mah at jump-ing.de>. */
/* APPLE LOCAL radar 4621575 */
-/* { dg-options "-fnext-runtime -fno-constant-cfstrings -fconstant-string-class=Foo -lobjc" } */
+/* { dg-options "-fnext-runtime -fno-constant-cfstrings -fconstant-string-class=Foo -lobjc -Wno-format" } */
/* { dg-do run { target *-*-darwin* } } */
/* APPLE LOCAL radar 5272224 */
/* { dg-require-effective-target ilp32 } */
Added: llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/method-bad-return-type.mm
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/obj-c%2B%2B.dg/method-bad-return-type.mm?rev=55730&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/method-bad-return-type.mm (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/method-bad-return-type.mm Wed Sep 3 15:53:26 2008
@@ -0,0 +1,16 @@
+/* APPLE LOCAL file radar 5424416 */
+/* Methods cannot return an array. */
+
+int v[2];
+
+ at interface Foo
+-(int[2])x;
+ at end
+
+ at implementation Foo
+-(int[2])x /* { dg-error "\'x\' declared as method returning an array" } */
+{
+ return v; /* { dg-error "cannot convert" } */
+}
+ at end
+
Modified: llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/objc-foreach-11.mm
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/obj-c%2B%2B.dg/objc-foreach-11.mm?rev=55730&r1=55729&r2=55730&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/objc-foreach-11.mm (original)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/objc-foreach-11.mm Wed Sep 3 15:53:26 2008
@@ -46,7 +46,7 @@
}
else {
result = false;
- printf("** failed: %s %s %s (%d vs %d)\n", style, test, message, counter, [reference count]);
+ printf("** failed: %s %s %s (%d vs %ld)\n", style, test, message, counter, (long)[reference count]);
++Errors;
}
return result;
@@ -67,7 +67,7 @@
}
else {
result = false;
- printf("** failed: %s %s %s (%d vs %d)\n", style, test, message, counter, [reference count]);
+ printf("** failed: %s %s %s (%d vs %ld)\n", style, test, message, counter, (long)[reference count]);
++Errors;
}
return result;
Modified: llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/objc-gc-assign-ivar-1.mm
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/obj-c%2B%2B.dg/objc-gc-assign-ivar-1.mm?rev=55730&r1=55729&r2=55730&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/objc-gc-assign-ivar-1.mm (original)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/objc-gc-assign-ivar-1.mm Wed Sep 3 15:53:26 2008
@@ -20,21 +20,25 @@
static
id objc_assign_strongCast(id value, id *dest) {
- printf("assign_ivar got value %p, dest %p\n", value, dest);
+ /* APPLE LOCAL default to Wformat-security 5764921 */
+ printf("assign_ivar got value %p, dest %p\n", (void*)value, (void*)dest);
printf("wanted %p, %p\n", WantedVal, WantedDest);
return nil;
}
static
id objc_assign_global(id value, id *dest) {
- printf("assign_ivar got value %p, dest %p\n", value, dest);
+ /* APPLE LOCAL default to Wformat-security 5764921 */
+ printf("assign_ivar got value %p, dest %p\n", (void*)value, (void*)dest);
printf("wanted %p, %p\n", WantedVal, WantedDest);
return nil;
}
static
id objc_assign_ivar(id value, id dest, ptrdiff_t offset) {
- printf("assign_ivar got value %p, dest %p, offset %ld\n", value, dest, offset);
- printf("wanted %p, %p, %ld\n", WantedVal, WantedDest, WantedOffset);
+ /* APPLE LOCAL default to Wformat-security 5764921 */
+ printf("assign_ivar got value %p, dest %p, offset %d\n", (void*)value, (void*)dest, (int)offset);
+ /* APPLE LOCAL default to Wformat-security 5764921 */
+ printf("wanted %p, %p, %d\n", WantedVal, WantedDest, (int)WantedOffset);
if (value != WantedVal)
abort ();
if (dest != WantedDest)
Removed: llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/objc2-const-str-64bit-1.mm
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/obj-c%2B%2B.dg/objc2-const-str-64bit-1.mm?rev=55729&view=auto
==============================================================================
(empty)
Modified: llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/objc2-ivar-offset.mm
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/obj-c%2B%2B.dg/objc2-ivar-offset.mm?rev=55730&r1=55729&r2=55730&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/objc2-ivar-offset.mm (original)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/objc2-ivar-offset.mm Wed Sep 3 15:53:26 2008
@@ -31,7 +31,8 @@
const char *ivartype = ivar_getTypeEncoding(iv_list[i]);
fprintf(stderr, "type: %s\n", ivartype);
ptrdiff_t ivaroffset = ivar_getOffset(iv_list[i]);
- fprintf(stderr, "offset: %p\n", ivaroffset);
+ /* APPLE LOCAL default to Wformat-security 5764921 */
+ fprintf(stderr, "offset: %x\n", (int)ivaroffset);
fprintf(stderr, "\n");
}
return 0;
Removed: llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/objc2-protocol-3.mm
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/obj-c%2B%2B.dg/objc2-protocol-3.mm?rev=55729&view=auto
==============================================================================
(empty)
Added: llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-1.mm
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/obj-c%2B%2B.dg/property-synthesize-ivar-1.mm?rev=55730&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-1.mm (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-1.mm Wed Sep 3 15:53:26 2008
@@ -0,0 +1,31 @@
+/* APPLE LOCAL file radar 5435299 */
+/* Test for synthesizing of one ivar for a synthesized property. */
+/* { dg-options "-fnew-property-ivar-synthesis -m64 -lobjc" { target i?86*-*-darwin* } } */
+/* { dg-options "-fnew-property-ivar-synthesis -fobjc-new-property -lobjc" { target arm*-*-darwin* } } */
+/* { dg-do run { target i?86*-*-darwin* arm*-*-darwin* } } */
+
+
+#ifdef __OBJC2__
+#import <objc/Object.h>
+#import <objc/runtime.h>
+#include <assert.h>
+
+ at interface Test1 : Object
+ at property int prop;
+ at end
+ at implementation Test1
+ at synthesize prop;
+ at end
+
+int main() {
+ unsigned int count;
+ Ivar *list;
+ Ivar ivar;
+ list = class_copyIvarList([Test1 class], &count);
+ assert(count == 1);
+ ivar = class_getInstanceVariable([Test1 class], "prop");
+ assert(ivar);
+ return 0;
+}
+
+#endif
Added: llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-2.mm
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/obj-c%2B%2B.dg/property-synthesize-ivar-2.mm?rev=55730&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-2.mm (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-2.mm Wed Sep 3 15:53:26 2008
@@ -0,0 +1,33 @@
+/* APPLE LOCAL file radar 5435299 */
+/* Test for property backed by generated ivar with specified name. */
+/* { dg-options "-fnew-property-ivar-synthesis -m64 -lobjc" { target i?86*-*-darwin* } } */
+/* { dg-options "-fnew-property-ivar-synthesis -fobjc-new-property -lobjc" { target arm*-*-darwin* } } */
+/* { dg-do run { target i?86*-*-darwin* arm*-*-darwin* } } */
+
+
+#ifdef __OBJC2__
+#import <objc/Object.h>
+#import <objc/runtime.h>
+#include <assert.h>
+
+ at interface Test2 : Object
+ at property int prop;
+ at end
+ at implementation Test2
+ at synthesize prop = prop_ivar;
+ at end
+
+int main() {
+ unsigned int count;
+ Ivar *list;
+ Ivar ivar;
+ list = class_copyIvarList([Test2 class], &count);
+ assert(count == 1);
+ ivar = class_getInstanceVariable([Test2 class], "prop");
+ assert(!ivar);
+ ivar = class_getInstanceVariable([Test2 class], "prop_ivar");
+ assert(ivar);
+ return 0;
+}
+
+#endif
Added: llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-3.mm
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/obj-c%2B%2B.dg/property-synthesize-ivar-3.mm?rev=55730&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-3.mm (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-3.mm Wed Sep 3 15:53:26 2008
@@ -0,0 +1,19 @@
+/* APPLE LOCAL file radar 5435299 */
+/* Multiple @synthesize of a single property is error. */
+/* { dg-options "-fnew-property-ivar-synthesis -mmacosx-version-min=10.5" { target powerpc*-*-darwin* i?86*-*-darwin* } } */
+/* { dg-options "-fnew-property-ivar-synthesis -fobjc-new-property" { target arm*-*-darwin* } } */
+/* { dg-do compile { target *-*-darwin* } } */
+
+#import <objc/Object.h>
+
+ at interface Test3 : Object
+{
+ int prop;
+}
+ at property int prop;
+ at end
+ at implementation Test3
+ at synthesize prop;
+ at synthesize prop; /* { dg-error "synthesized properties \\'prop\\' and \\'prop\\' both claim ivar \\'prop\\'" } */
+ /* { dg-error "property \\'prop\\' is already implemented" "" { target *-*-* } 17 } */
+ at end
Added: llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-32-5.mm
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/obj-c%2B%2B.dg/property-synthesize-ivar-32-5.mm?rev=55730&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-32-5.mm (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-32-5.mm Wed Sep 3 15:53:26 2008
@@ -0,0 +1,43 @@
+/* APPLE LOCAL file radar 5435299 */
+/* Test that one ivar cannot back multiple properties. */
+/* { dg-options "-fnew-property-ivar-synthesis -mmacosx-version-min=10.5 -m32" { target powerpc*-*-darwin* i?86*-*-darwin* } } */
+/* { dg-options "-fnew-property-ivar-synthesis -fobjc-new-property" { target arm*-*-darwin* } } */
+/* { dg-do compile { target *-*-darwin* } } */
+
+#import <objc/Object.h>
+
+ at interface Test5_1 : Object
+{
+ int ivar;
+}
+ at property int ivar;
+ at property int prop2;
+ at end
+ at implementation Test5_1
+ at synthesize ivar;
+ at synthesize prop2 = ivar; /* { dg-error "synthesized properties \\'prop2\\' and \\'ivar\\' both claim ivar \\'ivar\\'" } */
+ at end
+
+ at interface Test5_2 : Object
+{
+ int ivar;
+}
+ at property int prop2;
+ at property int ivar;
+ at end
+ at implementation Test5_2
+ at synthesize prop2 = ivar;
+ at synthesize ivar; /* { dg-error "synthesized properties \\'ivar\\' and \\'prop2\\' both claim ivar \\'ivar\\'" } */
+ at end
+
+ at interface Test5_3 : Object
+{
+ int ivar;
+}
+ at property int prop1;
+ at property int prop2;
+ at end
+ at implementation Test5_3
+ at synthesize prop1 = ivar;
+ at synthesize prop2 = ivar; /* { dg-error "synthesized properties \\'prop2\\' and \\'prop1\\' both claim ivar \\'ivar\\'" } */
+ at end
Added: llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-4.mm
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/obj-c%2B%2B.dg/property-synthesize-ivar-4.mm?rev=55730&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-4.mm (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-4.mm Wed Sep 3 15:53:26 2008
@@ -0,0 +1,18 @@
+/* APPLE LOCAL file radar 5435299 */
+/* Type mismatch of a property and its ivar. */
+/* { dg-options "-fnew-property-ivar-synthesis -mmacosx-version-min=10.5" { target powerpc*-*-darwin* i?86*-*-darwin* } } */
+/* { dg-options "-fnew-property-ivar-synthesis -fobjc-new-property" { target arm*-*-darwin* } } */
+/* { dg-do compile { target *-*-darwin* } } */
+
+#import <objc/Object.h>
+
+ at interface Test4 : Object
+{
+ char ivar;
+}
+ at property int prop;
+ at end
+ at implementation Test4
+ at synthesize prop = ivar; /* { dg-error "type of property \\'prop\\' does not match type of ivar \\'ivar\\'" } */
+ at end
+
Added: llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-5.mm
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/obj-c%2B%2B.dg/property-synthesize-ivar-5.mm?rev=55730&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-5.mm (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-5.mm Wed Sep 3 15:53:26 2008
@@ -0,0 +1,75 @@
+/* APPLE LOCAL file radar 5435299 */
+/* Test that one ivar cannot back multiple properties. */
+/* { dg-options "-fnew-property-ivar-synthesis -mmacosx-version-min=10.5 -m64" { target powerpc*-*-darwin* i?86*-*-darwin* } } */
+/* { dg-options "-fnew-property-ivar-synthesis -fobjc-new-property" { target arm*-*-darwin* } } */
+/* { dg-do compile { target *-*-darwin* } } */
+
+#import <objc/Object.h>
+
+#ifdef __OBJC2__
+
+ at interface Test5_1 : Object
+{
+ int ivar;
+}
+ at property int ivar;
+ at property int prop2;
+ at end
+ at implementation Test5_1
+ at synthesize ivar;
+ at synthesize prop2 = ivar; /* { dg-error "synthesized properties \\'prop2\\' and \\'ivar\\' both claim ivar \\'ivar\\'" } */
+ at end
+
+ at interface Test5_2 : Object
+{
+ int ivar;
+}
+ at property int prop2;
+ at property int ivar;
+ at end
+ at implementation Test5_2
+ at synthesize prop2 = ivar;
+ at synthesize ivar; /* { dg-error "synthesized properties \\'ivar\\' and \\'prop2\\' both claim ivar \\'ivar\\'" } */
+ at end
+
+ at interface Test5_3 : Object
+{
+ int ivar;
+}
+ at property int prop1;
+ at property int prop2;
+ at end
+ at implementation Test5_3
+ at synthesize prop1 = ivar;
+ at synthesize prop2 = ivar; /* { dg-error "synthesized properties \\'prop2\\' and \\'prop1\\' both claim ivar \\'ivar\\'" } */
+ at end
+
+
+ at interface Test5_4 : Object
+ at property int prop1;
+ at property int prop2;
+ at end
+ at implementation Test5_4
+ at synthesize prop1;
+ at synthesize prop2 = prop1; /* { dg-error "synthesized properties \\'prop2\\' and \\'prop1\\' both claim ivar \\'prop1\\'" } */
+ at end
+
+ at interface Test5_5 : Object
+ at property int prop1;
+ at property int prop2;
+ at end
+ at implementation Test5_5
+ at synthesize prop1 = prop2;
+ at synthesize prop2; /* { dg-error "synthesized properties \\'prop2\\' and \\'prop1\\' both claim ivar \\'prop2\\'" } */
+ at end
+
+ at interface Test5_6 : Object
+ at property int prop1;
+ at property int prop2;
+ at end
+ at implementation Test5_6
+ at synthesize prop1 = ivar;
+ at synthesize prop2 = ivar; /* { dg-error "synthesized properties \\'prop2\\' and \\'prop1\\' both claim ivar \\'ivar\\'" } */
+ at end
+
+#endif
Added: llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-6.mm
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/obj-c%2B%2B.dg/property-synthesize-ivar-6.mm?rev=55730&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-6.mm (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-6.mm Wed Sep 3 15:53:26 2008
@@ -0,0 +1,27 @@
+/* APPLE LOCAL file radar 5435299 */
+/* A synthesize property cannot use an ivar in its super class. */
+/* { dg-options "-fnew-property-ivar-synthesis -mmacosx-version-min=10.5 -m64" { target powerpc*-*-darwin* i?86*-*-darwin* } } */
+/* { dg-options "-fnew-property-ivar-synthesis -fobjc-new-property" { target arm*-*-darwin* } } */
+/* { dg-do compile { target *-*-darwin* } } */
+
+#ifdef __OBJC2__
+#import <objc/Object.h>
+
+ at interface Test6Super : Object
+{
+ int prop;
+}
+ at end
+
+ at implementation Test6Super @end
+
+ at interface Test6 : Test6Super
+ at property int prop;
+ at end
+
+ at implementation Test6
+ at synthesize prop; /* { dg-error "property \\'prop\\' attempting to use ivar \\'prop\\' in super class \\'Test6\\'" } */
+ at end
+
+#endif
+
Added: llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-7.mm
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/obj-c%2B%2B.dg/property-synthesize-ivar-7.mm?rev=55730&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-7.mm (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-7.mm Wed Sep 3 15:53:26 2008
@@ -0,0 +1,25 @@
+/* APPLE LOCAL file radar 5435299 */
+/* Test that synthesize ivar visibility is @private */
+/* { dg-options "-fnew-property-ivar-synthesis -mmacosx-version-min=10.5 -m64" { target powerpc*-*-darwin* i?86*-*-darwin* } } */
+/* { dg-options "-fnew-property-ivar-synthesis -fobjc-new-property" { target arm*-*-darwin* } } */
+/* { dg-do compile { target *-*-darwin* } } */
+
+#ifdef __OBJC2__
+#import <objc/Object.h>
+
+ at interface Test7 : Object
+ at property int prop;
+ at end
+
+ at implementation Test7
+ at synthesize prop;
+ at end
+
+ at interface Test7Sub : Test7 @end
+
+ at implementation Test7Sub
+-(int)method { return prop; } /* { dg-error "instance variable \\'prop\\' is declared private" } */
+ at end
+
+#endif
+
Added: llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-8.mm
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/obj-c%2B%2B.dg/property-synthesize-ivar-8.mm?rev=55730&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-8.mm (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-8.mm Wed Sep 3 15:53:26 2008
@@ -0,0 +1,65 @@
+/* APPLE LOCAL file radar 5435299 */
+/* Enforce order of generated ivars */
+/* { dg-options "-fnew-property-ivar-synthesis -m64 -lobjc" { target i?86*-*-darwin* } } */
+/* { dg-options "-fnew-property-ivar-synthesis -fobjc-new-property -lobjc" { target arm*-*-darwin* } } */
+/* { dg-do run { target i?86*-*-darwin* arm*-*-darwin* } } */
+
+
+#ifdef __OBJC2__
+#import <objc/Object.h>
+#import <objc/runtime.h>
+#include <assert.h>
+
+ at interface Test8 : Object
+{
+ int ivar1;
+ int ivar2;
+}
+// order of @property declarations has no effect on ivar order
+ at property int prop5;
+ at property int prop4;
+ at property int prop6;
+ at property int prop1;
+ at property int prop3;
+ at property int prop2;
+ at end
+
+ at implementation Test8
+// resulting ivar order should be: { ivar1; ivar2; prop3; prop4; prop5; prop6; }
+ at synthesize prop1 = ivar1;
+ at synthesize prop5; // prop5 ivar is generated 1st after ivar2
+ at synthesize prop2 = ivar2;
+ at synthesize prop3, prop4, prop6;
+ at end
+
+int main() {
+ Ivar ivar, ivar2, ivar3, ivar4, ivar5, ivar6;
+ ivar = class_getInstanceVariable([Test8 class], "ivar1");
+ assert(ivar);
+
+ ivar2 = class_getInstanceVariable([Test8 class], "ivar2");
+ assert(ivar2);
+
+ assert(ivar_getOffset(ivar) < ivar_getOffset(ivar2));
+
+ ivar3 = class_getInstanceVariable([Test8 class], "prop5");
+ assert(ivar3);
+ assert(ivar_getOffset(ivar2) < ivar_getOffset(ivar3));
+
+ ivar4 = class_getInstanceVariable([Test8 class], "prop3");
+ assert(ivar4);
+ assert(ivar_getOffset(ivar3) < ivar_getOffset(ivar4));
+
+ ivar5 = class_getInstanceVariable([Test8 class], "prop4");
+ assert(ivar5);
+ assert(ivar_getOffset(ivar4) < ivar_getOffset(ivar5));
+
+ ivar6 = class_getInstanceVariable([Test8 class], "prop6");
+ assert(ivar6);
+ assert(ivar_getOffset(ivar5) < ivar_getOffset(ivar6));
+
+ return 0;
+}
+
+#endif
+
Added: llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-9.mm
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/obj-c%2B%2B.dg/property-synthesize-ivar-9.mm?rev=55730&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-9.mm (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/property-synthesize-ivar-9.mm Wed Sep 3 15:53:26 2008
@@ -0,0 +1,41 @@
+/* APPLE LOCAL file radar 5435299 */
+/* The ivar's C scope extends from the @synthesize statement to the end of the file */
+/* { dg-options "-fnew-property-ivar-synthesis -mmacosx-version-min=10.5 -m64" { target powerpc*-*-darwin* i?86*-*-darwin* } } */
+/* { dg-options "-fnew-property-ivar-synthesis -fobjc-new-property" { target arm*-*-darwin* } } */
+/* { dg-do compile { target *-*-darwin* } } */
+
+#ifdef __OBJC2__
+#import <objc/Object.h>
+
+ at interface Test9_1 : Object
+ at property int prop;
+ at end
+
+ at implementation Test9_1
+-(int) method1 { return prop; } /* { dg-error "\\'prop\\' was not declared in this scope" } */
+ at synthesize prop;
+-(int) method2 { return prop; }
+ at end
+
+ at implementation Test9_1 (Category)
+-(int) method3 { return prop; }
+ at end
+
+ at interface Test9_2 : Object
+ at property int prop;
+ at end
+
+ at implementation Test9_2
+-(int) method1 { return prop_ivar; } /* { dg-error "\\'prop_ivar\\' was not declared in this scope" } */
+-(int) method2 { return prop; } /* { dg-error "\\'prop\\' was not declared in this scope" } */
+ at synthesize prop = prop_ivar;
+-(int) method3 { return prop_ivar; }
+-(int) method4 { return prop; } /* { dg-error "\\'prop\\' was not declared in this scope" } */
+ at end
+
+ at implementation Test9_2 (Category)
+-(int) method5 { return prop_ivar; }
+-(int) method6 { return prop; } /* { dg-error "\\'prop\\' was not declared in this scope" } */
+ at end
+
+#endif
Added: llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/type-nsobject-attribute-2.mm
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/obj-c%2B%2B.dg/type-nsobject-attribute-2.mm?rev=55730&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/type-nsobject-attribute-2.mm (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/type-nsobject-attribute-2.mm Wed Sep 3 15:53:26 2008
@@ -0,0 +1,53 @@
+/* APPLE LOCAL file radar 5595325 */
+/* Test for implementation of __attribute__ ((NSObject)) to make a struct pointer
+ a first class objective-c pointer to object. */
+/* { dg-options "-mmacosx-version-min=10.6 -Werror -framework Foundation" } */
+/* { dg-do run { target *-*-darwin* } } */
+
+#import <Foundation/Foundation.h>
+
+typedef struct _foo *__attribute__((NSObject)) Foo_ref;
+
+ at interface TestObject : NSObject {
+ Foo_ref dict;
+}
+ at property(retain) Foo_ref dict;
+ at end
+
+ at implementation TestObject
+ at synthesize dict;
+ at end
+
+int main(int argc, char *argv[]) {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ NSDictionary *dictRef = [NSDictionary dictionaryWithObject:@"Object" forKey:@"key"];
+ Foo_ref foo = (Foo_ref)dictRef;
+ TestObject *to = [[TestObject alloc] init];
+
+ // do Properties retain?
+ int before = [dictRef retainCount];
+ to.dict = foo;
+ int after = [dictRef retainCount];
+
+ if (after <= before) {
+ abort();
+ }
+ if ([foo retainCount] != [dictRef retainCount]) {
+ abort();
+ }
+
+ // do Blocks retain?
+ {
+ void (^block)(void) = ^{
+ [foo self];
+ };
+ before = [foo retainCount];
+ id save = [block copy];
+ after = [foo retainCount];
+ if (after <= before) {
+ abort();
+ }
+ }
+ return 0;
+}
+
Added: llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/type-nsobject-attribute.mm
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/obj-c%2B%2B.dg/type-nsobject-attribute.mm?rev=55730&view=auto
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/type-nsobject-attribute.mm (added)
+++ llvm-gcc-4.2/trunk/gcc/testsuite/obj-c++.dg/type-nsobject-attribute.mm Wed Sep 3 15:53:26 2008
@@ -0,0 +1,44 @@
+/* APPLE LOCAL file radar 5595325 */
+/* Test for implementation of __attribute__ ((NSObject)) to make a struct pointer
+ a first class objective-c pointer to object. */
+/* { dg-options "-mmacosx-version-min=10.6 -framework Foundation" } */
+/* { dg-do run { target *-*-darwin* } } */
+
+#import <Foundation/Foundation.h>
+
+typedef struct CGColor * __attribute__ ((NSObject)) CGColorRef;
+static int count;
+static CGColorRef tmp = 0;
+
+ at interface HandTested : NSObject {
+ at public
+ CGColorRef x;
+}
+ at property(copy) CGColorRef x;
+ at end
+
+void objc_setProperty(id self, SEL _sel, ptrdiff_t offset, id value, BOOL atomic, BOOL shouldCopy) {
+ if (count != 0 || !shouldCopy)
+ abort ();
+ ++ count;
+ ((HandTested *)self)->x = value;
+}
+
+id objc_getProperty(id self, SEL _sel, ptrdiff_t offset, BOOL atomic) {
+ if (count != 1)
+ abort();
+ return (id)((HandTested *)self)->x;
+}
+
+ at implementation HandTested
+ at synthesize x=x;
+ at end
+
+int main(char *argc, char *argv[]) {
+ HandTested *to = [HandTested new];
+ to.x = tmp; // setter
+ if (tmp != to.x)
+ abort ();
+ return 0;
+}
+
More information about the llvm-commits
mailing list