From 7211a0975c25b21baa8e31ebc2946f4d6d136fed Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 26 May 2016 21:12:27 +0200 Subject: c-parser.c (c_parser_omp_clause_schedule): Warn if OMP_CLAUSE_SCHEDULE_CHUNK_EXPR is known not to be positive. * c-parser.c (c_parser_omp_clause_schedule): Warn if OMP_CLAUSE_SCHEDULE_CHUNK_EXPR is known not to be positive. * semantics.c (finish_omp_clauses) : Warn if OMP_CLAUSE_SCHEDULE_CHUNK_EXPR is known not to be positive. * openmp.c (resolve_omp_clauses): Warn if chunk_size is known not to be positive. * c-c++-common/gomp/schedule-1.c: New test. * gfortran.dg/gomp/schedule-1.f90: New test. * testsuite/libgomp.c/doacross-1.c (main): Use schedule(static) instead of invalid schedule(static, 0). * testsuite/libgomp.c/doacross-2.c (main): Likewise. From-SVN: r236793 --- gcc/c/ChangeLog | 5 +++++ gcc/c/c-parser.c | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index f3bb0e9..f7d1a6d 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,8 @@ +2016-05-26 Jakub Jelinek + + * c-parser.c (c_parser_omp_clause_schedule): Warn if + OMP_CLAUSE_SCHEDULE_CHUNK_EXPR is known not to be positive. + 2016-05-25 Marek Polacek PR c/71265 diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 1cf4fb4..fda2df8 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -12128,7 +12128,20 @@ c_parser_omp_clause_schedule (c_parser *parser, tree list) "schedule % does not take " "a % parameter"); else if (TREE_CODE (TREE_TYPE (t)) == INTEGER_TYPE) - OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (c) = t; + { + /* Attempt to statically determine when the number isn't + positive. */ + tree s = fold_build2_loc (loc, LE_EXPR, boolean_type_node, t, + build_int_cst (TREE_TYPE (t), 0)); + protected_set_expr_location (s, loc); + if (s == boolean_true_node) + { + warning_at (loc, 0, + "chunk size value must be positive"); + t = integer_one_node; + } + OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (c) = t; + } else c_parser_error (parser, "expected integer expression"); -- cgit v1.1