From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1534) id BD5883858C33; Thu, 25 Aug 2022 06:35:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BD5883858C33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1661409314; bh=DQLizEabqqpieTfZ+Y6EgC1SiyFIhsf7y9rvuFQPdP4=; h=From:To:Subject:Date:From; b=sqK7aq8pGeZtOTE8/bA4ROlqi1Iqi3BDDmP7hOEZjgyv7cu6emjBdxKoiqRLs5VH+ TErDnMXCcMpFLT1MOgsui+7UQh75zjbNKgQZ5y8GOpiT+z3SSvHNhsv3HMhEWu+Wzt /vdhcHompN4dw5dXxc53JxBjlYZyDP+taYblemk0= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Tobias Burnus To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-2196] Fortran/OpenMP: Fix strictly structured blocks parsing X-Act-Checkin: gcc X-Git-Author: Tobias Burnus X-Git-Refname: refs/heads/master X-Git-Oldrev: b169b67d7dafe2b786f87c31d6b2efc603fd880c X-Git-Newrev: 33f24eb58748e9db7c827662753757c5c2217eb4 Message-Id: <20220825063514.BD5883858C33@sourceware.org> Date: Thu, 25 Aug 2022 06:35:14 +0000 (GMT) List-Id: https://gcc.gnu.org/g:33f24eb58748e9db7c827662753757c5c2217eb4 commit r13-2196-g33f24eb58748e9db7c827662753757c5c2217eb4 Author: Tobias Burnus Date: Thu Aug 25 08:34:03 2022 +0200 Fortran/OpenMP: Fix strictly structured blocks parsing 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. Diff: --- gcc/fortran/parse.cc | 2 +- .../gomp/strictly-structured-block-4.f90 | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/parse.cc b/gcc/fortran/parse.cc index 0b4c596996c..80492c952aa 100644 --- a/gcc/fortran/parse.cc +++ b/gcc/fortran/parse.cc @@ -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 index 00000000000..66cf0a3925e --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/strictly-structured-block-4.f90 @@ -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 +