[committed] Fortran: Add missing ST_OMP_END_SCOPE handling [PR102313]

Message ID 5654a4bf-9c4a-17b5-b248-d47efed42583@codesourcery.com
State New
Headers show
Series
  • [committed] Fortran: Add missing ST_OMP_END_SCOPE handling [PR102313]
Related show

Commit Message

Tobias Burnus Sept. 14, 2021, 12:25 p.m.
Committed as obvious as r12-3524.

I have also re-checked openmp.c omp_code_to_statement (seems to be
complete, 'omp declare...' + 'omp requires' missing but it is
probably fine that those are absent).

And I checked gfc_ascii_statement – missing are some internally
used ones (like ST_SIMPLE_IF), which are probably never reachable.

Thus, it seems as if G. Steinmetz managed to find the only missing one.

I have created a testcase with all missing ST_OMP_END_* and ST_OACC_END_*;
I am not quite sure why a different code path is triggered for some, but
at least here is now a parse check for all.

Tobias

-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

Comments

Thomas Schwinge Sept. 15, 2021, 8:29 a.m. | #1
Hi!

On 2021-09-14T14:25:20+0200, Tobias Burnus <tobias@codesourcery.com> wrote:
> I have created a testcase with all missing ST_OMP_END_* and ST_OACC_END_*;

> I am not quite sure why a different code path is triggered for some, but

> at least here is now a parse check for all.


At least the OpenACC one is explained easily:

> --- /dev/null

> +++ b/gcc/testsuite/gfortran.dg/goacc/unexpected-end.f90

> @@ -0,0 +1,23 @@

> +! PR fortran/102313

> +

> +!$acc end ATOMIC  ! { dg-error "Unexpected !.ACC END ATOMIC" }

> +

> +!$acc end DATA  ! { dg-error "Unexpected !.ACC END DATA" }

> +

> +!$acc end HOST DATA  ! { dg-error "Unclassifiable OpenACC directive" }


Pushed to master branch commit 8b69c481fc86e04c6c83f3a49eef2760c175a8f2
"Add OpenACC 'host_data' testing to 'gfortran.dg/goacc/unexpected-end.f90'",
see attached.


Grüße
 Thomas


> +

> +!$acc end KERNELS  ! { dg-error "Unexpected !.ACC END KERNELS" }

> +

> +!$acc end KERNELS LOOP  ! { dg-error "Unexpected !.ACC END KERNELS LOOP" }

> +

> +!$acc end LOOP  ! { dg-error "Unexpected !.ACC END LOOP" }

> +

> +!$acc end PARALLEL  ! { dg-error "Unexpected !.ACC END PARALLEL" }

> +

> +!$acc end PARALLEL LOOP  ! { dg-error "Unexpected !.ACC END PARALLEL LOOP" }

> +

> +!$acc end SERIAL  ! { dg-error "Unexpected !.ACC END SERIAL" }

> +

> +!$acc end SERIAL LOOP  ! { dg-error "Unexpected !.ACC END SERIAL LOOP" }

> +

> +end

> diff --git a/gcc/testsuite/gfortran.dg/gomp/unexpected-end.f90 b/gcc/testsuite/gfortran.dg/gomp/unexpected-end.f90

> new file mode 100644

> index 00000000000..d2e8daa3fde

> --- /dev/null

> +++ b/gcc/testsuite/gfortran.dg/gomp/unexpected-end.f90

> @@ -0,0 +1,123 @@

> +! PR fortran/102313

> +

> +!$omp end ATOMIC  ! { dg-error "Unexpected !.OMP END ATOMIC" }

> +

> +!$omp end CRITICAL  ! { dg-error "Unexpected !.OMP END CRITICAL" }

> +

> +!$omp end DISTRIBUTE  ! { dg-error "Unexpected !.OMP END DISTRIBUTE" }

> +

> +!$omp end DISTRIBUTE PARALLEL DO  ! { dg-error "Unexpected !.OMP END DISTRIBUTE PARALLEL DO" }

> +

