From 027935eec43173a89cd3eeace0b51967288ac075 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 21 Dec 2020 17:31:16 -0500 Subject: [PATCH] c++: Add some asserts in mangle.c 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 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index c1d9c737a16..7c32e2217aa 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -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 { -- 2.30.2