From: DJ Delorie Date: Wed, 18 Mar 2009 00:07:49 +0000 (+0000) Subject: merge from gcc X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c743cf5d81e46011aada39382daabf1383f3ad41;p=binutils-gdb.git merge from gcc --- diff --git a/include/ChangeLog b/include/ChangeLog index aef73a3a1cb..ac8f2848ae7 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,8 @@ +2009-03-17 Jason Merrill + + * demangle.h (enum demangle_component_type): Add + DEMANGLE_COMPONENT_FUNCTION_PARAM. + 2009-03-14 Dave Korn * coff/internal.h (struct internal_extra_pe_aouthdr): Correct type diff --git a/include/demangle.h b/include/demangle.h index 28c69f5e78c..eb39c7c13c4 100644 --- a/include/demangle.h +++ b/include/demangle.h @@ -221,6 +221,8 @@ enum demangle_component_type /* A template parameter. This holds a number, which is the template parameter index. */ DEMANGLE_COMPONENT_TEMPLATE_PARAM, + /* A function parameter. This holds a number, which is the index. */ + DEMANGLE_COMPONENT_FUNCTION_PARAM, /* A constructor. This holds a name and the kind of constructor. */ DEMANGLE_COMPONENT_CTOR, @@ -466,10 +468,10 @@ struct demangle_component int len; } s_string; - /* For DEMANGLE_COMPONENT_TEMPLATE_PARAM. */ + /* For DEMANGLE_COMPONENT_*_PARAM. */ struct { - /* Template parameter index. */ + /* Parameter index. */ long number; } s_number; diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index db7d2878bc0..00aa57a84e4 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,15 @@ +2009-03-17 Jason Merrill + + * cp-demangle.c (d_make_function_param): new fn. + (cplus_demangle_mangled_name): Work around abi v2 bug. + (d_expr_primary): Likewise. + (cplus_demangle_operators): Add alignof ops. + (d_expression): Handle function parameters and conversions + with other than 1 operand. + (d_print_comp): Handle function parameters. Fix bug with + function used in type of function. + * testsuite/demangle-expected: Upate tests. + 2009-02-21 Mark Mitchell * make-temp-file.c (): Include on Windows. diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c index 0b4e05c6e5c..e6d3d5ea902 100644 --- a/libiberty/cp-demangle.c +++ b/libiberty/cp-demangle.c @@ -964,6 +964,22 @@ d_make_template_param (struct d_info *di, long i) return p; } +/* Add a new function parameter. */ + +static struct demangle_component * +d_make_function_param (struct d_info *di, long i) +{ + struct demangle_component *p; + + p = d_make_empty (di); + if (p != NULL) + { + p->type = DEMANGLE_COMPONENT_FUNCTION_PARAM; + p->u.s_number.number = i; + } + return p; +} + /* Add a new standard substitution component. */ static struct demangle_component * @@ -989,7 +1005,11 @@ CP_STATIC_IF_GLIBCPP_V3 struct demangle_component * cplus_demangle_mangled_name (struct d_info *di, int top_level) { - if (! d_check_char (di, '_')) + if (! d_check_char (di, '_') + /* Allow missing _ if not at toplevel to work around a + bug in G++ abi-version=2 mangling; see the comment in + write_template_arg. */ + && top_level) return NULL; if (! d_check_char (di, 'Z')) return NULL; @@ -1481,6 +1501,8 @@ const struct demangle_operator_info cplus_demangle_operators[] = { "rs", NL (">>"), 2 }, { "st", NL ("sizeof "), 1 }, { "sz", NL ("sizeof "), 1 }, + { "at", NL ("alignof "), 1 }, + { "az", NL ("alignof "), 1 }, { NULL, NULL, 0, 0 } }; @@ -2564,12 +2586,25 @@ d_expression (struct d_info *di) d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, name, d_template_args (di))); } - else if (peek == 's' - && (d_peek_next_char (di) == 'T' || d_peek_next_char (di) == 'R')) + else if (peek == 'f' && d_peek_next_char (di) == 'p') { - /* Just demangle a parameter placeholder as its type. */ + /* Function parameter used in a late-specified return type. */ + int index; d_advance (di, 2); - return cplus_demangle_type (di); + if (d_peek_char (di) == '_') + index = 1; + else + { + index = d_number (di); + if (index < 0) + return NULL; + index += 2; + } + + if (! d_check_char (di, '_')) + return NULL; + + return d_make_function_param (di, index); } else if (IS_DIGIT (peek)) { @@ -2619,8 +2654,16 @@ d_expression (struct d_info *di) switch (args) { case 1: - return d_make_comp (di, DEMANGLE_COMPONENT_UNARY, op, - d_expression (di)); + { + struct demangle_component *operand; + if (op->type == DEMANGLE_COMPONENT_CAST + && d_check_char (di, '_')) + operand = d_exprlist (di); + else + operand = d_expression (di); + return d_make_comp (di, DEMANGLE_COMPONENT_UNARY, op, + operand); + } case 2: { struct demangle_component *left; @@ -2671,7 +2714,9 @@ d_expr_primary (struct d_info *di) if (! d_check_char (di, 'L')) return NULL; - if (d_peek_char (di) == '_') + if (d_peek_char (di) == '_' + /* Workaround for G++ bug; see comment in write_template_arg. */ + || d_peek_char (di) == 'Z') ret = cplus_demangle_mangled_name (di, 0); else { @@ -3293,6 +3338,7 @@ d_print_comp (struct d_print_info *dpi, the right place for the type. We also have to pass down any CV-qualifiers, which apply to the this parameter. */ hold_modifiers = dpi->modifiers; + dpi->modifiers = 0; i = 0; typed_name = d_left (dc); while (typed_name != NULL) @@ -3981,6 +4027,15 @@ d_print_comp (struct d_print_info *dpi, } return; + case DEMANGLE_COMPONENT_FUNCTION_PARAM: + { + char buf[25]; + d_append_string (dpi, "parm#"); + sprintf(buf,"%ld", dc->u.s_number.number); + d_append_string (dpi, buf); + return; + } + default: d_print_error (dpi); return; diff --git a/libiberty/testsuite/demangle-expected b/libiberty/testsuite/demangle-expected index d9efbc0d24e..cded6b5d71a 100644 --- a/libiberty/testsuite/demangle-expected +++ b/libiberty/testsuite/demangle-expected @@ -3723,7 +3723,7 @@ foo # This used to crash the demangler--PR 16240 --format=gnu-v3 --no-params _ZN13PatternDriver23StringScalarDeleteValueC1ERKNS_25ConflateStringScalarValueERKNS_25AbstractStringScalarValueERKNS_12TemplateEnumINS_12pdcomplementELZNS_16complement_namesEELZNS_14COMPLEMENTENUMEEEE -_ZN13PatternDriver23StringScalarDeleteValueC1ERKNS_25ConflateStringScalarValueERKNS_25AbstractStringScalarValueERKNS_12TemplateEnumINS_12pdcomplementELZNS_16complement_namesEELZNS_14COMPLEMENTENUMEEEE +PatternDriver::StringScalarDeleteValue::StringScalarDeleteValue(PatternDriver::ConflateStringScalarValue const&, PatternDriver::AbstractStringScalarValue const&, PatternDriver::TemplateEnum const&) PatternDriver::StringScalarDeleteValue::StringScalarDeleteValue # # This used to cause the demangler to walk into undefined memory--PR 22268 @@ -3884,12 +3884,12 @@ _ZGr32_java$Sutil$Siso4217$_properties java resource java/util/iso4217.properties # decltype/param placeholder test --format=gnu-v3 -_Z3addIidEDTplsTT_sTT0_ES0_S1_ -decltype ((int)+(double)) add(int, double) +_Z3addIidEDTplfp_fp0_ET_T0_ +decltype ((parm#1)+(parm#2)) add(int, double) # decltype/fn call test --format=gnu-v3 -_Z4add3IidEDTclL_Z1gEsTT_sTT0_EES0_S1_ -decltype (g(int, double)) add3(int, double) +_Z4add3IidEDTclL_Z1gEfp_fp0_EET_T0_ +decltype (g(parm#1, parm#2)) add3(int, double) # new (2008) built in types test --format=gnu-v3 _Z1fDfDdDeDhDsDi @@ -3900,5 +3900,9 @@ _Z1fIIPiPfPdEEvDpT_ void f(int*, float*, double*) # '.' test --format=gnu-v3 -_Z1hI1AIiEdEDTcldtsTT_1gIT0_EEES2_S3_ -decltype (((A).(g))()) h, double>(A, double) +_Z1hI1AIiEdEDTcldtfp_1gIT0_EEET_S2_ +decltype (((parm#1).(g))()) h, double>(A, double) +# test for typed function in decltype +--format=gnu-v3 +_ZN1AIiE1jIiEEDTplfp_clL_Z1xvEEET_ +decltype ((parm#1)+((x())())) A::j(int)