diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-03-17 23:31:18 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-03-17 23:31:18 +0000 |
commit | e92154af793a1276995512dfa15f72a69ecb4db9 (patch) | |
tree | a0bf6190acd7e4997d3304c4bfe60c3c1b461532 /libiberty | |
parent | 21b6de0b608fe2c3ce1bd0b9bd0e77109c061358 (diff) | |
download | gcc-e92154af793a1276995512dfa15f72a69ecb4db9.tar.gz |
cp/:
* decl.c (grokfndecl): Set DECL_CONTEXT on parms.
(duplicate_decls): Adjust DECL_CONTEXT of newdecl's parms.
* pt.c (check_explicit_specialization): Likewise.
(tsubst_copy) [PARM_DECL]: Return a dummy parm if we don't have a
local specialization.
* tree.c (cp_tree_equal) [PARM_DECL]: Check type and index, not name.
* decl2.c (parm_index): New fn.
* semantics.c (finish_decltype_type): Don't use describable_type.
* mangle.c (write_expression): Likewise. Mangle ALIGNOF_EXPR.
Give a sorry for unsupported codes rather than crash. Mangle
conversions with other than 1 operand. New mangling for PARM_DECL.
* operators.def (ALIGNOF_EXPR): Mangle as az.
* include/demangle.h (enum demangle_component_type): Add
DEMANGLE_COMPONENT_FUNCTION_PARAM.
* libiberty/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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@144924 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libiberty')
-rw-r--r-- | libiberty/ChangeLog | 12 | ||||
-rw-r--r-- | libiberty/cp-demangle.c | 71 | ||||
-rw-r--r-- | libiberty/testsuite/demangle-expected | 18 |
3 files changed, 86 insertions, 15 deletions
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 <jason@redhat.com> + + * 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 <mark@codesourcery.com> * make-temp-file.c (<windows.h>): 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<int (*) [3]> # 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<PatternDriver::pdcomplement, PatternDriver::complement_names, PatternDriver::COMPLEMENTENUM> 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>(int, double) +_Z3addIidEDTplfp_fp0_ET_T0_ +decltype ((parm#1)+(parm#2)) add<int, double>(int, double) # decltype/fn call test --format=gnu-v3 -_Z4add3IidEDTclL_Z1gEsTT_sTT0_EES0_S1_ -decltype (g(int, double)) add3<int, double>(int, double) +_Z4add3IidEDTclL_Z1gEfp_fp0_EET_T0_ +decltype (g(parm#1, parm#2)) add3<int, double>(int, double) # new (2008) built in types test --format=gnu-v3 _Z1fDfDdDeDhDsDi @@ -3900,5 +3900,9 @@ _Z1fIIPiPfPdEEvDpT_ void f<int*, float*, double*>(int*, float*, double*) # '.' test --format=gnu-v3 -_Z1hI1AIiEdEDTcldtsTT_1gIT0_EEES2_S3_ -decltype (((A<int>).(g<double>))()) h<A<int>, double>(A<int>, double) +_Z1hI1AIiEdEDTcldtfp_1gIT0_EEET_S2_ +decltype (((parm#1).(g<double>))()) h<A<int>, double>(A<int>, double) +# test for typed function in decltype +--format=gnu-v3 +_ZN1AIiE1jIiEEDTplfp_clL_Z1xvEEET_ +decltype ((parm#1)+((x())())) A<int>::j<int>(int) |