From patchwork Sat Dec 18 11:35:43 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 76061 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 8012BB6EE8 for ; Sat, 18 Dec 2010 22:35:57 +1100 (EST) Received: (qmail 4753 invoked by alias); 18 Dec 2010 11:35:55 -0000 Received: (qmail 4496 invoked by uid 22791); 18 Dec 2010 11:35:53 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, TW_BJ, TW_JL X-Spam-Check-By: sourceware.org Received: from c2bthomr07.btconnect.com (HELO mail.btconnect.com) (213.123.20.125) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 18 Dec 2010 11:35:47 +0000 Received: from host81-138-1-83.in-addr.btopenworld.com (EHLO thor.office) ([81.138.1.83]) by c2bthomr07.btconnect.com with ESMTP id BIA67968; Sat, 18 Dec 2010 11:35:44 +0000 (GMT) Cc: GCC Patches , Mike Stump Message-Id: <0772A5AF-C08B-43B6-B3A9-2B1864CC208E@sandoe-acoustics.co.uk> From: IainS To: Nicola Pero In-Reply-To: Mime-Version: 1.0 (Apple Message framework v936) Subject: Re: [Patch ObjC] fix objc.dg/exceptions2.m linkage error. Date: Sat, 18 Dec 2010 11:35:43 +0000 References: X-Mirapoint-IP-Reputation: reputation=Fair-1, source=Queried, refid=tid=0001.0A0B0302.4D0C9C90.0056, actions=TAG X-Junkmail-Signature-Raw: score=unknown, refid=str=0001.0A0B0203.4D0C9C91.0031, ss=1, fgs=0, ip=0.0.0.0, so=2010-07-22 22:03:31, dmn=2009-09-10 00:05:08, mode=single engine 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 Hi Nicola, On 17 Dec 2010, at 20:53, Mike Stump wrote: > On Dec 17, 2010, at 6:34 AM, IainS acoustics.co.uk> wrote: >> The NeXT runtime library names its m64 personality routine >> "___objc_personality_v0" >> >> So, in addition to the change to switch off sjlj exceptions (which >> causes linkage errors for the absent sjlj routines), >> we also need to generate the right name for the eh personality... >> >> OK? > > Ok. If you want to do once per unit, that's fine too. Hm. I tried the simple approach, with not-very-useful results. e.g: @try { <<< no error.... number++; @throw o; <<< error here... } === (2) @throw o; @try { number++; @throw o; <<< error here... } when I check the locus on entry to objc_build_throw_stmt () in (2) it seems a bit odd. I've made the desideratum a "TODO" since it looked like we would have to stray out of objc-act to fix it. ... although, perhaps, Nicola since you were last amongst this - maybe the issue will be obvious to you ;-) FWIW; I also corrected the syntax in the dg-error statements for the testcase. (they would give an error like FAIL -fnext-runtime is required to enable Objective-C exception syntax - which is very confusing) cheers Iain r168020; Index: gcc/objc/objc-act.c =================================================================== --- gcc/objc/objc-act.c (revision 168019) +++ gcc/objc/objc-act.c (working copy) @@ -5028,11 +5028,42 @@ tree objc_eh_personality (void) { if (!flag_objc_sjlj_exceptions && !objc_eh_personality_decl) - objc_eh_personality_decl = build_personality_function ("gnu_objc"); + objc_eh_personality_decl = build_personality_function + (flag_next_runtime + ? "objc" + : "gnu_objc"); return objc_eh_personality_decl; } #endif +static void +objc_init_exceptions (location_t loc) +{ + static bool done = false; + + /* -fobjc-exceptions is required to enable Objective-C exceptions. + For example, on Darwin, ObjC exceptions require a sufficiently + recent version of the runtime, so the user must ask for them + explicitly. On other platforms, at the moment -fobjc-exceptions + triggers -fexceptions which again is required for exceptions to + work. + */ + /* TODO: we only really need one error message when the flag is missing. */ + if (!flag_objc_exceptions) + { + error_at (loc, "%<-fobjc-exceptions%> is required to enable Objective-C exception syntax"); + } + + if (done) + return; + done = true; + +#ifndef OBJCPLUS + if (!flag_objc_sjlj_exceptions) + using_eh_for_cleanups (); +#endif +} + /* Build __builtin_eh_pointer, or the moral equivalent. In the case of Darwin, we'll arrange for it to be initialized (and associated with a binding) later. */ @@ -5334,17 +5365,7 @@ objc_begin_try_stmt (location_t try_locus, tree bo c->end_try_locus = input_location; cur_try_context = c; - /* -fobjc-exceptions is required to enable Objective-C exceptions. - For example, on Darwin, ObjC exceptions require a sufficiently - recent version of the runtime, so the user must ask for them - explicitly. On other platforms, at the moment -fobjc-exceptions - triggers -fexceptions which again is required for exceptions to - work. - */ - if (!flag_objc_exceptions) - { - error_at (try_locus, "%<-fobjc-exceptions%> is required to enable Objective-C exception syntax"); - } + objc_init_exceptions (try_locus); /* Collect the list of local variables. We'll mark them as volatile at the end of compilation of this function to prevent them being @@ -5552,10 +5573,7 @@ objc_build_throw_stmt (location_t loc, tree throw_ { tree args; - if (!flag_objc_exceptions) - { - error_at (loc, "%<-fobjc-exceptions%> is required to enable Objective-C exception syntax"); - } + objc_init_exceptions (loc); if (throw_expr == NULL) { Index: gcc/objc/ChangeLog =================================================================== --- gcc/objc/ChangeLog (revision 168019) +++ gcc/objc/ChangeLog (working copy) @@ -1,3 +1,11 @@ +2010-12-18 Iain Sandoe + + * objc/objc-act.c (objc_eh_personality): Select personality name on + runtime. + (objc_init_exceptions): New. + (objc_begin_try_stmt): Use objc_init_exceptions. + (objc_build_throw_stmt): Likewise. + 2010-12-10 Nicola Pero * objc-act.c (objc_in_class_extension): New. Index: gcc/testsuite/ChangeLog =================================================================== --- gcc/testsuite/ChangeLog (revision 168019) +++ gcc/testsuite/ChangeLog (working copy) @@ -1,3 +1,7 @@ +2010-12-18 Iain Sandoe + + * fobjc-exceptions.m: Update dg-error syntax. + 2010-12-18 Kai Tietz PR target/36834 Index: gcc/testsuite/objc.dg/fobjc-exceptions.m =================================================================== --- gcc/testsuite/objc.dg/fobjc-exceptions.m (revision 168019) +++ gcc/testsuite/objc.dg/fobjc-exceptions.m (working copy) @@ -5,25 +5,24 @@ int dummy (int number, Object *o) { - @try { /* { dg-error "fobjc-exceptions" "is required to enable Objective-C exception syntax" } */ + @try { /* { dg-error ".-fobjc-exceptions. is required to enable Objective-C exception syntax" } */ number++; - @throw o; /* { dg-error "fobjc-exceptions" "is required to enable Objective-C exception syntax" } */ + @throw o; /* { dg-error ".-fobjc-exceptions. is required to enable Objective-C exception syntax" } */ } @catch (id object) { number++; - @throw; /* { dg-error "fobjc-exceptions" "is required to enable Objective-C exception syntax" } */ + @throw; /* { dg-error ".-fobjc-exceptions. is required to enable Objective-C exception syntax" } */ } @finally { number++; } - @synchronized (o) /* { dg-error "fobjc-exceptions" "is required to enable Objective-C exception syntax" } */ + @synchronized (o) /* { dg-error ".-fobjc-exceptions. is required to enable Objective-C exception syntax" } */ { number++; } return number; } -