2010-12-02 Nicola Pero <nicola.pero@meta-innovation.com>
* objc-act.c (objc_build_throw_stmt): Return error_mark_node and
not NULL_TREE when a @throw is used outside of a @catch block.
In gcc/cp/:
2010-12-02 Nicola Pero <nicola.pero@meta-innovation.com>
* parser.c (cp_parser_objc_throw_statement): Use
cp_parser_expression, not cp_parser_assignment_expression, to
parse the argument of a @throw.
In gcc/testsuite/:
2010-12-02 Nicola Pero <nicola.pero@meta-innovation.com>
* objc.dg/exceptions-6.m: New.
* obj-c++.dg/exceptions-6.mm: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@167364
138bc75d-0d04-0410-961f-
82ee72b054a4
+2010-12-02 Nicola Pero <nicola.pero@meta-innovation.com>
+
+ * parser.c (cp_parser_objc_throw_statement): Use
+ cp_parser_expression, not cp_parser_assignment_expression, to
+ parse the argument of a @throw.
+
2010-12-01 Joseph Myers <joseph@codesourcery.com>
* cp-objcp-common.c, lex.c, typeck.c: Don't include toplev.h.
Returns NULL_TREE. */
static tree
-cp_parser_objc_synchronized_statement (cp_parser *parser) {
+cp_parser_objc_synchronized_statement (cp_parser *parser)
+{
location_t location;
tree lock, stmt;
Returns a constructed '@throw' statement. */
static tree
-cp_parser_objc_throw_statement (cp_parser *parser) {
+cp_parser_objc_throw_statement (cp_parser *parser)
+{
tree expr = NULL_TREE;
location_t loc = cp_lexer_peek_token (parser->lexer)->location;
cp_parser_require_keyword (parser, RID_AT_THROW, RT_AT_THROW);
if (cp_lexer_next_token_is_not (parser->lexer, CPP_SEMICOLON))
- expr = cp_parser_assignment_expression (parser, false, NULL);
+ expr = cp_parser_expression (parser, /*cast_p=*/false, NULL);
cp_parser_consume_semicolon_at_end_of_statement (parser);
/* Parse an Objective-C statement. */
static tree
-cp_parser_objc_statement (cp_parser * parser) {
+cp_parser_objc_statement (cp_parser * parser)
+{
/* Try to figure out what kind of declaration is present. */
cp_token *kwd = cp_lexer_peek_token (parser->lexer);
+2010-12-02 Nicola Pero <nicola.pero@meta-innovation.com>
+
+ * objc-act.c (objc_build_throw_stmt): Return error_mark_node and
+ not NULL_TREE when a @throw is used outside of a @catch block.
+
2010-11-30 Nicola Pero <nicola.pero@meta-innovation.com>
* objc-act.c (objc_build_volatilized_type): Removed.
|| cur_try_context->current_catch == NULL)
{
error_at (loc, "%<@throw%> (rethrow) used outside of a @catch block");
- return NULL_TREE;
+ return error_mark_node;
}
/* Otherwise the object is still sitting in the EXC_PTR_EXPR
+2010-12-02 Nicola Pero <nicola.pero@meta-innovation.com>
+
+ * objc.dg/exceptions-6.m: New.
+ * obj-c++.dg/exceptions-6.mm: New.
+
2010-12-01 Jan Hubicka <jh@suse.cz>
* gcc.c-torture/execute/bcp-1.c: Make ready for -fuse-linker-plugin
--- /dev/null
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */
+/* { dg-options "-fobjc-exceptions" } */
+/* { dg-do compile } */
+
+/* Test warnings when parsing syntax errors in @throw. */
+
+#include <objc/objc.h>
+
+void test (id object)
+{
+ @throw object; /* Ok */
+ @throw; /* { dg-error ".@throw. .rethrow. used outside of a @catch block" } */
+ @throw (object); /* Ok. */
+ @throw (id)0
+} /* { dg-error "expected" } */
+
+void test2 (id object)
+{
+ @throw object); /* { dg-error "expected" } */
+ @throw (...); /* { dg-error "expected" } */
+ @throw (); /* { dg-error "expected" } */
+ @throw
+} /* { dg-error "expected" } */
+
+void test3 (id object1, id object2)
+{
+ /* This is apparently valid. */
+ @throw object1, object2; /* Ok. */
+}
--- /dev/null
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */
+/* { dg-options "-fobjc-exceptions" } */
+/* { dg-do compile } */
+
+/* Test warnings when parsing syntax errors in @throw. */
+
+#include <objc/objc.h>
+
+void test (id object)
+{
+ @throw object; /* Ok */
+ @throw; /* { dg-error ".@throw. .rethrow. used outside of a @catch block" } */
+ @throw (object); /* Ok. */
+ @throw (id)0
+} /* { dg-error "expected" } */
+
+void test2 (id object)
+{
+ @throw object); /* { dg-error "expected" } */
+ @throw (...); /* { dg-error "expected" } */
+ @throw (); /* { dg-error "expected" } */
+ @throw
+} /* { dg-error "expected" } */
+
+void test3 (id object1, id object2)
+{
+ /* This is apparently valid. */
+ @throw object1, object2; /* Ok. */
+}