c++: Fix demangling of qualified-id after '.'
authorJason Merrill <jason@redhat.com>
Mon, 21 Dec 2020 20:50:02 +0000 (15:50 -0500)
committerJason Merrill <jason@redhat.com>
Mon, 21 Dec 2020 21:39:48 +0000 (16:39 -0500)
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.

libiberty/cp-demangle.c
libiberty/testsuite/demangle-expected

index 96f43b65ad6cba847a1143fc7cc0449f21da6a22..98ab47a34602ac9f7995d83bb98fe8517dd4e926 100644 (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);
index 6e3e6716defa6551ac34926c15d590fa1a157d25..6789d0d1d9d01538358cc9efae64277a2028a7e5 100644 (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)