public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Harald Anlauf <anlauf@gmx.de>
To: Tobias Burnus <tobias@codesourcery.com>,
	gcc-patches <gcc-patches@gcc.gnu.org>,
	fortran <fortran@gcc.gnu.org>, Jakub Jelinek <jakub@redhat.com>
Subject: Re: [Patch] Fortran/OpenMP: Fix strictly structured blocks parsing
Date: Wed, 24 Aug 2022 20:50:58 +0200	[thread overview]
Message-ID: <92c309c2-e962-91c1-ea87-88a3d0cf62d7@gmx.de> (raw)
In-Reply-To: <df662940-94b2-1b68-9884-b75cde55d385@codesourcery.com>

Hi Tobias,

Am 24.08.22 um 19:47 schrieb Tobias Burnus:
> This patch is about error diagnostic + an ICE for invalid code.
[...]
> (So far, so good, but then the parsing-code did run into a bug.)
>
> For the blocks, the following applies. OpenMP permits either
> * strictly structured blocks (with optional END_ST == 'end target')
>   !$omp target
>     block
>       ...
>     end block
>   !$omp end target  ! << this line is optional
> * loosely structured block
>   !$omp target
>      ... ! may not start with 'block' (and hence cannot end with 'end
> block')
>   !$omp end target  ! << required
>
>
> The parsing issue is in the following code,
> which first takes care of the 'strictly':  'end block' + optional 'end
> target'
> and then of the 'loosely structured' case with just:  'end target':
>
>       else if (block_construct && st == ST_END_BLOCK)
>         ...
>           st = next_statement ();
>           if (st == omp_end_st)
>               accept_statement (st);
>         ...
>       else if (st != omp_end_st)
>         {
>           unexpected_statement (st);
>           st = next_statement ();
>         }
>
> The fix is to change the second if condition to:
>       else if (st != omp_end_st || (block_construct && st == omp_end_st))
>
> or rather to the following equivalent code:
>       else if (st != omp_end_st || block_construct)

LGTM.

> OK for mainline and GCC 12?*

Yes for both.

Thanks for the patch!

Harald

> Tobias
>
> *strictly structured blocks were added in r12-4592.
>
>
> -----------------
> 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


      parent reply	other threads:[~2022-08-24 18:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-24 17:47 Tobias Burnus
2022-08-24 17:47 ` Tobias Burnus
2022-08-24 18:50 ` Harald Anlauf [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=92c309c2-e962-91c1-ea87-88a3d0cf62d7@gmx.de \
    --to=anlauf@gmx.de \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=tobias@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).