public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch ObjC] fix objc.dg/exceptions2.m linkage error.
@ 2010-12-17 15:52 IainS
  2010-12-17 19:03 ` Nicola Pero
  2010-12-17 21:09 ` Mike Stump
  0 siblings, 2 replies; 6+ messages in thread
From: IainS @ 2010-12-17 15:52 UTC (permalink / raw)
  To: GCC Patches; +Cc: Mike Stump, Nicola Pero

[-- Attachment #1: Type: text/plain, Size: 490 bytes --]

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?
Iain

objc:

	* 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.


[-- Attachment #2: 167976-objc-m64-except.txt --]
[-- Type: text/plain, Size: 2635 bytes --]

Index: gcc/objc/objc-act.c
===================================================================
--- gcc/objc/objc-act.c	(revision 167976)
+++ gcc/objc/objc-act.c	(working copy)
@@ -5028,11 +5028,41 @@ 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.
+  */
+  if (!flag_objc_exceptions)
+    {
+      error_at (loc, "%<-fobjc-exceptions%> is required to enable Objective-C exception syntax");
+    }
+
+  /* We could arrange for only one warning - by moving this before the check.  */
+  if (done)
+    return;
+  done = true;
+
+#ifndef OBJCPLUS
+  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 +5364,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 +5572,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)
     {

[-- Attachment #3: Type: text/plain, Size: 3 bytes --]





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-12-18 17:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-17 15:52 [Patch ObjC] fix objc.dg/exceptions2.m linkage error IainS
2010-12-17 19:03 ` Nicola Pero
2010-12-17 21:09 ` Mike Stump
2010-12-18 11:57   ` IainS
2010-12-18 14:27     ` Nicola Pero
2010-12-18 18:58       ` Mike Stump

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).