diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 3f3e89e778d1..44ca8085351a 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,13 @@ +2000-08-27 Alex Samuel + + * cp-demangle.c (demangle_name): Initialize template_p in local + name case. Don't re-add substitutions as candidates. + (demangle_nested_name): Use . + (demangle_prefix): Likewise. Don't add template names as + substitution candidates twice, or re-add a substitution or the + last prefix component. + (demangle_local_name): Adjust output format. + 2000-08-25 Alex Samuel * cp-demangle.c (result_add_separated_char): Change parameter to diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c index c0d27bdea36b..d8c7cedb595c 100644 --- a/libiberty/cp-demangle.c +++ b/libiberty/cp-demangle.c @@ -973,10 +973,11 @@ demangle_name (dm, template_p) int *template_p; { int start = substitution_start (dm); + char peek = peek_char (dm); DEMANGLE_TRACE ("name", dm); - switch (peek_char (dm)) + switch (peek) { case 'N': /* This is a . */ @@ -985,6 +986,7 @@ demangle_name (dm, template_p) case 'Z': RETURN_IF_ERROR (demangle_local_name (dm)); + *template_p = 0; break; case 'S': @@ -1005,8 +1007,11 @@ demangle_name (dm, template_p) If so, then we just demangled an . */ if (peek_char (dm) == 'I') { - RETURN_IF_ERROR (substitution_add (dm, start, 0, - NOT_TEMPLATE_PARM)); + /* The template name is a substitution candidate, unless it + was already a back-substitution. */ + if (peek != 'S') + RETURN_IF_ERROR (substitution_add (dm, start, 0, + NOT_TEMPLATE_PARM)); RETURN_IF_ERROR (demangle_template_args (dm)); *template_p = 1; } @@ -1041,7 +1046,7 @@ demangle_name (dm, template_p) /* Demangles and emits a . - ::= N [] E */ + ::= N [] E */ static status_t demangle_nested_name (dm, template_p) @@ -1072,8 +1077,8 @@ demangle_nested_name (dm, template_p) } RETURN_IF_ERROR (demangle_prefix (dm, template_p)); - /* No need to demangle the final ; demangle_prefix will - handle it. */ + /* No need to demangle the final ; demangle_prefix + will handle it. */ RETURN_IF_ERROR (demangle_char (dm, 'E')); return STATUS_OK; @@ -1081,16 +1086,13 @@ demangle_nested_name (dm, template_p) /* Demangles and emits a . - ::= + ::= ::= ::= # empty ::= ::= - ::= - - ::= - ::= */ + ::= */ static status_t demangle_prefix (dm, template_p) @@ -1145,8 +1147,7 @@ demangle_prefix (dm, template_p) RETURN_IF_ERROR (demangle_substitution (dm, template_p)); else { - /* It's just a name. Remember whether it's a - constructor. */ + /* It's just a name. */ RETURN_IF_ERROR (demangle_unqualified_name (dm)); *template_p = 0; } @@ -1160,8 +1161,6 @@ demangle_prefix (dm, template_p) RETURN_IF_ERROR (demangle_local_name (dm)); else if (peek == 'I') { - /* The template name is a substitution candidate. */ - RETURN_IF_ERROR (substitution_add (dm, start, 0, NOT_TEMPLATE_PARM)); RETURN_IF_ERROR (demangle_template_args (dm)); /* Now we want to indicate to the caller that we've @@ -1183,9 +1182,11 @@ demangle_prefix (dm, template_p) else return "Unexpected character in ."; - /* Add a new substitution for the prefix thus far. */ - RETURN_IF_ERROR (substitution_add (dm, start, *template_p, - NOT_TEMPLATE_PARM)); + if (peek != 'S' + && peek_char (dm) != 'E') + /* Add a new substitution for the prefix thus far. */ + RETURN_IF_ERROR (substitution_add (dm, start, *template_p, + NOT_TEMPLATE_PARM)); } } @@ -2975,7 +2976,7 @@ demangle_local_name (dm) RETURN_IF_ERROR (demangle_char (dm, 'Z')); RETURN_IF_ERROR (demangle_encoding (dm)); RETURN_IF_ERROR (demangle_char (dm, 'E')); - RETURN_IF_ERROR (result_append (dm, "'s ")); + RETURN_IF_ERROR (result_append (dm, "::")); if (peek_char (dm) == 's') { @@ -2988,7 +2989,6 @@ demangle_local_name (dm) else { int unused; - RETURN_IF_ERROR (result_append (dm, "local ")); /* Local name for some other entity. Demangle its name. */ RETURN_IF_ERROR (demangle_name (dm, &unused)); RETURN_IF_ERROR (demangle_discriminator (dm, 1));