diff options
| author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-05-15 10:02:26 +0000 |
|---|---|---|
| committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-05-15 10:02:26 +0000 |
| commit | c1d127dd97188cdb1508d0c0633dbbf77a62096b (patch) | |
| tree | 7388a01e1751bcddaf846846ad4e5f139e5bbc61 | |
| parent | 9438af576b2c64026be187b075868da20d53a545 (diff) | |
| download | ppe42-gcc-c1d127dd97188cdb1508d0c0633dbbf77a62096b.tar.gz ppe42-gcc-c1d127dd97188cdb1508d0c0633dbbf77a62096b.zip | |
* omp-low.c (check_omp_nesting_restrictions): New function.
(scan_omp_1): Call it.
* gcc.dg/gomp/critical-4.c: New test.
* gcc.dg/gomp/appendix-a/a.35.1.c: Add dg-warning.
* gcc.dg/gomp/appendix-a/a.35.3.c: Likewise.
* gfortran.dg/gomp/appendix-a/a.35.1.f90: Likewise.
* gfortran.dg/gomp/appendix-a/a.35.3.f90: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@113790 138bc75d-0d04-0410-961f-82ee72b054a4
| -rw-r--r-- | gcc/ChangeLog | 3 | ||||
| -rw-r--r-- | gcc/omp-low.c | 82 | ||||
| -rw-r--r-- | gcc/testsuite/ChangeLog | 8 | ||||
| -rw-r--r-- | gcc/testsuite/gcc.dg/gomp/appendix-a/a.35.1.c | 2 | ||||
| -rw-r--r-- | gcc/testsuite/gcc.dg/gomp/appendix-a/a.35.3.c | 2 | ||||
| -rw-r--r-- | gcc/testsuite/gcc.dg/gomp/critical-4.c | 28 | ||||
| -rw-r--r-- | gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.1.f90 | 3 | ||||
| -rw-r--r-- | gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.3.f90 | 3 |
8 files changed, 127 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 68ee5888aed..ed5920e07e3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,8 @@ 2006-05-15 Jakub Jelinek <jakub@redhat.com> + * omp-low.c (check_omp_nesting_restrictions): New function. + (scan_omp_1): Call it. + PR middle-end/27416 * omp-low.c (build_outer_var_ref): If VAR is reference in orphaned construct, return *VAR. diff --git a/gcc/omp-low.c b/gcc/omp-low.c index c6d186bee71..2b691fa4c4d 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -1245,6 +1245,84 @@ scan_omp_single (tree *stmt_p, omp_context *outer_ctx) } +/* Check OpenMP nesting restrictions. */ +static void +check_omp_nesting_restrictions (tree t, omp_context *ctx) +{ + switch (TREE_CODE (t)) + { + case OMP_FOR: + case OMP_SECTIONS: + case OMP_SINGLE: + for (; ctx != NULL; ctx = ctx->outer) + switch (TREE_CODE (ctx->stmt)) + { + case OMP_FOR: + case OMP_SECTIONS: + case OMP_SINGLE: + case OMP_ORDERED: + case OMP_MASTER: + warning (0, "work-sharing region may not be closely nested inside " + "of work-sharing, critical, ordered or master region"); + return; + case OMP_PARALLEL: + return; + default: + break; + } + break; + case OMP_MASTER: + for (; ctx != NULL; ctx = ctx->outer) + switch (TREE_CODE (ctx->stmt)) + { + case OMP_FOR: + case OMP_SECTIONS: + case OMP_SINGLE: + warning (0, "master region may not be closely nested inside " + "of work-sharing region"); + return; + case OMP_PARALLEL: + return; + default: + break; + } + break; + case OMP_ORDERED: + for (; ctx != NULL; ctx = ctx->outer) + switch (TREE_CODE (ctx->stmt)) + { + case OMP_CRITICAL: + warning (0, "ordered region may not be closely nested inside " + "of critical region"); + return; + case OMP_FOR: + if (find_omp_clause (OMP_CLAUSES (ctx->stmt), + OMP_CLAUSE_ORDERED) == NULL) + warning (0, "ordered region must be closely nested inside " + "a loop region with an ordered clause"); + return; + case OMP_PARALLEL: + return; + default: + break; + } + break; + case OMP_CRITICAL: + for (; ctx != NULL; ctx = ctx->outer) + if (TREE_CODE (ctx->stmt) == OMP_CRITICAL + && OMP_CRITICAL_NAME (t) == OMP_CRITICAL_NAME (ctx->stmt)) + { + warning (0, "critical region may not be nested inside a critical " + "region with the same name"); + return; + } + break; + default: + break; + } +} + + /* Callback for walk_stmts used to scan for OpenMP directives at TP. */ static tree @@ -1257,6 +1335,10 @@ scan_omp_1 (tree *tp, int *walk_subtrees, void *data) if (EXPR_HAS_LOCATION (t)) input_location = EXPR_LOCATION (t); + /* Check the OpenMP nesting restrictions. */ + if (OMP_DIRECTIVE_P (t) && ctx != NULL) + check_omp_nesting_restrictions (t, ctx); + *walk_subtrees = 0; switch (TREE_CODE (t)) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dd39f3512cd..de208a50dd9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2006-05-15 Jakub Jelinek <jakub@redhat.com> + + * gcc.dg/gomp/critical-4.c: New test. + * gcc.dg/gomp/appendix-a/a.35.1.c: Add dg-warning. + * gcc.dg/gomp/appendix-a/a.35.3.c: Likewise. + * gfortran.dg/gomp/appendix-a/a.35.1.f90: Likewise. + * gfortran.dg/gomp/appendix-a/a.35.3.f90: Likewise. + 2006-05-15 Volker Reichelt <reichelt@igpm.rwth-aachen.de> PR c++/27582 diff --git a/gcc/testsuite/gcc.dg/gomp/appendix-a/a.35.1.c b/gcc/testsuite/gcc.dg/gomp/appendix-a/a.35.1.c index 95556c948c7..4196b2d1521 100644 --- a/gcc/testsuite/gcc.dg/gomp/appendix-a/a.35.1.c +++ b/gcc/testsuite/gcc.dg/gomp/appendix-a/a.35.1.c @@ -15,7 +15,7 @@ wrong1 (int n) for (i = 0; i < n; i++) { /* incorrect nesting of loop regions */ -#pragma omp for +#pragma omp for /* { dg-warning "may not be closely nested" } */ for (j = 0; j < n; j++) work (i, j); } diff --git a/gcc/testsuite/gcc.dg/gomp/appendix-a/a.35.3.c b/gcc/testsuite/gcc.dg/gomp/appendix-a/a.35.3.c index f99e09b36c5..31b2ddf0367 100644 --- a/gcc/testsuite/gcc.dg/gomp/appendix-a/a.35.3.c +++ b/gcc/testsuite/gcc.dg/gomp/appendix-a/a.35.3.c @@ -12,7 +12,7 @@ wrong3 (int n) for (i = 0; i < n; i++) { /* incorrect nesting of regions */ -#pragma omp single +#pragma omp single /* { dg-warning "may not be closely nested" } */ work (i, 0); } } diff --git a/gcc/testsuite/gcc.dg/gomp/critical-4.c b/gcc/testsuite/gcc.dg/gomp/critical-4.c new file mode 100644 index 00000000000..530e7c976fc --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/critical-4.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ + +extern void bar(int); + +void +foo1 (void) +{ + #pragma omp critical + #pragma omp critical(foo) + #pragma omp critical(bar) + bar (0); +} + +void +foo2 (void) +{ + #pragma omp critical + #pragma omp critical /* { dg-warning "with the same name" } */ + bar (0); +} + +void +foo3 (void) +{ + #pragma omp critical(foo) + #pragma omp critical(foo) /* { dg-warning "with the same name" } */ + bar (0); +} diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.1.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.1.f90 index 7325e34005e..7431a6579c3 100644 --- a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.1.f90 +++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.1.f90 @@ -9,7 +9,8 @@ !$OMP PARALLEL DEFAULT(SHARED) !$OMP DO DO I = 1, N -!$OMP DO ! incorrect nesting of loop regions + ! incorrect nesting of loop regions +!$OMP DO ! { dg-warning "may not be closely nested" } DO J = 1, N CALL WORK(I,J) END DO diff --git a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.3.f90 b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.3.f90 index 63a558f72ab..bb3e02fefd9 100644 --- a/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.3.f90 +++ b/gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.3.f90 @@ -6,7 +6,8 @@ !$OMP PARALLEL DEFAULT(SHARED) !$OMP DO DO I = 1, N -!$OMP SINGLE ! incorrect nesting of regions + ! incorrect nesting of regions +!$OMP SINGLE ! { dg-warning "may not be closely nested" } CALL WORK(I, 1) !$OMP END SINGLE END DO |

