From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ciao.gmane.io (ciao.gmane.io [116.202.254.214]) by sourceware.org (Postfix) with ESMTPS id DB2A03858421 for ; Tue, 21 Mar 2023 19:10:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DB2A03858421 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=m.gmane-mx.org Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1pehN4-000AU2-SD for gcc-patches@gcc.gnu.org; Tue, 21 Mar 2023 20:10:10 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: gcc-patches@gcc.gnu.org From: Harald Anlauf Subject: Re: [PATCH] Fortran: reject MODULE PROCEDURE outside generic module interface [PR99036] Date: Tue, 21 Mar 2023 20:10:02 +0100 Message-ID: <61b37dce-036e-62b5-8993-9bbf848a677c@gmx.de> References: <7f9d0dc1-21d8-5b55-dc66-a12a5f8c114a@codesourcery.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Content-Language: en-US In-Reply-To: <7f9d0dc1-21d8-5b55-dc66-a12a5f8c114a@codesourcery.com> Cc: fortran@gcc.gnu.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,BODY_8BITS,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,GIT_PATCH_0,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,KAM_SHORT,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Message-ID: <20230321191002.FMbAEsKCRMMKKviVNuo9jdOJXiKdIeY5g6Wr1h56LNg@z> 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 >