diff options
author | Nicola Pero <nicola@gcc.gnu.org> | 2010-12-18 20:28:07 +0000 |
---|---|---|
committer | Nicola Pero <nicola@gcc.gnu.org> | 2010-12-18 20:28:07 +0000 |
commit | 46270f141bec8186f01faf7ec216c57fd81e1463 (patch) | |
tree | 7e133229359caed0887f2fb805a0c54ecaa63de2 | |
parent | b5dca6ea71c1de8775d723d5af41618c3581ae68 (diff) | |
download | gcc-46270f141bec8186f01faf7ec216c57fd81e1463.zip gcc-46270f141bec8186f01faf7ec216c57fd81e1463.tar.gz gcc-46270f141bec8186f01faf7ec216c57fd81e1463.tar.bz2 |
In gcc/: 2010-12-18 Nicola Pero <nicola.pero@meta-innovation.com>
In gcc/:
2010-12-18 Nicola Pero <nicola.pero@meta-innovation.com>
* c-parser.c (c_parser_objc_try_catch_finally_statement): Call
objc_maybe_warn_exceptions.
(c_parser_objc_synchronized_statement): Call
objc_maybe_warn_exceptions.
In gcc/cp/:
2010-12-18 Nicola Pero <nicola.pero@meta-innovation.com>
* parser.c (cp_parser_objc_try_catch_finally_statement): Call
objc_maybe_warn_exceptions.
(cp_parser_objc_synchronized_statement): Same change.
In gcc/c-family/:
2010-12-18 Nicola Pero <nicola.pero@meta-innovation.com>
* c-objc.h (objc_maybe_warn_exceptions): New.
* stub-objc.c (objc_maybe_warn_exceptions): New.
In gcc/objc/:
2010-12-18 Nicola Pero <nicola.pero@meta-innovation.com>
* objc-act.c (objc_init): Call using_eh_for_cleanups.
(objc_init_exceptions): Renamed to objc_maybe_warn_exceptions. Do
not call using_eh_for_cleanups.
(objc_begin_try_stmt): Do not call objc_init_exceptions.
(objc_build_throw_stmt): Updated call to
objc_maybe_warn_exceptions.
In gcc/testsuite/:
2010-12-18 Nicola Pero <nicola.pero@meta-innovation.com>
* objc.dg/fobjc-exceptions-1.m: Updated.
* objc.dg/fobjc-exceptions-2.m: New.
* objc.dg/fobjc-exceptions-3.m: New.
* obj-c++.dg/fobjc-exceptions-1.mm: New.
* obj-c++.dg/fobjc-exceptions-2.mm: New.
* obj-c++.dg/fobjc-exceptions-3.mm: New.
From-SVN: r168032
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/c-family/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/c-family/c-objc.h | 1 | ||||
-rw-r--r-- | gcc/c-family/stub-objc.c | 5 | ||||
-rw-r--r-- | gcc/c-parser.c | 2 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/parser.c | 2 | ||||
-rw-r--r-- | gcc/objc/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/objc/objc-act.c | 37 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/testsuite/obj-c++.dg/fobjc-exceptions-1.mm (renamed from gcc/testsuite/objc.dg/fobjc-exceptions.m) | 6 | ||||
-rw-r--r-- | gcc/testsuite/obj-c++.dg/fobjc-exceptions-2.mm | 29 | ||||
-rw-r--r-- | gcc/testsuite/obj-c++.dg/fobjc-exceptions-3.mm | 30 | ||||
-rw-r--r-- | gcc/testsuite/objc.dg/fobjc-exceptions-1.m | 28 | ||||
-rw-r--r-- | gcc/testsuite/objc.dg/fobjc-exceptions-2.m | 29 | ||||
-rw-r--r-- | gcc/testsuite/objc.dg/fobjc-exceptions-3.m | 30 |
16 files changed, 213 insertions, 24 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7f2a5ae..cf8d786 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2010-12-18 Nicola Pero <nicola.pero@meta-innovation.com> + + * c-parser.c (c_parser_objc_try_catch_finally_statement): Call + objc_maybe_warn_exceptions. + (c_parser_objc_synchronized_statement): Call + objc_maybe_warn_exceptions. + 2010-12-18 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/46985 diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 20d59d9..4be312d 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2010-12-18 Nicola Pero <nicola.pero@meta-innovation.com> + + * c-objc.h (objc_maybe_warn_exceptions): New. + * stub-objc.c (objc_maybe_warn_exceptions): New. + 2010-12-10 Nathan Froyd <froydnj@codesourcery.com> * c-common.h (readonly_error): Declare. diff --git a/gcc/c-family/c-objc.h b/gcc/c-family/c-objc.h index 4089293..afe7fcc 100644 --- a/gcc/c-family/c-objc.h +++ b/gcc/c-family/c-objc.h @@ -106,6 +106,7 @@ extern bool objc_is_property_ref (tree); extern bool objc_string_ref_type_p (tree); extern void objc_check_format_arg (tree, tree); extern void objc_finish_function (void); +extern void objc_maybe_warn_exceptions (location_t); /* The following are provided by the C and C++ front-ends, and called by ObjC/ObjC++. */ diff --git a/gcc/c-family/stub-objc.c b/gcc/c-family/stub-objc.c index 0600c2f..e3aa98d 100644 --- a/gcc/c-family/stub-objc.c +++ b/gcc/c-family/stub-objc.c @@ -455,3 +455,8 @@ void objc_finish_function (void) { } + +void +objc_maybe_warn_exceptions (location_t ARG_UNUSED (loc)) +{ +} diff --git a/gcc/c-parser.c b/gcc/c-parser.c index 261ea3d..4eaf868 100644 --- a/gcc/c-parser.c +++ b/gcc/c-parser.c @@ -7547,6 +7547,7 @@ c_parser_objc_try_catch_finally_statement (c_parser *parser) gcc_assert (c_parser_next_token_is_keyword (parser, RID_AT_TRY)); c_parser_consume_token (parser); location = c_parser_peek_token (parser)->location; + objc_maybe_warn_exceptions (location); stmt = c_parser_compound_statement (parser); objc_begin_try_stmt (location, stmt); @@ -7628,6 +7629,7 @@ c_parser_objc_synchronized_statement (c_parser *parser) gcc_assert (c_parser_next_token_is_keyword (parser, RID_AT_SYNCHRONIZED)); c_parser_consume_token (parser); loc = c_parser_peek_token (parser)->location; + objc_maybe_warn_exceptions (loc); if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) { expr = c_parser_expression (parser).value; diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8ac637a..872cd06 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2010-12-18 Nicola Pero <nicola.pero@meta-innovation.com> + + * parser.c (cp_parser_objc_try_catch_finally_statement): Call + objc_maybe_warn_exceptions. + (cp_parser_objc_synchronized_statement): Same change. + 2010-12-18 Joseph Myers <joseph@codesourcery.com> * pt.c (most_specialized_class): Use ngettext to determine diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 3e6930f..1a2d425 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -22692,6 +22692,7 @@ cp_parser_objc_try_catch_finally_statement (cp_parser *parser) cp_parser_require_keyword (parser, RID_AT_TRY, RT_AT_TRY); location = cp_lexer_peek_token (parser->lexer)->location; + objc_maybe_warn_exceptions (location); /* NB: The @try block needs to be wrapped in its own STATEMENT_LIST node, lest it get absorbed into the surrounding block. */ stmt = push_stmt_list (); @@ -22784,6 +22785,7 @@ cp_parser_objc_synchronized_statement (cp_parser *parser) cp_parser_require_keyword (parser, RID_AT_SYNCHRONIZED, RT_AT_SYNCHRONIZED); location = cp_lexer_peek_token (parser->lexer)->location; + objc_maybe_warn_exceptions (location); cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN); lock = cp_parser_expression (parser, false, NULL); cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN); diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog index 15af19d..d519ad7 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,3 +1,12 @@ +2010-12-18 Nicola Pero <nicola.pero@meta-innovation.com> + + * objc-act.c (objc_init): Call using_eh_for_cleanups. + (objc_init_exceptions): Renamed to objc_maybe_warn_exceptions. Do + not call using_eh_for_cleanups. + (objc_begin_try_stmt): Do not call objc_init_exceptions. + (objc_build_throw_stmt): Updated call to + objc_maybe_warn_exceptions. + 2010-12-18 Iain Sandoe <iains@gcc.gnu.org> * objc/objc-act.c (objc_eh_personality): Select personality name on diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index f05ab19..2076111 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; } @@ -5036,32 +5041,26 @@ objc_eh_personality (void) } #endif -static void -objc_init_exceptions (location_t loc) +void +objc_maybe_warn_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. */ + work. */ if (!flag_objc_exceptions) { - error_at (loc, "%<-fobjc-exceptions%> is required to enable Objective-C exception syntax"); - } + /* Warn only once per compilation unit. */ + static bool warned = false; - if (done) - return; - done = true; - -#ifndef OBJCPLUS - if (!flag_objc_sjlj_exceptions) - using_eh_for_cleanups (); -#endif + 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 @@ -5365,8 +5364,6 @@ objc_begin_try_stmt (location_t try_locus, tree body) c->end_try_locus = input_location; cur_try_context = c; - 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 clobbered by setjmp/longjmp. */ @@ -5573,7 +5570,7 @@ objc_build_throw_stmt (location_t loc, tree throw_expr) { tree args; - objc_init_exceptions (loc); + objc_maybe_warn_exceptions (loc); if (throw_expr == NULL) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4209e44..594bf06 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2010-12-18 Nicola Pero <nicola.pero@meta-innovation.com> + + * objc.dg/fobjc-exceptions-1.m: Updated. + * objc.dg/fobjc-exceptions-2.m: New. + * objc.dg/fobjc-exceptions-3.m: New. + * obj-c++.dg/fobjc-exceptions-1.mm: New. + * obj-c++.dg/fobjc-exceptions-2.mm: New. + * obj-c++.dg/fobjc-exceptions-3.mm: New. + 2010-12-18 Tobias Burnus <burnus@net-b.de> PR fortran/46974 @@ -15,7 +24,7 @@ 2010-12-18 Iain Sandoe <iains@gcc.gnu.org> - * fobjc-exceptions.m: Update dg-error syntax. + * objc.dg/fobjc-exceptions.m: Update dg-error syntax. 2010-12-18 Kai Tietz <kai.tietz@onevision.com> diff --git a/gcc/testsuite/objc.dg/fobjc-exceptions.m b/gcc/testsuite/obj-c++.dg/fobjc-exceptions-1.mm index 392e307..8cee4d8 100644 --- a/gcc/testsuite/objc.dg/fobjc-exceptions.m +++ b/gcc/testsuite/obj-c++.dg/fobjc-exceptions-1.mm @@ -7,19 +7,19 @@ int dummy (int number, Object *o) { @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; /* Nothing, error has already been produced. */ } @catch (id object) { number++; - @throw; /* { dg-error ".-fobjc-exceptions. is required to enable Objective-C exception syntax" } */ + @throw; /* Nothing, error has already been produced. */ } @finally { number++; } - @synchronized (o) /* { dg-error ".-fobjc-exceptions. is required to enable Objective-C exception syntax" } */ + @synchronized (o) /* Nothing, error has already been produced. */ { number++; } diff --git a/gcc/testsuite/obj-c++.dg/fobjc-exceptions-2.mm b/gcc/testsuite/obj-c++.dg/fobjc-exceptions-2.mm new file mode 100644 index 0000000..32b3506 --- /dev/null +++ b/gcc/testsuite/obj-c++.dg/fobjc-exceptions-2.mm @@ -0,0 +1,29 @@ +/* Test that Objective-C exceptions cause an error with -fobjc-exceptions. */ +/* { dg-do compile } */ + +@class Object; + +int dummy (int number, Object *o) +{ + @synchronized (o) /* { dg-error ".-fobjc-exceptions. is required to enable Objective-C exception syntax" } */ + { + number++; + } + + @try { /* Nothing, error has already been produced. */ + number++; + @throw o; /* Nothing, error has already been produced. */ + } + @catch (id object) + { + number++; + @throw; /* Nothing, error has already been produced. */ + } + @finally + { + number++; + } + + + return number; +} diff --git a/gcc/testsuite/obj-c++.dg/fobjc-exceptions-3.mm b/gcc/testsuite/obj-c++.dg/fobjc-exceptions-3.mm new file mode 100644 index 0000000..d3d6453 --- /dev/null +++ b/gcc/testsuite/obj-c++.dg/fobjc-exceptions-3.mm @@ -0,0 +1,30 @@ +/* Test that Objective-C exceptions cause an error with -fobjc-exceptions. */ +/* { dg-do compile } */ + +@class Object; + +int dummy (int number, Object *o) +{ + @throw o; /* { dg-error ".-fobjc-exceptions. is required to enable Objective-C exception syntax" } */ + + @try { /* Nothing, error has already been produced. */ + number++; + @throw o; /* Nothing, error has already been produced. */ + } + @catch (id object) + { + number++; + @throw; /* Nothing, error has already been produced. */ + } + @finally + { + number++; + } + + @synchronized (o) /* Nothing, error has already been produced. */ + { + number++; + } + + return number; +} diff --git a/gcc/testsuite/objc.dg/fobjc-exceptions-1.m b/gcc/testsuite/objc.dg/fobjc-exceptions-1.m new file mode 100644 index 0000000..8cee4d8 --- /dev/null +++ b/gcc/testsuite/objc.dg/fobjc-exceptions-1.m @@ -0,0 +1,28 @@ +/* Test that Objective-C exceptions cause an error with -fobjc-exceptions. */ +/* { dg-do compile } */ + +@class Object; + +int dummy (int number, Object *o) +{ + @try { /* { dg-error ".-fobjc-exceptions. is required to enable Objective-C exception syntax" } */ + number++; + @throw o; /* Nothing, error has already been produced. */ + } + @catch (id object) + { + number++; + @throw; /* Nothing, error has already been produced. */ + } + @finally + { + number++; + } + + @synchronized (o) /* Nothing, error has already been produced. */ + { + number++; + } + + return number; +} diff --git a/gcc/testsuite/objc.dg/fobjc-exceptions-2.m b/gcc/testsuite/objc.dg/fobjc-exceptions-2.m new file mode 100644 index 0000000..32b3506 --- /dev/null +++ b/gcc/testsuite/objc.dg/fobjc-exceptions-2.m @@ -0,0 +1,29 @@ +/* Test that Objective-C exceptions cause an error with -fobjc-exceptions. */ +/* { dg-do compile } */ + +@class Object; + +int dummy (int number, Object *o) +{ + @synchronized (o) /* { dg-error ".-fobjc-exceptions. is required to enable Objective-C exception syntax" } */ + { + number++; + } + + @try { /* Nothing, error has already been produced. */ + number++; + @throw o; /* Nothing, error has already been produced. */ + } + @catch (id object) + { + number++; + @throw; /* Nothing, error has already been produced. */ + } + @finally + { + number++; + } + + + return number; +} diff --git a/gcc/testsuite/objc.dg/fobjc-exceptions-3.m b/gcc/testsuite/objc.dg/fobjc-exceptions-3.m new file mode 100644 index 0000000..d3d6453 --- /dev/null +++ b/gcc/testsuite/objc.dg/fobjc-exceptions-3.m @@ -0,0 +1,30 @@ +/* Test that Objective-C exceptions cause an error with -fobjc-exceptions. */ +/* { dg-do compile } */ + +@class Object; + +int dummy (int number, Object *o) +{ + @throw o; /* { dg-error ".-fobjc-exceptions. is required to enable Objective-C exception syntax" } */ + + @try { /* Nothing, error has already been produced. */ + number++; + @throw o; /* Nothing, error has already been produced. */ + } + @catch (id object) + { + number++; + @throw; /* Nothing, error has already been produced. */ + } + @finally + { + number++; + } + + @synchronized (o) /* Nothing, error has already been produced. */ + { + number++; + } + + return number; +} |