This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, PR60189, Cilk+] Fix for ICE with incorrect Cilk_sync usage
- From: Jakub Jelinek <jakub at redhat dot com>
- To: "Zamyatin, Igor" <igor dot zamyatin at intel dot com>, Jason Merrill <jason at redhat dot com>
- Cc: "GCC Patches (gcc-patches at gcc dot gnu dot org)" <gcc-patches at gcc dot gnu dot org>, "Iyer, Balaji V" <balaji dot v dot iyer at intel dot com>
- Date: Thu, 10 Apr 2014 16:27:31 +0200
- Subject: Re: [PATCH, PR60189, Cilk+] Fix for ICE with incorrect Cilk_sync usage
- Authentication-results: sourceware.org; auth=none
- References: <0EFAB2BDD0F67E4FB6CCC8B9F87D7569429DBFEF at IRSMSX103 dot ger dot corp dot intel dot com> <0EFAB2BDD0F67E4FB6CCC8B9F87D7569429DC138 at IRSMSX103 dot ger dot corp dot intel dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Thu, Apr 10, 2014 at 02:23:16PM +0000, Zamyatin, Igor wrote:
> 2014-04-10 Igor Zamyatin <igor.zamyatin@intel.com>
>
> PR c++/60189
> * parser.c (cp_parser_postfix_expression): Make sure only
> semicolon can go after Cilk_sync.
>
> gcc/testsuite/ChangeLog:
>
> 2014-04-10 Igor Zamyatin <igor.zamyatin@intel.com>
>
> PR c++/60189
> * c-c++-common/cilk-plus/CK/invalid_sync.cÑ: New test.
CCing Jason as this is a C++ FE change.
> --- a/gcc/cp/parser.c
> +++ b/gcc/cp/parser.c
> @@ -5835,20 +5835,33 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
> }
> break;
> }
> -
> +
> case RID_CILK_SYNC:
> - if (flag_cilkplus)
> - {
> - tree sync_expr = build_cilk_sync ();
> - SET_EXPR_LOCATION (sync_expr,
> - cp_lexer_peek_token (parser->lexer)->location);
> - finish_expr_stmt (sync_expr);
> - }
> - else
> - error_at (token->location, "-fcilkplus must be enabled to use"
> - " %<_Cilk_sync%>");
> - cp_lexer_consume_token (parser->lexer);
> - break;
> + {
I don't see the point of adding the extra {} around the whole case,
there is no varaible declared at that point.
Other than that it looks good to me, but I'll defer the review to Jason.
> + cp_lexer_consume_token (parser->lexer);
> + if (flag_cilkplus)
> + {
> + token = cp_lexer_peek_token (parser->lexer);
> + if (token->type != CPP_SEMICOLON)
> + {
> + error_at (token->location, "%<_Cilk_sync%> must be followed"
> + " by semicolon");
> + postfix_expression = error_mark_node;
> + break;
> + }
> + tree sync_expr = build_cilk_sync ();
> + SET_EXPR_LOCATION (sync_expr,
> + cp_lexer_peek_token (parser->lexer)->location);
> + finish_expr_stmt (sync_expr);
> + }
> + else
> + {
> + error_at (token->location, "-fcilkplus must be enabled to use"
> + " %<_Cilk_sync%>");
> + postfix_expression = error_mark_node;
> + }
> + break;
> + }
Jakub