summaryrefslogtreecommitdiff
path: root/gcc/objc/objc-act.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/objc/objc-act.c')
-rw-r--r--gcc/objc/objc-act.c49
1 files changed, 32 insertions, 17 deletions
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index 131ce5524e4..2076111c4d6 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -626,6 +626,11 @@ objc_init (void)
if (print_struct_values && !flag_compare_debug)
generate_struct_by_value_array ();
+#ifndef OBJCPLUS
+ if (flag_objc_exceptions && !flag_objc_sjlj_exceptions)
+ using_eh_for_cleanups ();
+#endif
+
return true;
}
@@ -5028,11 +5033,36 @@ 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
+void
+objc_maybe_warn_exceptions (location_t loc)
+{
+ /* -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)
+ {
+ /* Warn only once per compilation unit. */
+ static bool warned = false;
+
+ if (!warned)
+ {
+ error_at (loc, "%<-fobjc-exceptions%> is required to enable Objective-C exception syntax");
+ warned = true;
+ }
+ }
+}
+
/* 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,18 +5364,6 @@ objc_begin_try_stmt (location_t try_locus, tree body)
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");
- }
-
/* 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. */
@@ -5552,10 +5570,7 @@ objc_build_throw_stmt (location_t loc, tree throw_expr)
{
tree args;
- if (!flag_objc_exceptions)
- {
- error_at (loc, "%<-fobjc-exceptions%> is required to enable Objective-C exception syntax");
- }
+ objc_maybe_warn_exceptions (loc);
if (throw_expr == NULL)
{