From 0dc64970060bb8ae37b885e9f5968c6250b68ece Mon Sep 17 00:00:00 2001
From: mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Sun, 11 Apr 1999 18:46:52 +0000
Subject: [PATCH] 	* cplus-dem.c (demangle_template_value_parm): Handle 
 pointers-to-members. 	(do_type): Handle template parameters as qualifiers.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@26350 138bc75d-0d04-0410-961f-82ee72b054a4
---
 libiberty/ChangeLog                   |  6 +++
 libiberty/cplus-dem.c                 | 76 ++++++++++++++++-----------
 libiberty/testsuite/demangle-expected |  4 ++
 3 files changed, 55 insertions(+), 31 deletions(-)

diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index 96c9f3095cc2..70dc8ddda728 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,9 @@
+1999-04-11  Mark Mitchell  <mark@codesourcery.com>
+
+	* cplus-dem.c (demangle_template_value_parm): Handle
+	pointers-to-members.
+	(do_type): Handle template parameters as qualifiers.
+
 1999-04-01  Jim Blandy  <jimb@zwingli.cygnus.com>
 
 	* cplus-dem.c: Attempt to handle overflows in counts with some
diff --git a/libiberty/cplus-dem.c b/libiberty/cplus-dem.c
index 2e509d891572..1ebcb7da6002 100644
--- a/libiberty/cplus-dem.c
+++ b/libiberty/cplus-dem.c
@@ -1505,36 +1505,43 @@ demangle_template_value_parm (work, mangled, s, tk)
     }
   else if (tk == tk_pointer || tk == tk_reference)
     {
-      int symbol_len = consume_count (mangled);
-      if (symbol_len == -1)
-	return -1;
-      if (symbol_len == 0)
-	string_appendn (s, "0", 1);
+      if (**mangled == 'Q')
+	success = demangle_qualified (work, mangled, s,
+				      /*isfuncname=*/0, 
+				      /*append=*/1);
       else
 	{
-	  char *p = xmalloc (symbol_len + 1), *q;
-	  strncpy (p, *mangled, symbol_len);
-	  p [symbol_len] = '\0';
-	  /* We use cplus_demangle here, rather than
-	     internal_cplus_demangle, because the name of the entity
-	     mangled here does not make use of any of the squangling
-	     or type-code information we have built up thus far; it is
-	     mangled independently.  */
-	  q = cplus_demangle (p, work->options);
-	  if (tk == tk_pointer)
-	    string_appendn (s, "&", 1);
-	  /* FIXME: Pointer-to-member constants should get a
-	            qualifying class name here.  */
-	  if (q)
+	  int symbol_len  = consume_count (mangled);
+	  if (symbol_len == -1)
+	    return -1;
+	  if (symbol_len == 0)
+	    string_appendn (s, "0", 1);
+	  else
 	    {
-	      string_append (s, q);
-	      free (q);
+	      char *p = xmalloc (symbol_len + 1), *q;
+	      strncpy (p, *mangled, symbol_len);
+	      p [symbol_len] = '\0';
+	      /* We use cplus_demangle here, rather than
+		 internal_cplus_demangle, because the name of the entity
+		 mangled here does not make use of any of the squangling
+		 or type-code information we have built up thus far; it is
+		 mangled independently.  */
+	      q = cplus_demangle (p, work->options);
+	      if (tk == tk_pointer)
+		string_appendn (s, "&", 1);
+	      /* FIXME: Pointer-to-member constants should get a
+		 qualifying class name here.  */
+	      if (q)
+		{
+		  string_append (s, q);
+		  free (q);
+		}
+	      else
+		string_append (s, p);
+	      free (p);
 	    }
-	  else
-	    string_append (s, p);
-	  free (p);
+	  *mangled += symbol_len;
 	}
-      *mangled += symbol_len;
     }
 
   return success;
@@ -3040,11 +3047,6 @@ do_type (work, mangled, result)
 
 	    member = **mangled == 'M';
 	    (*mangled)++;
-	    if (!isdigit ((unsigned char)**mangled) && **mangled != 't')
-	      {
-		success = 0;
-		break;
-	      }
 
 	    string_append (&decl, ")");
 	    string_prepend (&decl, SCOPE_STRING (work));
@@ -3060,7 +3062,13 @@ do_type (work, mangled, result)
 		string_prependn (&decl, *mangled, n);
 		*mangled += n;
 	      }
-	    else
+	    else if (**mangled == 'X' || **mangled == 'Y')
+	      {
+		string temp;
+		do_type (work, mangled, &temp);
+		string_prepends (&decl, &temp);
+	      }
+	    else if (**mangled == 't')
 	      {
 		string temp;
 		string_init (&temp);
@@ -3074,6 +3082,12 @@ do_type (work, mangled, result)
 		else
 		  break;
 	      }
+	    else
+	      {
+		success = 0;
+		break;
+	      }
+
 	    string_prepend (&decl, "(");
 	    if (member)
 	      {
diff --git a/libiberty/testsuite/demangle-expected b/libiberty/testsuite/demangle-expected
index 95dc4dda671a..ad04d116d8b4 100644
--- a/libiberty/testsuite/demangle-expected
+++ b/libiberty/testsuite/demangle-expected
@@ -2466,3 +2466,7 @@ basic_string<char,string_char_traits<char>,allocator>::unLink(void)
 
 _Utf390_1__1_9223372036854775807__9223372036854775
 _Utf390_1__1_9223372036854775807__9223372036854775
+#
+--format=gnu
+call__H1Z4Test_RX01_t1C2ZX01PMX01FPX01i_vQ2X016output
+C<Test, Test::output> call<Test>(Test &)
-- 
GitLab