public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Harald Anlauf <anlauf@gmx.de>
To: fortran@gcc.gnu.org
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] PR fortran/102332 - ICE in select_type_set_tmp, at fortran/match.c:6366
Date: Wed, 29 Dec 2021 18:25:12 +0100	[thread overview]
Message-ID: <7fe59cf4-873f-7ccf-556e-5aacf51defdf@gmx.de> (raw)
Message-ID: <20211229172512.KQWcBN6ASJMi8cRjpEi-hmcpgtpXa4jW8M7DZtZupv8@z> (raw)
In-Reply-To: <CAGkQGi+YbssaJ2D6maP64qkmQcQeHmDy6k8SHy5i4m8kxaQO9w@mail.gmail.com>

Hi Paul,

Am 29.12.21 um 12:45 schrieb Paul Richard Thomas via Fortran:
> Hi Harald,
> 
> That is the sort of thing that I had in mind. Is it worth adding the check
> for CLASS_DATA? I cannot remember if that is made redundant by the test of
> the class_ok attribute.

the macro CLASS_DATA appears to have been introduced by Janus
as a shortcut to the data component.  Accesses to the data
component still may require a protecting prior check when we
are confronted with random bad user code, as I sometimes see
sym->attr.class_ok == 1 but still sym->ts.u.derived == NULL.

Shall we open a PR for tracking issues with (the lack of)
canonical checking when CLASS is involved?  Where we could
collect ideas about macros that make the code more readable
and robust?  (I believe some PRs involving "associate" need
similar treatment in several places.)

Of course that would be something for post 12-release.

Cheers,
Harald

> Cheers
> 
> Paul
> 
> 
> On Tue, 28 Dec 2021 at 21:08, Harald Anlauf <anlauf@gmx.de> wrote:
> 
>> Hi Paul,
>>
>> Am 28.12.21 um 12:56 schrieb Paul Richard Thomas via Fortran:
>>> Hi Harald,
>>>
>>> This looks good to me. OK for mainline and, dare I suggest, 11-branch?
>>>
>>>   From a quick run through resolve.c, there are many places where the
>> extra
>>> checks that you introduced in the patch have been implemented. This makes
>>> me wonder whether a function or macro might not make the relevant code
>> more
>>> concise.
>>
>> I had thought about this in the past, too.  Suitably chosen macros
>> could help to make checking not only more concise, but also more
>> robust and (hopefully) readable at the same time.
>>
>> What do you think about e.g.
>>
>>
>> diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
>> index e5d2dd7971e..f3d22b46a75 100644
>> --- a/gcc/fortran/gfortran.h
>> +++ b/gcc/fortran/gfortran.h
>> @@ -3885,6 +3885,8 @@ bool gfc_is_finalizable (gfc_symbol *, gfc_expr **);
>>            && CLASS_DATA (sym) \
>>            && CLASS_DATA (sym)->attr.dimension \
>>            && !CLASS_DATA (sym)->attr.class_pointer)
>> +#define IS_CLASS_OBJ(sym) \
>> +       (sym->ts.type == BT_CLASS && sym->attr.class_ok)
>>
>>    /* frontend-passes.c */
>>
>>
>> to be used to ensure that we are dealing with a CLASS object where
>> attributes should already have been set up?  Or use a better name?
>> (IS_CLASS_OBJECT?)
>>
>> Thanks,
>> Harald
>>
>>> Thanks for the patch
>>>
>>> Paul
>>>
>>>
>>> On Mon, 27 Dec 2021 at 22:17, Harald Anlauf via Fortran <
>> fortran@gcc.gnu.org>
>>> wrote:
>>>
>>>> Dear all,
>>>>
>>>> there are a couple of NULL pointer dereferences leading to improper
>>>> error recovery when trying to handle Gerhard's testcases involving
>>>> SELECT TYPE and invalid uses of CLASS variables.
>>>>
>>>> The fixes look pretty obvious to me, but I'm submitting here to
>>>> check if there is more that should be done here.
>>>>
>>>> (I was surprised to see that there are several different places
>>>> involved by rather simple variations in the basic test case.)
>>>>
>>>> Regtested on x86_64-pc-linux-gnu.  OK for mainline?
>>>>
>>>> Thanks,
>>>> Harald
>>>>
>>>>
>>>
>>
>>
> 



  reply	other threads:[~2021-12-29 17:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-27 22:17 Harald Anlauf
2021-12-28 11:56 ` Paul Richard Thomas
2021-12-28 21:08   ` Harald Anlauf
2021-12-28 21:08     ` Harald Anlauf
2021-12-29 11:45     ` Paul Richard Thomas
2021-12-29 17:25       ` Harald Anlauf [this message]
2021-12-29 17:25         ` Harald Anlauf

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=7fe59cf4-873f-7ccf-556e-5aacf51defdf@gmx.de \
    --to=anlauf@gmx.de \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    /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).