===================================================================
@@ -11918,7 +11918,7 @@
c_cont_label = NULL_TREE;
body = c_parser_c99_block_statement (parser);
c_finish_cilk_loop (loc, cvar, cond, incr, body, c_cont_label, grain);
- add_stmt (c_end_compound_stmt (UNKNOWN_LOCATION, block, true));
+ add_stmt (c_end_compound_stmt (loc, block, true));
c_break_label = save_break;
c_cont_label = save_cont;
}
===================================================================
@@ -10970,7 +10970,7 @@
}
void
-c_finish_cilk_loop (location_t start_locus ATTRIBUTE_UNUSED, tree cvar,
+c_finish_cilk_loop (location_t start_locus, tree cvar,
tree cond, tree incr, tree body, tree clab, tree grain)
{
tree init;
@@ -10982,12 +10982,12 @@
if (!cond)
{
- error ("_Cilk_for missing condition");
+ error_at (start_locus, "_Cilk_for missing condition");
return;
}
if (!incr)
{
- error ("_Cilk_for missing increment");
+ error_at (start_locus, "_Cilk_for missing increment");
return;
}
@@ -10999,7 +10999,7 @@
}
if (!cvar)
{
- error ("missing control variable");
+ error_at (start_locus, "missing control variable");
return;
}
if (clab)
@@ -11007,7 +11007,31 @@
error_at (EXPR_LOCATION (clab), "_Cilk_for has continue");
return;
}
+
+ /* Checks if cond expr is one of the following: !=, <=, <, >=, or >. */
+ if (TREE_CODE (cond) != NE_EXPR
+ && TREE_CODE (cond) != LT_EXPR
+ && TREE_CODE (cond) != LE_EXPR
+ && TREE_CODE (cond) != GT_EXPR
+ && TREE_CODE (cond) != GE_EXPR)
+ {
+ error_at (EXPR_LOCATION (cond), "_Cilk_for condition must be one of the "
+ "following: !=, <=, <, >= or >");
+ return;
+ }
+ /* Checks if the induction variable is volatile or constant. */
+ if (TREE_THIS_VOLATILE (cvar))
+ {
+ error_at (start_locus, "_Cilk_for induction variable cannot be volatile");
+ return;
+ }
+ else if (TREE_CONSTANT (cvar) || TREE_READONLY (cvar))
+ {
+ error_at (start_locus, "_Cilk_for induction variable cannot be constant or "
+ "readonly");
+ return;
+ }
init = DECL_INITIAL (cvar);
c_tree = build_stmt (UNKNOWN_LOCATION, CILK_FOR_STMT, NULL_TREE, NULL_TREE,
===================================================================
@@ -0,0 +1,20 @@
+/* <feature>
+ The variable may not be const or volatile
+ </feature>
+*/
+
+#include "controls.h"
+
+int a[SMALL_INT_ARRAY_SIZE];
+
+int main (void)
+{
+ volatile int ii;
+ const int jj;
+
+
+ _Cilk_for(ii = 0; ii < SMALL_INT_ARRAY_SIZE; ii++) /* { dg-error "_Cilk_for induction variable cannot be volatile." } */
+ {
+ a[ii] = ii;
+ }
+}
===================================================================
@@ -0,0 +1,17 @@
+/* <feature>
+ The operator denoted OP shall be one of !=, <=, <, >=, or >
+ </feature>
+*/
+
+#define ARRAY_SIZE 10000
+
+int a[ARRAY_SIZE];
+
+int main (void)
+{
+ int ii;
+ _Cilk_for(ii = 0; ii == ARRAY_SIZE; ii++) /* { dg-error "_Cilk_for condition must be one of the following." */
+ {
+ a[ii] = ii;
+ }
+}
===================================================================
@@ -1,3 +1,10 @@
+2012-12-14 Balaji V. Iyer <balaji.v.iyer@intel.com>
+
+ * gcc.dg/cilk-plus/cilk_keywords_test/errors/cilk_for_invalid_compares.c:
+ New test.
+ * gcc.dg/cilk-plus/cilk_keywords_test/errors/cilk_for_volatile_var.c:
+ Likewise.
+
2012-12-12 Balaji V. Iyer <balaji.v.iyer@intel.com>
* gcc.dg/cilk-plus/cilk_keywords_test/errors/goto_inside_cilkfor.c:
===================================================================
@@ -1,3 +1,11 @@
+2012-12-14 Balaji V. Iyer <balaji.v.iyer@intel.com>
+
+ * c/c-parser.c (c_parser_cilk_for_statement): Replaced unknown location with the
+ correct location value.
+ * c/c-typeck.c (c_finish_cilk_loop): Checked if the increment is one of
+ the following: !=, <=, <, >=, or >. Report error otherwise. Also
+ report error if the induction variable is constant or volatile.
+
2012-12-13 Balaji V. Iyer <balaji.v.iyer@intel.com>
* tree-vect-loop.c (vect_determine_vectorization_factor): Added a