OSDN Git Service

/cp
[pf3gnuchains/gcc-fork.git] / gcc / cp / mangle.c
index cd2b7d7..13b0ed4 100644 (file)
@@ -743,6 +743,10 @@ decl_mangling_context (tree decl)
       if (extra)
        return extra;
     }
+    else if (TREE_CODE (decl) == TYPE_DECL
+            && TREE_CODE (TREE_TYPE (decl)) == TEMPLATE_TYPE_PARM)
+     /* template type parms have no mangling context.  */
+      return NULL_TREE;
   return CP_DECL_CONTEXT (decl);
 }
 
@@ -1577,11 +1581,11 @@ discriminator_for_local_entity (tree entity)
 {
   if (DECL_DISCRIMINATOR_P (entity))
     {
-      if (DECL_LANG_SPECIFIC (entity))
+      if (DECL_DISCRIMINATOR_SET_P (entity))
        return DECL_DISCRIMINATOR (entity);
       else
        /* The first entity with a particular name doesn't get
-          DECL_LANG_SPECIFIC/DECL_DISCRIMINATOR.  */
+          DECL_DISCRIMINATOR set up.  */
        return 0;
     }
   else if (TREE_CODE (entity) == TYPE_DECL)
@@ -2295,12 +2299,7 @@ write_member_name (tree member)
   if (TREE_CODE (member) == IDENTIFIER_NODE)
     write_source_name (member);
   else if (DECL_P (member))
-    {
-      /* G++ 3.2 incorrectly put out both the "sr" code and
-        the nested name of the qualified name.  */
-      G.need_abi_warning = 1;
-      write_unqualified_name (member);
-    }
+    write_unqualified_name (member);
   else if (TREE_CODE (member) == TEMPLATE_ID_EXPR)
     {
       tree name = TREE_OPERAND (member, 0);
@@ -2397,17 +2396,27 @@ write_expression (tree expr)
       write_string ("at");
       write_type (TREE_OPERAND (expr, 0));
     }
-  else if (abi_version_at_least (2) && TREE_CODE (expr) == SCOPE_REF)
+  else if (TREE_CODE (expr) == SCOPE_REF)
     {
       tree scope = TREE_OPERAND (expr, 0);
       tree member = TREE_OPERAND (expr, 1);
 
+      if (!abi_version_at_least (2))
+       {
+         write_string ("sr");
+         write_type (scope);
+         /* G++ 3.2 incorrectly put out both the "sr" code and
+            the nested name of the qualified name.  */
+         G.need_abi_warning = 1;
+         write_encoding (member);
+       }
+
       /* If the MEMBER is a real declaration, then the qualifying
         scope was not dependent.  Ideally, we would not have a
         SCOPE_REF in those cases, but sometimes we do.  If the second
         argument is a DECL, then the name must not have been
         dependent.  */
-      if (DECL_P (member))
+      else if (DECL_P (member))
        write_expression (member);
       else
        {
@@ -2572,12 +2581,6 @@ write_expression (tree expr)
          sorry ("mangling new-expression");
          break;
 
-       /* Handle pointers-to-members specially.  */
-       case SCOPE_REF:
-         write_type (TREE_OPERAND (expr, 0));
-         write_member_name (TREE_OPERAND (expr, 1));
-         break;
-
        default:
          for (i = 0; i < TREE_OPERAND_LENGTH (expr); ++i)
            {