https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60804

--- Comment #11 from ak at gcc dot gnu.org ---
Author: ak
Date: Tue Nov 11 05:10:58 2014
New Revision: 217336

URL: https://gcc.gnu.org/viewcvs?rev=217336&root=gcc&view=rev
Log:
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  <a...@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  <a...@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.

Modified:
    trunk/gcc/c-family/ChangeLog
    trunk/gcc/c-family/c-common.h
    trunk/gcc/c-family/cilk.c
    trunk/gcc/c/ChangeLog
    trunk/gcc/c/c-parser.c
    trunk/gcc/c/c-typeck.c

Reply via email to