diff options
author | Yvan Roux <yvan.roux@linaro.org> | 2016-08-22 15:07:28 +0200 |
---|---|---|
committer | Yvan Roux <yvan.roux@linaro.org> | 2016-08-22 15:07:28 +0200 |
commit | 34c4e6e08c214dbc961f9fae30ec020b5adc3589 (patch) | |
tree | 403f940f37964d4c9814be5d0c649cfe4a96a606 /libiberty | |
parent | ae1f46b14da7a3b3cdb81e9d1c164eeaefb05e10 (diff) |
Merge branches/gcc-6-branch rev 239654.
Change-Id: I21e71f9dc10e3bedc0760cd5cc6b8d36234e3d41
Diffstat (limited to 'libiberty')
-rw-r--r-- | libiberty/ChangeLog | 17 | ||||
-rw-r--r-- | libiberty/cp-demangle.c | 153 | ||||
-rw-r--r-- | libiberty/testsuite/demangle-expected | 18 |
3 files changed, 181 insertions, 7 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 4a6b38a7573..9efc384c0a8 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,20 @@ +2016-08-22 Release Manager + + * GCC 6.2.0 released. + +2016-07-21 Jason Merrill <jason@redhat.com> + + * cp-demangle.c (cplus_demangle_operators): Add f[lrLR]. + (d_expression_1): Handle them. + (d_maybe_print_fold_expression): New. + (d_print_comp_inner): Use it. + (d_index_template_argument): Handle negative index. + + * cp-demangle.c (cplus_demangle_operators): Add sP and sZ. + (d_print_comp_inner): Handle them. + (d_template_args_1): Split out from d_template_args. + (d_args_length): New. + 2016-05-19 Jakub Jelinek <jakub@redhat.com> Backported from mainline diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c index 09d64699466..be3832e45b9 100644 --- a/libiberty/cp-demangle.c +++ b/libiberty/cp-demangle.c @@ -344,7 +344,7 @@ struct d_print_info /* Set to 1 if we saw a demangling error. */ int demangle_failure; /* The current index into any template argument packs we are using - for printing. */ + for printing, or -1 to print the whole pack. */ int pack_index; /* Number of d_print_flush calls so far. */ unsigned long int flush_count; @@ -466,6 +466,7 @@ static struct demangle_component * d_template_param (struct d_info *); static struct demangle_component *d_template_args (struct d_info *); +static struct demangle_component *d_template_args_1 (struct d_info *); static struct demangle_component * d_template_arg (struct d_info *); @@ -1761,6 +1762,10 @@ const struct demangle_operator_info cplus_demangle_operators[] = { "eO", NL ("^="), 2 }, { "eo", NL ("^"), 2 }, { "eq", NL ("=="), 2 }, + { "fL", NL ("..."), 3 }, + { "fR", NL ("..."), 3 }, + { "fl", NL ("..."), 2 }, + { "fr", NL ("..."), 2 }, { "ge", NL (">="), 2 }, { "gs", NL ("::"), 1 }, { "gt", NL (">"), 2 }, @@ -1795,6 +1800,8 @@ const struct demangle_operator_info cplus_demangle_operators[] = { "rc", NL ("reinterpret_cast"), 2 }, { "rm", NL ("%"), 2 }, { "rs", NL (">>"), 2 }, + { "sP", NL ("sizeof..."), 1 }, + { "sZ", NL ("sizeof..."), 1 }, { "sc", NL ("static_cast"), 2 }, { "st", NL ("sizeof "), 1 }, { "sz", NL ("sizeof "), 1 }, @@ -2995,6 +3002,19 @@ d_template_param (struct d_info *di) static struct demangle_component * d_template_args (struct d_info *di) { + if (d_peek_char (di) != 'I' + && d_peek_char (di) != 'J') + return NULL; + d_advance (di, 1); + + return d_template_args_1 (di); +} + +/* <template-arg>* E */ + +static struct demangle_component * +d_template_args_1 (struct d_info *di) +{ struct demangle_component *hold_last_name; struct demangle_component *al; struct demangle_component **pal; @@ -3004,11 +3024,6 @@ d_template_args (struct d_info *di) constructor or destructor. */ hold_last_name = di->last_name; - if (d_peek_char (di) != 'I' - && d_peek_char (di) != 'J') - return NULL; - d_advance (di, 1); - if (d_peek_char (di) == 'E') { /* An argument pack can be empty. */ @@ -3270,6 +3285,8 @@ d_expression_1 (struct d_info *di) if (op->type == DEMANGLE_COMPONENT_CAST && d_check_char (di, '_')) operand = d_exprlist (di, 'E'); + else if (code && !strcmp (code, "sP")) + operand = d_template_args_1 (di); else operand = d_expression_1 (di); @@ -3292,6 +3309,9 @@ d_expression_1 (struct d_info *di) return NULL; if (op_is_new_cast (op)) left = cplus_demangle_type (di); + else if (code[0] == 'f') + /* fold-expression. */ + left = d_operator_name (di); else left = d_expression_1 (di); if (!strcmp (code, "cl")) @@ -3326,6 +3346,13 @@ d_expression_1 (struct d_info *di) second = d_expression_1 (di); third = d_expression_1 (di); } + else if (code[0] == 'f') + { + /* fold-expression. */ + first = d_operator_name (di); + second = d_expression_1 (di); + third = d_expression_1 (di); + } else if (code[0] == 'n') { /* new-expression. */ @@ -4179,13 +4206,17 @@ cplus_demangle_print (int options, const struct demangle_component *dc, } /* Returns the I'th element of the template arglist ARGS, or NULL on - failure. */ + failure. If I is negative, return the entire arglist. */ static struct demangle_component * d_index_template_argument (struct demangle_component *args, int i) { struct demangle_component *a; + if (i < 0) + /* Print the whole argument pack. */ + return args; + for (a = args; a != NULL; a = d_right (a)) @@ -4285,6 +4316,30 @@ d_pack_length (const struct demangle_component *dc) return count; } +/* Returns the number of template args in DC, expanding any pack expansions + found there. */ + +static int +d_args_length (struct d_print_info *dpi, const struct demangle_component *dc) +{ + int count = 0; + for (; dc && dc->type == DEMANGLE_COMPONENT_TEMPLATE_ARGLIST; + dc = d_right (dc)) + { + struct demangle_component *elt = d_left (dc); + if (elt == NULL) + break; + if (elt->type == DEMANGLE_COMPONENT_PACK_EXPANSION) + { + struct demangle_component *a = d_find_pack (dpi, d_left (elt)); + count += d_pack_length (a); + } + else + ++count; + } + return count; +} + /* DC is a component of a mangled expression. Print it, wrapped in parens if needed. */ @@ -4361,6 +4416,70 @@ d_get_saved_scope (struct d_print_info *dpi, return NULL; } +/* If DC is a C++17 fold-expression, print it and return true; otherwise + return false. */ + +static int +d_maybe_print_fold_expression (struct d_print_info *dpi, int options, + const struct demangle_component *dc) +{ + const struct demangle_component *ops, *operator_, *op1, *op2; + int save_idx; + + const char *fold_code = d_left (dc)->u.s_operator.op->code; + if (fold_code[0] != 'f') + return 0; + + ops = d_right (dc); + operator_ = d_left (ops); + op1 = d_right (ops); + op2 = 0; + if (op1->type == DEMANGLE_COMPONENT_TRINARY_ARG2) + { + op2 = d_right (op1); + op1 = d_left (op1); + } + + /* Print the whole pack. */ + save_idx = dpi->pack_index; + dpi->pack_index = -1; + + switch (fold_code[1]) + { + /* Unary left fold, (... + X). */ + case 'l': + d_append_string (dpi, "(..."); + d_print_expr_op (dpi, options, operator_); + d_print_subexpr (dpi, options, op1); + d_append_char (dpi, ')'); + break; + + /* Unary right fold, (X + ...). */ + case 'r': + d_append_char (dpi, '('); + d_print_subexpr (dpi, options, op1); + d_print_expr_op (dpi, options, operator_); + d_append_string (dpi, "...)"); + break; + + /* Binary left fold, (42 + ... + X). */ + case 'L': + /* Binary right fold, (X + ... + 42). */ + case 'R': + d_append_char (dpi, '('); + d_print_subexpr (dpi, options, op1); + d_print_expr_op (dpi, options, operator_); + d_append_string (dpi, "..."); + d_print_expr_op (dpi, options, operator_); + d_print_subexpr (dpi, options, op2); + d_append_char (dpi, ')'); + break; + } + + dpi->pack_index = save_idx; + return 1; +} + /* Subroutine to handle components. */ static void @@ -5121,6 +5240,21 @@ d_print_comp_inner (struct d_print_info *dpi, int options, } } + /* For sizeof..., just print the pack length. */ + if (code && !strcmp (code, "sZ")) + { + struct demangle_component *a = d_find_pack (dpi, operand); + int len = d_pack_length (a); + d_append_num (dpi, len); + return; + } + else if (code && !strcmp (code, "sP")) + { + int len = d_args_length (dpi, operand); + d_append_num (dpi, len); + return; + } + if (op->type != DEMANGLE_COMPONENT_CAST) d_print_expr_op (dpi, options, op); else @@ -5162,6 +5296,9 @@ d_print_comp_inner (struct d_print_info *dpi, int options, return; } + if (d_maybe_print_fold_expression (dpi, options, dc)) + 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. */ @@ -5217,6 +5354,8 @@ d_print_comp_inner (struct d_print_info *dpi, int options, d_print_error (dpi); return; } + if (d_maybe_print_fold_expression (dpi, options, dc)) + return; { struct demangle_component *op = d_left (dc); struct demangle_component *first = d_left (d_right (dc)); diff --git a/libiberty/testsuite/demangle-expected b/libiberty/testsuite/demangle-expected index d124261121f..90669428bc7 100644 --- a/libiberty/testsuite/demangle-expected +++ b/libiberty/testsuite/demangle-expected @@ -4421,6 +4421,24 @@ void baz<int>(A<sizeof (foo((int)(), (floatcomplex )00000000_00000000))>*) --format=gnu-v3 _Z3fooI1FEN1XIXszdtcl1PclcvT__EEE5arrayEE4TypeEv X<sizeof ((P(((F)())())).array)>::Type foo<F>() + +_Z1fIJidEEv1AIXsZT_EE +void f<int, double>(A<2>) + +_ZN1A1fIJiiEiJiiiEEEvRAsPDpT_T0_DpT1_E_iS3_S5_ +void A::f<int, int, int, int, int, int>(int (&) [6], int, int, int, int) + +_Z10unary_leftIJLi1ELi2ELi3EEEv1AIXflplT_EE +void unary_left<1, 2, 3>(A<(...+(1, 2, 3))>) + +_Z11unary_rightIJLi1ELi2ELi3EEEv1AIXfrplT_EE +void unary_right<1, 2, 3>(A<((1, 2, 3)+...)>) + +_Z11binary_leftIJLi1ELi2ELi3EEEv1AIXfLplLi42ET_EE +void binary_left<1, 2, 3>(A<((42)+...+(1, 2, 3))>) + +_Z12binary_rightIJLi1ELi2ELi3EEEv1AIXfRplT_Li42EEE +void binary_right<1, 2, 3>(A<((1, 2, 3)+...+(42))>) # # Tests a use-after-free problem PR70481 |