mangle.c (write_name): Check for null context.
authorJason Merrill <jason@redhat.com>
Mon, 29 Jul 2013 19:40:13 +0000 (15:40 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 29 Jul 2013 19:40:13 +0000 (15:40 -0400)
* mangle.c (write_name): Check for null context.
(write_unscoped_name): Allow PARM_DECL context.

From-SVN: r201317

gcc/cp/ChangeLog
gcc/cp/mangle.c

index 2669375b7f51c50287c8a677ef9dea6a6e8d8b78..21eaa1ff312bda2dbea4ef91b89c049660968e68 100644 (file)
@@ -1,3 +1,8 @@
+2013-07-29  Jason Merrill  <jason@redhat.com>
+
+       * mangle.c (write_name): Check for null context.
+       (write_unscoped_name): Allow PARM_DECL context.
+
 2013-07-25  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/57981
index 68b956bbbd143eeda148f390a113197b5a91d96d..3cfca583cb023d660623e77d5ae360577f753c50 100644 (file)
@@ -798,13 +798,14 @@ write_name (tree decl, const int ignore_local_scope)
 
   context = decl_mangling_context (decl);
 
+  gcc_assert (context != NULL_TREE);
+
   /* A decl in :: or ::std scope is treated specially.  The former is
      mangled using <unscoped-name> or <unscoped-template-name>, the
      latter with a special substitution.  Also, a name that is
      directly in a local function scope is also mangled with
      <unscoped-name> rather than a full <nested-name>.  */
-  if (context == NULL
-      || context == global_namespace
+  if (context == global_namespace
       || DECL_NAMESPACE_STD_P (context)
       || (ignore_local_scope
          && (TREE_CODE (context) == FUNCTION_DECL
@@ -837,10 +838,10 @@ write_name (tree decl, const int ignore_local_scope)
             directly in that function's scope, either decl or one of
             its enclosing scopes.  */
          tree local_entity = decl;
-         while (context != NULL && context != global_namespace)
+         while (context != global_namespace)
            {
              /* Make sure we're always dealing with decls.  */
-             if (context != NULL && TYPE_P (context))
+             if (TYPE_P (context))
                context = TYPE_NAME (context);
              /* Is this a function?  */
              if (TREE_CODE (context) == FUNCTION_DECL
@@ -883,9 +884,10 @@ write_unscoped_name (const tree decl)
   else
     {
       /* If not, it should be either in the global namespace, or directly
-        in a local function scope.  */
+        in a local function scope.  A lambda can also be mangled in the
+        scope of a default argument.  */
       gcc_assert (context == global_namespace
-                 || context != NULL
+                 || TREE_CODE (context) == PARM_DECL
                  || TREE_CODE (context) == FUNCTION_DECL);
 
       write_unqualified_name (decl);