From patchwork Tue May 24 21:41:49 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicola Pero X-Patchwork-Id: 97230 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 B1634B6EE9 for ; Wed, 25 May 2011 07:42:10 +1000 (EST) Received: (qmail 15067 invoked by alias); 24 May 2011 21:42:09 -0000 Received: (qmail 15058 invoked by uid 22791); 24 May 2011 21:42:08 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL, BAYES_00, SARE_SUB_ENC_UTF8, 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; Tue, 24 May 2011 21:41:52 +0000 Received: from eggs.gnu.org ([140.186.70.92]:36435) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1QOzMN-0006yo-Tf for gcc-patches@gnu.org; Tue, 24 May 2011 17:41:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QOzMM-0002q7-K7 for gcc-patches@gnu.org; Tue, 24 May 2011 17:41:51 -0400 Received: from smtp161.iad.emailsrvr.com ([207.97.245.161]:58962) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOzMM-0002pv-Hh for gcc-patches@gnu.org; Tue, 24 May 2011 17:41:50 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp56.relay.iad1a.emailsrvr.com (SMTP Server) with ESMTP id 013173D8507 for ; Tue, 24 May 2011 17:41:49 -0400 (EDT) Received: from dynamic14.wm-web.iad.mlsrvr.com (dynamic14.wm-web.iad1a.rsapps.net [192.168.2.221]) by smtp56.relay.iad1a.emailsrvr.com (SMTP Server) with ESMTP id D1A643D84DE for ; Tue, 24 May 2011 17:41:49 -0400 (EDT) Received: from meta-innovation.com (localhost [127.0.0.1]) by dynamic14.wm-web.iad.mlsrvr.com (Postfix) with ESMTP id C13ED2E9802E for ; Tue, 24 May 2011 17:41:49 -0400 (EDT) Received: by www2.webmail.us (Authenticated sender: nicola.pero@meta-innovation.com, from: nicola.pero@meta-innovation.com) with HTTP; Tue, 24 May 2011 23:41:49 +0200 (CEST) Date: Tue, 24 May 2011 23:41:49 +0200 (CEST) Subject: =?utf-8?Q?Fix_for_libobjc=2F48177.__Can_I_apply_it_to_4.6_as_well_=3F?= From: "Nicola Pero" To: "gcc-patches@gnu.org" MIME-Version: 1.0 X-Type: plain Message-ID: <1306273309.79029136@www2.webmail.us> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 207.97.245.161 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 fixes libobjc/48177. I applied it to trunk. I'd like to apply this patch to the 4.6 branch too. Do I need permission from a Release Manager ? Can I get it ? :-) It is a fairly obvious fix as selector types should generally be compared using sel_types_match() and not strcmp(). But note that this bug has been in libobjc forever; it never mattered much because the traditional API (the only one available before GCC 4.6) had a number of different functions for dealing with typed selectors, and gnustep-base (the main user of this API) was using some other function to do this and the problem wasn't visible. The modern API (recommended from GCC 4.6.0 onwards) has a more limited, and elegant, set of functions, and the code in gnustep-base would be massively simplified ... if only this bug wasn't in the way! :-( Due to this bug, gnustep-base actually has to forcefully use the traditional API in the middle of the modern API, which it does by copying some declarations from the traditional API and it's all quite horrible. Ideally, we'd fix this bug in trunk and in 4.6.1, so that once 4.6.1 is released, gnustep-base can remove the horrible hacks, simply use the Modern API, and just tell everyone running 4.6.0 to upgrade to 4.6.1 to get the fix. :-) So, OK to commit to the 4.6 branch too ? Thanks Index: libobjc/ChangeLog =================================================================== --- libobjc/ChangeLog (revision 174141) +++ libobjc/ChangeLog (working copy) @@ -1,3 +1,10 @@ +2011-05-24 Nicola Pero + + PR libobjc/48177 + * selector.c (__sel_register_typed_name): Use sel_types_match() + instead of strcmp() to compare selector types (Suggestion by + Richard Frith-Macdonald ). + 2011-04-15 Rainer Orth PR libobjc/32037 Index: libobjc/selector.c =================================================================== --- libobjc/selector.c (revision 174138) +++ libobjc/selector.c (working copy) @@ -597,7 +597,7 @@ __sel_register_typed_name (const char *name, const return s; } } - else if (! strcmp (s->sel_types, types)) + else if (sel_types_match (s->sel_types, types)) { if (orig) { Index: gcc/testsuite/ChangeLog =================================================================== --- gcc/testsuite/ChangeLog (revision 174142) +++ gcc/testsuite/ChangeLog (working copy) @@ -1,5 +1,10 @@ 2011-05-24 Nicola Pero + PR libobjc/48177 + * objc.dg/pr48177.m: New testcase. + +2011-05-24 Nicola Pero + PR objc/48187 * objc.dg/pr48187.m: New testcase. * obj-c++.dg/pr48187.mm: New testcase. Index: gcc/testsuite/objc.dg/pr48177.m =================================================================== --- gcc/testsuite/objc.dg/pr48177.m (revision 0) +++ gcc/testsuite/objc.dg/pr48177.m (revision 0) @@ -0,0 +1,35 @@ +/* Contributed by Nicola Pero , May 2011. */ +/* { dg-do run } */ +/* { dg-skip-if "No API#2 pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */ + +#include +#include + +int main(int argc, void **args) +{ +#ifdef __GNU_LIBOBJC__ + /* This special test tests that, if you have a selector already + registered in the runtime with full type information, you can use + sel_registerTypedName() to get it even if you specify the type + with incorrect argframe information. This is helpful as + selectors generated by the compiler (which have correct argframe + information) are usually registered before hand-written ones + (which often have incorrect argframe information, but need the + correct one). + + Note that in this hand-written test, even the type information of + the first selector may be wrong (on this machine); but that's OK + as we'll never actually use the selectors. */ + SEL selector1 = sel_registerTypedName ("testMethod", "i8@0:4"); + SEL selector2 = sel_registerTypedName ("testMethod", "i8@8:8"); + + /* We compare the selectors using ==, not using sel_isEqual(). This + is because we are testing internals of the runtime and we know + that in the current implementation they should be identical if + the stuff is to work as expected. Don't do this at home. */ + if (selector1 != selector2) + abort (); +#endif + + return 0; +}