aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/mangle.c24
-rw-r--r--gcc/testsuite/g++.dg/abi/mangle39.C28
-rw-r--r--libiberty/ChangeLog5
-rw-r--r--libiberty/cp-demangle.c15
5 files changed, 73 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 5f7190e..a6a3eb2 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2010-01-20 Jason Merrill <jason@redhat.com>
+
+ PR c++/42338
+ * mangle.c (write_expression): Handle tree codes that have extra
+ arguments in the middle-end.
+
2010-01-20 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/42038
diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index 13b0ed4..7e4cf66 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -2481,7 +2481,7 @@ write_expression (tree expr)
}
else
{
- int i;
+ int i, len;
const char *name;
/* When we bind a variable or function to a non-type template
@@ -2582,7 +2582,27 @@ write_expression (tree expr)
break;
default:
- for (i = 0; i < TREE_OPERAND_LENGTH (expr); ++i)
+ /* In the middle-end, some expressions have more operands than
+ they do in templates (and mangling). */
+ switch (code)
+ {
+ case PREINCREMENT_EXPR:
+ case PREDECREMENT_EXPR:
+ case POSTINCREMENT_EXPR:
+ case POSTDECREMENT_EXPR:
+ len = 1;
+ break;
+
+ case ARRAY_REF:
+ len = 2;
+ break;
+
+ default:
+ len = TREE_OPERAND_LENGTH (expr);
+ break;
+ }
+
+ for (i = 0; i < len; ++i)
{
tree operand = TREE_OPERAND (expr, i);
/* As a GNU extension, the middle operand of a
diff --git a/gcc/testsuite/g++.dg/abi/mangle39.C b/gcc/testsuite/g++.dg/abi/mangle39.C
new file mode 100644
index 0000000..30a08b0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/abi/mangle39.C
@@ -0,0 +1,28 @@
+// PR c++/42338
+// { dg-options "-std=c++0x" }
+// { dg-final { scan-assembler "_Z1fIPiEDTcmppfp_Li0EET_" } }
+// { dg-final { scan-assembler "_Z1gIiEvRK1AIT_EDTixfp_Li0EE" } }
+
+template<typename T>
+auto f(T t) -> decltype(++t, 0)
+{
+ ++t;
+ return 0;
+}
+
+template <class T>
+struct A
+{
+ T operator[](int) const { return 0; }
+};
+
+template< typename T >
+void g(const A<T> &a, decltype(a[0]) t) { }
+
+int main()
+{
+ f((int*)0);
+
+ A<int> a;
+ g(a,1);
+}
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index 6d30823..1e2fbff 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,8 @@
+2010-01-20 Jason Merrill <jason@redhat.com>
+
+ PR c++/42338
+ * cp-demangle.c (d_print_comp): Fix array index printing.
+
2010-01-11 Tristan Gingold <gingold@adacore.com>
* cplus-dem.c (ada_demangle): Remove prototype.
diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index d37c90e..f28e163 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -4037,9 +4037,18 @@ d_print_comp (struct d_print_info *dpi,
d_append_char (dpi, '(');
d_print_subexpr (dpi, d_left (d_right (dc)));
- if (strcmp (d_left (dc)->u.s_operator.op->code, "cl") != 0)
- d_print_expr_op (dpi, d_left (dc));
- d_print_subexpr (dpi, d_right (d_right (dc)));
+ if (strcmp (d_left (dc)->u.s_operator.op->code, "ix") == 0)
+ {
+ d_append_char (dpi, '[');
+ d_print_comp (dpi, d_right (d_right (dc)));
+ d_append_char (dpi, ']');
+ }
+ else
+ {
+ if (strcmp (d_left (dc)->u.s_operator.op->code, "cl") != 0)
+ d_print_expr_op (dpi, d_left (dc));
+ d_print_subexpr (dpi, d_right (d_right (dc)));
+ }
if (d_left (dc)->type == DEMANGLE_COMPONENT_OPERATOR
&& d_left (dc)->u.s_operator.op->len == 1