public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r11-6293] c++: Fix demangling of x.operator type
Date: Mon, 21 Dec 2020 20:46:26 +0000 (GMT)	[thread overview]
Message-ID: <20201221204626.1DB553857821@sourceware.org> (raw)

https://gcc.gnu.org/g:71690493322238d0fb9be776d9fceed0a7bf727e

commit r11-6293-g71690493322238d0fb9be776d9fceed0a7bf727e
Author: Jason Merrill <jason@redhat.com>
Date:   Sat Dec 19 13:10:01 2020 -0500

    c++: Fix demangling of x.operator type
    
    d_operator_name decides whether "cv" indicates a cast or a conversion
    operator based on is_expression.  "on" specifies that we want the conversion
    operator.
    
    libiberty/ChangeLog:
    
            * cp-demangle.c (d_unqualified_name): Clear is_expression.
            * testsuite/demangle-expected: Add tests.

Diff:
---
 libiberty/cp-demangle.c               | 8 +++++++-
 libiberty/testsuite/demangle-expected | 6 ++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index a9f8e759ff5..96f43b65ad6 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -1632,9 +1632,15 @@ d_unqualified_name (struct d_info *di)
     ret = d_source_name (di);
   else if (IS_LOWER (peek))
     {
+      int was_expr = di->is_expression;
       if (peek == 'o' && d_peek_next_char (di) == 'n')
-	d_advance (di, 2);
+	{
+	  d_advance (di, 2);
+	  /* Treat cv as naming a conversion operator.  */
+	  di->is_expression = 0;
+	}
       ret = d_operator_name (di);
+      di->is_expression = was_expr;
       if (ret != NULL && ret->type == DEMANGLE_COMPONENT_OPERATOR)
 	{
 	  di->expansion += sizeof "operator" + ret->u.s_operator.op->len - 2;
diff --git a/libiberty/testsuite/demangle-expected b/libiberty/testsuite/demangle-expected
index 4ad9da82f2c..6e3e6716def 100644
--- a/libiberty/testsuite/demangle-expected
+++ b/libiberty/testsuite/demangle-expected
@@ -1476,3 +1476,9 @@ void f<int>(decltype (__alignof__(int)))
 
 _Z1fIiEvDTv111__alignof__tlT_EE
 void f<int>(decltype (__alignof__(int{})))
+
+_Z1gI1AEv1SIXadsrT_oncviEE
+void g<A>(S<&A::operator int>)
+
+_Z1jI1AEDTcldtfp_oncvPT_EES1_
+decltype (({parm#1}.(operator A*))()) j<A>(A)


                 reply	other threads:[~2020-12-21 20:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201221204626.1DB553857821@sourceware.org \
    --to=jason@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).