Commit 336669e7 by Carlo Wood Committed by Craig Rodrigues

re PR other/5390 ([3.3 only?] Libiberty fails to demangle multi-digit template parameters.)

2002-02-18  Carlo Wood  <carlo@gnu.org>

	PR c++/5390
        * cplus-dem.c (demangle_integral_value): Accept multi-digit
        numbers that do not start with an underscore; This is needed
        for integer template parameters. This doesn't break anything
        because multi-digit numbers are never followed by a digit.
        * testsuite/demangle-expected: Corrected all mangled test
        cases with multi-digit template parameters: g++ 2.95.x does
        not generate underscores around these parameters.

From-SVN: r49851
parent d4d6d0ce
2002-02-18 Carlo Wood <carlo@gnu.org>
PR c++/5390
* cplus-dem.c (demangle_integral_value): Accept multi-digit
numbers that do not start with an underscore; This is needed
for integer template parameters. This doesn't break anything
because multi-digit numbers are never followed by a digit.
* testsuite/demangle-expected: Corrected all mangled test
cases with multi-digit template parameters: g++ 2.95.x does
not generate underscores around these parameters.
2002-02-05 Jason Merrill <jason@redhat.com> 2002-02-05 Jason Merrill <jason@redhat.com>
* cplus-dem.c (flags): Add DMGL_VERBOSE * cplus-dem.c (flags): Add DMGL_VERBOSE
......
...@@ -1787,7 +1787,7 @@ demangle_integral_value (work, mangled, s) ...@@ -1787,7 +1787,7 @@ demangle_integral_value (work, mangled, s)
/* By default, we let the number decide whether we shall consume an /* By default, we let the number decide whether we shall consume an
underscore. */ underscore. */
int consume_following_underscore = 0; int multidigit_without_leading_underscore = 0;
int leave_following_underscore = 0; int leave_following_underscore = 0;
success = 0; success = 0;
...@@ -1804,23 +1804,34 @@ demangle_integral_value (work, mangled, s) ...@@ -1804,23 +1804,34 @@ demangle_integral_value (work, mangled, s)
`m'-prefix we must do it here, using consume_count and `m'-prefix we must do it here, using consume_count and
adjusting underscores: we have to consume the underscore adjusting underscores: we have to consume the underscore
matching the prepended one. */ matching the prepended one. */
consume_following_underscore = 1; multidigit_without_leading_underscore = 1;
string_appendn (s, "-", 1); string_appendn (s, "-", 1);
(*mangled) += 2; (*mangled) += 2;
} }
else if (**mangled == '_') else if (**mangled == '_')
{ {
/* Do not consume a following underscore; /* Do not consume a following underscore;
consume_following_underscore will consume what should be multidigit_without_leading_underscore will consume what should be
consumed. */ consumed. */
leave_following_underscore = 1; leave_following_underscore = 1;
} }
else
{
/* 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,
we have to call consume_count. */
multidigit_without_leading_underscore = 1;
/* These multi-digit numbers never end on an underscore,
so if there is one then don't eat it. */
leave_following_underscore = 1;
}
/* We must call consume_count if we expect to remove a trailing /* We must call consume_count if we expect to remove a trailing
underscore, since consume_count_with_underscores expects underscore, since consume_count_with_underscores expects
the leading underscore (that we consumed) if it is to handle the leading underscore (that we consumed) if it is to handle
multi-digit numbers. */ multi-digit numbers. */
if (consume_following_underscore) if (multidigit_without_leading_underscore)
value = consume_count (mangled); value = consume_count (mangled);
else else
value = consume_count_with_underscores (mangled); value = consume_count_with_underscores (mangled);
...@@ -1838,7 +1849,7 @@ demangle_integral_value (work, mangled, s) ...@@ -1838,7 +1849,7 @@ demangle_integral_value (work, mangled, s)
is wrong. If other (arbitrary) cases are followed by an is wrong. If other (arbitrary) cases are followed by an
underscore, we need to do something more radical. */ underscore, we need to do something more radical. */
if ((value > 9 || consume_following_underscore) if ((value > 9 || multidigit_without_leading_underscore)
&& ! leave_following_underscore && ! leave_following_underscore
&& **mangled == '_') && **mangled == '_')
(*mangled)++; (*mangled)++;
......
...@@ -2476,15 +2476,15 @@ fn__FPQ21n1cPMQ21n1cFPQ21n1c_i ...@@ -2476,15 +2476,15 @@ fn__FPQ21n1cPMQ21n1cFPQ21n1c_i
fn(n::c *, int (n::c::*)(n::c *)) fn(n::c *, int (n::c::*)(n::c *))
# #
--format=gnu --format=gnu
f__FGt3Bar1i21i f__FGt3Bar1i2G1i
f(Bar<2>, i) f(Bar<2>, i)
# #
--format=gnu --format=gnu
f__FGt3Bar1i_21_i f__FGt3Bar1i21i
f(Bar<21>, int) f(Bar<21>, int)
# #
--format=gnu --format=gnu
f__FGt3Bar1i24XY_t f__FGt3Bar1i2G4XY_t
f(Bar<2>, XY_t) f(Bar<2>, XY_t)
# #
--format=gnu --format=gnu
...@@ -2492,11 +2492,11 @@ foo__H1Zt2TA2ZRCiZt2NA1Ui9_X01_i ...@@ -2492,11 +2492,11 @@ foo__H1Zt2TA2ZRCiZt2NA1Ui9_X01_i
int foo<TA<int const &, NA<9> > >(TA<int const &, NA<9> >) int foo<TA<int const &, NA<9> > >(TA<int const &, NA<9> >)
# #
--format=gnu --format=gnu
foo__H1Zt2TA2ZcZt2NA1Ui_20__X01_i foo__H1Zt2TA2ZcZt2NA1Ui20_X01_i
int foo<TA<char, NA<20> > >(TA<char, NA<20> >) int foo<TA<char, NA<20> > >(TA<char, NA<20> >)
# #
--format=gnu --format=gnu
foo__H1Zt2TA2ZiZt8N___A___1Ui_99__X01_i foo__H1Zt2TA2ZiZt8N___A___1Ui99_X01_i
int foo<TA<int, N___A___<99> > >(TA<int, N___A___<99> >) int foo<TA<int, N___A___<99> > >(TA<int, N___A___<99> >)
# #
--format=gnu --format=gnu
...@@ -2532,7 +2532,7 @@ __opi__t2TA2ZiZt8N___A___1i_m99_ ...@@ -2532,7 +2532,7 @@ __opi__t2TA2ZiZt8N___A___1i_m99_
TA<int, N___A___<-99> >::operator int(void) TA<int, N___A___<-99> >::operator int(void)
# #
--format=gnu --format=gnu
foo___bar__baz_____H1Zt2TA2ZiZt8N___A___1i_99__X01_i foo___bar__baz_____H1Zt2TA2ZiZt8N___A___1i99_X01_i
int foo___bar__baz___<TA<int, N___A___<99> > >(TA<int, N___A___<99> >) int foo___bar__baz___<TA<int, N___A___<99> > >(TA<int, N___A___<99> >)
# #
--format=gnu --format=gnu
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment