summaryrefslogtreecommitdiff
path: root/gcc/c-omp.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2009-03-19 16:34:00 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2009-03-19 16:34:00 +0100
commitea1199ee953ac11b8b0635da6ba2908e5311fc49 (patch)
tree3413aca2f5e318c5d2997003e2eef0683021ee20 /gcc/c-omp.c
parent58929c1068f0550be90d3921305b14fb3dc37132 (diff)
downloadgcc-ea1199ee953ac11b8b0635da6ba2908e5311fc49.tar.gz
re PR c/39495 (OMP parallel loop w/ unsigned index var rejected)
PR c/39495 * c-omp.c (c_finish_omp_for): Allow NE_EXPR with TREE_TYPE (decl)'s minimum or maximum value. * parser.c (cp_parser_omp_for_cond): Don't check lhs if decl is NULL. (cp_parser_omp_for_loop): Always use cp_parser_omp_for_cond. * gcc.dg/gomp/pr39495-1.c: New test. * gcc.dg/gomp/pr39495-2.c: New test. * g++.dg/gomp/pr39495-1.C: New test. * g++.dg/gomp/pr39495-2.C: New test. From-SVN: r144965
Diffstat (limited to 'gcc/c-omp.c')
-rw-r--r--gcc/c-omp.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/gcc/c-omp.c b/gcc/c-omp.c
index 3be3729a32c..33f0a83e1a8 100644
--- a/gcc/c-omp.c
+++ b/gcc/c-omp.c
@@ -1,7 +1,7 @@
/* This file contains routines to construct GNU OpenMP constructs,
called from parsing in the C and C++ front ends.
- Copyright (C) 2005, 2007, 2008 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
Contributed by Richard Henderson <rth@redhat.com>,
Diego Novillo <dnovillo@redhat.com>.
@@ -280,7 +280,8 @@ c_finish_omp_for (location_t locus, tree declv, tree initv, tree condv,
if (TREE_CODE (cond) == LT_EXPR
|| TREE_CODE (cond) == LE_EXPR
|| TREE_CODE (cond) == GT_EXPR
- || TREE_CODE (cond) == GE_EXPR)
+ || TREE_CODE (cond) == GE_EXPR
+ || TREE_CODE (cond) == NE_EXPR)
{
tree op0 = TREE_OPERAND (cond, 0);
tree op1 = TREE_OPERAND (cond, 1);
@@ -324,6 +325,22 @@ c_finish_omp_for (location_t locus, tree declv, tree initv, tree condv,
TREE_OPERAND (cond, 0) = decl;
cond_ok = true;
}
+
+ if (TREE_CODE (cond) == NE_EXPR)
+ {
+ if (!INTEGRAL_TYPE_P (TREE_TYPE (decl)))
+ cond_ok = false;
+ else if (operand_equal_p (TREE_OPERAND (cond, 1),
+ TYPE_MIN_VALUE (TREE_TYPE (decl)),
+ 0))
+ TREE_SET_CODE (cond, GT_EXPR);
+ else if (operand_equal_p (TREE_OPERAND (cond, 1),
+ TYPE_MAX_VALUE (TREE_TYPE (decl)),
+ 0))
+ TREE_SET_CODE (cond, LT_EXPR);
+ else
+ cond_ok = false;
+ }
}
if (!cond_ok)