Patchwork Re: C++ member function template id not matching linkage name (PR debug/49408)

login
register
mail settings
Submitter Jan Kratochvil
Date June 30, 2011, 8:59 p.m.
Message ID <20110630205932.GA1870@host1.jankratochvil.net>
Download mbox | patch
Permalink /patch/102835/
State New
Headers show

Comments

Jan Kratochvil - June 30, 2011, 8:59 p.m.
On Thu, 30 Jun 2011 00:27:31 +0200, Jason Merrill wrote:
> The earlier output was correct.  We just don't want to print "g(int,
> double)".

OK, understood now.  It got more clear with the new testcase:

_Z1tIlEDTplcvT_Li5EclL_Z1qsELi6EEEv

decltype (((long)(5))+((q(short))(6))) t<long>()
->
decltype (((long)(5))+(q(6))) t<long>()

OK to check it in if the regression testing underway is OK?


Thanks,
Jan


libiberty/
2011-06-30  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* cp-demangle.c (d_print_comp): Suppress argument list for function
	references by the '&' unary operator.  Keep also already processed
	variant without the argument list.  Suppress argument list types for
	function call used in an expression.
	* testsuite/demangle-expected: Fix excessive argument list types in
	`test for typed function in decltype'.  New testcase for no argument
	list types printed.  3 new testcases for function references by the
	'&' unary operator..
Jason Merrill - July 1, 2011, 4:27 p.m.
OK.

Jason
Jan Kratochvil - July 1, 2011, 5:20 p.m.
On Fri, 01 Jul 2011 18:27:36 +0200, Jason Merrill wrote:
> OK.

Checked in:
	http://gcc.gnu.org/viewcvs?view=revision&revision=175761

No regressions on gcc-4.6.1-1.fc15.x86_64 (it is not trunk but hopefully
similar enough).


Thanks,
Jan

Patch

--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -4139,7 +4169,46 @@  d_print_comp (struct d_print_info *dpi, int options,
       return;
 
     case DEMANGLE_COMPONENT_UNARY:
-      if (d_left (dc)->type != DEMANGLE_COMPONENT_CAST)
+      if (d_left (dc)->type == DEMANGLE_COMPONENT_OPERATOR
+	  && d_left (dc)->u.s_operator.op->len == 1
+	  && d_left (dc)->u.s_operator.op->name[0] == '&'
+	  && d_right (dc)->type == DEMANGLE_COMPONENT_TYPED_NAME
+	  && d_left (d_right (dc))->type == DEMANGLE_COMPONENT_QUAL_NAME
+	  && d_right (d_right (dc))->type == DEMANGLE_COMPONENT_FUNCTION_TYPE)
+	{
+	  /* Address of a function (therefore in an expression context) must
+	     have its argument list suppressed.
+
+	     unary operator ... dc
+	       operator & ... d_left (dc)
+	       typed name ... d_right (dc)
+		 qualified name ... d_left (d_right (dc))
+		   <names>
+		 function type ... d_right (d_right (dc))
+		   argument list
+		     <arguments>  */
+
+	  d_print_expr_op (dpi, options, d_left (dc));
+	  d_print_comp (dpi, options, d_left (d_right (dc)));
+	  return;
+	}
+      else if (d_left (dc)->type == DEMANGLE_COMPONENT_OPERATOR
+	       && d_left (dc)->u.s_operator.op->len == 1
+	       && d_left (dc)->u.s_operator.op->name[0] == '&'
+	       && d_right (dc)->type == DEMANGLE_COMPONENT_QUAL_NAME)
+	{
+	  /* Keep also already processed variant without the argument list.
+
+	     unary operator ... dc
+	       operator & ... d_left (dc)
+	       qualified name ... d_right (dc)
+		 <names>  */
+
+	  d_print_expr_op (dpi, options, d_left (dc));
+	  d_print_comp (dpi, options, d_right (dc));
+	  return;
+	}
+      else if (d_left (dc)->type != DEMANGLE_COMPONENT_CAST)
 	d_print_expr_op (dpi, options, d_left (dc));
       else
 	{
@@ -4165,7 +4234,21 @@  d_print_comp (struct d_print_info *dpi, int options,
 	  && d_left (dc)->u.s_operator.op->name[0] == '>')
 	d_append_char (dpi, '(');
 
-      d_print_subexpr (dpi, options, d_left (d_right (dc)));
+      if (strcmp (d_left (dc)->u.s_operator.op->code, "cl") == 0
+          && d_left (d_right (dc))->type == DEMANGLE_COMPONENT_TYPED_NAME)
+	{
+	  /* Function call used in an expression should not have printed types
+	     of the function arguments.  Values of the function arguments still
+	     get printed below.  */
+
+	  const struct demangle_component *func = d_left (d_right (dc));
+
+	  if (d_right (func)->type != DEMANGLE_COMPONENT_FUNCTION_TYPE)
+	    d_print_error (dpi);
+	  d_print_subexpr (dpi, options, d_left (func));
+	}
+      else
+	d_print_subexpr (dpi, options, d_left (d_right (dc)));
       if (strcmp (d_left (dc)->u.s_operator.op->code, "ix") == 0)
 	{
 	  d_append_char (dpi, '[');
--- a/libiberty/testsuite/demangle-expected
+++ b/libiberty/testsuite/demangle-expected
@@ -3920,7 +3920,11 @@  decltype (({parm#1}.(g<double>))()) h<A<int>, double>(A<int>, double)
 # test for typed function in decltype
 --format=gnu-v3
 _ZN1AIiE1jIiEEDTplfp_clL_Z1xvEEET_
-decltype ({parm#1}+((x())())) A<int>::j<int>(int)
+decltype ({parm#1}+(x())) A<int>::j<int>(int)
+# typed function in decltype with an argument list
+--format=gnu-v3
+_Z1tIlEDTplcvT_Li5EclL_Z1qsELi6EEEv
+decltype (((long)(5))+(q(6))) t<long>()
 # test for expansion of function parameter pack
 --format=gnu-v3
 _Z1gIIidEEDTclL_Z1fEspplfp_Li1EEEDpT_
@@ -3990,6 +3994,18 @@  outer(short (*)(int), long)
 _Z6outer2IsEPFilES1_
 outer2<short>(int (*)(long))
 #
+--format=gnu-v3 --no-params
+_ZN1KIXadL_ZN1S1mEiEEE1fEv
+K<&S::m>::f()
+K<&S::m>::f
+--format=gnu-v3
+_ZN1KILi1EXadL_ZN1S1mEiEEE1fEv
+K<1, &S::m>::f()
+# Here the `(int)' argument list of `S::m' is already removed.
+--format=gnu-v3
+_ZN1KILi1EXadL_ZN1S1mEEEE1fEv
+K<1, &S::m>::f()
+#
 # Ada (GNAT) tests.
 #
 # Simple test.