cp-demangle.c (d_expression): Handle 'this'.
authorJason Merrill <jason@redhat.com>
Mon, 4 Jul 2011 21:44:11 +0000 (17:44 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 4 Jul 2011 21:44:11 +0000 (17:44 -0400)
* cp-demangle.c (d_expression): Handle 'this'.
(d_print_comp) [DEMANGLE_COMPONENT_FUNCTION_PARAM]: Likewise.

From-SVN: r175836

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

index 2f8e73497d9f0cfbd0daddd5d9d4417aad6b3d10..cd71565e582b86905af065fdb1b310afa0fcfef1 100644 (file)
@@ -1,3 +1,8 @@
+2011-07-04  Jason Merrill  <jason@redhat.com>
+
+       * cp-demangle.c (d_expression): Handle 'this'.
+       (d_print_comp) [DEMANGLE_COMPONENT_FUNCTION_PARAM]: Likewise.
+
 2011-07-01  Joel Brobecker  <brobecker@adacore.com>
 
        * filename_cmp.c (filename_cmp, filename_ncmp): Add handling of
index f1363226c564833745238d92e3918db4c5a20e05..29badbba1875661437d73b499e8d830eaa4bca9d 100644 (file)
@@ -2738,10 +2738,18 @@ d_expression (struct d_info *di)
       /* Function parameter used in a late-specified return type.  */
       int index;
       d_advance (di, 2);
-      index = d_compact_number (di);
-      if (index < 0)
-       return NULL;
-
+      if (d_peek_char (di) == 'T')
+       {
+         /* 'this' parameter.  */
+         d_advance (di, 1);
+         index = 0;
+       }
+      else
+       {
+         index = d_compact_number (di) + 1;
+         if (index == 0)
+           return NULL;
+       }
       return d_make_function_param (di, index);
     }
   else if (IS_DIGIT (peek)
@@ -4400,9 +4408,17 @@ d_print_comp (struct d_print_info *dpi, int options,
       return;
 
     case DEMANGLE_COMPONENT_FUNCTION_PARAM:
-      d_append_string (dpi, "{parm#");
-      d_append_num (dpi, dc->u.s_number.number + 1);
-      d_append_char (dpi, '}');
+      {
+       long num = dc->u.s_number.number;
+       if (num == 0)
+         d_append_string (dpi, "this");
+       else
+         {
+           d_append_string (dpi, "{parm#");
+           d_append_num (dpi, num);
+           d_append_char (dpi, '}');
+         }
+      }
       return;
 
     case DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS:
index 4980cf1728d8ae313eef5b26b9cb9b3dc9077ace..2dc74beb9e233f425cd601a5ebaa741f9238380b 100644 (file)
@@ -3905,6 +3905,10 @@ decltype ({parm#1}+{parm#2}) add<int, double>(int, double)
 --format=gnu-v3
 _Z4add3IidEDTclL_Z1gEfp_fp0_EET_T0_
 decltype (g({parm#1}, {parm#2})) add3<int, double>(int, double)
+# 'this' test
+--format=gnu-v3
+_ZN1A1fIiEEDTcldtdtdefpT1b1fIT_EEEv
+decltype ((((*this).b).(f<int>))()) A::f<int>()
 # new (2008) built in types test
 --format=gnu-v3
 _Z1fDfDdDeDhDsDi