]> gcc.gnu.org Git - gcc.git/commitdiff
cp-demangle.c (demangle_name): Initialize template_p in local name case.
authorAlex Samuel <samuel@codesourcery.com>
Mon, 28 Aug 2000 05:23:40 +0000 (05:23 +0000)
committerAlex Samuel <samuel@gcc.gnu.org>
Mon, 28 Aug 2000 05:23:40 +0000 (05:23 +0000)
* cp-demangle.c (demangle_name): Initialize template_p in local
name case.  Don't re-add substitutions as candidates.
(demangle_nested_name): Use <unqualified-name>.
(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.

From-SVN: r36014

libiberty/ChangeLog
libiberty/cp-demangle.c

index 3f3e89e778d1f159c8550e666f57b75fc4077fbc..44ca8085351aa86a1aaa8e9743cfbec1573ea909 100644 (file)
@@ -1,3 +1,13 @@
+2000-08-27  Alex Samuel  <samuel@codesourcery.com>
+
+       * cp-demangle.c (demangle_name): Initialize template_p in local
+       name case.  Don't re-add substitutions as candidates.
+       (demangle_nested_name): Use <unqualified-name>.
+       (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  <samuel@codesourcery.com>
 
        * cp-demangle.c (result_add_separated_char): Change parameter to
index c0d27bdea36b8a42dda69e44d74a61d3c9e963b8..d8c7cedb595c7a8811b150daf0c5bb694f23d5ab 100644 (file)
@@ -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 <nested-name>.  */
@@ -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 <unqualified-template-name>.  */
       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 <nested-name>. 
 
-    <nested-name>       ::= N [<CV-qualifiers>] <prefix> <component> E  */
+    <nested-name>     ::= N [<CV-qualifiers>] <prefix> <unqulified-name> 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 <component>; demangle_prefix will
-     handle it.  */
+  /* No need to demangle the final <unqualified-name>; 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 <prefix>.
 
-    <prefix>            ::= <prefix> <component>
+    <prefix>            ::= <prefix> <unqualified-name>
                         ::= <template-prefix> <template-args>
                        ::= # empty
                        ::= <substitution>
 
     <template-prefix>   ::= <prefix>
-                        ::= <substitution>
-
-    <component>         ::= <unqualified-name>
-                        ::= <local-name>  */
+                        ::= <substitution>  */
 
 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 <compound-name>.";
 
-      /* 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));
This page took 0.083114 seconds and 5 git commands to generate.