@@ -834,12 +834,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;
-
/* -Woverlength-strings is off by default, but is enabled by -Wpedantic.
It is never enabled in C++, as the minimum limit is not normative
in that standard. */
@@ -1058,8 +1058,8 @@ Enable inline checks for nil receivers with the NeXT runtime and ABI version 2.
; 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)
@@ -3126,18 +3126,6 @@ darwin_override_options (void)
flag_reorder_blocks = 1;
}
- /* FIXME: flag_objc_sjlj_exceptions is no longer needed since there is only
- one valid choice of exception scheme for each runtime. */
- if (!global_options_set.x_flag_objc_sjlj_exceptions)
- global_options.x_flag_objc_sjlj_exceptions =
- flag_next_runtime && !TARGET_64BIT;
-
- /* FIXME: and this could be eliminated then too. */
- if (!global_options_set.x_flag_exceptions
- && flag_objc_exceptions
- && TARGET_64BIT)
- flag_exceptions = 1;
-
if (flag_mkernel || flag_apple_kext)
{
/* -mkernel implies -fapple-kext for C++ */
@@ -4126,7 +4126,7 @@ objc_begin_try_stmt (location_t try_locus, tree body)
/* Collect the list of local variables. We'll mark them as volatile
at the end of compilation of this function to prevent them being
clobbered by setjmp/longjmp. */
- if (flag_objc_sjlj_exceptions)
+ if (runtime.exceptions_model == objc_exceptions_sjlj)
objc_mark_locals_volatile (NULL);
}
@@ -132,12 +132,20 @@ objc_gnu_runtime_abi_01_init (objc_runtime_hooks *rthooks)
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;
+ /* GNU runtime uses dwarf unwinding. */
+ rthooks->exceptions_model = objc_exceptions_dwarf;
+
+ /* 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. */
@@ -97,6 +97,9 @@ along with GCC; see the file COPYING3. If not see
#define CLS_HAS_CXX_STRUCTORS 0x2000L
+/* For this ABI, there is no choice but to use sjlj, presently. */
+#define 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
@@ -144,13 +147,9 @@ static tree finish_try_stmt (struct objc_try_context **);
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. */
+ rthooks->exceptions_model = objc_exceptions_sjlj;
rthooks->initialize = next_runtime_01_initialize;
rthooks->default_constant_string_class_name = DEF_CONSTANT_STRING_CLASS_NAME;
@@ -383,7 +382,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 && !OBJC_SJLJ_EXCEPTIONS)
using_eh_for_cleanups ();
lang_hooks.eh_runtime_type = objc_eh_runtime_type;
lang_hooks.eh_personality = objc_eh_personality;
@@ -2847,6 +2846,7 @@ objc_eh_personality (void)
{
if (!objc_eh_personality_decl)
#ifndef OBJCPLUS
+ /* The personality for ABI=0,1 is just the gcc one. */
objc_eh_personality_decl = build_personality_function ("gcc");
#else
objc_eh_personality_decl = build_personality_function ("gxx");
@@ -2877,7 +2877,7 @@ build_throw_stmt (location_t loc, tree throw_expr, bool rethrown ATTRIBUTE_UNUSE
static tree
objc_build_exc_ptr (struct objc_try_context **cur_try_context)
{
- if (flag_objc_sjlj_exceptions)
+ if (OBJC_SJLJ_EXCEPTIONS)
{
tree var = (*cur_try_context)->caught_decl;
if (!var)
@@ -2925,7 +2925,7 @@ finish_try_stmt (struct objc_try_context **cur_try_context)
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 (OBJC_SJLJ_EXCEPTIONS)
{
bool save = in_late_binary_op;
in_late_binary_op = true;
@@ -239,11 +239,20 @@ objc_next_runtime_abi_02_init (objc_runtime_hooks *rthooks)
{
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;
+ /* NeXT ABI v2 runtime uses dwarf unwinding. */
+ rthooks->exceptions_model = objc_exceptions_dwarf;
+
+ /* 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;
@@ -478,7 +487,8 @@ static void next_runtime_02_initialize (void)
objc_getPropertyStruct_decl = NULL_TREE;
objc_setPropertyStruct_decl = NULL_TREE;
- gcc_assert (!flag_objc_sjlj_exceptions);
+ gcc_checking_assert (!flag_objc_exceptions
+ || (runtime.exceptions_model == objc_exceptions_dwarf));
/* Although we warn that fobjc-exceptions is required for exceptions
code, we carry on and create it anyway. */
@@ -33,6 +33,15 @@ along with GCC; see the file COPYING3. If not see
and so on, and the purpose of this interface is to abstract such
differences from the parser's perspective. */
+/* Currently, two different exceptions models are used (depends on which
+ runtime and ABI is selected). */
+
+typedef enum {
+ objc_exceptions_unk = 0,
+ objc_exceptions_sjlj,
+ objc_exceptions_dwarf
+} objc_exceptions_model_t;
+
/* TODO: Do we want the initial underscore ? */
typedef struct _objc_runtime_hooks_r
{
@@ -97,6 +106,9 @@ typedef struct _objc_runtime_hooks_r
during parsing. */
void (*generate_metadata) (void);
+ /* What kind of exceptions code to generate. */
+ objc_exceptions_model_t exceptions_model;
+
} objc_runtime_hooks;
/* For shared support that needs to access these. */