From: Jakub Jelinek Date: Fri, 19 Oct 2018 22:52:06 +0000 (+0200) Subject: re PR middle-end/85488 (segmentation fault when compiling code using the ordered... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=173670e2b443ac501fd0ae3d61124faed8f13b22;p=gcc.git re PR middle-end/85488 (segmentation fault when compiling code using the ordered(n) clause in OpenMP 4.5) PR middle-end/85488 PR middle-end/87649 * omp-low.c (check_omp_nesting_restrictions): Diagnose ordered without depend closely nested inside of loop with ordered clause with a parameter. * c-c++-common/gomp/doacross-2.c: New test. * c-c++-common/gomp/sink-3.c: Expect another error during error recovery. From-SVN: r265335 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3875841b5fb..84ad488b6cb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2018-10-19 Jakub Jelinek + + PR middle-end/85488 + PR middle-end/87649 + * omp-low.c (check_omp_nesting_restrictions): Diagnose ordered without + depend closely nested inside of loop with ordered clause with + a parameter. + 2018-10-19 David Malcolm * Makefile.in (TEXI_GCCINT_FILES): Add ux.texi. diff --git a/gcc/omp-low.c b/gcc/omp-low.c index fdabf67249b..bbcbc121bae 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -2762,14 +2762,25 @@ check_omp_nesting_restrictions (gimple *stmt, omp_context *ctx) case GIMPLE_OMP_FOR: if (gimple_omp_for_kind (ctx->stmt) == GF_OMP_FOR_KIND_TASKLOOP) goto ordered_in_taskloop; - if (omp_find_clause (gimple_omp_for_clauses (ctx->stmt), - OMP_CLAUSE_ORDERED) == NULL) + tree o; + o = omp_find_clause (gimple_omp_for_clauses (ctx->stmt), + OMP_CLAUSE_ORDERED); + if (o == NULL) { error_at (gimple_location (stmt), "% region must be closely nested inside " "a loop region with an % clause"); return false; } + if (OMP_CLAUSE_ORDERED_EXPR (o) != NULL_TREE + && omp_find_clause (c, OMP_CLAUSE_DEPEND) == NULL_TREE) + { + error_at (gimple_location (stmt), + "% region without % clause may " + "not be closely nested inside a loop region with " + "an % clause with a parameter"); + return false; + } return true; case GIMPLE_OMP_TARGET: if (gimple_omp_target_kind (ctx->stmt) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 80c0b4b01ba..3000e214a16 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2018-10-19 Jakub Jelinek + + PR middle-end/85488 + PR middle-end/87649 + * c-c++-common/gomp/doacross-2.c: New test. + * c-c++-common/gomp/sink-3.c: Expect another error during error + recovery. + 2018-10-19 Segher Boessenkool * gcc.target/powerpc/safe-indirect-jump-2.c: Do not check assigned CR diff --git a/gcc/testsuite/c-c++-common/gomp/doacross-2.c b/gcc/testsuite/c-c++-common/gomp/doacross-2.c new file mode 100644 index 00000000000..cc454879553 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/doacross-2.c @@ -0,0 +1,49 @@ +/* PR middle-end/87649 */ + +void +foo (void) +{ + int i; + #pragma omp for ordered(1) + for (i = 0; i < 64; i++) + { + #pragma omp ordered /* { dg-error "'ordered' region without 'depend' clause may not be closely nested inside a loop region with an 'ordered' clause with a parameter" } */ + ; + } + #pragma omp for ordered(1) + for (i = 0; i < 64; i++) + { + #pragma omp ordered threads /* { dg-error "'ordered' region without 'depend' clause may not be closely nested inside a loop region with an 'ordered' clause with a parameter" } */ + ; + } +} + +void +bar (void) +{ + int i; + #pragma omp for ordered + for (i = 0; i < 64; i++) + { + #pragma omp ordered depend(source) /* { dg-error "'ordered' construct with 'depend' clause must be closely nested inside a loop with 'ordered' clause with a parameter" } */ + #pragma omp ordered depend(sink: i - 1) /* { dg-error "'ordered' construct with 'depend' clause must be closely nested inside a loop with 'ordered' clause with a parameter" } */ + } + #pragma omp for + for (i = 0; i < 64; i++) + { + #pragma omp ordered depend(source) /* { dg-error "'ordered' construct with 'depend' clause must be closely nested inside a loop with 'ordered' clause with a parameter" } */ + #pragma omp ordered depend(sink: i - 1) /* { dg-error "'ordered' construct with 'depend' clause must be closely nested inside a loop with 'ordered' clause with a parameter" } */ + } + #pragma omp for + for (i = 0; i < 64; i++) + { + #pragma omp ordered /* { dg-error "'ordered' region must be closely nested inside a loop region with an 'ordered' clause" } */ + ; + } + #pragma omp for + for (i = 0; i < 64; i++) + { + #pragma omp ordered threads /* { dg-error "'ordered' region must be closely nested inside a loop region with an 'ordered' clause" } */ + ; + } +} diff --git a/gcc/testsuite/c-c++-common/gomp/sink-3.c b/gcc/testsuite/c-c++-common/gomp/sink-3.c index 7cb16ed0f76..588aea215c9 100644 --- a/gcc/testsuite/c-c++-common/gomp/sink-3.c +++ b/gcc/testsuite/c-c++-common/gomp/sink-3.c @@ -14,7 +14,7 @@ foo () for (i=0; i < 100; ++i) { #pragma omp ordered depend(sink:poo-1,paa+1) /* { dg-error "poo.*declared.*paa.*declared" } */ - bar(&i); + bar(&i); /* { dg-error "may not be closely nested" "" { target *-*-* } .-1 } */ #pragma omp ordered depend(source) } }