From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1059) id 491E83858D38; Tue, 13 Jun 2023 21:07:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 491E83858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686690448; bh=9gXHXfnY21VUSLVCPlJm4xd/vJcs4VwisKkFC4hAwCU=; h=From:To:Subject:Date:From; b=MvvoNZ9E9bxvGiQXdQAXhFJRzm9yjzWuGu911TCV86HafYBL6AtDMNHPfv6gpLo0D avrhTYZzGGJP5hwCDm8Zte0eXlDhOqA+AW0KCoT/t5fP8hweZlO81NB7BSofTUQmJl xzgV/aC1utvM2Er4bLe2p11fjlGKJ6IL/kqSQ47Y= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Nathan Sidwell To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-1797] c++: Fix templated convertion operator demangling X-Act-Checkin: gcc X-Git-Author: Nathan Sidwell X-Git-Refname: refs/heads/trunk X-Git-Oldrev: a54c71ccc24874ce79019b51150b3a00b7c785cd X-Git-Newrev: 5a897036187468d4ded330b90b2abdaff5061ed6 Message-Id: <20230613210728.491E83858D38@sourceware.org> Date: Tue, 13 Jun 2023 21:07:28 +0000 (GMT) List-Id: https://gcc.gnu.org/g:5a897036187468d4ded330b90b2abdaff5061ed6 commit r14-1797-g5a897036187468d4ded330b90b2abdaff5061ed6 Author: Nathan Sidwell Date: Mon Jun 12 19:37:04 2023 -0400 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. Diff: --- 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))); - - /* 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; + d_print_comp (dpi, options, d_left (dc)); - 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