summaryrefslogtreecommitdiff
path: root/gcc/c-parser.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2009-03-23 22:05:30 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2009-03-23 22:05:30 +0100
commitc5cdb03fb9e13c384901671a424555550ed098f1 (patch)
treea9fdfdfd88e5b8dd5deaf726ac04e0979d9d8ed9 /gcc/c-parser.c
parent6afcfe0a8080cf3816e841f0f1c2b96a73baed43 (diff)
downloadgcc-c5cdb03fb9e13c384901671a424555550ed098f1.tar.gz
re PR c/39495 (OMP parallel loop w/ unsigned index var rejected)
PR c/39495 * c-parser.c (c_parser_omp_for_loop): Call c_parser_binary_expression instead of c_parser_expression_conv, if original_code isn't one of the 4 allowed comparison codes, fail. * semantics.c (handle_omp_for_class_iterator): Swap cond operands and code if iter is the second operand. * parser.c (cp_parser_binary_expression): Add no_toplevel_fold_p argument. If it is set, don't build the toplevel expression with build_x_binary_op, but build2. (cp_parser_assignment_expression, cp_parser_omp_for_incr): Adjust callers. (cp_parser_omp_for_cond): Don't assume the first operand of the comparison must be decl. * gcc.dg/gomp/pr39495-2.c: Remove xfails. * testsuite/libgomp.c/loop-12.c: New test. * testsuite/libgomp.c/loop-11.c: New test. * testsuite/libgomp.c++/loop-11.C: New test. * testsuite/libgomp.c++/loop-12.C: New test. * testsuite/libgomp.c++/for-8.C: New test. From-SVN: r145014
Diffstat (limited to 'gcc/c-parser.c')
-rw-r--r--gcc/c-parser.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/gcc/c-parser.c b/gcc/c-parser.c
index 6dfcb601597..ea0036c0ba2 100644
--- a/gcc/c-parser.c
+++ b/gcc/c-parser.c
@@ -7652,9 +7652,23 @@ c_parser_omp_for_loop (c_parser *parser, tree clauses, tree *par_clauses)
if (c_parser_next_token_is_not (parser, CPP_SEMICOLON))
{
location_t cond_loc = c_parser_peek_token (parser)->location;
+ struct c_expr cond_expr = c_parser_binary_expression (parser, NULL);
- cond = c_parser_expression_conv (parser).value;
+ cond = cond_expr.value;
cond = c_objc_common_truthvalue_conversion (cond_loc, cond);
+ 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);
}
c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");