From patchwork Sat Dec 10 21:23:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 32097 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1499364wrr; Sat, 10 Dec 2022 13:24:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf6fQhgjFIJwUs+nFQBAl+UDuxBlJPsU/lKKB0F/IG9QtsHciJCJlZQLj2asN59YgrqfU+R5 X-Received: by 2002:a17:906:2458:b0:7c0:9a2f:ac93 with SMTP id a24-20020a170906245800b007c09a2fac93mr8450786ejb.31.1670707454685; Sat, 10 Dec 2022 13:24:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670707454; cv=none; d=google.com; s=arc-20160816; b=Ks6uevB3eG29CCNWixtZujpSICsDKljv58MNd+mXXxUmvoOHY7j1jXKJrSUFROHKa4 rj21t5543j8aYQHKCLtMdxu+5hdMtziQTOr2dxuoALn6uOZqz6XB9muQMcU4WdnSy7To XM2KdQlWkVZLlMBKinSqVwHfZx1j+J+InJ2rEP9lS+0Wbk285xoQfa23Xwjuw+Fn9Fng 9vfY+ycVD3sxV9o0zjL6kdUm/KEHrJglgTqA8Vwi3m13mJlmv2HfbslYOvzXKGiYKEOy 5B4bJgXDciLBqrsGQr34E+qbgLJAlOQhFpSLhGpRpoHcO+3dVbdMTkLSNpkR8yQcZ9as 6iag== 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=J3hMBH1ulzJc+6q2TCIyR+LATVepjqdoRlzRRdqRzq8=; b=yHH5nRTtWfkwnJcoI8KnAS9LHu7hpCOa31ou2Nk/wJ5+qcOTz6Y3883bW3PzSC3wfO FUy6aGhTg2mINYOmO3vCw5vik36DZgNGvhtDN8LAKMOOF9iMvlzrQwi+w5hGDliCvGxQ QeEtIfFrYvFfUiwznFldjUz1Z2IxAxnLD2L5zIi4F/QKG/q53zhPROfTFuYiZ1NsDXTL cavNlAbjsY0OKEtikwutzLB2ze2IW8ALhfmRQWEArZi8MVGVpCFIVDGcrA8XUie9OhNC qaAD1hc5QeIy8Eht1CpSwOu5twNd+avVOEIjUSjrGnSXWJEU05JWbLpAKhg9Pron5Sko vhaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=x8P44b+4; 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 (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id ht20-20020a170907609400b007c0fa8181c3si3490333ejc.454.2022.12.10.13.24.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Dec 2022 13:24:14 -0800 (PST) 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=x8P44b+4; 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 9E61D38500A1 for ; Sat, 10 Dec 2022 21:24:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9E61D38500A1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1670707453; bh=J3hMBH1ulzJc+6q2TCIyR+LATVepjqdoRlzRRdqRzq8=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=x8P44b+4uNV0s5PqFa0IE6ghjr3LmHh583ouyu9cUj0ko4iBCXMrMrpHzf8381XXT ku7fUgf/d5Bht8ixM9TnDfC0SAKz96Z3fMg03jyKBW/fB5Kb1Ei2GzMZkQoy915DRL mMZaTLwwHPIg6AXujhUrnXYZQs6tpQRPDkh7p/DU= 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.21]) by sourceware.org (Postfix) with ESMTPS id E6D5E38537B0; Sat, 10 Dec 2022 21:23:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E6D5E38537B0 X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [93.207.84.200] ([93.207.84.200]) by web-mail.gmx.net (3c-app-gmx-bap38.server.lan [172.19.172.108]) (via HTTP); Sat, 10 Dec 2022 22:23:26 +0100 MIME-Version: 1.0 Message-ID: To: fortran , gcc-patches Subject: [PATCH] Fortran: fix ICE on bad use of statement function [PR107995] Date: Sat, 10 Dec 2022 22:23:26 +0100 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:yFbU0u7DCZ+lTMf5K1PF9ifWUIAqxO24UXqHZz2PXLgIIxysNnCzCpU9LeIxE0X94YP3T r9xROV0LpMAwKyV7uzoxu4p5zBY89VWkW2rj9Uxmb9BooF1TYNmMUR123mTKtY6h0i2g5Ur2Vf9S zYzqhR6k4kjnCGlHk8HVuVKdHHV4wtrveRihP2AUAHzdxMR0Qr6hAaNlR+8NUkuIAJ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, 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?1751863740101058471?= X-GMAIL-MSGID: =?utf-8?q?1751863740101058471?= Dear all, I'm submitting the attached patch on behalf of Steve. It fixes an ICE that occurs on an obscure use of a statement function as argument to that function. Regtested on x86_64-pc-linux-gnu. OK for mainline? Thanks, Harald From f717054e7d656588650f6d4fd5a03840c6dc9a9c Mon Sep 17 00:00:00 2001 From: Steve Kargl Date: Sat, 10 Dec 2022 22:17:15 +0100 Subject: [PATCH] Fortran: fix ICE on bad use of statement function [PR107995] gcc/fortran/ChangeLog: PR fortran/107995 * interface.cc (gfc_check_dummy_characteristics): Reject statement function dummy arguments. gcc/testsuite/ChangeLog: PR fortran/107995 * gfortran.dg/pr107995.f90: New test. --- gcc/fortran/interface.cc | 6 ++++++ gcc/testsuite/gfortran.dg/pr107995.f90 | 10 ++++++++++ 2 files changed, 16 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr107995.f90 diff --git a/gcc/fortran/interface.cc b/gcc/fortran/interface.cc index 73799c175b7..7d8eeda5a99 100644 --- a/gcc/fortran/interface.cc +++ b/gcc/fortran/interface.cc @@ -1334,6 +1334,12 @@ gfc_check_dummy_characteristics (gfc_symbol *s1, gfc_symbol *s2, if (s1 == NULL || s2 == NULL) return s1 == s2 ? true : false; + if (s1->attr.proc == PROC_ST_FUNCTION || s2->attr.proc == PROC_ST_FUNCTION) + { + strncpy (errmsg, "Statement function", err_len); + return false; + } + /* Check type and rank. */ if (type_must_agree) { diff --git a/gcc/testsuite/gfortran.dg/pr107995.f90 b/gcc/testsuite/gfortran.dg/pr107995.f90 new file mode 100644 index 00000000000..22e878630b8 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr107995.f90 @@ -0,0 +1,10 @@ +! { dg-do compile } +! PR fortran/107995 +! Contributed by G.Steinmetz + +program p + implicit none + integer :: n ! { dg-error "Self-referential argument" } + n(n) = 1 ! { dg-warning "Statement function" } + print *, n(n) ! { dg-error "Statement function" } +end -- 2.35.3