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>,
	fortran <fortran@gcc.gnu.org>,
	gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Fortran: reject MODULE PROCEDURE outside generic module interface [PR99036]
Date: Tue, 21 Mar 2023 20:10:02 +0100	[thread overview]
Message-ID: <61b37dce-036e-62b5-8993-9bbf848a677c@gmx.de> (raw)
In-Reply-To: <7f9d0dc1-21d8-5b55-dc66-a12a5f8c114a@codesourcery.com>

Hi Tobias,

Am 21.03.23 um 09:31 schrieb Tobias Burnus:
> On 20.03.23 21:57, Harald Anlauf via Gcc-patches wrote:
>> --- a/gcc/fortran/decl.cc
>> +++ b/gcc/fortran/decl.cc
>> @@ -9998,6 +9998,7 @@ gfc_match_modproc (void)
>>     if ((gfc_state_stack->state != COMP_INTERFACE
>>          && gfc_state_stack->state != COMP_CONTAINS)
>>         || gfc_state_stack->previous == NULL
>> +      || !current_interface.type
>>         || current_interface.type == INTERFACE_NAMELESS
>>         || current_interface.type == INTERFACE_ABSTRACT)
>>       {
>
> First, I do not like '!var' comparisons for enum values,
> only for Booleans/logicals and pointer.

I was hesitating to do this and thought about adding an
enum value that it 0 numerically, but ...

> Secondly, I am not sure that it is really guaranteed that
> the value is 0.

... had assumed that this would be guaranteed.

> I think something like the following makes more sense
> and, as just tried, it also regtests (w/ your testcase included).
> If you agree, feel free to package and commit it.
>
>
> diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc
> index c8f0bb83c2c..233bf244d62 100644
> --- a/gcc/fortran/decl.cc
> +++ b/gcc/fortran/decl.cc
> @@ -9996,7 +9996,8 @@ gfc_match_modproc (void)
>     gfc_interface *old_interface_head, *interface;
>
> -  if ((gfc_state_stack->state != COMP_INTERFACE
> -       && gfc_state_stack->state != COMP_CONTAINS)
> -      || gfc_state_stack->previous == NULL
> +  if (gfc_state_stack->previous == NULL
> +      || (gfc_state_stack->state != COMP_INTERFACE
> +         && (gfc_state_stack->state != COMP_CONTAINS
> +             || gfc_state_stack->previous->state != COMP_INTERFACE))
>         || current_interface.type == INTERFACE_NAMELESS
>         || current_interface.type == INTERFACE_ABSTRACT)
>

Yes, that's a much cleaner solution.  Pushed as:

https://gcc.gnu.org/g:dd282b16bfd3c6e218dffb7798a375365b10ae22
commit r13-6790-gdd282b16bfd3c6e218dffb7798a375365b10ae22

Thanks for the review!

Harald


> Thanks for working on this and all the other issues!
>
> Tobias
>
> -----------------
> 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
>


WARNING: multiple messages have this Message-ID
From: Harald Anlauf <anlauf@gmx.de>
To: gcc-patches@gcc.gnu.org
Cc: fortran@gcc.gnu.org
Subject: Re: [PATCH] Fortran: reject MODULE PROCEDURE outside generic module interface [PR99036]
Date: Tue, 21 Mar 2023 20:10:02 +0100	[thread overview]
Message-ID: <61b37dce-036e-62b5-8993-9bbf848a677c@gmx.de> (raw)
Message-ID: <20230321191002.FMbAEsKCRMMKKviVNuo9jdOJXiKdIeY5g6Wr1h56LNg@z> (raw)
In-Reply-To: <7f9d0dc1-21d8-5b55-dc66-a12a5f8c114a@codesourcery.com>

Hi Tobias,

Am 21.03.23 um 09:31 schrieb Tobias Burnus:
> On 20.03.23 21:57, Harald Anlauf via Gcc-patches wrote:
>> --- a/gcc/fortran/decl.cc
>> +++ b/gcc/fortran/decl.cc
>> @@ -9998,6 +9998,7 @@ gfc_match_modproc (void)
>>     if ((gfc_state_stack->state != COMP_INTERFACE
>>          && gfc_state_stack->state != COMP_CONTAINS)
>>         || gfc_state_stack->previous == NULL
>> +      || !current_interface.type
>>         || current_interface.type == INTERFACE_NAMELESS
>>         || current_interface.type == INTERFACE_ABSTRACT)
>>       {
> 
> First, I do not like '!var' comparisons for enum values,
> only for Booleans/logicals and pointer.

I was hesitating to do this and thought about adding an
enum value that it 0 numerically, but ...

> Secondly, I am not sure that it is really guaranteed that
> the value is 0.

... had assumed that this would be guaranteed.

> I think something like the following makes more sense
> and, as just tried, it also regtests (w/ your testcase included).
> If you agree, feel free to package and commit it.
> 
> 
> diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc
> index c8f0bb83c2c..233bf244d62 100644
> --- a/gcc/fortran/decl.cc
> +++ b/gcc/fortran/decl.cc
> @@ -9996,7 +9996,8 @@ gfc_match_modproc (void)
>     gfc_interface *old_interface_head, *interface;
> 
> -  if ((gfc_state_stack->state != COMP_INTERFACE
> -       && gfc_state_stack->state != COMP_CONTAINS)
> -      || gfc_state_stack->previous == NULL
> +  if (gfc_state_stack->previous == NULL
> +      || (gfc_state_stack->state != COMP_INTERFACE
> +         && (gfc_state_stack->state != COMP_CONTAINS
> +             || gfc_state_stack->previous->state != COMP_INTERFACE))
>         || current_interface.type == INTERFACE_NAMELESS
>         || current_interface.type == INTERFACE_ABSTRACT)
> 

Yes, that's a much cleaner solution.  Pushed as:

https://gcc.gnu.org/g:dd282b16bfd3c6e218dffb7798a375365b10ae22
commit r13-6790-gdd282b16bfd3c6e218dffb7798a375365b10ae22

Thanks for the review!

Harald


> Thanks for working on this and all the other issues!
> 
> Tobias
> 
> -----------------
> 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
> 



  reply	other threads:[~2023-03-21 19:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-20 20:57 Harald Anlauf
2023-03-21  7:09 ` Paul Richard Thomas
2023-03-21  8:31 ` Tobias Burnus
2023-03-21 19:10   ` Harald Anlauf [this message]
2023-03-21 19:10     ` 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=61b37dce-036e-62b5-8993-9bbf848a677c@gmx.de \
    --to=anlauf@gmx.de \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --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).