Error out for Cilk_spawn or array expression in forbidden places
authorAndi Kleen <ak@linux.intel.com>
Tue, 11 Nov 2014 05:10:58 +0000 (05:10 +0000)
committerAndi Kleen <ak@gcc.gnu.org>
Tue, 11 Nov 2014 05:10:58 +0000 (05:10 +0000)
commite5e442524724592b9f6e969354ba33c4f20f6ab2
tree71d74f86916e6654aeaf8532ad17469a9101b2cd
parent300553307af73f9a4ba83affc62c8263d3b90f9e
Error out for Cilk_spawn or array expression in forbidden places

_Cilk_spawn or Cilk array expressions are only allowed on their own,
but not in for(), if(), switch, do, while, goto, etc.
The C parser didn't always check for that, which lead to ICEs earlier
for invalid code.

Add a generic helper that checks this and call it where needed
in the C frontend.

I chose to allow spawn/array for for init and increment expressions.
While the Cilk spec could be interpreted to forbid it there too
there didn't seem any reason to not allow it.

One dark corner is spawn, array in statement expressions not at
the end. Right now that's forbidden too.

gcc/c-family/:

2014-11-10  Andi Kleen  <ak@linux.intel.com>

PR c/60804
* c-common.h (check_no_cilk): Declare.
* cilk.c (get_error_location): New function.
(check_no_cilk): Dito.

gcc/c/:

2014-11-10  Andi Kleen  <ak@linux.intel.com>

PR c/60804
* c-parser.c (c_parser_statement_after_labels): Call
check_no_cilk.
(c_parser_if_statement): Dito.
(c_parser_switch_statement): Dito.
(c_parser_while_statement): Dito.
(c_parser_do_statement): Dito.
(c_parser_for_statement): Dito.
* c-typeck.c (c_finish_loop): Dito.

From-SVN: r217336
gcc/c-family/ChangeLog
gcc/c-family/c-common.h
gcc/c-family/cilk.c
gcc/c/ChangeLog
gcc/c/c-parser.c
gcc/c/c-typeck.c