aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBalaji V. Iyer <balaji.v.iyer@intel.com>2012-12-16 22:06:22 +0000
committerBalaji V. Iyer <balaji.v.iyer@intel.com>2012-12-16 22:06:22 +0000
commit5bb8159ba2479fed72454758ef286a1acad0daef (patch)
tree1eba6906004a7fcb5c27fe7d067cff2ede155a6f
parent9ec1b3bba24d69dd56beaeee2416099e36c314cc (diff)
Reject consecutive _Cilk_spawn keywords.
testsuite/ChangeLog.cilkplus + * gcc.dg/cilk-plus/cilk_keywords_test/errors/concec_cilk_spawn.c: + Likewise. gcc/ChangeLog.cilkplus + (c_parser_postfix_expression): Added check for consecutive _Cilk_spawn + keyword. If found, emit and error. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/cilkplus@194542 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog.cilkplus2
-rw-r--r--gcc/c/c-parser.c18
-rw-r--r--gcc/testsuite/ChangeLog.cilkplus2
-rw-r--r--gcc/testsuite/gcc.dg/cilk-plus/cilk_keywords_test/errors/concec_cilk_spawn.c17
4 files changed, 38 insertions, 1 deletions
diff --git a/gcc/ChangeLog.cilkplus b/gcc/ChangeLog.cilkplus
index f773b914fd8..577760b5550 100644
--- a/gcc/ChangeLog.cilkplus
+++ b/gcc/ChangeLog.cilkplus
@@ -5,6 +5,8 @@
* 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.
+ (c_parser_postfix_expression): Added check for consecutive _Cilk_spawn
+ keyword. If found, emit and error.
2012-12-14 Balaji V. Iyer <balaji.v.iyer@intel.com>
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index ec5dc7c5b27..09cd288fbf4 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -6938,7 +6938,23 @@ c_parser_postfix_expression (c_parser *parser)
c_parser_consume_token (parser);
if (!flag_enable_cilk)
{
- error ("-fcilkplus must be enabled to use %<cilk_spawn%>");
+ error ("-fcilkplus must be enabled to use %<_Cilk_spawn%>");
+ expr.value = error_mark_node;
+ }
+ else if (c_parser_peek_token (parser)->keyword == RID_CILK_SPAWN)
+ {
+ c_parser_consume_token (parser);
+ error_at (input_location, "consecutive _Cilk_spawn keyword not "
+ "permitted");
+
+ /* Now for some reason there are a whole bunch of them, we flush
+ them all out. */
+ while (c_parser_peek_token (parser)->keyword == RID_CILK_SPAWN)
+ c_parser_consume_token (parser);
+
+ /* We are doing this to get rid of whatever the postfix expr
+ is after the spawns. */
+ expr = c_parser_postfix_expression (parser);
expr.value = error_mark_node;
}
else
diff --git a/gcc/testsuite/ChangeLog.cilkplus b/gcc/testsuite/ChangeLog.cilkplus
index c90c98f79fe..4b209561786 100644
--- a/gcc/testsuite/ChangeLog.cilkplus
+++ b/gcc/testsuite/ChangeLog.cilkplus
@@ -6,6 +6,8 @@
Likewise.
* gcc.dg/cilk-plus/cilk_keywords_test/errors/cilk_for_multiple_init.c:
Likewise.
+ * gcc.dg/cilk-plus/cilk_keywords_test/errors/concec_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/concec_cilk_spawn.c b/gcc/testsuite/gcc.dg/cilk-plus/cilk_keywords_test/errors/concec_cilk_spawn.c
new file mode 100644
index 00000000000..1942570f178
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cilk-plus/cilk_keywords_test/errors/concec_cilk_spawn.c
@@ -0,0 +1,17 @@
+/* <feature> Consecutive _Cilk_spawn tokens are not permitted
+ </feature>
+*/
+
+int spawn_func (int arg)
+{
+ return arg + 1;
+}
+
+void func ()
+{
+ int a;
+ a = _Cilk_spawn _Cilk_spawn spawn_func (4); /* { dg-error "consecutive _Cilk_spawn keyword not permitted" } */
+ a = _Cilk_spawn _Cilk_spawn _Cilk_spawn spawn_func (4); /* { dg-error "consecutive _Cilk_spawn keyword not permitted" } */
+ a = _Cilk_spawn _Cilk_spawn _Cilk_spawn _Cilk_spawn spawn_func (4); /* { dg-error "consecutive _Cilk_spawn keyword not permitted" } */
+ return;
+}