aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2012-05-24 14:47:06 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2012-05-24 14:47:06 +0000
commitc7837f7efbc81c2a3a4efa2648a8e7e51fad6cf8 (patch)
tree9d218f7ebda18691bc2375c32448bc890ccb048e
parent49bdc0a65dfe8dbd6d13e776a79418932d7aebc0 (diff)
downloadgcc-c7837f7efbc81c2a3a4efa2648a8e7e51fad6cf8.zip
gcc-c7837f7efbc81c2a3a4efa2648a8e7e51fad6cf8.tar.gz
gcc-c7837f7efbc81c2a3a4efa2648a8e7e51fad6cf8.tar.bz2
re PR c++/32080 (Can goto a function try-block)
/cp 2012-05-24 Paolo Carlini <paolo.carlini@oracle.com> PR c++/32080 * parser.c (cp_parser_ctor_initializer_opt_and_function_body, cp_parser_function_body): Add a bool parameter, true when parsing a function-try-block. (cp_parser_function_try_block): Pass true to the above. (cp_parser_function_definition_after_declarator, cp_parser_function_transaction): Adjust. /testsuite 2012-05-24 Paolo Carlini <paolo.carlini@oracle.com> PR c++/32080 * g++.dg/eh/goto2.C: New. From-SVN: r187837
-rw-r--r--gcc/cp/ChangeLog10
-rw-r--r--gcc/cp/parser.c28
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/eh/goto2.C12
4 files changed, 42 insertions, 13 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index c3d9841..4da78b8 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,13 @@
+2012-05-24 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/32080
+ * parser.c (cp_parser_ctor_initializer_opt_and_function_body,
+ cp_parser_function_body): Add a bool parameter, true when parsing
+ a function-try-block.
+ (cp_parser_function_try_block): Pass true to the above.
+ (cp_parser_function_definition_after_declarator,
+ cp_parser_function_transaction): Adjust.
+
2012-05-23 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/29185
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 56e5463..165fdc2 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -1989,7 +1989,7 @@ static cp_parameter_declarator *cp_parser_parameter_declaration
static tree cp_parser_default_argument
(cp_parser *, bool);
static void cp_parser_function_body
- (cp_parser *);
+ (cp_parser *, bool);
static tree cp_parser_initializer
(cp_parser *, bool *, bool *);
static tree cp_parser_initializer_clause
@@ -2000,7 +2000,7 @@ static VEC(constructor_elt,gc) *cp_parser_initializer_list
(cp_parser *, bool *);
static bool cp_parser_ctor_initializer_opt_and_function_body
- (cp_parser *);
+ (cp_parser *, bool);
/* Classes [gram.class] */
@@ -17395,16 +17395,18 @@ cp_parser_default_argument (cp_parser *parser, bool template_parm_p)
compound_statement */
static void
-cp_parser_function_body (cp_parser *parser)
+cp_parser_function_body (cp_parser *parser, bool in_function_try_block)
{
- cp_parser_compound_statement (parser, NULL, false, true);
+ cp_parser_compound_statement (parser, NULL, in_function_try_block, true);
}
/* Parse a ctor-initializer-opt followed by a function-body. Return
- true if a ctor-initializer was present. */
+ true if a ctor-initializer was present. When IN_FUNCTION_TRY_BLOCK
+ is true we are parsing a function-try-block. */
static bool
-cp_parser_ctor_initializer_opt_and_function_body (cp_parser *parser)
+cp_parser_ctor_initializer_opt_and_function_body (cp_parser *parser,
+ bool in_function_try_block)
{
tree body, list;
bool ctor_initializer_p;
@@ -17431,7 +17433,7 @@ cp_parser_ctor_initializer_opt_and_function_body (cp_parser *parser)
last = STATEMENT_LIST_TAIL (list)->stmt;
}
/* Parse the function-body. */
- cp_parser_function_body (parser);
+ cp_parser_function_body (parser, in_function_try_block);
if (check_body_p)
check_constexpr_ctor_body (last, list);
/* Finish the function body. */
@@ -19707,8 +19709,8 @@ cp_parser_function_try_block (cp_parser* parser)
/* Let the rest of the front end know where we are. */
try_block = begin_function_try_block (&compound_stmt);
/* Parse the function-body. */
- ctor_initializer_p
- = cp_parser_ctor_initializer_opt_and_function_body (parser);
+ ctor_initializer_p = cp_parser_ctor_initializer_opt_and_function_body
+ (parser, /*in_function_try_block=*/true);
/* We're done with the `try' part. */
finish_function_try_block (try_block);
/* Parse the handlers. */
@@ -21048,8 +21050,8 @@ cp_parser_function_definition_after_declarator (cp_parser* parser,
else if (cp_lexer_next_token_is_keyword (parser->lexer, RID_TRY))
ctor_initializer_p = cp_parser_function_try_block (parser);
else
- ctor_initializer_p
- = cp_parser_ctor_initializer_opt_and_function_body (parser);
+ ctor_initializer_p = cp_parser_ctor_initializer_opt_and_function_body
+ (parser, /*in_function_try_block=*/false);
finish_lambda_scope ();
@@ -27224,8 +27226,8 @@ cp_parser_function_transaction (cp_parser *parser, enum rid keyword)
if (cp_lexer_next_token_is_keyword (parser->lexer, RID_TRY))
ctor_initializer_p = cp_parser_function_try_block (parser);
else
- ctor_initializer_p
- = cp_parser_ctor_initializer_opt_and_function_body (parser);
+ ctor_initializer_p = cp_parser_ctor_initializer_opt_and_function_body
+ (parser, /*in_function_try_block=*/false);
parser->in_transaction = old_in;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index eeeb8e2..c00557e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2012-05-24 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/32080
+ * g++.dg/eh/goto2.C: New.
+
2012-05-24 Richard Guenther <rguenther@suse.de>
PR middle-end/53460
diff --git a/gcc/testsuite/g++.dg/eh/goto2.C b/gcc/testsuite/g++.dg/eh/goto2.C
new file mode 100644
index 0000000..de06d50
--- /dev/null
+++ b/gcc/testsuite/g++.dg/eh/goto2.C
@@ -0,0 +1,12 @@
+// PR c++/32080
+
+void f()
+try
+ {
+ goto l2; // { dg-error "from here" }
+ l1: ; // { dg-error "jump to label 'l1'" }
+ } catch (...)
+ {
+ l2: ; // { dg-error "jump to label 'l2'|enters catch block" }
+ goto l1; // { dg-error "from here|enters try block" }
+ }