There is really no point in having a flag to control the Objective C (or Objective C++) exceptions [@throw, as opposed to throw] scheme, since we actually only support one scheme for each permutation of runtime and ABI.

This removes the flag_objc_sjlj_exceptions (or, more correctly, localizes its effect to the ObjC FEs).

All ObjC exceptions choices are now handled in the FE initialization code.

In the case of the code for NeXT runtime (ABI 0/1) the code has been left in place for the DW2 based unwinder (should it occur that Darwin gets a DW2-based NeXT 01 variant). I have arranged that it will be DCE'd unless/until that happens by making the choice a constant.

OK for trunk?
Iain

gcc/c-family:

        * c.opt (fobjc-sjlj-exceptions): Remove as a User control.
        * c-opts.c (flag_objc_sjlj_exceptions): Remove.
        (flag_objc_exceptions/flag_exceptions): Remove code setting
        flag_exceptions.

gcc/objc:

        * objc-next-runtime-abi-01.c (FLAG_OBJC_SJLJ_EXCEPTIONS): New.
(objc_next_runtime_abi_01_init): flag_objc_sjlj_exceptions set constant.
        (next_runtime_01_initialize): Likewise.
        (objc_build_exc_ptr): Likewise.
        * objc-next-runtime-abi-02.c (objc_next_runtime_abi_02_init): Remove
reference to flag_objc_sjlj_exceptions, set flag_exceptions as required.
        * objc-gnu-runtime-abi-01.c (objc_gnu_runtime_abi_01_init): Likewise.
        * objc-act.h (flag_objc_sjlj_exceptions): New objc-local flag.
* objc-act.c (flag_objc_sjlj_exceptions): New objc-local flag, default to false.

gcc:

        * config/darwin.h (SUBTARGET_C_COMMON_OVERRIDE_OPTIONS):
        Remove references to x_flag_objc_sjlj_exceptions.


Index: gcc/c-family/c.opt
===================================================================
--- gcc/c-family/c.opt  (revision 181853)
+++ gcc/c-family/c.opt  (working copy)
@@ -919,8 +919,8 @@ Enable inline checks for nil receivers with the Ne
 
 ; Nonzero means that we generate NeXT setjmp based exceptions.
 fobjc-sjlj-exceptions
-ObjC ObjC++ Var(flag_objc_sjlj_exceptions) Init(-1)
-Enable Objective-C setjmp exception handling runtime
+ObjC ObjC++ Ignore Warn(switch %qs has been removed and is set automatically 
where required)
+Option removed
 
 fobjc-std=objc1
 ObjC ObjC++ Var(flag_objc1_only)
Index: gcc/c-family/c-opts.c
===================================================================
--- gcc/c-family/c-opts.c       (revision 181853)
+++ gcc/c-family/c-opts.c       (working copy)
@@ -894,12 +894,6 @@ c_common_post_options (const char **pfilename)
   else if (!flag_gnu89_inline && !flag_isoc99)
     error ("-fno-gnu89-inline is only supported in GNU99 or C99 mode");
 
-  /* Default to ObjC sjlj exception handling if NeXT runtime.  */
-  if (flag_objc_sjlj_exceptions < 0)
-    flag_objc_sjlj_exceptions = flag_next_runtime;
-  if (flag_objc_exceptions && !flag_objc_sjlj_exceptions)
-    flag_exceptions = 1;
-
   /* -Wextra implies the following flags
      unless explicitly overridden.  */
   if (warn_type_limits == -1)
Index: gcc/objc/objc-next-runtime-abi-01.c
===================================================================
--- gcc/objc/objc-next-runtime-abi-01.c (revision 181853)
+++ gcc/objc/objc-next-runtime-abi-01.c (working copy)
@@ -98,6 +98,8 @@ along with GCC; see the file COPYING3.  If not see
 
 #define CLS_HAS_CXX_STRUCTORS          0x2000L
 
+#define FLAG_OBJC_SJLJ_EXCEPTIONS true
+
 /* rt_trees identifiers - shared between NeXT implementations.  These
    allow the FE to tag meta-data in a manner that survives LTO and can
    be used when the runtime requires that certain meta-data items
@@ -145,14 +147,11 @@ static tree finish_try_stmt (struct objc_try_conte
 bool
 objc_next_runtime_abi_01_init (objc_runtime_hooks *rthooks)
 {
-  if (flag_objc_exceptions
-      && !flag_objc_sjlj_exceptions)
-    {
-      warning_at (UNKNOWN_LOCATION, OPT_Wall,
-               "%<-fobjc-sjlj-exceptions%> is the only supported exceptions "
-               "system for %<-fnext-runtime%> with %<-fobjc-abi-version%> < 
2");
-    }
+  /* NeXT V0/1 Objective-C and Objective-C++ exceptions (i.e. @throw) are 
+     SjLj exceptions.  */
 
+  flag_objc_sjlj_exceptions = FLAG_OBJC_SJLJ_EXCEPTIONS;
+
   rthooks->initialize = next_runtime_01_initialize;
   rthooks->default_constant_string_class_name = DEF_CONSTANT_STRING_CLASS_NAME;
   rthooks->tag_getclass = TAG_GETCLASS;
@@ -384,7 +383,7 @@ static void next_runtime_01_initialize (void)
   objc_setPropertyStruct_decl = NULL_TREE;
 
   build_next_objc_exception_stuff ();
-  if (flag_objc_exceptions && !flag_objc_sjlj_exceptions)
+  if (flag_objc_exceptions && !FLAG_OBJC_SJLJ_EXCEPTIONS)
     using_eh_for_cleanups ();
   lang_hooks.eh_runtime_type = objc_eh_runtime_type;
   lang_hooks.eh_personality = objc_eh_personality;
