From: Jason Merrill Date: Sat, 19 Dec 2020 18:10:01 +0000 (-0500) Subject: c++: Fix demangling of x.operator type X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=71690493322238d0fb9be776d9fceed0a7bf727e;p=gcc.git 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 --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(decltype (__alignof__(int))) _Z1fIiEvDTv111__alignof__tlT_EE void f(decltype (__alignof__(int{}))) + +_Z1gI1AEv1SIXadsrT_oncviEE +void g(S<&A::operator int>) + +_Z1jI1AEDTcldtfp_oncvPT_EES1_ +decltype (({parm#1}.(operator A*))()) j(A)