c++: Add some asserts in mangle.c
authorJason Merrill <jason@redhat.com>
Mon, 21 Dec 2020 22:31:16 +0000 (17:31 -0500)
committerJason Merrill <jason@redhat.com>
Tue, 22 Dec 2020 02:17:04 +0000 (21:17 -0500)
The added asserts are places I noticed that we aren't adding the "on" to
distinguish an operator name from an expression involving the operator.
Hopefully that's because operator names never get there; if not, crash bug
reports will let us fix the issue.

gcc/cp/ChangeLog:

* mangle.c (write_member_name): Add assert.
(write_expression): Add asserts.

gcc/cp/mangle.c

index c1d9c737a165d6cde80d5bf48515140b2365f47a..7c32e2217aa2326d7c21d7340a591bdd28224d04 100644 (file)
@@ -2877,7 +2877,10 @@ write_member_name (tree member)
       write_unqualified_id (member);
     }
   else if (DECL_P (member))
-    write_unqualified_name (member);
+    {
+      gcc_assert (!DECL_OVERLOADED_OPERATOR_P (member));
+      write_unqualified_name (member);
+    }
   else if (TREE_CODE (member) == TEMPLATE_ID_EXPR)
     {
       tree name = TREE_OPERAND (member, 0);
@@ -3162,6 +3165,7 @@ write_expression (tree expr)
        write_expression (member);
       else
        {
+         gcc_assert (code != BASELINK || BASELINK_QUALIFIED_P (expr));
          write_string ("sr");
          write_type (scope);
          write_member_name (member);
@@ -3344,7 +3348,9 @@ write_expression (tree expr)
     }
   else if (dependent_name (expr))
     {
-      write_unqualified_id (dependent_name (expr));
+      tree name = dependent_name (expr);
+      gcc_assert (!IDENTIFIER_ANY_OP_P (name));
+      write_unqualified_id (name);
     }
   else
     {