From patchwork Wed Mar 22 18:30:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 73611 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp2498000wrt; Wed, 22 Mar 2023 11:31:10 -0700 (PDT) X-Google-Smtp-Source: AK7set+or6OCnWAPEdpEGLD5WoRyxcf19mi39K2WfYVoYVq6d+T4Z6ylFjJGHEOqFIhimHP98Cl7 X-Received: by 2002:a17:906:808:b0:92b:f0d9:15f3 with SMTP id e8-20020a170906080800b0092bf0d915f3mr2850229ejd.37.1679509869836; Wed, 22 Mar 2023 11:31:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679509869; cv=none; d=google.com; s=arc-20160816; b=s2btMTl0pZaR+AnzGYefZTJE+SdCs10MPA25O8/fmhcQYWR25EYWycJUuiYAsvv7E8 W+9QCYqJQyCkUILp2CfS3ZXBdL4vgN1TSJ8HvPluqcmu0gWLrwAaRYS2bgnHCA+j2RAN etfE63/uiNkYnMZ66qOIC87IXocrvMP/4u3YRF5Z3RasgiADh+xot1HP3s3o6SJ1KYlm RE8rwsy8I++6hdhJ+98YBk2BSh4AS9qS57c09pws5kVap/SycCDSO+bS/x26J+3Bpnr1 z4+X97Vhi6Fd2YOgbALKkbdQdl16+gC/S5jL43tPhNeLwXTt7B78aeFsNi4xweBxNZQm qA+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:ui-outboundreport :sensitivity:importance:date:subject:to:message-id:mime-version :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=1gCHz41ZPkldF/bnn5uxp5mEegPan/hLaRx5oDZ14dA=; b=Pwb8Y93ae3tIAvjk0Aqat/mf34W7PToy6QgET1jMnxFGeVjg5lgNq7PwgVqHxqCAfI MjHMw+65zu04m1DvKl7pJDhZ/8oJpdquNiGX8kHKTrRQedeuZQYvSN6sTUcN55aLFUBF I8YFqsyoz1nZhXtekAFpTUglW51bRvSKajAV62jzmWHiABEWTbVwh44St9gkn0DaDDIG 1CxrH03Wu11Vcp+g1Wfe/70C6Bh5HuQ0m4+apsft4doQkOoY+8rMB3WR65bIveLQmRAd pr/tsUeHDySxmEHDhJINsRaV1GEdxc9HW5PDu3xH9dJzzlCjZKjXGaEUCrQIWjNrJQB4 yujg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Z3IarB86; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id h7-20020a1709067cc700b00925e679dea3si10232911ejp.689.2023.03.22.11.31.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Mar 2023 11:31:09 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Z3IarB86; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D28F2385843D for ; Wed, 22 Mar 2023 18:31:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D28F2385843D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679509868; bh=1gCHz41ZPkldF/bnn5uxp5mEegPan/hLaRx5oDZ14dA=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Z3IarB86CsP/lY7UQH6Uw3myo0mHUcdf9IHQwWuwlk1A1AKq7sPtwnFuy1HSF5wIN l7lkfBhcRSPyVrcQp3z2NWkhCCrW8K4KrpzNVnqXts1NNeOhnMRtYkeYGlJdodGwua X3tB9r5kIT7SP95CeJvBKD8BqPr3ON6KPvNtZICA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by sourceware.org (Postfix) with ESMTPS id A6CEE3858436; Wed, 22 Mar 2023 18:30:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A6CEE3858436 X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [93.207.81.6] ([93.207.81.6]) by web-mail.gmx.net (3c-app-gmx-bap55.server.lan [172.19.172.125]) (via HTTP); Wed, 22 Mar 2023 19:30:23 +0100 MIME-Version: 1.0 Message-ID: To: fortran , gcc-patches Subject: [PATCH, committed] Fortran: improve checking of FINAL subroutine arguments [PR104572] Date: Wed, 22 Mar 2023 19:30:23 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:k4k7zSxG4zlbkbhNgbAyjNeWvmmHHEIQS9vYeWDIA6PWxBxssHBICL3sONsxaZJz5x6L3 IuCRkIgDAeLv0KT+eOSH9/TEHkPX6/YeeLy/kCxhs3acGlix82EYwp9JjZwGjjHPmci/hl+hbInr 4Fd5ZBTgj8Gt2Sow1d9j5asif2ajLPF6SJJW6h5WXFrfmirK4LarQhp5t+kplCIwx25KVArPJ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M_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Harald Anlauf via Gcc-patches From: Harald Anlauf Reply-To: Harald Anlauf Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761093741190679596?= X-GMAIL-MSGID: =?utf-8?q?1761093741190679596?= Dear all, I've committed the attached simple patch after discussion with Steve (see PR). We need to reject alternate return arguments of FINAL subroutines. Regtested on x86_64-pc-linux-gnu. Thanks, Harald From 3e791f45ded89626bc1f9f8013728f6e035801b2 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Wed, 22 Mar 2023 19:20:41 +0100 Subject: [PATCH] Fortran: improve checking of FINAL subroutine arguments [PR104572] gcc/fortran/ChangeLog: PR fortran/104572 * resolve.cc (gfc_resolve_finalizers): Argument of a FINAL subroutine cannot be an alternate return. gcc/testsuite/ChangeLog: PR fortran/104572 * gfortran.dg/pr104572.f90: New test. Co-authored-by: Steven G. Kargl --- gcc/fortran/resolve.cc | 7 +++++++ gcc/testsuite/gfortran.dg/pr104572.f90 | 14 ++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr104572.f90 diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 1a03e458d99..f6ec76acb0b 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -13986,6 +13986,13 @@ gfc_resolve_finalizers (gfc_symbol* derived, bool *finalizable) } arg = dummy_args->sym; + if (!arg) + { + gfc_error ("Argument of FINAL procedure at %L must be of type %qs", + &list->proc_sym->declared_at, derived->name); + goto error; + } + if (arg->as && arg->as->type == AS_ASSUMED_RANK && ((list != derived->f2k_derived->finalizers) || list->next)) { diff --git a/gcc/testsuite/gfortran.dg/pr104572.f90 b/gcc/testsuite/gfortran.dg/pr104572.f90 new file mode 100644 index 00000000000..59fd688d798 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr104572.f90 @@ -0,0 +1,14 @@ +! { dg-do compile } +! { dg-additional-options "-w" } +! PR fortran/104572 - ICE in gfc_resolve_finalizers +! Contributed by G. Steinmetz + +module m + type t + contains + final :: s + end type +contains + subroutine s(*) ! { dg-error "Argument of FINAL procedure" } + end +end -- 2.35.3