> +!$omp end DISTRIBUTE PARALLEL DO SIMD  ! { dg-error "Unexpected !.OMP END DISTRIBUTE PARALLEL DO SIMD" }

> +

> +!$omp end DISTRIBUTE SIMD  ! { dg-error "Unexpected !.OMP END DISTRIBUTE SIMD" }

> +

> +!$omp end DO  ! { dg-error "Unexpected !.OMP END DO" }

> +

> +!$omp end DO SIMD  ! { dg-error "Unexpected !.OMP END DO SIMD" }

> +

> +!$omp end LOOP  ! { dg-error "Unclassifiable OpenMP directive" }

> +

> +!$omp parallel loop

> +do i = 1, 5

> +end do

> +!$omp end LOOP  ! { dg-error "Unclassifiable OpenMP directive" }

> +

> +!$omp end MASKED  ! { dg-error "Unexpected !.OMP END MASKED" }

> +

> +!$omp end MASKED TASKLOOP  ! { dg-error "Unexpected !.OMP END MASKED TASKLOOP" }

> +

> +!$omp end MASKED TASKLOOP SIMD  ! { dg-error "Unexpected !.OMP END MASKED TASKLOOP SIMD" }

> +

> +!$omp end MASTER  ! { dg-error "Unexpected !.OMP END MASTER" }

> +

> +!$omp end MASTER TASKLOOP  ! { dg-error "Unexpected !.OMP END MASTER TASKLOOP" }

> +

> +!$omp end MASTER TASKLOOP SIMD  ! { dg-error "Unexpected !.OMP END MASTER TASKLOOP SIMD" }

> +

> +!$omp end ORDERED  ! { dg-error "Unexpected !.OMP END ORDERED" }

> +

> +!$omp end PARALLEL  ! { dg-error "Unexpected !.OMP END PARALLEL" }

> +

> +!$omp end PARALLEL DO  ! { dg-error "Unexpected !.OMP END PARALLEL DO" }

> +

> +!$omp end PARALLEL DO SIMD  ! { dg-error "Unexpected !.OMP END PARALLEL DO SIMD" }

> +

> +!$omp loop

> +!$omp end PARALLEL LOOP  ! { dg-error "Unexpected junk" }

> +

> +!$omp end PARALLEL MASKED  ! { dg-error "Unexpected !.OMP END PARALLEL MASKED" }

> +

> +!$omp end PARALLEL MASKED TASKLOOP  ! { dg-error "Unexpected !.OMP END PARALLEL MASKED TASKLOOP" }

> +

> +!$omp end PARALLEL MASKED TASKLOOP SIMD  ! { dg-error "Unexpected !.OMP END PARALLEL MASKED TASKLOOP SIMD" }

> +

> +!$omp end PARALLEL MASTER  ! { dg-error "Unexpected !.OMP END PARALLEL MASTER" }

> +

> +!$omp end PARALLEL MASTER TASKLOOP  ! { dg-error "Unexpected !.OMP END PARALLEL MASTER TASKLOOP" }

> +

> +!$omp end PARALLEL MASTER TASKLOOP SIMD  ! { dg-error "Unexpected !.OMP END PARALLEL MASTER TASKLOOP SIMD" }

> +

> +!$omp end PARALLEL SECTIONS  ! { dg-error "Unexpected !.OMP END PARALLEL SECTIONS" }

> +

> +!$omp end PARALLEL WORKSHARE  ! { dg-error "Unexpected !.OMP END PARALLEL WORKSHARE" }

> +

> +!$omp end SCOPE  ! { dg-error "Unexpected !.OMP END SCOPE" }

> +

> +!$omp end SECTIONS  ! { dg-error "Unexpected !.OMP END SECTIONS" }

> +

> +!$omp end SIMD  ! { dg-error "Unexpected !.OMP END SIMD" }

> +

> +!$omp end SINGLE  ! { dg-error "Unexpected !.OMP END SINGLE" }

> +

> +!$omp end TARGET  ! { dg-error "Unexpected !.OMP END TARGET" }

> +

