c++: Fix demangling of qualified-id after '.'

The demangler was assuming that only an unqualified-id could appear after
. or ->.

libiberty/ChangeLog:

	* cp-demangle.c (d_expression_1): Recognize qualified-id
	on RHS of dt/pt.
	* testsuite/demangle-expected: Add test.
This commit is contained in:
Jason Merrill 2020-12-21 15:50:02 -05:00
parent 7169049332
commit 8cd42d3cc2
2 changed files with 19 additions and 4 deletions

View File

@ -3476,10 +3476,22 @@ d_expression_1 (struct d_info *di)
right = d_exprlist (di, 'E');
else if (!strcmp (code, "dt") || !strcmp (code, "pt"))
{
right = d_unqualified_name (di);
if (d_peek_char (di) == 'I')
right = d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE,
right, d_template_args (di));
peek = d_peek_char (di);
/* These codes start a qualified name. */
if ((peek == 'g' && d_peek_next_char (di) == 's')
|| (peek == 's' && d_peek_next_char (di) == 'r'))
right = d_expression_1 (di);
else
{
/* Otherwise it's an unqualified name. We use
d_unqualified_name rather than d_expression_1 here for
old mangled names that didn't add 'on' before operator
names. */
right = d_unqualified_name (di);
if (d_peek_char (di) == 'I')
right = d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE,
right, d_template_args (di));
}
}
else
right = d_expression_1 (di);

View File

@ -1482,3 +1482,6 @@ void g<A>(S<&A::operator int>)
_Z1jI1AEDTcldtfp_oncvPT_EES1_
decltype (({parm#1}.(operator A*))()) j<A>(A)
_Z1fI1AEDtdtfp_srT_1xES1_
decltype ({parm#1}.A::x) f<A>(A)