summaryrefslogtreecommitdiffstats
path: root/gcc/c-family/cilk.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/c-family/cilk.c')
-rw-r--r--gcc/c-family/cilk.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/gcc/c-family/cilk.c b/gcc/c-family/cilk.c
index f2179dfc128..6a7bf4f1efa 100644
--- a/gcc/c-family/cilk.c
+++ b/gcc/c-family/cilk.c
@@ -235,6 +235,9 @@ recognize_spawn (tree exp, tree *exp0)
walk_tree (exp0, unwrap_cilk_spawn_stmt, NULL, NULL);
spawn_found = true;
}
+ /* _Cilk_spawn can't be wrapped in expression such as PLUS_EXPR. */
+ else if (contains_cilk_spawn_stmt (exp))
+ error ("invalid use of %<_Cilk_spawn%>");
return spawn_found;
}
@@ -1292,3 +1295,25 @@ build_cilk_sync (void)
TREE_SIDE_EFFECTS (sync) = 1;
return sync;
}
+
+/* Helper for contains_cilk_spawn_stmt, callback for walk_tree. Return
+ non-null tree if TP contains CILK_SPAWN_STMT. */
+
+static tree
+contains_cilk_spawn_stmt_walker (tree *tp, int *, void *)
+{
+ if (TREE_CODE (*tp) == CILK_SPAWN_STMT)
+ return *tp;
+ else
+ return NULL_TREE;
+}
+
+/* Returns true if EXPR or any of its subtrees contain CILK_SPAWN_STMT
+ node. */
+
+bool
+contains_cilk_spawn_stmt (tree expr)
+{
+ return walk_tree (&expr, contains_cilk_spawn_stmt_walker, NULL, NULL)
+ != NULL_TREE;
+}
OpenPOWER on IntegriCloud