aboutsummaryrefslogtreecommitdiff
path: root/libiberty
diff options
context:
space:
mode:
authorAlex Samuel <samuel@codesourcery.com>2000-09-07 05:44:46 +0000
committerAlex Samuel <samuel@codesourcery.com>2000-09-07 05:44:46 +0000
commitead7663f1ded954f7974191ff687e6585ba9a269 (patch)
tree33bfc3b5bf05d6271f9b145c5b079f77463f2001 /libiberty
parentdad2441f9bd38c6ab28e4252733079d92a6d9fc5 (diff)
* cp-demangle.c (status_allocation_failed): Rearrange whitespace.
(demangle_type): Handle substitution candidates correctly in the face of special substitutions. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@36228 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libiberty')
-rw-r--r--libiberty/ChangeLog6
-rw-r--r--libiberty/cp-demangle.c31
2 files changed, 32 insertions, 5 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index fd7f555ee4e..597e840e0dc 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,9 @@
+2000-09-06 Alex Samuel <samuel@codesourcery.com>
+
+ * cp-demangle.c (status_allocation_failed): Rearrange whitespace.
+ (demangle_type): Handle substitution candidates correctly in the
+ face of special substitutions.
+
2000-09-05 Alex Samuel <samuel@codesourcery.com>
* cp-demangle.c (demangle_encoding): Rename variable.
diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index 48325e66d9f..5b16c4e3507 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -170,7 +170,7 @@ typedef const char *status_t;
#define STATUS_INTERNAL_ERROR "Internal error."
/* This status code indicates a failure in malloc or realloc. */
-static const char* const status_allocation_failed = "Allocation failed.";
+static const char *const status_allocation_failed = "Allocation failed.";
#define STATUS_ALLOCATION_FAILED status_allocation_failed
/* Non-zero if STATUS indicates that no error has occurred. */
@@ -2284,10 +2284,31 @@ demangle_type (dm)
is_substitution_candidate = 0;
}
else
- /* While the special substitution token itself is not a
- substitution candidate, the <class-enum-type> is, so
- don't clear is_substitution_candidate. */
- RETURN_IF_ERROR (demangle_class_enum_type (dm, &encode_return_type));
+ {
+ /* Now some trickiness. We have a special substitution
+ here. Often, the special substitution provides the
+ name of a template that's subsequently instantiated,
+ for instance `SaIcE' => std::allocator<char>. In these
+ cases we need to add a substitution candidate for the
+ entire <class-enum-type> and thus don't want to clear
+ the is_substitution_candidate flag.
+
+ However, it's possible that what we have here is a
+ substitution token representing an entire type, such as
+ `Ss' => std::string. In this case, we mustn't add a
+ new substitution candidate for this substitution token.
+ To detect this case, remember where the start of the
+ substitution token is. */
+ const char *next = dm->next;
+ /* Now demangle the <class-enum-type>. */
+ RETURN_IF_ERROR
+ (demangle_class_enum_type (dm, &encode_return_type));
+ /* If all that was just demangled is the two-character
+ special substitution token, supress the addition of a
+ new candidate for it. */
+ if (dm->next == next + 2)
+ is_substitution_candidate = 0;
+ }
break;