From patchwork Tue Jun 13 21:11:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 107547 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp826295vqr; Tue, 13 Jun 2023 14:11:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7xcbSQSXr2qRBexT5gdHH2kVrDiBqQaksseIBO8JMFaj3CYxUSz9FQ86jvAcz+08Ijclo5 X-Received: by 2002:a19:6445:0:b0:4f6:1e9c:cb11 with SMTP id b5-20020a196445000000b004f61e9ccb11mr6485867lfj.14.1686690710445; Tue, 13 Jun 2023 14:11:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686690710; cv=none; d=google.com; s=arc-20160816; b=oEyBKVbHz0VxcY+vGxAsVfzUlBjJD85/7WabtOEFuWi+UPdsadBiE7Zf1dGbtVHJ3s FSSXRJGP0r7b5PkcXW9u8/lfQoUI4KK6qDZT2X4vurKETzKoCkIFJ6tbK9p/1gVenL2T Zd4AyIXty19IZ5gsl7lbY9ly2sgqneb8Inf8stH74F+2zF3REev0eikh9eaTRohGdyfA Ao4UmT4FuaDzGAzaQ2AZeNclRAbdACXgLL6JHU7Ri3q6jSZ72AJVyAnpH0LhjpmrTvCR SbcO3m80clJgCJGNZnC31OZgEWTcbYKurMbO6ZAbIx0Urpku5V2yEWu3PI02oZzozaMQ lHqw== 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:subject:to :content-language:user-agent:mime-version:date:message-id :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=J+KxJkaTW4J9T8pBkYne7bo3TD83yAKBRDrxGs2cc5A=; b=G2nzLRpIYiWQZfdqo/gp2hs7bsyVyo8259YDejQsm9TBfN+M/9DOxhmKW2aywUV4Rz opPW1MNy//KjXJBhV/TxNBrWevk/XMOdo5f6EjR2e4ssb68Yl8N0a7nrkyJ+QZ1oe9N2 TZmvnnD3BBHhbWVuNpwvN5a2qiVapW00RvPXPaYfXmDDVUaIxFK9DxG36WiSVCwNUxFT 9re43mHN/HF02z1LGPOxD10+A5SXMdX0iDDgj2h0nQcR+nIdUAgM+OusY3EC0WClFG2M S9Qecp7MAzJt9+1Sf5Kpl9gcwyj3cM+n1A0pgXWmHvn71S4McnJ5HcwExTB42j7DRBSH kaZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="ox/PJKAu"; 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 m2-20020a170906848200b0096f441389d3si6623430ejx.659.2023.06.13.14.11.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jun 2023 14:11:50 -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="ox/PJKAu"; 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 E51723858C2C for ; Tue, 13 Jun 2023 21:11:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E51723858C2C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686690708; bh=J+KxJkaTW4J9T8pBkYne7bo3TD83yAKBRDrxGs2cc5A=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ox/PJKAuqgQ1obAH4Gc1xOIrz3Dxg9K7eVo2jkQe6KSWaLco+FUsPtgKgfZTLYcac 92YY2h2YG1hqknaLE5mHejWElVbB9m5Zfwz9I8VT+CHVxYIGfqX5MJdzdlaGcuoS3z xgpAZTxAAjSd9ZRB/7b9sJ2wjSmD8fgcJPdGAvzM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by sourceware.org (Postfix) with ESMTPS id 518373858C39 for ; Tue, 13 Jun 2023 21:11:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 518373858C39 Received: by mail-qk1-x72f.google.com with SMTP id af79cd13be357-75d44cb20a2so128835585a.3 for ; Tue, 13 Jun 2023 14:11:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686690663; x=1689282663; h=subject:from:to:content-language:user-agent:mime-version:date :message-id:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=J+KxJkaTW4J9T8pBkYne7bo3TD83yAKBRDrxGs2cc5A=; b=CQH2fMZrLlWl6lOnL3dUaT62I6yomwVKZMr9RukrT3IXCB4sD062XJT85o5QrbpCZl +ja8ljKBd/KqtIot7NBgcg7gZMoNIwVHuLtupJwVKV7N9kW8BBeg2dJBfN8vopCgguJx K9htLa+zJ9pRhfkB2OSygaHYoU6VC0vOoblWZtwcQ/Qp5SyY2ddNv9eM5v5AkKsmIZiR 8Ohu1BwxQnqrGfgqYcLgS7G8yI06D8AkTp+JrUoqwAos/caEKXyhbdBYlgXCejStxzWr /5KQm+kIaMWcFYGJ++iwNSWXicbcI+fZgVf6keuOB7K80I1jKdqtpm9tSNCBpLdpbkea XTiw== X-Gm-Message-State: AC+VfDyR98yDmi/C/BS8K9UIpXxoNdIaarevX2i/gawXRlQhSXCfDMAc w+/XApyageUnq7o3NVD+DRQND51qy7P4tA== X-Received: by 2002:a05:620a:8809:b0:761:8b5:d661 with SMTP id qj9-20020a05620a880900b0076108b5d661mr4629553qkn.38.1686690663480; Tue, 13 Jun 2023 14:11:03 -0700 (PDT) Received: from ?IPV6:2601:19c:527f:bfd0::2? ([2601:19c:527f:bfd0::2]) by smtp.googlemail.com with ESMTPSA id e26-20020a05620a12da00b00761fc8a7bc4sm397953qkl.22.2023.06.13.14.11.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Jun 2023 14:11:03 -0700 (PDT) Message-ID: Date: Tue, 13 Jun 2023 17:11:02 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Content-Language: en-US To: GCC Patches Subject: Fix templated conversion operator demangling X-Spam-Status: No, score=-3038.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, 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: Nathan Sidwell via Gcc-patches From: Nathan Sidwell Reply-To: Nathan Sidwell 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?1768623398055615289?= X-GMAIL-MSGID: =?utf-8?q?1768623398055615289?= I came across this when working on the conversion operator deduction fix. We'd successfully demangle an instantiation of 'template operator X & ()', but fail for 'template operator X ()'. The demangle printer was trying to specially handle the instantiation in the latter case -- seeing the template inst of X. That code appears to be completely unnecessary. Added a bunch of conversion operator demangling tests. nathan From 5a897036187468d4ded330b90b2abdaff5061ed6 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Mon, 12 Jun 2023 19:37:04 -0400 Subject: [PATCH] c++: Fix templated convertion operator demangling Instantiations of templated conversion operators failed to demangle for cases such as 'operator X', but worked for 'operator X &', due to thinking the template instantiation of X was the instantiation of the conversion operator itself. libiberty/ * cp-demangle.c (d_print_conversion): Remove incorrect template instantiation handling. * testsuite/demangle-expected: Add testcases. --- libiberty/cp-demangle.c | 28 +++------------------------ libiberty/testsuite/demangle-expected | 27 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c index 18ab28fd028..3bd303a7544 100644 --- a/libiberty/cp-demangle.c +++ b/libiberty/cp-demangle.c @@ -6660,32 +6660,10 @@ d_print_conversion (struct d_print_info *dpi, int options, dpt.template_decl = dpi->current_template; } - if (d_left (dc)->type != DEMANGLE_COMPONENT_TEMPLATE) - { - d_print_comp (dpi, options, d_left (dc)); - if (dpi->current_template != NULL) - dpi->templates = dpt.next; - } - else - { - d_print_comp (dpi, options, d_left (d_left (dc))); + d_print_comp (dpi, options, d_left (dc)); - /* For a templated cast operator, we need to remove the template - parameters from scope after printing the operator name, - so we need to handle the template printing here. */ - if (dpi->current_template != NULL) - dpi->templates = dpt.next; - - if (d_last_char (dpi) == '<') - d_append_char (dpi, ' '); - d_append_char (dpi, '<'); - d_print_comp (dpi, options, d_right (d_left (dc))); - /* Avoid generating two consecutive '>' characters, to avoid - the C++ syntactic ambiguity. */ - if (d_last_char (dpi) == '>') - d_append_char (dpi, ' '); - d_append_char (dpi, '>'); - } + if (dpi->current_template != NULL) + dpi->templates = dpt.next; } /* Initialize the information structure we use to pass around diff --git a/libiberty/testsuite/demangle-expected b/libiberty/testsuite/demangle-expected index 52dff883a18..0acd2d635db 100644 --- a/libiberty/testsuite/demangle-expected +++ b/libiberty/testsuite/demangle-expected @@ -1662,3 +1662,30 @@ X::F()::{lambda(int)#1}::operator()(int) const _Z1fIiEv1AIXnxtlT_EEE void f(A) + +_ZNO1Ycv1XEv +Y::operator X() && + +_ZNO1Ycv1XIT_EIvEEv +Y::operator X() && + +_ZNO1Y3bobEv +Y::bob() && + +_ZNR1Y3bobEv +Y::bob() & + +_ZNKR1YcvRK1XIT_EIvEEv +Y::operator X const&() const & + +_ZZN1XIiEcviEvE1y +X::operator int()::y + +_ZZN1XIiEcv1ZIiEEvE1y +X::operator Z()::y + +_ZZN1Xcv1ZIT_EIiEEvE1y +X::operator Z()::y + +_ZZN1XIfEcv1ZIT_EIiEEvE1y +X::operator Z()::y -- 2.40.1