@@ -5837,17 +5837,27 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
}
case RID_CILK_SYNC:
+ cp_lexer_consume_token (parser->lexer);
if (flag_cilkplus)
- {
+ {
+ if (cp_lexer_next_token_is_not (parser->lexer, 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);
+ SET_EXPR_LOCATION (sync_expr,
+ token->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);
+ {
+ error_at (token->location, "-fcilkplus must be enabled to use"
+ " %<_Cilk_sync%>");
+ postfix_expression = error_mark_node;
+ }
break;
case RID_BUILTIN_SHUFFLE:
new file mode 100644
@@ -0,0 +1,9 @@
+/* PR c/60189 */
+/* { dg-do compile } */
+/* { dg-options "-fcilkplus" } */
+
+int main (void)
+{
+ _Cilk_sync return; /* { dg-error " '_Cilk_sync' must be followed by semicolon" } */
+ return 0;
+}