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) <case OMP_CLAUSE_SCHEDULE>: 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
This commit is contained in:
Jakub Jelinek 2016-05-26 21:12:27 +02:00 committed by Jakub Jelinek
parent cac177cfad
commit 7211a0975c
12 changed files with 84 additions and 4 deletions

View File

@ -1,3 +1,8 @@
2016-05-26 Jakub Jelinek <jakub@redhat.com>
* 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 <polacek@redhat.com>
PR c/71265

View File

@ -12128,7 +12128,20 @@ c_parser_omp_clause_schedule (c_parser *parser, tree list)
"schedule %<auto%> does not take "
"a %<chunk_size%> 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");

View File

@ -1,3 +1,8 @@
2016-05-26 Jakub Jelinek <jakub@redhat.com>
* semantics.c (finish_omp_clauses) <case OMP_CLAUSE_SCHEDULE>: Warn
if OMP_CLAUSE_SCHEDULE_CHUNK_EXPR is known not to be positive.
2016-05-26 Patrick Palka <ppalka@gcc.gnu.org>
PR c++/70822

View File

@ -6319,6 +6319,17 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
break;
}
}
else
{
t = maybe_constant_value (t);
if (TREE_CODE (t) == INTEGER_CST
&& tree_int_cst_sgn (t) != 1)
{
warning_at (OMP_CLAUSE_LOCATION (c), 0,
"chunk size value must be positive");
t = integer_one_node;
}
}
t = fold_build_cleanup_point_expr (TREE_TYPE (t), t);
}
OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (c) = t;

View File

@ -1,3 +1,8 @@
2016-05-26 Jakub Jelinek <jakub@redhat.com>
* openmp.c (resolve_omp_clauses): Warn if chunk_size is known not to
be positive.
2016-05-23 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/66461

View File

@ -3259,6 +3259,11 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses,
|| expr->ts.type != BT_INTEGER || expr->rank != 0)
gfc_error ("SCHEDULE clause's chunk_size at %L requires "
"a scalar INTEGER expression", &expr->where);
else if (expr->expr_type == EXPR_CONSTANT
&& expr->ts.type == BT_INTEGER
&& mpz_sgn (expr->value.integer) <= 0)
gfc_warning (0, "INTEGER expression of SCHEDULE clause's chunk_size "
"at %L must be positive", &expr->where);
}
/* Check that no symbol appears on multiple clauses, except that

View File

@ -1,3 +1,8 @@
2016-05-26 Jakub Jelinek <jakub@redhat.com>
* c-c++-common/gomp/schedule-1.c: New test.
* gfortran.dg/gomp/schedule-1.f90: New test.
2016-05-26 Patrick Palka <ppalka@gcc.gnu.org>
PR c++/70822

View File

@ -0,0 +1,14 @@
void
foo (void)
{
int i;
#pragma omp for schedule(static, 1)
for (i = 0; i < 10; i++)
;
#pragma omp for schedule(static, 0) /* { dg-warning "chunk size value must be positive" } */
for (i = 0; i < 10; i++)
;
#pragma omp for schedule(static, -7) /* { dg-warning "chunk size value must be positive" } */
for (i = 0; i < 10; i++)
;
}

View File

@ -0,0 +1,11 @@
integer :: i
!$omp do schedule(static, 1)
do i = 1, 10
end do
!$omp do schedule(static, 0) ! { dg-warning "must be positive" }
do i = 1, 10
end do
!$omp do schedule(static, -7) ! { dg-warning "must be positive" }
do i = 1, 10
end do
end

View File

@ -1,3 +1,9 @@
2016-05-26 Jakub Jelinek <jakub@redhat.com>
* testsuite/libgomp.c/doacross-1.c (main): Use schedule(static)
instead of invalid schedule(static, 0).
* testsuite/libgomp.c/doacross-2.c (main): Likewise.
2016-05-26 Chung-Lin Tang <cltang@codesourcery.com>
* oacc-plugin.h (GOMP_PLUGIN_async_unmap_vars): Add int parameter.

View File

@ -36,7 +36,7 @@ main ()
#pragma omp atomic write
a[i] = 3;
}
#pragma omp for schedule(static, 0) ordered (3) nowait
#pragma omp for schedule(static) ordered (3) nowait
for (i = 2; i < N / 16 - 1; i++)
for (j = 0; j < 8; j += 2)
for (k = 1; k <= 3; k++)

View File

@ -38,7 +38,7 @@ main ()
#pragma omp atomic write
a[i] = 3;
}
#pragma omp for schedule(static, 0) ordered (3) nowait
#pragma omp for schedule(static) ordered (3) nowait
for (i = 3; i < N / 16 - 1 + f; i++)
for (j = 0; j < 8; j += 2)
for (k = 1; k <= 3; k++)
@ -120,7 +120,7 @@ main ()
#pragma omp atomic write
c[i][j][k] = 3;
}
#pragma omp for schedule(static, 0) ordered (3) nowait
#pragma omp for schedule(static) ordered (3) nowait
for (j = 0; j < N / 16 - 1; j++)
for (k = 0; k < 8; k += 2)
for (i = 3; i <= 5 + f; i++)