@@ -2909,7 +2908,7 @@ build_throw_stmt (location_t loc, tree throw_expr,
 static tree
 objc_build_exc_ptr (struct objc_try_context **cur_try_context)
 {
-  if (flag_objc_sjlj_exceptions)
+  if (FLAG_OBJC_SJLJ_EXCEPTIONS)
     {
       tree var = (*cur_try_context)->caught_decl;
       if (!var)
@@ -2957,7 +2956,7 @@ finish_try_stmt (struct objc_try_context **cur_try
   tree stmt;
   struct objc_try_context *c = *cur_try_context;
   /* If we're doing Darwin setjmp exceptions, build the big nasty.  */
-  if (flag_objc_sjlj_exceptions)
+  if (FLAG_OBJC_SJLJ_EXCEPTIONS)
     {
       bool save = in_late_binary_op;
       in_late_binary_op = true;
Index: gcc/objc/objc-next-runtime-abi-02.c
===================================================================
--- gcc/objc/objc-next-runtime-abi-02.c (revision 181853)
+++ gcc/objc/objc-next-runtime-abi-02.c (working copy)
@@ -239,11 +239,17 @@ objc_next_runtime_abi_02_init (objc_runtime_hooks
 {
   extern_names = ggc_alloc_cleared_vec_hash (SIZEHASHTABLE);
 
-  if (flag_objc_exceptions && flag_objc_sjlj_exceptions)
+  if (flag_objc_exceptions)
     {
-      inform (UNKNOWN_LOCATION, "%<-fobjc-sjlj-exceptions%> is ignored for "
-                               "%<-fnext-runtime%> when %<-fobjc-abi-version%> 
>= 2");
-      flag_objc_sjlj_exceptions = 0;
+      /* If the User has not specified fexceptions, set it silently.  */
+      if (!global_options_set.x_flag_exceptions)
+       flag_exceptions = 1;
+      else if (!flag_exceptions)
+        /* If the User has explicitly specified -fno-exceptions together
+           with -fobjc-exceptions, this is an error.  */
+        error_at (UNKNOWN_LOCATION, "%<-fobjc-exceptions%> requires"
+                                   "%<-fexceptions%> for the 64 bit NeXT"
+                                   " runtime");
     }
 
   rthooks->initialize = next_runtime_02_initialize;
Index: gcc/objc/objc-act.c
===================================================================
--- gcc/objc/objc-act.c (revision 181853)
+++ gcc/objc/objc-act.c (working copy)
@@ -267,6 +267,11 @@ FILE *gen_declaration_file;
 /* Hooks for stuff that differs between runtimes.  */
 objc_runtime_hooks runtime;
 
+/* We've removed the SjLj switch, but there is still one case where the
+   code generated here needs to account for it.  */
+
+bool flag_objc_sjlj_exceptions = false;
+
 /* Create a temporary variable of type 'type'.  If 'name' is set, uses
    the specified name, else use no name.  Returns the declaration of
    the type.  The 'name' is mostly useful for debugging.
Index: gcc/objc/objc-act.h
===================================================================
--- gcc/objc/objc-act.h (revision 181853)
+++ gcc/objc/objc-act.h (working copy)
@@ -689,6 +689,11 @@ struct objc_try_context
   tree rethrow_decl;
 };
 
+/* We've removed the SjLj switch, but there is still one case where the
+   code generated in objc-act.c needs to account for it.  */
+
+extern bool flag_objc_sjlj_exceptions;
+
 /*  A small number of routines used by the FE parser and the runtime code
    generators.  Put here as inlines for efficiency in non-lto builds rather
    than making them externs.  */
Index: gcc/objc/objc-gnu-runtime-abi-01.c
===================================================================
--- gcc/objc/objc-gnu-runtime-abi-01.c  (revision 181853)
+++ gcc/objc/objc-gnu-runtime-abi-01.c  (working copy)
@@ -132,12 +132,17 @@ objc_gnu_runtime_abi_01_init (objc_runtime_hooks *
       flag_objc_gc = 0;
     }
 
-  /* Although I guess we could, we don't currently support SJLJ exceptions for 
the
-     GNU runtime.  */
-  if (flag_objc_sjlj_exceptions)
+  /* Objective C exceptions implies -fexceptions for the GNU Runtime.  */
+  if (flag_objc_exceptions)
     {
-      inform (UNKNOWN_LOCATION, "%<-fobjc-sjlj-exceptions%> is ignored for 
%<-fgnu-runtime%>");
-      flag_objc_sjlj_exceptions = 0;
+      /* If the User has not specified fexceptions, set it silently.  */
+      if (!global_options_set.x_flag_exceptions)
+       flag_exceptions = 1;
+      else if (!flag_exceptions)
+        /* If the User has explicitly specified -fno-exceptions together
+           with -fobjc-exceptions, this is an error.  */
+        error_at (UNKNOWN_LOCATION, "%<-fobjc-exceptions%> requires"
+                                   "%<-fexceptions%> for the GNU runtime");
     }
 
   /* TODO: Complain if -fobjc-abi-version=N was used.  */
Index: gcc/config/darwin.h
===================================================================
--- gcc/config/darwin.h (revision 181853)
+++ gcc/config/darwin.h (working copy)
@@ -140,9 +140,6 @@ extern GTY(()) int darwin_ms_struct;
   } while (0)
 
 #define SUBTARGET_C_COMMON_OVERRIDE_OPTIONS do {                        \
-    if (!global_options_set.x_flag_objc_sjlj_exceptions)               \
-      global_options.x_flag_objc_sjlj_exceptions =                     \
-                               flag_next_runtime && !TARGET_64BIT;     \
     if (flag_mkernel || flag_apple_kext)                               \
       {                                                                        
\
        if (flag_use_cxa_atexit == 2)                                   \

Reply via email to