From 4d43dcdeb57d58ad5e3aade44b93fa48d051c770 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 20 Jan 2010 20:58:53 -0500 Subject: re PR c++/42338 ([c++0x] ICE on decltype usage with templates) PR c++/42338 * mangle.c (write_expression): Handle tree codes that have extra arguments in the middle-end. * cp-demangle.c (d_print_comp): Fix array index printing. From-SVN: r156103 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/mangle.c | 24 ++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) (limited to 'gcc/cp') 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 + + PR c++/42338 + * mangle.c (write_expression): Handle tree codes that have extra + arguments in the middle-end. + 2010-01-20 Paolo Carlini 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 -- cgit v1.1