aboutsummaryrefslogtreecommitdiff
path: root/libiberty
diff options
context:
space:
mode:
authorDJ Delorie <dj@redhat.com>2009-03-18 00:07:49 +0000
committerDJ Delorie <dj@redhat.com>2009-03-18 00:07:49 +0000
commitc743cf5d81e46011aada39382daabf1383f3ad41 (patch)
tree404e807c19fa4d2e25153858a712397b8ba0c5c1 /libiberty
parent5b548f9aa4f12b5b0912a5b5a9d1a30ccb2338e5 (diff)
downloadgdb-c743cf5d81e46011aada39382daabf1383f3ad41.zip
gdb-c743cf5d81e46011aada39382daabf1383f3ad41.tar.gz
gdb-c743cf5d81e46011aada39382daabf1383f3ad41.tar.bz2
merge from gcc
Diffstat (limited to 'libiberty')
-rw-r--r--libiberty/ChangeLog12
-rw-r--r--libiberty/cp-demangle.c71
-rw-r--r--libiberty/testsuite/demangle-expected18
3 files changed, 86 insertions, 15 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index db7d287..00aa57a 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 0b4e05c..e6d3d5e 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 d9efbc0..cded6b5 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)