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: 159363 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp1662054vqb; Sun, 29 Oct 2023 05:30:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEW80Sjht/RlA5N5ilrNpC20roBFq0wwRwplpGU7Bsr8AB2Du8o2v832cxCR9y6DS4Gnqfk X-Received: by 2002:a25:3447:0:b0:d9a:3c95:a3dd with SMTP id b68-20020a253447000000b00d9a3c95a3ddmr6220938yba.63.1698582612406; Sun, 29 Oct 2023 05:30:12 -0700 (PDT) Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id a5-20020ad45c45000000b0067108a1897fsi2350944qva.488.2023.10.29.05.30.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Oct 2023 05:30:12 -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=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=MB2jRsDn; arc=fail (body hash mismatch); 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 306E23861859 for ; Sun, 29 Oct 2023 12:30:12 +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-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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781092961118519243 X-GMAIL-MSGID: 1781092961118519243 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; }