public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Kwok Cheung Yeung <kcy@codesourcery.com>
To: Jakub Jelinek <jakub@redhat.com>, Mikael Morin <morin-mikael@orange.fr>
Cc: Tobias Burnus <tobias@codesourcery.com>, <gscfq@t-online.de>,
	gcc-patches <gcc-patches@gcc.gnu.org>,
	fortran <fortran@gcc.gnu.org>
Subject: Re: [PATCH] openmp, fortran: Check that event handles passed to detach clauses are not arrays [PR104131]
Date: Mon, 28 Feb 2022 18:38:48 +0000	[thread overview]
Message-ID: <c4a524f9-4962-e36d-73ba-222b4ed33453@codesourcery.com> (raw)
In-Reply-To: <Yh0IS7FQxufDFSM2@tucnak>

On 28/02/2022 5:37 pm, Jakub Jelinek wrote:
> On Mon, Feb 28, 2022 at 06:33:15PM +0100, Mikael Morin wrote:
>>> It is true that the spots I saw in fortran/openmp.cc that test rank look
>>> like:
>>>           if (!gfc_resolve_expr (el->expr)
>>>               || el->expr->ts.type != BT_INTEGER || el->expr->rank != 0)
>>> etc., so probably !gfc_resolve_expr call is missing.
>>>
>> As long as the expression is expected to not be a (contained) function call,
>> I think it should work.
>>
>> In the general case non-syntaxic errors are preferably checked and reported
>> later at resolution stage, where contained functions are known.
> 
> Oh, I've missed that it is done during parsing and not during resolution.
> That !gfc_resolve_expr call and the checking if it is BT_INTEGER etc.
> should be certainly moved to resolve_omp_clauses.
> 

Calling gfc_resolve_expr does not work to update the rank when called 
from gfc_match_omp_detach:

(gdb) p *e->ref
$3 = {type = REF_ARRAY, u = {ar = {type = AR_ELEMENT, dimen = 0, codimen 
= 1, in_allocate = false, team = 0x0, stat = 0x0, where = {nextc = 
0x2e532d8, lb = 0x2e53260}, as = 0x2e04110, c_where = {{nextc = 0x0, lb 
= 0x0} <repeats 15 times>}, start = {0x0 <repeats 15 times>}, end = {0x0 
<repeats 15 times>}, stride = {0x0 <repeats 15 times>}, dimen_type = 
{DIMEN_THIS_IMAGE, 0 <repeats 14 times>}}, c = {component = 0x2, sym = 
0x1}, ss = {start = 0x2, end = 0x1, length = 0x0}, i = INQUIRY_KIND}, 
next = 0x0}

In gfc_expression_rank, e->ref is non-NULL, so e->rank is not set from 
the symtree. It then iterates through the ref elements - ref->type == 
REF_ARRAY and ref->u.ar.type == AR_ELEMENT, so e->rank remains at 0.

I'll move the check to resolve_omp_clauses and see if it works there.

Thanks

Kwok

  reply	other threads:[~2022-02-28 18:38 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-28 14:01 Kwok Cheung Yeung
2022-02-28 14:07 ` Jakub Jelinek
2022-02-28 14:27   ` Kwok Cheung Yeung
2022-02-28 15:54     ` Mikael Morin
2022-02-28 16:00       ` Jakub Jelinek
2022-02-28 17:33         ` Mikael Morin
2022-02-28 17:37           ` Jakub Jelinek
2022-02-28 18:38             ` Kwok Cheung Yeung [this message]
2022-02-28 20:37               ` Mikael Morin
2022-02-28 20:45                 ` Mikael Morin
2022-02-28 21:37                   ` Jakub Jelinek
2022-02-28 22:36                     ` Mikael Morin
2022-03-01  7:58                     ` Tobias Burnus
2022-03-01  8:16                       ` Jakub Jelinek
2022-03-01  9:17                         ` Tobias Burnus
2022-03-01 15:37                           ` Mikael Morin
2022-03-02 17:22                             ` [PATCH][v2] openmp, fortran: Check that the type of an event handle in a detach clause is suitable [PR104131] Kwok Cheung Yeung
2022-03-02 17:31                               ` Jakub Jelinek

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=c4a524f9-4962-e36d-73ba-222b4ed33453@codesourcery.com \
    --to=kcy@codesourcery.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gscfq@t-online.de \
    --cc=jakub@redhat.com \
    --cc=morin-mikael@orange.fr \
    --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).