> +!$omp end TARGET DATA  ! { dg-error "Unexpected !.OMP END TARGET DATA" }

> +

> +!$omp end TARGET PARALLEL  ! { dg-error "Unexpected !.OMP END TARGET PARALLEL" }

> +

> +!$omp end TARGET PARALLEL DO  ! { dg-error "Unexpected !.OMP END TARGET PARALLEL DO" }

> +

> +!$omp end TARGET PARALLEL DO SIMD  ! { dg-error "Unexpected !.OMP END TARGET PARALLEL DO SIMD" }

> +

> +!$omp end TARGET PARALLEL LOOP  ! { dg-error "Unexpected junk" }

> +

> +!$omp end TARGET SIMD  ! { dg-error "Unexpected !.OMP END TARGET SIMD" }

> +

> +!$omp end TARGET TEAMS  ! { dg-error "Unexpected !.OMP END TARGET TEAMS" }

> +

> +!$omp end TARGET TEAMS DISTRIBUTE  ! { dg-error "Unexpected !.OMP END TARGET TEAMS DISTRIBUTE" }

> +

> +!$omp end TARGET TEAMS DISTRIBUTE PARALLEL DO  ! { dg-error "Unexpected !.OMP END TARGET TEAMS DISTRIBUTE PARALLEL DO" }

> +

> +!$omp end TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD  ! { dg-error "Unexpected !.OMP END TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD" }

> +

> +!$omp end TARGET TEAMS DISTRIBUTE SIMD  ! { dg-error "Unexpected !.OMP END TARGET TEAMS DISTRIBUTE SIMD" }

> +

> +!$omp end TARGET TEAMS LOOP  ! { dg-error "Unexpected junk" }

> +

> +!$omp end TASK  ! { dg-error "Unexpected !.OMP END TASK" }

> +

> +!$omp end TASKGROUP  ! { dg-error "Unexpected !.OMP END TASKGROUP" }

> +

> +!$omp end TASKLOOP  ! { dg-error "Unexpected !.OMP END TASKLOOP" }

> +

> +!$omp end TASKLOOP SIMD  ! { dg-error "Unexpected !.OMP END TASKLOOP SIMD" }

> +

> +!$omp end TEAMS  ! { dg-error "Unexpected !.OMP END TEAMS" }

> +

> +!$omp end TEAMS DISTRIBUTE  ! { dg-error "Unexpected !.OMP END TEAMS DISTRIBUTE" }

> +

> +!$omp end TEAMS DISTRIBUTE PARALLEL DO  ! { dg-error "Unexpected !.OMP END TEAMS DISTRIBUTE PARALLEL DO" }

> +

> +!$omp end TEAMS DISTRIBUTE PARALLEL DO SIMD  ! { dg-error "Unexpected !.OMP END TEAMS DISTRIBUTE PARALLEL DO SIMD" }

> +

> +!$omp end TEAMS DISTRIBUTE SIMD  ! { dg-error "Unexpected !.OMP END TEAMS DISTRIBUTE SIMD" }

> +

> +!$omp end TEAMS LOOP  ! { dg-error "Unexpected junk" }

> +

> +!$omp end WORKSHARE  ! { dg-error "Unexpected !.OMP END WORKSHARE" }

> +

> +end  ! { dg-error "Unexpected END statement" }

> +

> +! { dg-excess-errors "Unexpected end of file" }



-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
From 8b69c481fc86e04c6c83f3a49eef2760c175a8f2 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>

Date: Wed, 15 Sep 2021 10:25:53 +0200
Subject: [PATCH] Add OpenACC 'host_data' testing to
 'gfortran.dg/goacc/unexpected-end.f90'

Use underscore instead of space in 'host_data'.

Follow-up to recent commit 33fdbbe4ce6055eb858096d01720ccf94aa854ec
"Fortran: Add missing ST_OMP_END_SCOPE handling [PR102313]".

	gcc/testsuite/
	* gfortran.dg/goacc/unexpected-end.f90: Add OpenACC 'host_data'
	testing.
