public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Harald Anlauf <anlauf@gmx.de>
To: Paul Richard Thomas <paul.richard.thomas@gmail.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>, fortran <fortran@gcc.gnu.org>
Subject: Re: [PATCH] PR fortran/102332 - ICE in select_type_set_tmp, at fortran/match.c:6366
Date: Tue, 28 Dec 2021 22:08:03 +0100	[thread overview]
Message-ID: <5187e5f9-fc22-be34-a671-0268f718a78b@gmx.de> (raw)
In-Reply-To: <CAGkQGiJ+hPhB1nviaTOdzUPhsT+XFEKS+=WuU1Wc+-2XtL9VmQ@mail.gmail.com>

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
>>
>>
>


WARNING: multiple messages have this Message-ID
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: Tue, 28 Dec 2021 22:08:03 +0100	[thread overview]
Message-ID: <5187e5f9-fc22-be34-a671-0268f718a78b@gmx.de> (raw)
Message-ID: <20211228210803.13OLyggH01z52oeC2zCiW_VIPoJGusJFIeEeDHV6c2A@z> (raw)
In-Reply-To: <CAGkQGiJ+hPhB1nviaTOdzUPhsT+XFEKS+=WuU1Wc+-2XtL9VmQ@mail.gmail.com>

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-28 21:08 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 [this message]
2021-12-28 21:08     ` Harald Anlauf
2021-12-29 11:45     ` Paul Richard Thomas
2021-12-29 17:25       ` Harald Anlauf
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=5187e5f9-fc22-be34-a671-0268f718a78b@gmx.de \
    --to=anlauf@gmx.de \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=paul.richard.thomas@gmail.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).