From patchwork Sun Oct 29 12:29:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Richard Thomas X-Patchwork-Id: 1856723 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=MB2jRsDn; 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 4SJG2339y4z1yQ7 for ; Sun, 29 Oct 2023 23:30:02 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E77F83870C25 for ; Sun, 29 Oct 2023 12:29:59 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by sourceware.org (Postfix) with ESMTPS id A6C733858C66; Sun, 29 Oct 2023 12:29:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A6C733858C66 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 A6C733858C66 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1035 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698582589; cv=none; b=m99UB8Ie5kmbsAGOmPnrnPIy22sUtOmnA89iFwQI8rvQTOLYx/g9y2TxSoCTELbwQrXJnnDh2vCjEFZUp0L3w3PojFuU8yFzkBaW7vvxp2nRGx7QRA+G/E+FsOBB803vZ50Rw9gKCA5y1YJ8ckYCj7kWXONQCSSD/iYuXbs0dCk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698582589; c=relaxed/simple; bh=SJ5pgpTX2T2Kr03+5gXva4Yg8W/dcXUYvuJYUZPquLw=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=EqezhcCUdSLVF800vQH+YYtYTTyPbXcPLgKpLFds0hJ3QiwzWBuzRdgFK82aW7GYL8Lo/es/eekk/EoS+MZSJXyxT5CT0lG9nUFYKsfwJHvyt5awWKdNXQLiibEjA6oYBW4yJpfUuocmmI5sC/toPnzdtwRn7qy+wanA4ozRvPc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-28041176e77so172153a91.0; Sun, 29 Oct 2023 05:29:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698582586; x=1699187386; darn=gcc.gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=7Pp1gC8lL+nu6JMAwHPgyCRBJcYhrrlFEPjaHHWWQVE=; b=MB2jRsDn/6uxnEtOH8jV8Ae5T8ssEhTTdz7yL4FPQUlWO2m+kAQaroGBdkCI1JhpRv 4I3oznNTeNApxefsIDEJiIi9Qru5jgT1BDZWriiNuhxeKhu9VIrtoVSRJ/HhXXK5nAsP 26QwJjc6mNbWxMrimbhiHIVjLmhGH9PRXzxXUP0/P5zZoVZnGyCIbGeqFpl8yjM4TIk5 ncC5S88DeVbUYDemvroKIUTr/wlP7D9/T5/kyoqQoa7jvliALQF12cdakWhf5sGbpEBb 3KvHpvDKC+OrFHroCMXqy+chDGpZsjJ9IxDWhczf2zdu/xbCUJbciIeZEgMlO3tMknPJ 1tOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698582586; x=1699187386; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=7Pp1gC8lL+nu6JMAwHPgyCRBJcYhrrlFEPjaHHWWQVE=; b=gZ6aDqc/CKB5fGKLUybvDtdNsTEq050yEtLtworNbReeWAtf6gKLCi1VwCdYXU38ZV kx5aQIfCjfVQTgx8KUPJTieoif5KTw/1Ysr6cnwDKN6ju7PVUDHQahSmCl5c73ZAy/B4 0tq5bjcwGNdXA9yzXLjGhS+cx3n1P+z8YoZepjZ2L2en+HTGsHiddFsm8SaH2oAujYN7 vDlXO6uCWR7zzTzrtBwSybaKqOFSJAipk1+ohVPE0nrzE9+QKkEyuUkUMtOBMYZ6H0Ux F8jIpsAwSXaZvAmxUg7KxYEL6Wnn53kpOjR+wzsaQJ27IusfBkIJpe0ZUsCVeIwskxBV /hSw== X-Gm-Message-State: AOJu0YxDsHPk7AjnoLyQjvXffEb0EFRqp+MvnVFrOvHuFrrRFJybB086 BogGnh/8XAVo1+y1U3ZzOoYViJ/y64fmnelHkUOCQMu/N6I= X-Google-Smtp-Source: AGHT+IH87DeUcHRBg4MhT/1ED1SrT/gh8RNO1UW3HvJpzDVP/qRtaXtuwuO+S19EGDiy/NN++eRzwlQ3wfKGgsNFNpg= X-Received: by 2002:a17:90a:fd8e:b0:27f:f61c:327d with SMTP id cx14-20020a17090afd8e00b0027ff61c327dmr4896627pjb.0.1698582586027; Sun, 29 Oct 2023 05:29:46 -0700 (PDT) MIME-Version: 1.0 From: Paul Richard Thomas Date: Sun, 29 Oct 2023 12:29:34 +0000 Message-ID: Subject: [Patch, fortran] PR104555 - ICE in gfc_compare_derived_types, at fortran/interface.cc:628 since r10-2912-g70570ec192745095 To: "fortran@gcc.gnu.org" , gcc-patches X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, HTML_MESSAGE, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, WEIRD_PORT 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 Bizarrely, since the fix for pr101625, the testcase compiles and runs correctly with s/select type (y => x)/select type (y => (x))/ ! The fix is straightforward and appears to be one of those wrinkles arising from the use of associate variables as a selector. The fault is reasonable since the expression is a reference to the _data field, which is of derived type. However, being a select type selector, the selector must be a class with that declared type. Regtests fine. OK for mainline? Paul Fortran: Fix a problem with SELECT TYPE selectors [PR104555]. 2023-10-29 Paul Thomas gcc/fortran PR fortran/104555 * resolve.cc (resolve_select_type): If the selector expression has no class component references and the expression is a derived type, copy the typespec of the symbol to that of the expression. gcc/testsuite/ PR fortran/104555 * gfortran.dg/pr104555.f90: New test. diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 9f4dc072645..b394f7fc79c 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -9578,6 +9578,12 @@ resolve_select_type (gfc_code *code, gfc_namespace *old_ns) { if (code->expr1->symtree->n.sym->attr.untyped) code->expr1->symtree->n.sym->ts = code->expr2->ts; + /* Sometimes the selector expression is given the typespec of the + '_data' field, which is logical enough but inappropraite here. */ + if (code->expr2->ts.type == BT_DERIVED + && code->expr2->symtree + && code->expr2->symtree->n.sym->ts.type == BT_CLASS) + code->expr2->ts = code->expr2->symtree->n.sym->ts; selector_type = CLASS_DATA (code->expr2) ? CLASS_DATA (code->expr2)->ts.u.derived : code->expr2->ts.u.derived; }