This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gomp] Fix a !$omp do parsing bug, testcase fixes
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Henderson <rth at redhat dot com>, Diego Novillo <dnovillo at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Date: Tue, 18 Oct 2005 14:00:48 -0400
- Subject: [gomp] Fix a !$omp do parsing bug, testcase fixes
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
I misread A.6.1 and thought there is just a typo in the standard. Turns out
I was wrong, here is a fix.
Additionally there are some changes to the tests:
1) dejagnu doesn't like multiple dg-errors for the same error same line,
even when the error is supposed to be printed multiple times - one dg-error
will cover all such errors and the extra dg-error lines result in errors
2) we only issue default (none) diagnostic the first time we see a bug on
a particular variable (which is the right thing IMNSHO). Thus we can't
expect the errors in the additional places where the var is used as well.
I have cloned the testcase and commented out a line in the clone, so that
more errors can be detected. Though y is still reported on the firstprivate (y)
line rather than on z[i] = y;, but even that makes sense. firstprivate
actually uses the outer variable.
3) add dg-error lines to a.6.[12].f90.
Ok for gomp?
2005-10-18 Jakub Jelinek <jakub@redhat.com>
fortran/
* parse.c (parse_omp_do): Handle implied end do properly.
(parse_executable): If parse_omp_do returned ST_IMPLIED_ENDDO,
return it instead of continuing.
testsuite/
* gcc.dg/gomp/appendix-a/a.24.1.c: Remove some unexpected
dg-error lines.
* gcc.dg/gomp/appendix-a/a.24.1a.c: New test.
* gfortran.dg/gomp/appendix-a/a.24.1.f90: Add dg-error lines.
* gfortran.dg/gomp/appendix-a/a.6.2.f90: Likewise.
--- gcc/fortran/parse.c.jj 2005-10-10 11:30:07.000000000 +0200
+++ gcc/fortran/parse.c 2005-10-18 19:13:00.000000000 +0200
@@ -2288,6 +2288,22 @@ parse_omp_do (gfc_statement omp_st)
}
parse_do_block ();
+ if (gfc_statement_label != NULL
+ && gfc_state_stack->previous != NULL
+ && gfc_state_stack->previous->state == COMP_DO
+ && gfc_state_stack->previous->ext.end_do_label == gfc_statement_label)
+ {
+ /* In
+ DO 100 I=1,10
+ !$OMP DO
+ DO J=1,10
+ ...
+ 100 CONTINUE
+ there should be no !$OMP END DO. */
+ pop_state ();
+ return ST_IMPLIED_ENDDO;
+ }
+
check_do_closure ();
pop_state ();
@@ -2599,6 +2615,8 @@ parse_executable (gfc_statement st)
case ST_OMP_DO:
case ST_OMP_PARALLEL_DO:
st = parse_omp_do (st);
+ if (st == ST_IMPLIED_ENDDO)
+ return st;
continue;
case ST_OMP_ATOMIC:
--- gcc/testsuite/gcc.dg/gomp/appendix-a/a.24.1.c.jj 2005-10-17 22:10:37.000000000 +0200
+++ gcc/testsuite/gcc.dg/gomp/appendix-a/a.24.1.c 2005-10-18 18:20:45.000000000 +0200
@@ -20,7 +20,6 @@ a24 (int a)
/* { dg-error "'i' not specified" "" { target *-*-* } 19 } */
/* { dg-error "enclosing parallel" "" { target *-*-* } 11 } */
/* { dg-error "'y' not specified" "" { target *-*-* } 19 } */
- /* { dg-error "enclosing parallel" "" { target *-*-* } 11 } */
#pragma omp for firstprivate(y)
for (i = 0; i < 10; i++)
{
@@ -28,9 +27,5 @@ a24 (int a)
/* - y is listed in firstprivate clause */
}
z[i] = y;
- /* { dg-error "'i' not specified" "" { target *-*-* } 28 } */
- /* { dg-error "enclosing parallel" "" { target *-*-* } 11 } */
- /* { dg-error "'y' not specified" "" { target *-*-* } 28 } */
- /* { dg-error "enclosing parallel" "" { target *-*-* } 11 } */
}
}
--- gcc/testsuite/gfortran.dg/gomp/appendix-a/a.24.1.f90.jj 2005-10-18 01:10:59.000000000 +0200
+++ gcc/testsuite/gfortran.dg/gomp/appendix-a/a.24.1.f90 2005-10-18 18:23:57.000000000 +0200
@@ -17,6 +17,9 @@
! - Z is listed in SHARED clause
X=1 ! O.K. - X is THREADPRIVATE
Z(I) = Y ! Error - cannot reference I or Y here
+! { dg-error "'i' not specified" "" { target *-*-* } 19 } */
+! { dg-error "enclosing parallel" "" { target *-*-* } 13 } */
+! { dg-error "'y' not specified" "" { target *-*-* } 19 } */
!$OMP DO firstprivate(y)
DO I = 1,10
Z(I) = Y ! O.K. - I is the loop iteration variable
--- gcc/testsuite/gfortran.dg/gomp/appendix-a/a.6.2.f90.jj 2005-10-18 01:10:59.000000000 +0200
+++ gcc/testsuite/gfortran.dg/gomp/appendix-a/a.6.2.f90 2005-10-18 19:14:55.000000000 +0200
@@ -11,5 +11,5 @@
DO 100 J = 1,10
CALL WORK(I,J)
100 CONTINUE
-!$OMP ENDDO
+!$OMP ENDDO ! { dg-error "Unexpected ..OMP END DO statement" }
END SUBROUTINE A6_WRONG
--- gcc/testsuite/gcc.dg/gomp/appendix-a/a.24.1a.c.jj 2005-10-18 18:32:05.000000000 +0200
+++ gcc/testsuite/gcc.dg/gomp/appendix-a/a.24.1a.c 2005-10-18 18:34:24.000000000 +0200
@@ -0,0 +1,31 @@
+/* { dg-do compile } */
+
+extern int omp_get_num_threads (void);
+int x, y, z[1000];
+#pragma omp threadprivate(x)
+void
+a24 (int a)
+{
+ const int c = 1;
+ int i = 0;
+#pragma omp parallel default(none) private(a) shared(z)
+ {
+ int j = omp_get_num_threads ();
+ /* O.K. - j is declared within parallel region */
+ /* O.K. - a is listed in private clause */
+ /* - z is listed in shared clause */
+ x = c; /* O.K. - x is threadprivate */
+ /* - c has const-qualified type */
+ /* z[i] = y; */
+#pragma omp for firstprivate(y)
+ for (i = 0; i < 10; i++)
+ {
+ z[i] = y; /* O.K. - i is the loop iteration variable */
+ /* - y is listed in firstprivate clause */
+ }
+ z[i] = y;
+ /* { dg-error "'i' not specified" "" { target *-*-* } 26 } */
+ /* { dg-error "enclosing parallel" "" { target *-*-* } 11 } */
+ /* { dg-error "'y' not specified" "" { target *-*-* } 20 } */
+ }
+}
Jakub