summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2012-05-24 14:47:06 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2012-05-24 14:47:06 +0000
commit376a817be957345c2d6e4d37fd6fb7b1425c4966 (patch)
tree9d218f7ebda18691bc2375c32448bc890ccb048e /gcc
parent141de90eb66692b4e3567b45ab73d756b6538b29 (diff)
downloadgcc-376a817be957345c2d6e4d37fd6fb7b1425c4966.tar.gz
/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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@187837 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-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 c3d98418316..4da78b850cb 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 56e54634a4e..165fdc2c4e6 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 eeeb8e21f55..c00557ece63 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 00000000000..de06d50b6e3
--- /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" }
+ }