From patchwork Tue Oct 4 19:27:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 1701 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp276316wrs; Tue, 4 Oct 2022 12:27:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5E4Zd7ttIMvSIBuW8kvDBvCJiftMRDxcX2CSOpJJ1nPbxGfreCOEeKUJvxjHE+dXVWr7iI X-Received: by 2002:a17:907:3f26:b0:78d:1b32:bf85 with SMTP id hq38-20020a1709073f2600b0078d1b32bf85mr3281440ejc.628.1664911679288; Tue, 04 Oct 2022 12:27:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664911679; cv=none; d=google.com; s=arc-20160816; b=epWSeipFdZbZosUsZAHI5dZtudS8U3rT3TGm+sdryDz5CW87DNGDLXk2WD+F3wx7jv 8XDLhlyvcpiCiGmTfyXW1YYhxtP11/cDQpZVk4e7j1iRdU/Y7x3i0/L9mZT3QKAZLsTJ 39PQsHGyyq0hK3/cjohjzUQ2JX40NOjlzSM09yPG95FAPHPwIOIFZbU4ns49fUd+/19a ly4McpDWr0XIWFM3uhhV90gOlHW38NoYgSoUSuHb98lN3R+hsiLdAfXtQ+6XCEh328Iq qN8dbUOTpyVNheIsJjeEc1z8Sl6Qz+2fJnDhdDGnRbjIK+WxY/KNSGX6b+aOrWXDwCz2 5Z+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:sensitivity :importance:date:subject:to:message-id:mime-version:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=sklRSGh9dF4wW+Uh0K2Rqn4wGgssA11ctpZr60/YucM=; b=QNpDC3wyt8en2bj+htJHlNacpSyZB0k+YX0MfE09Zg19cmAAXIecvjJby/cjc2lKzc hqUy/+w0RKTvDa3HEyagTwmzzWV/9dlrsJ4Q+yVgSEyggjpl4YSbtrt3B740i7YgwPMJ sNupQ8f5+6rdZCkFzR/pBfW2ZasucWq2Yuk499digjAEj4IH4IrUJ+DWsrsVaT2rlfT+ I79sCBQ9jUpNZy+rTqnnIyEx4a36lWjQTS5tVC8HZFeYFiZp3NbAYzhB/fa/yS1fwt3F nOnpRBHLtZip9u2Usw+tPt5SW6WFpF2XxXafs2x+IBsFqeDwirGgk4sLIx5t59cN/aSP O6ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ue829F6R; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id g12-20020a1709065d0c00b0078aeb7747c0si6729873ejt.640.2022.10.04.12.27.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Oct 2022 12:27:59 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ue829F6R; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 17FDF3858424 for ; Tue, 4 Oct 2022 19:27:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 17FDF3858424 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664911678; bh=sklRSGh9dF4wW+Uh0K2Rqn4wGgssA11ctpZr60/YucM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ue829F6RgU596lSCnSlnQe87Bc8M8M8zxTVZGevwtEuh7aS+Qi0nqr43mbaqPT7Yq iEW7BhOGHSYxahzVIsMv1d85wqSXhR2zmSn3E/TjK7YFOve2A+xJ79lk0b8S3F0uSi JaYCrMt6jgAVGGe2kOD0vd0kk4y8SLX+2M66kIiQ= 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.15.19]) by sourceware.org (Postfix) with ESMTPS id 32E933858D39; Tue, 4 Oct 2022 19:27:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 32E933858D39 X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [93.207.82.142] ([93.207.82.142]) by web-mail.gmx.net (3c-app-gmx-bs14.server.lan [172.19.170.66]) (via HTTP); Tue, 4 Oct 2022 21:27:11 +0200 MIME-Version: 1.0 Message-ID: To: fortran , gcc-patches Subject: [PATCH] Fortran: reject procedures and procedure pointers as output item [PR107074] Date: Tue, 4 Oct 2022 21:27:11 +0200 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:hsDUaRgVJc0cEg4rT4fZdIg6aYsowsNDfjbkzmjQh5IVGfOV3HxAduilU7s6sk9T13siu UBFafOuiwW3eGH6mJI73UCZmYrxRSHZ1M2PqEUx0WzEsZdOKheQ2Z0BnGzn6yaMdDhWgDiuu7N9T ZnGY4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DKIM_VALID, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, 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?1745786428720094978?= X-GMAIL-MSGID: =?utf-8?q?1745786428720094978?= Dear all, when looking at output item lists we didn't catch procedures and procedure pointers and ran into a gfc_internal_error(). Such items are not allowed by the Fortran standard, e.g. for procedure pointers there is C1233 (R1217) An expression that is an output-item shall not have a value that is a procedure pointer. Attached patch generates an error instead. Regtested on x86_64-pc-linux-gnu. OK for mainline? Thanks, Harald From 3b15fe83830c1e75339114e0241e9d2158393017 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Tue, 4 Oct 2022 21:19:21 +0200 Subject: [PATCH] Fortran: reject procedures and procedure pointers as output item [PR107074] gcc/fortran/ChangeLog: PR fortran/107074 * trans-io.cc (transfer_expr): A procedure or a procedure pointer cannot be output items. gcc/testsuite/ChangeLog: PR fortran/107074 * gfortran.dg/pr107074.f90: New test. --- gcc/fortran/trans-io.cc | 14 ++++++++++++++ gcc/testsuite/gfortran.dg/pr107074.f90 | 11 +++++++++++ 2 files changed, 25 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr107074.f90 diff --git a/gcc/fortran/trans-io.cc b/gcc/fortran/trans-io.cc index 9f86815388c..c4e1537eed6 100644 --- a/gcc/fortran/trans-io.cc +++ b/gcc/fortran/trans-io.cc @@ -2430,6 +2430,20 @@ transfer_expr (gfc_se * se, gfc_typespec * ts, tree addr_expr, break; + case BT_PROCEDURE: + if (code->expr1 + && code->expr1->symtree + && code->expr1->symtree->n.sym) + { + if (code->expr1->symtree->n.sym->attr.proc_pointer) + gfc_error ("Procedure pointer at %C cannot be an output item"); + else + gfc_error ("Procedure at %C cannot be an output item"); + return; + } + /* If a PROCEDURE item gets through to here, fall through and ICE. */ + gcc_fallthrough (); + case_bt_struct: case BT_CLASS: if (gfc_bt_struct (ts->type) || ts->type == BT_CLASS) diff --git a/gcc/testsuite/gfortran.dg/pr107074.f90 b/gcc/testsuite/gfortran.dg/pr107074.f90 new file mode 100644 index 00000000000..a09088c2e9d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr107074.f90 @@ -0,0 +1,11 @@ +! { dg-do compile } +! PR fortran/107074 - ICE: Bad IO basetype (8) +! Contributed by G.Steinmetz + +program p + implicit none + integer, external :: a + procedure(real), pointer :: b + print *, merge (a, a, .true.) ! { dg-error "Procedure" } + print *, merge (b, b, .true.) ! { dg-error "Procedure pointer" } +end -- 2.35.3