summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2013-04-17 17:00:36 -0500
committerAldy Hernandez <aldyh@redhat.com>2013-04-17 17:00:36 -0500
commit518ec74d4e86ae435f092ca7061c8fe0f88b2fd6 (patch)
tree5c0e3055cc92a9327021b22477f0113826f93ea5
parent45eb9b9131409d9e443d4072e1b3890d8c6df882 (diff)
downloadgcc-518ec74d4e86ae435f092ca7061c8fe0f88b2fd6.tar.gz
Misc cleanups, plus document remaining items for _Cilk_for parsing.
-rw-r--r--gcc/c/c-parser.c49
-rw-r--r--gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/compile/for1.c4
2 files changed, 31 insertions, 22 deletions
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 8fb623cfc20..7ab0d9cf161 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -11791,10 +11791,11 @@ c_parse_file (void)
FOR_KEYWORD can be either RID_CILK_FOR or RID_FOR, for parsing
_cilk_for or the <#pragma simd> for loop construct respectively.
- // FIXME: Parse clauses in caller and pass them here.
- CLAUSES is ??.
+ For a <#pragma simd>, CLAUSES are the clauses that should have been
+ previously parsed. If there are none, or if we are parsing a
+ _Cilk_for instead, this will be NULL.
- GRAIN is CilkPlus grainsize. */
+ GRAIN is CilkPlus grainsize when parsing a _Cilk_for. */
static void
c_parser_cilk_for_statement (c_parser *parser, enum rid for_keyword,
@@ -11810,7 +11811,7 @@ c_parser_cilk_for_statement (c_parser *parser, enum rid for_keyword,
if (!c_parser_next_token_is_keyword (parser, for_keyword))
{
if (for_keyword == RID_CILK_FOR)
- c_parser_error (parser, "cilk_for statement expected");
+ c_parser_error (parser, "_Cilk_for statement expected");
else
c_parser_error (parser, "for statement expected");
return;
@@ -11883,22 +11884,6 @@ c_parser_cilk_for_statement (c_parser *parser, enum rid for_keyword,
cond = cond_expr.value;
cond = c_objc_common_truthvalue_conversion (cond_loc, cond);
cond = c_fully_fold (cond, false, NULL);
-#if 0 // Find out what this is for?
- switch (cond_expr.original_code)
- {
- case GT_EXPR:
- case GE_EXPR:
- case LT_EXPR:
- case LE_EXPR:
- break;
- default:
- /* Can't be cond = error_mark_node, because we want to preserve
- the location until c_finish_omp_for. */
- cond = build1 (NOP_EXPR, boolean_type_node, error_mark_node);
- break;
- }
- protected_set_expr_location (cond, cond_loc);
-#endif
}
c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
@@ -11926,9 +11911,29 @@ c_parser_cilk_for_statement (c_parser *parser, enum rid for_keyword,
c_break_label = save_break;
c_cont_label = save_cont;
+ // FIXME: TODO items for remaining parsing duties.
+
+ // FIXME: The specs says "the total number of iterations (loop
+ // count) can be determined before beginning the loop
+ // execution". We should probably wrap the RHS of the
+ // conditional expression in a SAVE_EXPR and avoid executing
+ // it multiple times. And of course, we should write an
+ // execution test to go along with this.
+ //
+ // foo < SAVE_EXPR(RHS)
+
+ // FIXME: Similarly for the increment. The spec says "the increment
+ // and limit expressions may be evaluated fewer times than in
+ // the serialization". We should probably use SAVE_EXPR here
+ // too.
+ //
+ // foo += SAVE_EXPR(INCR)
+
+ // FIXME: Parse the #<pragma simd> clauses.
+
// FIXME: Error on RETURN or GOTO within body. This is probably
- // best done by analyzing the CFG at some point and seeing if any
- // path goes into or out of for loop body.
+ // best done by analyzing the CFG at some point and seeing if
+ // any path goes into or out of the loop body.
if (!fail)
{
diff --git a/gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/compile/for1.c b/gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/compile/for1.c
index ddee119782b..23f8ccf114f 100644
--- a/gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/compile/for1.c
+++ b/gcc/testsuite/gcc.dg/cilk-plus/pragma_simd_tests/compile/for1.c
@@ -43,6 +43,10 @@ void foo()
for (struct S ss = { 0 }; ss.i <= 1000; ++ss.i) /* { dg-error "initialization variable must be of integral or pointer type" } */
a[ss.i] = b[ss.i];
+ #pragma simd
+ for (float f=0.0; f < 15.0; ++f) /* { dg-error "must be of integral" } */
+ a[(int)f] = (int) f;
+
// Pointers are OK.
#pragma simd
for (int *i=c; i < &c[100]; ++i)