From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12540 invoked by alias); 11 Mar 2003 02:26:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 12509 invoked by uid 71); 11 Mar 2003 02:26:01 -0000 Date: Tue, 11 Mar 2003 02:26:00 -0000 Message-ID: <20030311022601.12508.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Carlo Wood Subject: Re: c++/5390: Libiberty fails to demangle multi-digit template parameters. Reply-To: Carlo Wood X-SW-Source: 2003-03/txt/msg00525.txt.bz2 List-Id: The following reply was made to PR c++/5390; it has been noted by GNATS. From: Carlo Wood To: Wolfgang Bangerth Cc: gcc-gnats@gcc.gnu.org, gcc-patches@gcc.gnu.org, dj@redhat.com Subject: Re: c++/5390: Libiberty fails to demangle multi-digit template parameters. Date: Tue, 11 Mar 2003 03:23:41 +0100 --zhXaljGHf11kAtnf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Mar 10, 2003 at 03:03:05PM -0600, Wolfgang Bangerth wrote: > > So, as far as I am concerned you can close this PR. > > Does this still hold given DJ's mail? > > > (Personally, I'd fix it though if I were you - but I am a perfectionist). > > I might if I could. I have no knowledge of gcc, libiberty, etc at all. My > place is gnats, beyond that I can only try to get patch creators and > reviewers into contact -- usually a fruitless endeavor... I tested it again and, as I've written to DJ in private, it seems that my patch WAS applied more or less to gcc version 3.1. However, the way it is now is that it doesn't work for negative template integrals less than -9. For example: /usr/src/gcc/gcc-cvs-3.3/libiberty>echo 'main(int argc, char* argv[]) { printf("%s\n", cplus_demangle(argv[1], 3)); }' > main.c /usr/src/gcc/gcc-cvs-3.3/libiberty>gcc -I../include cplus-dem.c safe-ctype.c xmalloc.c xexit.c xstrdup.c cp-demangle.c dyn-string.c main.c /usr/src/gcc/gcc-cvs-3.3/libiberty>a.out X__FGt3Bar1im10i X(Bar<-1>, , int) I corrected cplus-dem.c again to completely reflect my original patch after which I get correctly: /usr/src/gcc/gcc-cvs-3.3/libiberty>a.out X__FGt3Bar1im10i X(Bar<-10>, int) The new diff is attached. Log entry: 2003-03-10 Carlo Wood * cplus-dem.c (demangle_integral_value): Correction to reflect patch of 2002-01-10 in order to also make negative multi-digits without leading underscore work. -- Carlo Wood --zhXaljGHf11kAtnf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="dem3.diff" Index: cplus-dem.c =================================================================== RCS file: /cvsroot/gcc/gcc/libiberty/cplus-dem.c,v retrieving revision 1.89.4.1 diff -u -d -p -r1.89.4.1 cplus-dem.c --- cplus-dem.c 4 Mar 2003 02:57:48 -0000 1.89.4.1 +++ cplus-dem.c 11 Mar 2003 02:07:23 -0000 @@ -1797,31 +1797,34 @@ demangle_integral_value (work, mangled, success = 0; - /* Negative numbers are indicated with a leading `m'. */ - if (**mangled == 'm') - { - string_appendn (s, "-", 1); - (*mangled)++; - } - else if (mangled[0][0] == '_' && mangled[0][1] == 'm') - { - /* Since consume_count_with_underscores does not handle the - `m'-prefix we must do it here, using consume_count and - adjusting underscores: we have to consume the underscore - matching the prepended one. */ - multidigit_without_leading_underscore = 1; - string_appendn (s, "-", 1); - (*mangled) += 2; - } - else if (**mangled == '_') - { - /* Do not consume a following underscore; - multidigit_without_leading_underscore will consume what should be - consumed. */ - leave_following_underscore = 1; + if (**mangled == '_') + { + if (mangled[0][1] == 'm') + { + /* Since consume_count_with_underscores does not handle the + `m'-prefix we must do it here, using consume_count and + adjusting underscores: we have to consume the underscore + matching the prepended one. */ + multidigit_without_leading_underscore = 1; + string_appendn (s, "-", 1); + (*mangled) += 2; + } + else + { + /* Do not consume a following underscore; + consume_count_with_underscores will consume what + should be consumed. */ + leave_following_underscore = 1; + } } else { + /* Negative numbers are indicated with a leading `m'. */ + if (**mangled == 'm') + { + string_appendn (s, "-", 1); + (*mangled)++; + } /* Since consume_count_with_underscores does not handle multi-digit numbers that do not start with an underscore, and this number can be an integer template parameter, @@ -1862,7 +1865,7 @@ demangle_integral_value (work, mangled, /* All is well. */ success = 1; } - } + } return success; } --zhXaljGHf11kAtnf--