---
 gcc/testsuite/gfortran.dg/goacc/unexpected-end.f90 | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gfortran.dg/goacc/unexpected-end.f90 b/gcc/testsuite/gfortran.dg/goacc/unexpected-end.f90
index 442724fea83..e9db47b3270 100644
--- a/gcc/testsuite/gfortran.dg/goacc/unexpected-end.f90
+++ b/gcc/testsuite/gfortran.dg/goacc/unexpected-end.f90
@@ -4,7 +4,7 @@
 
 !$acc end DATA  ! { dg-error "Unexpected !.ACC END DATA" }
 
-!$acc end HOST DATA  ! { dg-error "Unclassifiable OpenACC directive" }
+!$acc end HOST_DATA  ! { dg-error "Unexpected !.ACC END HOST_DATA" }
 
 !$acc end KERNELS  ! { dg-error "Unexpected !.ACC END KERNELS" }
 
@@ -20,4 +20,6 @@
 
 !$acc end SERIAL LOOP  ! { dg-error "Unexpected !.ACC END SERIAL LOOP" }
 
+!$acc end EUPHORBIA LATHYRIS  ! { dg-error "Unclassifiable OpenACC directive" }
+
 end
-- 
2.33.0

Patch

commit 33fdbbe4ce6055eb858096d01720ccf94aa854ec
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Tue Sep 14 14:17:35 2021 +0200

    Fortran: Add missing ST_OMP_END_SCOPE handling [PR102313]
    
            PR fortran/102313
    
    gcc/fortran/ChangeLog:
    
            * parse.c (gfc_ascii_statement): Add missing ST_OMP_END_SCOPE.
    
    gcc/testsuite/ChangeLog:
    
            * gfortran.dg/goacc/unexpected-end.f90: New test.
            * gfortran.dg/gomp/unexpected-end.f90: New test.
---
 gcc/fortran/parse.c                                |   3 +
 gcc/testsuite/gfortran.dg/goacc/unexpected-end.f90 |  23 ++++
 gcc/testsuite/gfortran.dg/gomp/unexpected-end.f90  | 123 +++++++++++++++++++++
 3 files changed, 149 insertions(+)

diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c
index d37a0b5a697..7d765a0866d 100644
--- a/gcc/fortran/parse.c
+++ b/gcc/fortran/parse.c
@@ -2406,6 +2406,9 @@  gfc_ascii_statement (gfc_statement st)
     case ST_OMP_END_DO_SIMD:
       p = "!$OMP END DO SIMD";
       break;
+    case ST_OMP_END_SCOPE:
+      p = "!$OMP END SCOPE";
+      break;
     case ST_OMP_END_SIMD:
       p = "!$OMP END SIMD";
       break;
