re PR other/43838 (Incorrect output from abi::__cxa_demangle)

PR other/43838
	* cp-demangle.c (struct d_print_info): Add flush_count field.
	(d_print_init): Initialize it to 0.
	(d_print_flush): Increment it.
	(d_print_comp): If needed flush before appending ", ".  Only
	decrement dpi->len if no flushes happened during the recursive
	call.
	* testsuite/demangle-expected: Add a test for this.

2009-06-16  Nick Clifton  <nickc@redhat.com>

	PR 10197
	* testsuite/test-demangle.c: Rename getline to get_line to avoid
	conflicts with system function of the same name.

From-SVN: r160556
This commit is contained in:
Jakub Jelinek 2010-06-10 17:31:56 +02:00
parent fb0e39260c
commit 98d7984464
4 changed files with 37 additions and 7 deletions

View File

@ -1,3 +1,20 @@
2010-06-10 Jakub Jelinek <jakub@redhat.com>
PR other/43838
* cp-demangle.c (struct d_print_info): Add flush_count field.
(d_print_init): Initialize it to 0.
(d_print_flush): Increment it.
(d_print_comp): If needed flush before appending ", ". Only
decrement dpi->len if no flushes happened during the recursive
call.
* testsuite/demangle-expected: Add a test for this.
2009-06-16 Nick Clifton <nickc@redhat.com>
PR 10197
* testsuite/test-demangle.c: Rename getline to get_line to avoid
conflicts with system function of the same name.
2010-04-29 Release Manager
* GCC 4.4.4 released.

View File

@ -302,6 +302,8 @@ struct d_print_info
/* The current index into any template argument packs we are using
for printing. */
int pack_index;
/* Number of d_print_flush calls so far. */
unsigned long int flush_count;
};
#ifdef CP_DEMANGLE_DEBUG
@ -3064,6 +3066,7 @@ d_print_init (struct d_print_info *dpi, int options,
dpi->last_char = '\0';
dpi->templates = NULL;
dpi->modifiers = NULL;
dpi->flush_count = 0;
dpi->callback = callback;
dpi->opaque = opaque;
@ -3093,6 +3096,7 @@ d_print_flush (struct d_print_info *dpi)
dpi->buf[dpi->len] = '\0';
dpi->callback (dpi->buf, dpi->len, dpi->opaque);
dpi->len = 0;
dpi->flush_count++;
}
/* Append characters and buffers for printing. */
@ -3819,12 +3823,18 @@ d_print_comp (struct d_print_info *dpi,
if (d_right (dc) != NULL)
{
size_t len;
unsigned long int flush_count;
/* Make sure ", " isn't flushed by d_append_string, otherwise
dpi->len -= 2 wouldn't work. */
if (dpi->len >= sizeof (dpi->buf) - 2)
d_print_flush (dpi);
d_append_string (dpi, ", ");
len = dpi->len;
flush_count = dpi->flush_count;
d_print_comp (dpi, d_right (dc));
/* If that didn't print anything (which can happen with empty
template argument packs), remove the comma and space. */
if (dpi->len == len)
if (dpi->flush_count == flush_count && dpi->len == len)
dpi->len -= 2;
}
return;

View File

@ -3910,6 +3910,9 @@ decltype (parm#1+((x())())) A<int>::j<int>(int)
--format=gnu-v3
_Z1gIIidEEDTclL_Z1fEspplfp_Li1EEEDpT_
decltype (f((parm#1+(1))...)) g<int, double>(int, double)
--format=gnu-v3
_ZN5aaaaa6bbbbbb5cccccIN23ddddddddddddddddddddddd3eeeENS2_4ffff16ggggggggggggggggENS0_9hhhhhhhhhES6_S6_S6_S6_S6_S6_S6_EE
aaaaa::bbbbbb::ccccc<ddddddddddddddddddddddd::eee, ddddddddddddddddddddddd::ffff::gggggggggggggggg, aaaaa::bbbbbb::hhhhhhhhh, aaaaa::bbbbbb::hhhhhhhhh, aaaaa::bbbbbb::hhhhhhhhh, aaaaa::bbbbbb::hhhhhhhhh, aaaaa::bbbbbb::hhhhhhhhh, aaaaa::bbbbbb::hhhhhhhhh, aaaaa::bbbbbb::hhhhhhhhh, aaaaa::bbbbbb::hhhhhhhhh>
#
# Used to crash the demangler.
--format=gnu-v3

View File

@ -1,5 +1,5 @@
/* Demangler test program,
Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
Copyright (C) 2002, 2003, 2004, 2010 Free Software Foundation, Inc.
Written by Zack Weinberg <zack@codesourcery.com
This file is part of GNU libiberty.
@ -46,7 +46,7 @@ static unsigned int lineno;
#define LINELEN 80
static void
getline(buf)
get_line(buf)
struct line *buf;
{
char *data = buf->data;
@ -196,12 +196,12 @@ main(argc, argv)
{
const char *inp;
getline (&format);
get_line (&format);
if (feof (stdin))
break;
getline (&input);
getline (&expect);
get_line (&input);
get_line (&expect);
inp = protect_end (input.data);
@ -322,7 +322,7 @@ main(argc, argv)
if (no_params)
{
getline (&expect);
get_line (&expect);
result = cplus_demangle (inp, DMGL_ANSI|DMGL_TYPES);
if (result