diff options
author | Torvald Riegel <triegel@redhat.com> | 2011-11-15 12:16:13 +0000 |
---|---|---|
committer | Torvald Riegel <torvald@gcc.gnu.org> | 2011-11-15 12:16:13 +0000 |
commit | 69b765189a3dd5f235c2711d0908bad331ce40b7 (patch) | |
tree | 7baa283db79257b474598846b79f119e071d5cc1 /gcc/cp/parser.c | |
parent | 402356d1466804239212e0fec68d3753114d0cfe (diff) | |
download | gcc-69b765189a3dd5f235c2711d0908bad331ce40b7.zip gcc-69b765189a3dd5f235c2711d0908bad331ce40b7.tar.gz gcc-69b765189a3dd5f235c2711d0908bad331ce40b7.tar.bz2 |
Require parentheses when parsing transaction expressions.
gcc/
* c-parser.c (c_parser_transaction_expression): Require parentheses
when parsing transaction expressions.
gcc/cp/
* parser.c (cp_parser_transaction_expression): Require parentheses
when parsing transaction expressions.
gcc/testsuite/
* c-c++-common/tm/trxn-expr-3.c: New test.
From-SVN: r181383
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r-- | gcc/cp/parser.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 23885b8..f839112 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -26811,7 +26811,7 @@ cp_parser_transaction_expression (cp_parser *parser, enum rid keyword) unsigned char old_in = parser->in_transaction; unsigned char this_in = 1; cp_token *token; - tree ret; + tree expr; gcc_assert (keyword == RID_TRANSACTION_ATOMIC || keyword == RID_TRANSACTION_RELAXED); @@ -26832,22 +26832,19 @@ cp_parser_transaction_expression (cp_parser *parser, enum rid keyword) this_in |= TM_STMT_ATTR_RELAXED; parser->in_transaction = this_in; - if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_PAREN)) - { - tree expr = cp_parser_expression (parser, /*cast_p=*/false, NULL); - ret = build_transaction_expr (token->location, expr, this_in); - } - else - { - cp_parser_error (parser, "expected %<(%>"); - ret = error_mark_node; - } + cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN); + + expr = cp_parser_expression (parser, /*cast_p=*/false, NULL); + finish_parenthesized_expr (expr); + expr = build_transaction_expr (token->location, expr, this_in); + + cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN); parser->in_transaction = old_in; if (cp_parser_non_integral_constant_expression (parser, NIC_TRANSACTION)) return error_mark_node; - return (flag_tm ? ret : error_mark_node); + return (flag_tm ? expr : error_mark_node); } /* Parse a function-transaction-block. |