aboutsummaryrefslogtreecommitdiff
path: root/libiberty/cp-demangle.c
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2011-07-01 17:30:48 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2011-07-01 17:30:48 +0000
commit02e7efbffbcf85bbb9766f4ca0d278a79b4ae2b3 (patch)
tree7947b6369701dc9005cafb9d1b922d5fe80e5fc2 /libiberty/cp-demangle.c
parent2dad5a910a51933d37238538bb70991433cb6a7e (diff)
downloadgdb-02e7efbffbcf85bbb9766f4ca0d278a79b4ae2b3.zip
gdb-02e7efbffbcf85bbb9766f4ca0d278a79b4ae2b3.tar.gz
gdb-02e7efbffbcf85bbb9766f4ca0d278a79b4ae2b3.tar.bz2
merge from gcc
libiberty/ PR debug/49408 * 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..
Diffstat (limited to 'libiberty/cp-demangle.c')
-rw-r--r--libiberty/cp-demangle.c57
1 files changed, 55 insertions, 2 deletions
diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index d664e5f..f136322 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -4139,7 +4139,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 +4204,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, '[');