summaryrefslogtreecommitdiff
path: root/libiberty/cp-demangle.c
diff options
context:
space:
mode:
Diffstat (limited to 'libiberty/cp-demangle.c')
-rw-r--r--libiberty/cp-demangle.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index 27cc323f2a2..258aaa71550 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -1582,11 +1582,13 @@ const struct demangle_operator_info cplus_demangle_operators[] =
{ "an", NL ("&"), 2 },
{ "at", NL ("alignof "), 1 },
{ "az", NL ("alignof "), 1 },
+ { "cc", NL ("const_cast"), 2 },
{ "cl", NL ("()"), 2 },
{ "cm", NL (","), 2 },
{ "co", NL ("~"), 1 },
{ "dV", NL ("/="), 2 },
{ "da", NL ("delete[] "), 1 },
+ { "dc", NL ("dynamic_cast"), 2 },
{ "de", NL ("*"), 1 },
{ "dl", NL ("delete "), 1 },
{ "ds", NL (".*"), 2 },
@@ -1626,8 +1628,10 @@ const struct demangle_operator_info cplus_demangle_operators[] =
{ "qu", NL ("?"), 3 },
{ "rM", NL ("%="), 2 },
{ "rS", NL (">>="), 2 },
+ { "rc", NL ("reinterpret_cast"), 2 },
{ "rm", NL ("%"), 2 },
{ "rs", NL (">>"), 2 },
+ { "sc", NL ("static_cast"), 2 },
{ "st", NL ("sizeof "), 1 },
{ "sz", NL ("sizeof "), 1 },
{ "tr", NL ("throw"), 0 },
@@ -2809,6 +2813,18 @@ d_exprlist (struct d_info *di, char terminator)
return list;
}
+/* Returns nonzero iff OP is an operator for a C++ cast: const_cast,
+ dynamic_cast, static_cast or reinterpret_cast. */
+
+static int
+op_is_new_cast (struct demangle_component *op)
+{
+ const char *code = op->u.s_operator.op->code;
+ return (code[1] == 'c'
+ && (code[0] == 's' || code[0] == 'd'
+ || code[0] == 'c' || code[0] == 'r'));
+}
+
/* <expression> ::= <(unary) operator-name> <expression>
::= <(binary) operator-name> <expression> <expression>
::= <(trinary) operator-name> <expression> <expression> <expression>
@@ -2971,7 +2987,10 @@ d_expression (struct d_info *di)
struct demangle_component *left;
struct demangle_component *right;
- left = d_expression (di);
+ if (op_is_new_cast (op))
+ left = cplus_demangle_type (di);
+ else
+ left = d_expression (di);
if (!strcmp (code, "cl"))
right = d_exprlist (di, 'E');
else if (!strcmp (code, "dt") || !strcmp (code, "pt"))
@@ -4455,6 +4474,17 @@ d_print_comp (struct d_print_info *dpi, int options,
return;
}
+ if (op_is_new_cast (d_left (dc)))
+ {
+ d_print_expr_op (dpi, options, d_left (dc));
+ d_append_char (dpi, '<');
+ d_print_comp (dpi, options, d_left (d_right (dc)));
+ d_append_string (dpi, ">(");
+ d_print_comp (dpi, options, d_right (d_right (dc)));
+ d_append_char (dpi, ')');
+ return;
+ }
+
/* We wrap an expression which uses the greater-than operator in
an extra layer of parens so that it does not get confused
with the '>' which ends the template parameters. */