From 42746c601b8b5dbd05784079e4dc451acf8723bc Mon Sep 17 00:00:00 2001 From: DJ Delorie Date: Wed, 18 Jul 2012 20:08:53 +0000 Subject: merge from gcc --- libiberty/ChangeLog | 6 ++++++ libiberty/cp-demangle.c | 32 +++++++++++++++++++++++++++++++- libiberty/testsuite/demangle-expected | 3 +++ 3 files changed, 40 insertions(+), 1 deletion(-) (limited to 'libiberty') diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 4ece5ab7474..716a2ce9d23 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,9 @@ +2012-07-18 Jason Merrill + + * cp-demangle.c (cplus_demangle_operators): Add *_cast. + (op_is_new_cast): New. + (d_expression, d_print_comp): Check it. + 2012-07-13 Doug Evans * filename_cmp.c (filename_hash, filename_eq): New functions. 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')); +} + /* ::= <(unary) operator-name> ::= <(binary) operator-name> ::= <(trinary) operator-name> @@ -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. */ diff --git a/libiberty/testsuite/demangle-expected b/libiberty/testsuite/demangle-expected index 58c13681877..6b55d30298e 100644 --- a/libiberty/testsuite/demangle-expected +++ b/libiberty/testsuite/demangle-expected @@ -4081,6 +4081,9 @@ decltype (new auto({parm#1})) f(int) --format=gnu-v3 _Z1fIiERDaRKT_S1_ auto& f(int const&, int) +--format=gnu-v3 +_Z1gILi1EEvR1AIXT_EER1BIXscbT_EE +void g<1>(A<1>&, B(1)>&) # # Ada (GNAT) tests. # -- cgit v1.2.1