This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RFA: Another demangler patch--check for end of string
- From: Ian Lance Taylor <ian at wasabisystems dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: dj at redhat dot com
- Date: 29 Nov 2003 01:16:37 -0500
- Subject: RFA: Another demangler patch--check for end of string
I realized that if my new demangler code found it could demangle a
prefix of the string, it would do so, and discard the rest. This is
obviously wrong, and this patch fixes it. This does not affect the
libiberty or gdb testsuites.
This patch also corrects one unrelated comment.
Ian
2003-11-29 Ian Lance Taylor <ian@wasabisystems.com>
* cp-demangle.c (d_demangle): Only return success if we consumed
the entire demangled string.
(is_ctor_or_dtor): Likewise.
Index: cp-demangle.c
===================================================================
RCS file: /cvs/gcc/gcc/libiberty/cp-demangle.c,v
retrieving revision 1.55
diff -u -p -r1.55 cp-demangle.c
--- cp-demangle.c 26 Nov 2003 23:33:04 -0000 1.55
+++ cp-demangle.c 29 Nov 2003 06:10:36 -0000
@@ -3324,7 +3324,7 @@ d_print_cast (dpi, dc)
/* It appears that for a templated cast operator, we need to put
the template parameters in scope for the operator name, but
not for the parameters. The effect is that we need to handle
- the template printing here. FIXME: Verify this. */
+ the template printing here. */
hold_dpm = dpi->modifiers;
dpi->modifiers = NULL;
@@ -3456,6 +3456,11 @@ d_demangle (mangled, options, palc)
else
dc = d_type (&di);
+ /* If we didn't consume the entire mangled string, then we didn't
+ successfully demangle it. */
+ if (d_peek_char (&di) != '\0')
+ dc = NULL;
+
#ifdef CP_DEMANGLE_DEBUG
if (dc == NULL)
printf ("failed demangling\n");
@@ -3657,7 +3662,7 @@ is_ctor_or_dtor (mangled, ctor_kind, dto
dc = d_mangled_name (&di, 1);
- if (dc == NULL)
+ if (dc == NULL || d_peek_char (&di) != '\0')
return 0;
while (dc != NULL)