aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBalaji V. Iyer <balaji.v.iyer@intel.com>2012-12-16 22:37:49 +0000
committerBalaji V. Iyer <balaji.v.iyer@intel.com>2012-12-16 22:37:49 +0000
commitf08893260faaa7602946fad5e806e8168fe32fd9 (patch)
treef1503dfe29d107b3727ca4b11fc380314402af3e
parent5bb8159ba2479fed72454758ef286a1acad0daef (diff)
Reject Spawned functions inside a compound expression.
+++ gcc/testsuite/ChangeLog.cilkplus + * gcc.dg/cilk-plus/cilk_keywords_test/errors/compound_cilk_spawn.c: + Likewise. +++ gcc/ChangeLog.cilkplus + (build_compound_expr): Added a check for spawned function call in a + compound expression. If so, then emit an error. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/cilkplus@194543 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog.cilkplus2
-rw-r--r--gcc/c/c-typeck.c9
-rw-r--r--gcc/testsuite/ChangeLog.cilkplus2
-rw-r--r--gcc/testsuite/gcc.dg/cilk-plus/cilk_keywords_test/errors/compound_cilk_spawn.c23
4 files changed, 36 insertions, 0 deletions
diff --git a/gcc/ChangeLog.cilkplus b/gcc/ChangeLog.cilkplus
index 577760b5550..40d661db494 100644
--- a/gcc/ChangeLog.cilkplus
+++ b/gcc/ChangeLog.cilkplus
@@ -2,6 +2,8 @@
* c/c-typeck.c (c_finish_cilk_loop): Added a check for multiple expr. in
condition or increment inside a _Cilk_for. If so, then emit an error.
+ (build_compound_expr): Added a check for spawned function call in a
+ compound expression. If so, then emit an error.
* c/c-parser.c (c_parser_cilk_for_statement): Added a check for
multiple expressions for initialization for a Cilk_for. If so, then
emit an error.
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index 7abb1f6092b..1e287a86877 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -4393,6 +4393,15 @@ build_compound_expr (location_t loc, tree expr1, tree expr2)
tree eptype = NULL_TREE;
tree ret;
+ if (flag_enable_cilk
+ && ((expr1 && TREE_CODE (expr1) == CALL_EXPR && SPAWN_CALL_P (expr1))
+ || (expr2 && TREE_CODE (expr2) == CALL_EXPR && SPAWN_CALL_P (expr2))))
+ {
+ error_at (loc, "spawned function call cannot be part of a comma "
+ "expression");
+ return error_mark_node;
+ }
+
expr1_int_operands = EXPR_INT_CONST_OPERANDS (expr1);
if (expr1_int_operands)
expr1 = remove_c_maybe_const_expr (expr1);
diff --git a/gcc/testsuite/ChangeLog.cilkplus b/gcc/testsuite/ChangeLog.cilkplus
index 4b209561786..b60ba577fd5 100644
--- a/gcc/testsuite/ChangeLog.cilkplus
+++ b/gcc/testsuite/ChangeLog.cilkplus
@@ -8,6 +8,8 @@
Likewise.
* gcc.dg/cilk-plus/cilk_keywords_test/errors/concec_cilk_spawn.c:
Likewise.
+ * gcc.dg/cilk-plus/cilk_keywords_test/errors/compound_cilk_spawn.c:
+ Likewise.
2012-12-14 Balaji V. Iyer <balaji.v.iyer@intel.com>
diff --git a/gcc/testsuite/gcc.dg/cilk-plus/cilk_keywords_test/errors/compound_cilk_spawn.c b/gcc/testsuite/gcc.dg/cilk-plus/cilk_keywords_test/errors/compound_cilk_spawn.c
new file mode 100644
index 00000000000..8016e4ccead
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cilk-plus/cilk_keywords_test/errors/compound_cilk_spawn.c
@@ -0,0 +1,23 @@
+/* <feature>
+ A program is considered ill formed if the _Cilk_spawn form of this
+ expression appears other than in one of the following contexts:
+ as the entire body of an expression statement,
+ as the entire right hand side of an assignment expression that is the entire
+ body of an expression statement, or as the entire initializer-clause in a
+ simple declaration.
+ </feature>
+*/
+
+int spawn_func (int arg)
+{
+ return arg + 1;
+}
+
+int check()
+{
+ int z;
+ z = 23, _Cilk_spawn spawn_func (3), 3424; /* { dg-error "spawned function call cannot be part of a comma expression" } */
+ 23, spawn_func (5), _Cilk_spawn spawn_func (3); /* { dg-error "spawned function call cannot be part of a comma expression" } */
+ _Cilk_spawn spawn_func (0), _Cilk_spawn spawn_func (3), 3, spawn_func (0); /* { dg-error "spawned function call cannot be part of a comma expression" } */
+ return _Cilk_spawn spawn_func (3), 23; /* { dg-error "spawned function call cannot be part of a comma expression" } */
+}