From patchwork Fri Sep 2 19:46:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 938 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:ecc5:0:0:0:0:0 with SMTP id s5csp879163wro; Fri, 2 Sep 2022 12:47:06 -0700 (PDT) X-Google-Smtp-Source: AA6agR6+J8dihwNplc5hCBLJ81oyroB+G4o29tztuIGpEzPdjHAfXuB+vyz6h5nKRgueQ1g9dqD5 X-Received: by 2002:a17:907:1c08:b0:741:9c32:8596 with SMTP id nc8-20020a1709071c0800b007419c328596mr17110012ejc.498.1662148026756; Fri, 02 Sep 2022 12:47:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662148026; cv=none; d=google.com; s=arc-20160816; b=zQ5iFPlBcEWSTwlktibLkz6HuHygoXDXWfE37tkB5+WAnj8vfW5bGvqdBQoRNLOCr5 Bf0gI71YHwbsPYkzKDiLt0pSlmCRoP0HIn18HupSwZhGsU7RVCrRehTOIX0skKNIJoD3 q1+bdOYU2cgZ4/qip4mjREYCVRAYW1YsuuloelGVqbJikaPDdIiGxk8Vx1S0ZkTlv/95 hpT4rmjJehvI1hhadF5o0qJFmp3YCA6diNOrAu4K/+hNjx3mGoMXctAGAdn7Zn92Erys rDtVoz8UggN+ZMiXnJhH2w65sV+9vMHbIiq5H27uW1WBlx2KnrOVQtuXGC1pudS3bhI9 XSGQ== 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=pzCV67MKOqJixXnUUlXq9PMpM1fjN7poWlQbo4zZgxg=; b=PAEDgzBbpLHqRoySxq3U8oIX3nO2ZVTn/Ym0q7XKcrHz2vAD/zzVEiylN0NSUsIgtd hyQdXcdTecC57SOPjobbSHHINDQmrCZKTyanq1OfdcOx2Ve4YPvKOvk+AE3TLKA+BuLn gN0U19akDENF9/+I3S8EH6ZOSzNm0uWUL2xgUoF0eyWXWIgghyD8eK7bUTmVoKGeH//7 kaZ5Jqlco5mBgLn0/2NSzXW7YMJGeECXxaLxMVFjKLoeZ8wvvZBdlq6unnyCmaV0GRuo NB4tAxKlq3fXUIDBcw8GVIsdL19ePQ9jAZPG5SzhHhBw6QFFpB/8v7vIEBtNAnHSM+Xh FCnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=nYATz15Z; 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 qn2-20020a170907210200b0073c227a5543si2330025ejb.169.2022.09.02.12.47.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 12:47:06 -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=nYATz15Z; 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 8ED0E3858421 for ; Fri, 2 Sep 2022 19:47:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8ED0E3858421 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662148021; bh=pzCV67MKOqJixXnUUlXq9PMpM1fjN7poWlQbo4zZgxg=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=nYATz15Zncu3hSEMjjWHXtoownTLbvy1upZdNoJSX0EUpdbXIZk2LJHfZzoi03qv7 m2Cq8tWM1Nu3B76tD+VX0/J3/jiNY+pFP1yytthjVTiyisibeCV2vVZRoiktFh+aZu U8VqfdQFUROTCZNdmHnfWTenBXQ3T6+Dpq5QsZas= 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.15]) by sourceware.org (Postfix) with ESMTPS id 0E4D43858D1E; Fri, 2 Sep 2022 19:46:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0E4D43858D1E X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [79.251.1.151] ([79.251.1.151]) by web-mail.gmx.net (3c-app-gmx-bs46.server.lan [172.19.170.98]) (via HTTP); Fri, 2 Sep 2022 21:46:14 +0200 MIME-Version: 1.0 Message-ID: To: fortran , gcc-patches Subject: Proxy ping [PATCH] Fortran: Fix ICE with automatic reallocation [PR100245] Date: Fri, 2 Sep 2022 21:46:14 +0200 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:qqD48eNG1LHePEc5mbn7dQZt6rM/TNKvprsnQPezxPhrWxfuQmHcUwV51kXLFHZhSbsea kHOaeifVQZz675X4wWo8oZSm7dF8/iDlvbV19qjmEHQXYEZVH9txTlDkKbQmQlAz6sDYOOzFdk3W itMcRDJYfAzUWYcY8hzWDp1TLN3bRQmuYZFkhK1KiaDQ+eGSwj7gre2HA/7ttUhr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DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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?1742888529217624930?= X-GMAIL-MSGID: =?utf-8?q?1742888529217624930?= Dear all, Jose posted a small patch here that was never reviewed: https://gcc.gnu.org/pipermail/fortran/2021-April/055982.html IMHO the patch is fine and nearly obvious. I inquired in the PR, and Jose did not object to my handling of his patch. So - unless there are objections - I will commit the patch in the next days in the slightly corrected version as attached below (with fixed PR typo in commit message ;-). Regtested on x86_64-pc-linux-gnu. Thanks, Harald From d7e5cca20be4a4ed00705f0d577302819ad97123 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rui=20Faustino=20de=20Sousa?= Date: Fri, 2 Sep 2022 21:35:22 +0200 Subject: [PATCH] Fortran: Fix ICE with automatic reallocation [PR100245] gcc/fortran/ChangeLog: PR fortran/100245 * trans-expr.cc (trans_class_assignment): Add if clause to handle derived type in the LHS. gcc/testsuite/ChangeLog: PR fortran/100245 * gfortran.dg/PR100245.f90: New test. --- gcc/fortran/trans-expr.cc | 3 +++ gcc/testsuite/gfortran.dg/PR100245.f90 | 28 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/PR100245.f90 diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index 850007fd2e1..13c3e7df45f 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -11436,6 +11436,9 @@ trans_class_assignment (stmtblock_t *block, gfc_expr *lhs, gfc_expr *rhs, class_han = GFC_CLASS_TYPE_P (TREE_TYPE (lse->expr)) ? gfc_class_data_get (lse->expr) : lse->expr; + if (!POINTER_TYPE_P (TREE_TYPE (class_han))) + class_han = gfc_build_addr_expr (NULL_TREE, class_han); + /* Allocate block. */ gfc_init_block (&alloc); gfc_allocate_using_malloc (&alloc, class_han, size, NULL_TREE); diff --git a/gcc/testsuite/gfortran.dg/PR100245.f90 b/gcc/testsuite/gfortran.dg/PR100245.f90 new file mode 100644 index 00000000000..07c1f7b3a1c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/PR100245.f90 @@ -0,0 +1,28 @@ +! { dg-do run } +! +! Test the fix for PR100245 +! + +program main_p + + implicit none + + type :: foo_t + integer :: a + end type foo_t + + integer, parameter :: a = 42 + + class(foo_t), allocatable :: val + class(foo_t), allocatable :: rs1 + type(foo_t), allocatable :: rs2 + + allocate(val, source=foo_t(42)) + if (val%a/=a) stop 1 + rs1 = val + if (rs1%a/=a) stop 2 + rs2 = val + if (rs2%a/=a) stop 3 + deallocate(val, rs1, rs2) + +end program main_p -- 2.35.3