OSDN Git Service

PR c++/50089
[pf3gnuchains/gcc-fork.git] / gcc / cp / mangle.c
index 4a83c9a..1fcd999 100644 (file)
@@ -747,6 +747,11 @@ write_encoding (const tree decl)
 static tree
 decl_mangling_context (tree decl)
 {
+  tree tcontext = targetm.cxx.decl_mangling_context (decl);
+
+  if (tcontext != NULL_TREE)
+    return tcontext;
+
   if (TREE_CODE (decl) == TYPE_DECL
       && LAMBDA_TYPE_P (TREE_TYPE (decl)))
     {
@@ -857,7 +862,7 @@ write_name (tree decl, const int ignore_local_scope)
 static void
 write_unscoped_name (const tree decl)
 {
-  tree context = CP_DECL_CONTEXT (decl);
+  tree context = decl_mangling_context (decl);
 
   MANGLE_TRACE_TREE ("unscoped-name", decl);
 
@@ -952,6 +957,7 @@ write_nested_name (const tree decl)
 /* <prefix> ::= <prefix> <unqualified-name>
            ::= <template-param>
            ::= <template-prefix> <template-args>
+           ::= <decltype>
            ::= # empty
            ::= <substitution>  */
 
@@ -968,6 +974,12 @@ write_prefix (const tree node)
 
   MANGLE_TRACE_TREE ("prefix", node);
 
+  if (TREE_CODE (node) == DECLTYPE_TYPE)
+    {
+      write_type (node);
+      return;
+    }
+
   if (find_substitution (node))
     return;
 
@@ -1941,7 +1953,7 @@ write_type (tree type)
             case DECLTYPE_TYPE:
              /* These shouldn't make it into mangling.  */
              gcc_assert (!DECLTYPE_FOR_LAMBDA_CAPTURE (type)
-                         && !DECLTYPE_FOR_LAMBDA_RETURN (type));
+                         && !DECLTYPE_FOR_LAMBDA_PROXY (type));
 
              /* In ABI <5, we stripped decltype of a plain decl.  */
              if (!abi_version_at_least (5)
@@ -2750,29 +2762,34 @@ write_template_arg_literal (const tree value)
   write_char ('L');
   write_type (TREE_TYPE (value));
 
-  switch (TREE_CODE (value))
-    {
-    case CONST_DECL:
-      write_integer_cst (DECL_INITIAL (value));
-      break;
+  /* Write a null member pointer value as (type)0, regardless of its
+     real representation.  */
+  if (null_member_pointer_value_p (value))
+    write_integer_cst (integer_zero_node);
+  else
+    switch (TREE_CODE (value))
+      {
+      case CONST_DECL:
+       write_integer_cst (DECL_INITIAL (value));
+       break;
 
-    case INTEGER_CST:
-      gcc_assert (!same_type_p (TREE_TYPE (value), boolean_type_node)
-                 || integer_zerop (value) || integer_onep (value));
-      write_integer_cst (value);
-      break;
+      case INTEGER_CST:
+       gcc_assert (!same_type_p (TREE_TYPE (value), boolean_type_node)
+                   || integer_zerop (value) || integer_onep (value));
+       write_integer_cst (value);
+       break;
 
-    case REAL_CST:
-      write_real_cst (value);
-      break;
+      case REAL_CST:
+       write_real_cst (value);
+       break;
 
-    case STRING_CST:
-      sorry ("string literal in function template signature");
-      break;
+      case STRING_CST:
+       sorry ("string literal in function template signature");
+       break;
 
-    default:
-      gcc_unreachable ();
-    }
+      default:
+       gcc_unreachable ();
+      }
 
   write_char ('E');
 }
@@ -2833,7 +2850,8 @@ write_template_arg (tree node)
     /* A template appearing as a template arg is a template template arg.  */
     write_template_template_arg (node);
   else if ((TREE_CODE_CLASS (code) == tcc_constant && code != PTRMEM_CST)
-          || (abi_version_at_least (2) && code == CONST_DECL))
+          || (abi_version_at_least (2) && code == CONST_DECL)
+          || null_member_pointer_value_p (node))
     write_template_arg_literal (node);
   else if (DECL_P (node))
     {