From patchwork Sun Oct 9 18:57:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 1839 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1264602wrs; Sun, 9 Oct 2022 11:58:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4oJXcooV0+2cJs4nPdGdSmOpz7+gMcKhAfIX7DN5/OBLUJ4sEECkf+lBfDFOGyH8Y0r2AS X-Received: by 2002:a17:907:743:b0:740:ef93:2ffc with SMTP id xc3-20020a170907074300b00740ef932ffcmr12033572ejb.514.1665341892329; Sun, 09 Oct 2022 11:58:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665341892; cv=none; d=google.com; s=arc-20160816; b=gUzk5qYS8I/O9FiHeqQDSTf21ZH2bCqDXZrxDwlSBF+/c+McdEA7ZP9iHFS0RQHntX nd02AujOEBU9HP62yZDk+drcuqtGKmgYJiCBGtYTNhXaAZASo4HFTrftknDW4MPZZFwm ABpg6PPws8UhL2zWsHhUEhZ73JnqR2jAXdG//brZp5uCmRKEpa1vReOFULsTqJYenrhs ckASeIiG8YcWJkx3J4qXY6pKenoYtMmUZdjgKNQt9cpSYa4zBe0BxaWFi/uunyR3KJxy XNXOwo8mTddLKPuYbLYxt0X6y4nxsgymKxls3+4hfZO0yF1a1psXS6nxBxAgLqt/dfxK P23Q== 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=YXyzNZTvTVlXA2yEzaALfCi6mqVyPCL+adVoSVBrNGg=; b=JtdtEvh2wHkzmVJPBSFIr1SbSpQuaRc+csmPpWTwK3gTax7DrYSirVHuOF4jMk3W2w i8TwkIHccdG1SF5okA/7hHi0VvpNfG10uZy2c5xJwMNEWDb7WqXCOKFSGA0Bp+V0kOWx uGvDUcb2tl65n+wLvEJ7SaDW3YeauxPFC/lY6oSgamn9OOKGoTaIsz7DePdEbsoy8Odo 0SbwX2b05CXzfCIYyQaoOt/rO6JqOIQ/UffYBF4V6CZi2U0otpx0M7m6eKA6H4Sw5ReA ZNFbdZL2PT5Rev5h8v2vSc9yOpo3ywYeefvs5tYt7n5q43d4Z2sl16dq7kZnYIt/aU4y aslg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=BjqL+Bhp; 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 w12-20020a05640234cc00b0044f3b9ef98bsi10143708edc.27.2022.10.09.11.58.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Oct 2022 11:58:12 -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=BjqL+Bhp; 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 8B1433857B9A for ; Sun, 9 Oct 2022 18:58:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8B1433857B9A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665341887; bh=YXyzNZTvTVlXA2yEzaALfCi6mqVyPCL+adVoSVBrNGg=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=BjqL+BhpWCh1Wi0RBCzhmyTdHKEKLFwrqKUWZ5q82gHIgVy4/MtzoDK413N5qDzLX yK4H21tvZr23gdGQ53Hilinzz3EqN31hPLVEiWKP5DpoK2ZkO+jBmX8dYBL7fQFUrD o5sEJMGWVjVfNbhwbS1giLr+aakoh+M+4OMxlp5Q= 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 83D173858D1E; Sun, 9 Oct 2022 18:57:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 83D173858D1E X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [79.251.13.236] ([79.251.13.236]) by web-mail.gmx.net (3c-app-gmx-bs08.server.lan [172.19.170.59]) (via HTTP); Sun, 9 Oct 2022 20:57:06 +0200 MIME-Version: 1.0 Message-ID: To: fortran , gcc-patches Subject: [PATCH] Fortran: fix check of polymorphic elements in data transfers [PR100971] Date: Sun, 9 Oct 2022 20:57:06 +0200 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:AOQhonKmQXyFqmW7TnACei3iv8qjMnaFhCWWATrUuDnCloP8AKb0yJx+f4X5zGbTa9Fyc /3exDRUdwQwEfIwm5j0b7vdDjo9CYhDp7g8mrroEqqfeprQHxXE4y3ItomGYZ12VGwrUABbc4JpW izShPpiPMvZEm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Kpjwu1xLTe8M tmTf2RiLWiZbhfljyBbxMYpbOb4yEDdtX25ZzFQA1UQZkVOPIy0TotDMlafoKYZTgWDhGxxmm ffWqXG8CM1wA41IdB53kdt3kBpJfWBE1fa6cqMxB7zSH1nzojn49dQ2Ia1wwMdZ4JZo3rrb+H DieUhfkNgHfdUBfFWBjn8dzuRVuaW06FxdToXnjLM+22QS9mHCk61wR7iwnbCxH0fclVO17Pk Zlw0sExLJFFzi4Vdlim9fUVpn5GXww8uq+PNGXfqTDzRbYoEeXbucKnGrpaV8+KZeud0z90zU MUkl45yLUGJYjIRqowAGP6Gxiqwd6ACUFzvTb90ooQyK3kBfKlliu9tuxCgwgGAFaILjnXSBL FPaaFX/6nBjkrhxtWjO5s0CcdMfIyEvd2qwiWsr9DukSfDGuTP5MwaJlOkwIVJfWe/XjecCuU eCrLdLTc X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, 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?1746237540128459681?= X-GMAIL-MSGID: =?utf-8?q?1746237540128459681?= Dear all, the check of data transfer elements needs to verify that for polymorphic objects there is a user defined DTIO procedure. This check worked fine for scalars, but skipped arrays, leading to an ICE later. The obvious fix is to allow this check to inspect arrays. Regtested on x86_64-pc-linux-gnu. OK for mainline? Thanks, Harald From 4db0aba8309a2c7e2c7ac95195621dff02e9796c Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Sun, 9 Oct 2022 20:43:32 +0200 Subject: [PATCH] Fortran: fix check of polymorphic elements in data transfers [PR100971] gcc/fortran/ChangeLog: PR fortran/100971 * resolve.cc (resolve_transfer): Extend check for permissibility of polymorphic elements in a data transfer to arrays. gcc/testsuite/ChangeLog: PR fortran/100971 * gfortran.dg/der_io_5.f90: New test. --- gcc/fortran/resolve.cc | 5 +++++ gcc/testsuite/gfortran.dg/der_io_5.f90 | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/der_io_5.f90 diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index d133bc2d034..9202e2f10ad 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -10017,6 +10017,7 @@ resolve_transfer (gfc_code *code) if (exp == NULL || (exp->expr_type != EXPR_VARIABLE && exp->expr_type != EXPR_FUNCTION + && exp->expr_type != EXPR_ARRAY && exp->expr_type != EXPR_STRUCTURE)) return; @@ -10030,6 +10031,7 @@ resolve_transfer (gfc_code *code) const gfc_typespec *ts = exp->expr_type == EXPR_STRUCTURE || exp->expr_type == EXPR_FUNCTION + || exp->expr_type == EXPR_ARRAY ? &exp->ts : &exp->symtree->n.sym->ts; /* Go to actual component transferred. */ @@ -10128,6 +10130,9 @@ resolve_transfer (gfc_code *code) if (exp->expr_type == EXPR_STRUCTURE) return; + if (exp->expr_type == EXPR_ARRAY) + return; + sym = exp->symtree->n.sym; if (sym->as != NULL && sym->as->type == AS_ASSUMED_SIZE && exp->ref diff --git a/gcc/testsuite/gfortran.dg/der_io_5.f90 b/gcc/testsuite/gfortran.dg/der_io_5.f90 new file mode 100644 index 00000000000..193916c4a65 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/der_io_5.f90 @@ -0,0 +1,17 @@ +! { dg-do compile } +! PR fortran/100971 - ICE: Bad IO basetype (7) +! Contributed by G.Steinmetz + +program p + implicit none + type t + end type + class(t), allocatable :: a, b(:) + type(t) :: x, y(1) + integer :: i + allocate (a,b(1)) + print *, [a] ! { dg-error "Data transfer element at .1. cannot be polymorphic" } + print *, [(b(i),i=1,1)] ! { dg-error "Data transfer element at .1. cannot be polymorphic" } + print *, [x] + print *, [(y(i),i=1,1)] +end -- 2.35.3