From patchwork Sun Dec 26 18:05:40 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicola Pero X-Patchwork-Id: 76718 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 8A2CCB70EB for ; Mon, 27 Dec 2010 05:05:57 +1100 (EST) Received: (qmail 9877 invoked by alias); 26 Dec 2010 18:05:55 -0000 Received: (qmail 9869 invoked by uid 22791); 26 Dec 2010 18:05:53 -0000 X-SWARE-Spam-Status: No, hits=-0.0 required=5.0 tests=AWL, BAYES_50, TW_BJ, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (140.186.70.10) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 26 Dec 2010 18:05:47 +0000 Received: from eggs.gnu.org ([140.186.70.92]:60123) by fencepost.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1PWuyU-00018v-Bc for gcc-patches@gnu.org; Sun, 26 Dec 2010 13:05:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PWuyV-0003g6-DI for gcc-patches@gnu.org; Sun, 26 Dec 2010 13:05:45 -0500 Received: from smtp111.iad.emailsrvr.com ([207.97.245.111]:57769) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PWuyV-0003g2-8k for gcc-patches@gnu.org; Sun, 26 Dec 2010 13:05:43 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp41.relay.iad1a.emailsrvr.com (SMTP Server) with ESMTP id B4A38290A9F for ; Sun, 26 Dec 2010 13:05:42 -0500 (EST) Received: by smtp41.relay.iad1a.emailsrvr.com (Authenticated sender: nicola.pero-AT-meta-innovation.com) with ESMTPA id 12E02290491 for ; Sun, 26 Dec 2010 13:05:41 -0500 (EST) Message-Id: <7BA29E90-39B1-4CE5-8DE3-82934EB347C0@meta-innovation.com> From: Nicola Pero To: gcc-patches@gnu.org Mime-Version: 1.0 (Apple Message framework v936) Subject: libobjc: run testcases with Apple runtime as well Date: Sun, 26 Dec 2010 19:05:40 +0100 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This patch (as discussed in previous emails), upates the libobjc testcases API to be used with the Apple/NeXT runtime as well (on Apple). This is meant to test the testcases themselves against a reference implementation of the API. ;-) When I tried this out on Apple, it did find a bug in one of the testcases, which I fixed. We are starting to look good in terms of the new Objective-C runtime API. :-) Committed to trunk. Thanks objc/runtime.h. */ @@ -16,11 +15,13 @@ { Class isa; } + alloc; - init; ++ initialize; @end @implementation MyRootClass + alloc { return class_createInstance (self, 0); } - init { return self; } ++ initialize { return self; } @end @protocol MyProtocol @@ -50,15 +51,22 @@ int main () /* TODO: Test new ABI (when available). */ std::cout << "Testing property_getAttributes () ...\n"; { + /* The Apple/NeXT runtime seems to crash on the following. */ +#ifdef __GNU_LIBOBJC__ if (property_getAttributes (NULL) != NULL) abort (); +#endif } /* TODO: Test new ABI (when available). */ std::cout << "Testing property_getName () ...\n"; { + /* The Apple/NeXT runtime seems to crash on the following. */ +#ifdef __GNU_LIBOBJC__ + if (property_getName (NULL) != NULL) abort (); +#endif } return (0); Index: ChangeLog =================================================================== --- ChangeLog (revision 168251) +++ ChangeLog (working copy) @@ -1,5 +1,29 @@ 2010-12-26 Nicola Pero + * objc.dg/gnu-api-2-class.m: Updated the test to work with the + Apple runtime as well. + * obj-c++.dg/gnu-api-2-class.mm: Same change. + * objc.dg/gnu-api-2-ivar.m: Same change. + * obj-c++.dg/gnu-api-2-ivar.mm: Same change. + * objc.dg/gnu-api-2-method.m: Same change. + * obj-c++.dg/gnu-api-2-method.mm: Same change. + * objc.dg/gnu-api-2-objc.m: Same change. + * obj-c++.dg/gnu-api-2-objc.mm: Same change. + * objc.dg/gnu-api-2-object.m: Same change. + * obj-c++.dg/gnu-api-2-object.mm: Same change. + * objc.dg/gnu-api-2-property.m: Same change. + * obj-c++.dg/gnu-api-2-property.mm: Same change. + * objc.dg/gnu-api-2-protocol.m: Same change. + * obj-c++.dg/gnu-api-2-protocol.mm: Same change. + + * objc.dg/gnu-api-2-objc.m: Also, fixed test for + objc_disposeClassPair not to create a new class pair with the same + name as an existing class, and to test that the class pair is + created correctly. + * obj-c++.dg/gnu-api-2-objc.mm: Same change. + +2010-12-26 Nicola Pero + * objc.dg/special/special.exp: Added load-category-2 and load-category-3 tests. * objc.dg/special/load-category-2.h: New. Index: objc.dg/gnu-api-2-ivar.m =================================================================== --- objc.dg/gnu-api-2-ivar.m (revision 168251) +++ objc.dg/gnu-api-2-ivar.m (working copy) @@ -3,7 +3,6 @@ This is test 'ivar', covering all functions starting with 'ivar'. */ /* { dg-do run } */ -/* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */ /* To get the modern GNU Objective-C Runtime API, you include objc/runtime.h. */ @@ -16,11 +15,13 @@ { Class isa; } + alloc; - init; ++ initialize; @end @implementation MyRootClass + alloc { return class_createInstance (self, 0); } - init { return self; } ++ initialize { return self; } @end @protocol MyProtocol Index: objc.dg/gnu-api-2-object.m =================================================================== --- objc.dg/gnu-api-2-object.m (revision 168251) +++ objc.dg/gnu-api-2-object.m (working copy) @@ -3,7 +3,6 @@ This is test 'object', covering all functions starting with 'object'. */ /* { dg-do run } */ -/* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */ /* To get the modern GNU Objective-C Runtime API, you include objc/runtime.h. */ @@ -16,11 +15,13 @@ { Class isa; } + alloc; - init; ++ initialize; @end @implementation MyRootClass + alloc { return class_createInstance (self, 0); } - init { return self; } ++ initialize { return self; } @end @protocol MyProtocol Index: objc.dg/gnu-api-2-objc.m =================================================================== --- objc.dg/gnu-api-2-objc.m (revision 168251) +++ objc.dg/gnu-api-2-objc.m (working copy) @@ -3,7 +3,6 @@ This is test 'objc', covering all functions starting with 'objc'. */ /* { dg-do run } */ -/* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */ /* To get the modern GNU Objective-C Runtime API, you include objc/runtime.h. */ @@ -16,11 +15,13 @@ { Class isa; } + alloc; - init; ++ initialize; @end @implementation MyRootClass + alloc { return class_createInstance (self, 0); } - init { return self; } ++ initialize { return self; } @end @protocol MyProtocol @@ -103,7 +104,10 @@ int main(int argc, void **args) printf ("Testing objc_disposeClassPair ()...\n"); { Method method = class_getInstanceMethod (objc_getClass ("MySubClass"), @selector (setVariable:)); - Class new_class = objc_allocateClassPair (objc_getClass ("MyRootClass"), "MyNewSubClass", 0); + Class new_class = objc_allocateClassPair (objc_getClass ("MyRootClass"), "MyNewSubClass2", 0); + + if (new_class == Nil) + abort (); /* Add a bit of everything to the class to exercise undoing all these changes. */ Index: objc.dg/gnu-api-2-protocol.m =================================================================== --- objc.dg/gnu-api-2-protocol.m (revision 168251) +++ objc.dg/gnu-api-2-protocol.m (working copy) @@ -3,7 +3,6 @@ This is test 'protocol', covering all functions starting with 'protocol'. */ /* { dg-do run } */ -/* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */ /* To get the modern GNU Objective-C Runtime API, you include objc/runtime.h. */ @@ -16,11 +15,13 @@ { Class isa; } + alloc; - init; ++ initialize; @end @implementation MyRootClass + alloc { return class_createInstance (self, 0); } - init { return self; } ++ initialize { return self; } @end @protocol MyProtocol @@ -88,7 +89,7 @@ int main(int argc, void **args) printf ("Testing protocol_copyPropertyList ()...\n"); { unsigned int count; - Property *list; + objc_property_t *list; list = protocol_copyPropertyList (@protocol (MyProtocol), &count); @@ -136,7 +137,7 @@ int main(int argc, void **args) /* TODO: Test new ABI (when available). */ printf ("Testing protocol_getProperty ()...\n"); { - Property property; + objc_property_t property; property = protocol_getProperty (objc_getProtocol ("MyProtocol"), "someProperty", YES, YES); Index: objc.dg/gnu-api-2-class.m =================================================================== --- objc.dg/gnu-api-2-class.m (revision 168251) +++ objc.dg/gnu-api-2-class.m (working copy) @@ -3,7 +3,6 @@ This is test 'class', covering all functions starting with 'class'. */ /* { dg-do run } */ -/* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */ /* To get the modern GNU Objective-C Runtime API, you include objc/runtime.h. */ @@ -16,11 +15,13 @@ { Class isa; } + alloc; - init; ++ initialize; @end @implementation MyRootClass + alloc { return class_createInstance (self, 0); } - init { return self; } ++ initialize { return self; } @end @protocol MyProtocol @@ -256,7 +257,7 @@ int main(int argc, void **args) printf ("Testing class_copyPropertyList ()...\n"); { unsigned int count; - Property * list = class_copyPropertyList (objc_getClass ("MySubClass"), &count); + objc_property_t * list = class_copyPropertyList (objc_getClass ("MySubClass"), &count); if (count != 0 || list != NULL) abort (); Index: objc.dg/gnu-api-2-method.m =================================================================== --- objc.dg/gnu-api-2-method.m (revision 168251) +++ objc.dg/gnu-api-2-method.m (working copy) @@ -3,7 +3,6 @@ This is test 'method', covering all functions starting with 'method'. */ /* { dg-do run } */ -/* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */ /* To get the modern GNU Objective-C Runtime API, you include objc/runtime.h. */ @@ -16,11 +15,13 @@ { Class isa; } + alloc; - init; ++ initialize; @end @implementation MyRootClass + alloc { return class_createInstance (self, 0); } - init { return self; } ++ initialize { return self; } @end @protocol MyProtocol Index: objc.dg/gnu-api-2-property.m =================================================================== --- objc.dg/gnu-api-2-property.m (revision 168251) +++ objc.dg/gnu-api-2-property.m (working copy) @@ -3,7 +3,6 @@ This is test 'property', covering all functions starting with 'property'. */ /* { dg-do run } */ -/* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */ /* To get the modern GNU Objective-C Runtime API, you include objc/runtime.h. */ @@ -16,11 +15,13 @@ { Class isa; } + alloc; - init; ++ initialize; @end @implementation MyRootClass + alloc { return class_createInstance (self, 0); } - init { return self; } ++ initialize { return self; } @end @protocol MyProtocol @@ -50,15 +51,21 @@ int main(int argc, void **args) /* TODO: Test new ABI (when available). */ printf ("Testing property_getAttributes () ...\n"); { + /* The Apple/NeXT runtime seems to crash on the following. */ +#ifdef __GNU_LIBOBJC__ if (property_getAttributes (NULL) != NULL) abort (); +#endif } /* TODO: Test new ABI (when available). */ printf ("Testing property_getName () ...\n"); { + /* The Apple/NeXT runtime seems to crash on the following. */ +#ifdef __GNU_LIBOBJC__ if (property_getName (NULL) != NULL) abort (); +#endif } return 0; Index: obj-c++.dg/gnu-api-2-protocol.mm =================================================================== --- obj-c++.dg/gnu-api-2-protocol.mm (revision 168251) +++ obj-c++.dg/gnu-api-2-protocol.mm (working copy) @@ -3,7 +3,6 @@ This is test 'protocol', covering all functions starting with 'protocol'. */ /* { dg-do run } */ -/* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */ /* To get the modern GNU Objective-C Runtime API, you include objc/runtime.h. */ @@ -16,11 +15,13 @@ { Class isa; } + alloc; - init; ++ initialize; @end @implementation MyRootClass + alloc { return class_createInstance (self, 0); } - init { return self; } ++ initialize { return self; } @end @protocol MyProtocol @@ -88,7 +89,7 @@ int main () std::cout << "Testing protocol_copyPropertyList ()...\n"; { unsigned int count; - Property *list; + objc_property_t *list; list = protocol_copyPropertyList (@protocol (MyProtocol), &count); @@ -136,7 +137,7 @@ int main () /* TODO: Test new ABI (when available). */ std::cout << "Testing protocol_getProperty ()...\n"; { - Property property; + objc_property_t property; property = protocol_getProperty (objc_getProtocol ("MyProtocol"), "someProperty", YES, YES); Index: obj-c++.dg/gnu-api-2-object.mm =================================================================== --- obj-c++.dg/gnu-api-2-object.mm (revision 168251) +++ obj-c++.dg/gnu-api-2-object.mm (working copy) @@ -3,7 +3,6 @@ This is test 'object', covering all functions starting with 'object'. */ /* { dg-do run } */ -/* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */ /* To get the modern GNU Objective-C Runtime API, you include objc/runtime.h. */ @@ -16,11 +15,13 @@ { Class isa; } + alloc; - init; ++ initialize; @end @implementation MyRootClass + alloc { return class_createInstance (self, 0); } - init { return self; } ++ initialize { return self; } @end @protocol MyProtocol Index: obj-c++.dg/gnu-api-2-method.mm =================================================================== --- obj-c++.dg/gnu-api-2-method.mm (revision 168251) +++ obj-c++.dg/gnu-api-2-method.mm (working copy) @@ -3,7 +3,6 @@ This is test 'method', covering all functions starting with 'method'. */ /* { dg-do run } */ -/* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */ /* To get the modern GNU Objective-C Runtime API, you include objc/runtime.h. */ @@ -16,11 +15,13 @@ { Class isa; } + alloc; - init; ++ initialize; @end @implementation MyRootClass + alloc { return class_createInstance (self, 0); } - init { return self; } ++ initialize { return self; } @end @protocol MyProtocol Index: obj-c++.dg/gnu-api-2-objc.mm =================================================================== --- obj-c++.dg/gnu-api-2-objc.mm (revision 168251) +++ obj-c++.dg/gnu-api-2-objc.mm (working copy) @@ -3,7 +3,6 @@ This is test 'objc', covering all functions starting with 'objc'. */ /* { dg-do run } */ -/* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */ /* To get the modern GNU Objective-C Runtime API, you include objc/runtime.h. */ @@ -16,11 +15,13 @@ { Class isa; } + alloc; - init; ++ initialize; @end @implementation MyRootClass + alloc { return class_createInstance (self, 0); } - init { return self; } ++ initialize { return self; } @end @protocol MyProtocol @@ -103,7 +104,10 @@ int main () std::cout << "Testing objc_disposeClassPair ()...\n"; { Method method = class_getInstanceMethod (objc_getClass ("MySubClass"), @selector (setVariable:)); - Class new_class = objc_allocateClassPair (objc_getClass ("MyRootClass"), "MyNewSubClass", 0); + Class new_class = objc_allocateClassPair (objc_getClass ("MyRootClass"), "MyNewSubClass2", 0); + + if (new_class == Nil) + abort (); /* Add a bit of everything to the class to exercise undoing all these changes. */ Index: obj-c++.dg/gnu-api-2-ivar.mm =================================================================== --- obj-c++.dg/gnu-api-2-ivar.mm (revision 168251) +++ obj-c++.dg/gnu-api-2-ivar.mm (working copy) @@ -3,7 +3,6 @@ This is test 'ivar', covering all functions starting with 'ivar'. */ /* { dg-do run } */ -/* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */ /* To get the modern GNU Objective-C Runtime API, you include objc/runtime.h. */ @@ -16,11 +15,13 @@ { Class isa; } + alloc; - init; ++ initialize; @end @implementation MyRootClass + alloc { return class_createInstance (self, 0); } - init { return self; } ++ initialize { return self; } @end @protocol MyProtocol Index: obj-c++.dg/gnu-api-2-class.mm =================================================================== --- obj-c++.dg/gnu-api-2-class.mm (revision 168251) +++ obj-c++.dg/gnu-api-2-class.mm (working copy) @@ -3,7 +3,6 @@ This is test 'class', covering all functions starting with 'class'. */ /* { dg-do run } */ -/* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */ /* To get the modern GNU Objective-C Runtime API, you include objc/runtime.h. */ @@ -16,11 +15,13 @@ { Class isa; } + alloc; - init; ++ initialize; @end @implementation MyRootClass + alloc { return class_createInstance (self, 0); } - init { return self; } ++ initialize { return self; } @end @protocol MyProtocol @@ -256,7 +257,7 @@ int main () std::cout << "Testing class_copyPropertyList ()...\n"; { unsigned int count; - Property * list = class_copyPropertyList (objc_getClass ("MySubClass"), &count); + objc_property_t * list = class_copyPropertyList (objc_getClass ("MySubClass"), &count); if (count != 0 || list != NULL) abort (); Index: obj-c++.dg/gnu-api-2-property.mm =================================================================== --- obj-c++.dg/gnu-api-2-property.mm (revision 168251) +++ obj-c++.dg/gnu-api-2-property.mm (working copy) @@ -3,7 +3,6 @@ This is test 'property', covering all functions starting with 'property'. */ /* { dg-do run } */ -/* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */ /* To get the modern GNU Objective-C Runtime API, you include