From patchwork Wed Apr 24 16:26:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Richard Thomas X-Patchwork-Id: 1927279 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=cm/oTJ6a; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VPkt74wzsz1yZr for ; Thu, 25 Apr 2024 02:27:41 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 18AC1384770C for ; Wed, 24 Apr 2024 16:27:40 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id 92D36385840D; Wed, 24 Apr 2024 16:27:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 92D36385840D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 92D36385840D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::435 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713976036; cv=none; b=Ymab0mlSUCCQeOezu+q4tHbnHw6tKiLz9SGaPTbaLCJUhbd8fv4P6sWM/Hgrx3jO7ldgrp4MDtkm8Xy+nq53avxhLNeCCFDopIrcXb2yWOKlr0b5Wnc56685ZmGfKOHsUVanH3asY0MmRYRJKoWCATaVz9jkfy6bcH2kZq5XQrk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713976036; c=relaxed/simple; bh=UZaSI9jZTO/YYZhm3IwoTW2STxzxmbjSjHroowQ7xxQ=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=jb9trjTBAwyi559/T3KMaUAka+usrDwujEkybpzN8lnzSzc+pVkN6CmS4zfeFcG2HU4s9yQ1zhDInnMf3REzuvpU+YId28vSO6D70wJh9TgHJQAb2vSO5dZljNev5pO79JDBip/9rzYUoxEhExSZHYSgg5CsG5ssD+ARrYmFJbg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-6ed2dc03df6so91266b3a.1; Wed, 24 Apr 2024 09:27:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713976032; x=1714580832; darn=gcc.gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=iaH6aSRxpS5Naj5fo8kkarL13Kx7pIfayQa6YnZRPEs=; b=cm/oTJ6aeH/+uAUVF/og6qqJTwkrCYZUaeIQqBDNkpPI8/9xk+BcbLDXnEnSu0lrtN gaBdej1whmR+PLyWqjVaR99HYLX4cu5/QkgRPeDZDdol985ENrcjroELSDd4bZverDpY 5LtmbBuHuxSHVmNf/iwx8+vJpXN0yTs4iXQbr5//sKg3XW2lSicSMzOz35tJ2lu2d/db YQDMf7QEInLKBqI1bcXKppf6WGiPahdrWLwh3n2Ujs4skTZTBtjd82V7eCbCte0mb2m2 Ubv4Ond4ibZgc7bDLntOTSHaMrqufNYXxkuihGTXzz2dmXroCFbo2opCoOT6s8TZhEo+ jywg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713976032; x=1714580832; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=iaH6aSRxpS5Naj5fo8kkarL13Kx7pIfayQa6YnZRPEs=; b=pn7a/txk1SS28AqCJYghUJjomRnlmAA7WFl8pQr4o3WUJ/loTUaaFeL01IrH6JHN0w gDBXCgSiH7u/Dm6lT05I15sTtP0x9Ai+F5MlWw+oEiKuIJbi+4aJV2TVqjiIVeXGWzqb 4TC+Mekcs8PQpe4Te/Y0jzGTGFkfY8irsQMtH2uVRLnbRKlJdkmvMqeArPOBX4QWJFP0 VX+F85Tb7w/M1gNSrJ8dlwp9OCUPN8mL6Z81VrXo95lZ9rgiAJYnJ2ALSwgP2xzMjXFQ rvu6lUPlcgW48aT7UrzuhK6k3Jy/jh74BKdVhAWuSmvxN1h7UKugIOiQVzDJQfENwIY6 +chw== X-Forwarded-Encrypted: i=1; AJvYcCWTNpyEij5kNcAZruitN6aYC4flcqti2riHqbkBlR+2ZyPgbON3/U+FgHJ+OIr4kzONMgnN/4T+/grTjkD1YmMgSNYKC0wD7A== X-Gm-Message-State: AOJu0YyPl6lD0snwHcsNEAivPrPHCaIK5QYMOjNpIztuTpv5k836l146 DKQL8iB6mDb13lnbhK+eAPaZMZcWSCmd/NvMfzN2PaT/w1FksEGfBOS+VPSzzB6k0NHT8Q08xnJ F0j9OOeO2QUFs+SyYvxzFHUuv2Ff24cwX X-Google-Smtp-Source: AGHT+IGr+XJ6V/LavducBlb4lFVepH4pP43Bp35qnwomU5T8BY2fiZH03uiUm584mk9zfhEGquvUz+pENL9Kd5v1SEo= X-Received: by 2002:a05:6a20:9788:b0:1a7:3b4b:4153 with SMTP id hx8-20020a056a20978800b001a73b4b4153mr3054364pzc.58.1713976031848; Wed, 24 Apr 2024 09:27:11 -0700 (PDT) MIME-Version: 1.0 From: Paul Richard Thomas Date: Wed, 24 Apr 2024 17:26:59 +0100 Message-ID: Subject: [Patch, fortran] PR93678 - [11/12/13/14 Regression] ICE with TRANSFER and typebound procedures To: "fortran@gcc.gnu.org" , gcc-patches X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Hi there, This regression turned out to be low hanging fruit, although it has taken four years to reach it :-( The ChangeLog says it all. OK for mainline and backporting after a suitable delay? Paul Fortran: Fix ICE in gfc_trans_create_temp_array from bad type [PR93678] 2024-04-24 Paul Thomas gcc/fortran PR fortran/93678 * trans-expr.cc (gfc_conv_procedure_call): Use the interface, where possible, to obtain the type of character procedure pointers of class entities. gcc/testsuite/ PR fortran/93678 * gfortran.dg/pr93678.f90: New test. diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index 605434f4ddb..072adf3fe77 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -7879,8 +7879,14 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, { gcc_assert (se->loop && info); - /* Set the type of the array. */ - tmp = gfc_typenode_for_spec (&comp->ts); + /* Set the type of the array. vtable charlens are not always reliable. + Use the interface, if possible. */ + if (comp->ts.type == BT_CHARACTER + && expr->symtree->n.sym->ts.type == BT_CLASS + && comp->ts.interface && comp->ts.interface->result) + tmp = gfc_typenode_for_spec (&comp->ts.interface->result->ts); + else + tmp = gfc_typenode_for_spec (&comp->ts); gcc_assert (se->ss->dimen == se->loop->dimen); /* Evaluate the bounds of the result, if known. */ diff --git a/gcc/testsuite/gfortran.dg/pr93678.f90 b/gcc/testsuite/gfortran.dg/pr93678.f90 new file mode 100644 index 00000000000..403bedd0c4f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr93678.f90 @@ -0,0 +1,32 @@ +! { dg-do compile } +! Test the fix for PR93678 in which the charlen for the 'unpackbytes' +! vtable field was incomplete and caused the ICE as indicated. +! Contributed by Luis Kornblueh +! +! The testcase was reduced by various gfortran regulars. +module mo_a + implicit none + type t_b + integer :: i + contains + procedure :: unpackbytes => b_unpackbytes + end type t_b +contains + function b_unpackbytes (me) result (res) + class(t_b), intent(inout) :: me + character :: res(1) + res = char (me%i) + end function b_unpackbytes + subroutine b_unpackint (me, c) + class(t_b), intent(inout) :: me + character, intent(in) :: c +! print *, b_unpackbytes (me) ! ok + if (any (me% unpackbytes () .ne. c)) stop 1 ! ICEd here + end subroutine b_unpackint +end module mo_a + + use mo_a + class(t_b), allocatable :: z + allocate (z, source = t_b(97)) + call b_unpackint (z, "a") +end