aboutsummaryrefslogtreecommitdiff
path: root/libiberty/cp-demangle.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2017-09-26 02:38:12 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2017-09-26 02:38:12 +0000
commit68aac47f3a4c310890099e67ba239b7dee05bd2c (patch)
tree547e9168bded4abd7b82d1b93f314af3923cdde1 /libiberty/cp-demangle.c
parent30854aa04d9d8f7a8196015e83858c820b7575a8 (diff)
downloadgcc-68aac47f3a4c310890099e67ba239b7dee05bd2c.zip
gcc-68aac47f3a4c310890099e67ba239b7dee05bd2c.tar.gz
gcc-68aac47f3a4c310890099e67ba239b7dee05bd2c.tar.bz2
re PR demangler/82195 (Undemangleable lambda)
PR demangler/82195 * cp-demangle.c (d_encoding): Strip return type when name is a LOCAL_NAME. (d_local_name): Strip return type of enclosing TYPED_NAME. * testsuite/demangle-expected: Add and adjust tests. From-SVN: r253186
Diffstat (limited to 'libiberty/cp-demangle.c')
-rw-r--r--libiberty/cp-demangle.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index ae3469d..8e64347 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -1338,8 +1338,18 @@ d_encoding (struct d_info *di, int top_level)
ftype = d_bare_function_type (di, has_return_type (dc));
if (ftype)
- dc = d_make_comp (di, DEMANGLE_COMPONENT_TYPED_NAME,
- dc, ftype);
+ {
+ /* If this is a non-top-level local-name, clear the
+ return type, so it doesn't confuse the user by
+ being confused with the return type of whaever
+ this is nested within. */
+ if (!top_level && dc->type == DEMANGLE_COMPONENT_LOCAL_NAME
+ && ftype->type == DEMANGLE_COMPONENT_FUNCTION_TYPE)
+ d_left (ftype) = NULL;
+
+ dc = d_make_comp (di, DEMANGLE_COMPONENT_TYPED_NAME,
+ dc, ftype);
+ }
else
dc = NULL;
}
@@ -3621,6 +3631,13 @@ d_local_name (struct d_info *di)
name = d_make_default_arg (di, num, name);
}
+ /* Elide the return type of the containing function so as to not
+ confuse the user thinking it is the return type of whatever local
+ function we might be containing. */
+ if (function->type == DEMANGLE_COMPONENT_TYPED_NAME
+ && d_right (function)->type == DEMANGLE_COMPONENT_FUNCTION_TYPE)
+ d_left (d_right (function)) = NULL;
+
return d_make_comp (di, DEMANGLE_COMPONENT_LOCAL_NAME, function, name);
}