diff --git a/gcc/testsuite/gfortran.dg/goacc/unexpected-end.f90 b/gcc/testsuite/gfortran.dg/goacc/unexpected-end.f90
new file mode 100644
index 00000000000..442724fea83
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc/unexpected-end.f90
@@ -0,0 +1,23 @@ 
+! PR fortran/102313
+
+!$acc end ATOMIC  ! { dg-error "Unexpected !.ACC END ATOMIC" }
+
+!$acc end DATA  ! { dg-error "Unexpected !.ACC END DATA" }
+
+!$acc end HOST DATA  ! { dg-error "Unclassifiable OpenACC directive" }
+
+!$acc end KERNELS  ! { dg-error "Unexpected !.ACC END KERNELS" }
+
+!$acc end KERNELS LOOP  ! { dg-error "Unexpected !.ACC END KERNELS LOOP" }
+
+!$acc end LOOP  ! { dg-error "Unexpected !.ACC END LOOP" }
+
+!$acc end PARALLEL  ! { dg-error "Unexpected !.ACC END PARALLEL" }
+
+!$acc end PARALLEL LOOP  ! { dg-error "Unexpected !.ACC END PARALLEL LOOP" }
+
+!$acc end SERIAL  ! { dg-error "Unexpected !.ACC END SERIAL" }
+
+!$acc end SERIAL LOOP  ! { dg-error "Unexpected !.ACC END SERIAL LOOP" }
+
+end
diff --git a/gcc/testsuite/gfortran.dg/gomp/unexpected-end.f90 b/gcc/testsuite/gfortran.dg/gomp/unexpected-end.f90
new file mode 100644
index 00000000000..d2e8daa3fde
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/unexpected-end.f90
@@ -0,0 +1,123 @@ 
+! PR fortran/102313
+
+!$omp end ATOMIC  ! { dg-error "Unexpected !.OMP END ATOMIC" }
+
+!$omp end CRITICAL  ! { dg-error "Unexpected !.OMP END CRITICAL" }
+
+!$omp end DISTRIBUTE  ! { dg-error "Unexpected !.OMP END DISTRIBUTE" }
+
+!$omp end DISTRIBUTE PARALLEL DO  ! { dg-error "Unexpected !.OMP END DISTRIBUTE PARALLEL DO" }
+
+!$omp end DISTRIBUTE PARALLEL DO SIMD  ! { dg-error "Unexpected !.OMP END DISTRIBUTE PARALLEL DO SIMD" }
+
+!$omp end DISTRIBUTE SIMD  ! { dg-error "Unexpected !.OMP END DISTRIBUTE SIMD" }
+
+!$omp end DO  ! { dg-error "Unexpected !.OMP END DO" }
+
+!$omp end DO SIMD  ! { dg-error "Unexpected !.OMP END DO SIMD" }
+
+!$omp end LOOP  ! { dg-error "Unclassifiable OpenMP directive" }
+
+!$omp parallel loop
+do i = 1, 5
+end do
+!$omp end LOOP  ! { dg-error "Unclassifiable OpenMP directive" }
+
+!$omp end MASKED  ! { dg-error "Unexpected !.OMP END MASKED" }
+
+!$omp end MASKED TASKLOOP  ! { dg-error "Unexpected !.OMP END MASKED TASKLOOP" }
+
+!$omp end MASKED TASKLOOP SIMD  ! { dg-error "Unexpected !.OMP END MASKED TASKLOOP SIMD" }
+
+!$omp end MASTER  ! { dg-error "Unexpected !.OMP END MASTER" }
+
+!$omp end MASTER TASKLOOP  ! { dg-error "Unexpected !.OMP END MASTER TASKLOOP" }
+
+!$omp end MASTER TASKLOOP SIMD  ! { dg-error "Unexpected !.OMP END MASTER TASKLOOP SIMD" }
+
+!$omp end ORDERED  ! { dg-error "Unexpected !.OMP END ORDERED" }
+
+!$omp end PARALLEL  ! { dg-error "Unexpected !.OMP END PARALLEL" }
+
+!$omp end PARALLEL DO  ! { dg-error "Unexpected !.OMP END PARALLEL DO" }
+
+!$omp end PARALLEL DO SIMD  ! { dg-error "Unexpected !.OMP END PARALLEL DO SIMD" }
+
+!$omp loop
+!$omp end PARALLEL LOOP  ! { dg-error "Unexpected junk" }
+
+!$omp end PARALLEL MASKED  ! { dg-error "Unexpected !.OMP END PARALLEL MASKED" }
+
+!$omp end PARALLEL MASKED TASKLOOP  ! { dg-error "Unexpected !.OMP END PARALLEL MASKED TASKLOOP" }
+
+!$omp end PARALLEL MASKED TASKLOOP SIMD  ! { dg-error "Unexpected !.OMP END PARALLEL MASKED TASKLOOP SIMD" }
+
+!$omp end PARALLEL MASTER  ! { dg-error "Unexpected !.OMP END PARALLEL MASTER" }
+
+!$omp end PARALLEL MASTER TASKLOOP  ! { dg-error "Unexpected !.OMP END PARALLEL MASTER TASKLOOP" }
+
+!$omp end PARALLEL MASTER TASKLOOP SIMD  ! { dg-error "Unexpected !.OMP END PARALLEL MASTER TASKLOOP SIMD" }
+
+!$omp end PARALLEL SECTIONS  ! { dg-error "Unexpected !.OMP END PARALLEL SECTIONS" }
+
+!$omp end PARALLEL WORKSHARE  ! { dg-error "Unexpected !.OMP END PARALLEL WORKSHARE" }
+
+!$omp end SCOPE  ! { dg-error "Unexpected !.OMP END SCOPE" }
+
+!$omp end SECTIONS  ! { dg-error "Unexpected !.OMP END SECTIONS" }
+
+!$omp end SIMD  ! { dg-error "Unexpected !.OMP END SIMD" }
+
+!$omp end SINGLE  ! { dg-error "Unexpected !.OMP END SINGLE" }
+
+!$omp end TARGET  ! { dg-error "Unexpected !.OMP END TARGET" }
+
+!$omp end TARGET DATA  ! { dg-error "Unexpected !.OMP END TARGET DATA" }
+
+!$omp end TARGET PARALLEL  ! { dg-error "Unexpected !.OMP END TARGET PARALLEL" }
+
+!$omp end TARGET PARALLEL DO  ! { dg-error "Unexpected !.OMP END TARGET PARALLEL DO" }
+
+!$omp end TARGET PARALLEL DO SIMD  ! { dg-error "Unexpected !.OMP END TARGET PARALLEL DO SIMD" }
+
+!$omp end TARGET PARALLEL LOOP  ! { dg-error "Unexpected junk" }
+
+!$omp end TARGET SIMD  ! { dg-error "Unexpected !.OMP END TARGET SIMD" }
+
+!$omp end TARGET TEAMS  ! { dg-error "Unexpected !.OMP END TARGET TEAMS" }
+
+!$omp end TARGET TEAMS DISTRIBUTE  ! { dg-error "Unexpected !.OMP END TARGET TEAMS DISTRIBUTE" }
+
+!$omp end TARGET TEAMS DISTRIBUTE PARALLEL DO  ! { dg-error "Unexpected !.OMP END TARGET TEAMS DISTRIBUTE PARALLEL DO" }
+
+!$omp end TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD  ! { dg-error "Unexpected !.OMP END TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD" }
+
+!$omp end TARGET TEAMS DISTRIBUTE SIMD  ! { dg-error "Unexpected !.OMP END TARGET TEAMS DISTRIBUTE SIMD" }
+
+!$omp end TARGET TEAMS LOOP  ! { dg-error "Unexpected junk" }
+
+!$omp end TASK  ! { dg-error "Unexpected !.OMP END TASK" }
+
+!$omp end TASKGROUP  ! { dg-error "Unexpected !.OMP END TASKGROUP" }
+
+!$omp end TASKLOOP  ! { dg-error "Unexpected !.OMP END TASKLOOP" }
+
+!$omp end TASKLOOP SIMD  ! { dg-error "Unexpected !.OMP END TASKLOOP SIMD" }
+
+!$omp end TEAMS  ! { dg-error "Unexpected !.OMP END TEAMS" }
+
+!$omp end TEAMS DISTRIBUTE  ! { dg-error "Unexpected !.OMP END TEAMS DISTRIBUTE" }
+
+!$omp end TEAMS DISTRIBUTE PARALLEL DO  ! { dg-error "Unexpected !.OMP END TEAMS DISTRIBUTE PARALLEL DO" }
+
+!$omp end TEAMS DISTRIBUTE PARALLEL DO SIMD  ! { dg-error "Unexpected !.OMP END TEAMS DISTRIBUTE PARALLEL DO SIMD" }
+
+!$omp end TEAMS DISTRIBUTE SIMD  ! { dg-error "Unexpected !.OMP END TEAMS DISTRIBUTE SIMD" }
+
+!$omp end TEAMS LOOP  ! { dg-error "Unexpected junk" }
+
+!$omp end WORKSHARE  ! { dg-error "Unexpected !.OMP END WORKSHARE" }
+
+end  ! { dg-error "Unexpected END statement" }
+
+! { dg-excess-errors "Unexpected end of file" }