]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fortran/OpenMP: Fix strictly structured blocks parsing
authorTobias Burnus <tobias@codesourcery.com>
Thu, 25 Aug 2022 06:34:03 +0000 (08:34 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Thu, 25 Aug 2022 06:34:40 +0000 (08:34 +0200)
gcc/fortran/ChangeLog:

* parse.cc (parse_omp_structured_block): When parsing strictly
structured blocks, issue an error if the end-directive comes
before the 'end block'.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/strictly-structured-block-4.f90: New test.

gcc/fortran/parse.cc
gcc/testsuite/gfortran.dg/gomp/strictly-structured-block-4.f90 [new file with mode: 0644]

index 0b4c596996c6e1406134192beaf7270495e8f42e..80492c952aa0ded6dba90697b215dcd704fc2bf4 100644 (file)
@@ -5709,7 +5709,7 @@ parse_omp_structured_block (gfc_statement omp_st, bool workshare_stmts_only)
            }
          return st;
        }
-      else if (st != omp_end_st)
+      else if (st != omp_end_st || block_construct)
        {
          unexpected_statement (st);
          st = next_statement ();
diff --git a/gcc/testsuite/gfortran.dg/gomp/strictly-structured-block-4.f90 b/gcc/testsuite/gfortran.dg/gomp/strictly-structured-block-4.f90
new file mode 100644 (file)
index 0000000..66cf0a3
--- /dev/null
@@ -0,0 +1,21 @@
+! { dg-do compile }
+implicit none
+integer ::x,z
+x = 42
+print '(*(z16:" "))', loc(x)
+!$omp target map(x, z)
+block
+  integer :: y
+  x = 123
+  y = 99
+  !$omp target device(ancestor:1) map(always,tofrom:x) map(y) ! { dg-error "'ancestor' device modifier not preceded by 'requires' directive with 'reverse_offload' clause" }
+    print '(*(z16:" "))', loc(x), loc(y)
+    print * ,x, y
+    x = -x
+    y = -y
+  !$omp end target ! { dg-error "Unexpected ..OMP END TARGET statement" }
+  z = y
+end block
+    print * ,x !, z
+end
+