summaryrefslogtreecommitdiff
path: root/gcc/cp/error.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/error.c')
-rw-r--r--gcc/cp/error.c80
1 files changed, 62 insertions, 18 deletions
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index 00f07677454..6a0eed5e16b 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -66,6 +66,8 @@ static void dump_aggr_type (tree, int);
static void dump_type_prefix (tree, int);
static void dump_type_suffix (tree, int);
static void dump_function_name (tree, int);
+static void dump_call_expr_args (tree, int, bool);
+static void dump_aggr_init_expr_args (tree, int, bool);
static void dump_expr_list (tree, int);
static void dump_global_iord (tree);
static void dump_parameters (tree, int);
@@ -1265,6 +1267,55 @@ dump_template_parms (tree info, int primary, int flags)
pp_cxx_end_template_argument_list (cxx_pp);
}
+/* Print out the arguments of CALL_EXPR T as a parenthesized list using
+ flags FLAGS. Skip over the first argument if SKIPFIRST is true. */
+
+static void
+dump_call_expr_args (tree t, int flags, bool skipfirst)
+{
+ tree arg;
+ call_expr_arg_iterator iter;
+
+ pp_cxx_left_paren (cxx_pp);
+ FOR_EACH_CALL_EXPR_ARG (arg, iter, t)
+ {
+ if (skipfirst)
+ skipfirst = false;
+ else
+ {
+ dump_expr (arg, flags | TFF_EXPR_IN_PARENS);
+ if (more_call_expr_args_p (&iter))
+ pp_separate_with_comma (cxx_pp);
+ }
+ }
+ pp_cxx_right_paren (cxx_pp);
+}
+
+/* Print out the arguments of AGGR_INIT_EXPR T as a parenthesized list
+ using flags FLAGS. Skip over the first argument if SKIPFIRST is
+ true. */
+
+static void
+dump_aggr_init_expr_args (tree t, int flags, bool skipfirst)
+{
+ tree arg;
+ aggr_init_expr_arg_iterator iter;
+
+ pp_cxx_left_paren (cxx_pp);
+ FOR_EACH_AGGR_INIT_EXPR_ARG (arg, iter, t)
+ {
+ if (skipfirst)
+ skipfirst = false;
+ else
+ {
+ dump_expr (arg, flags | TFF_EXPR_IN_PARENS);
+ if (more_aggr_init_expr_args_p (&iter))
+ pp_separate_with_comma (cxx_pp);
+ }
+ }
+ pp_cxx_right_paren (cxx_pp);
+}
+
/* Print out a list of initializers (subr of dump_expr). */
static void
@@ -1387,8 +1438,8 @@ dump_expr (tree t, int flags)
{
tree fn = NULL_TREE;
- if (TREE_CODE (TREE_OPERAND (t, 0)) == ADDR_EXPR)
- fn = TREE_OPERAND (TREE_OPERAND (t, 0), 0);
+ if (TREE_CODE (AGGR_INIT_EXPR_FN (t)) == ADDR_EXPR)
+ fn = TREE_OPERAND (AGGR_INIT_EXPR_FN (t), 0);
if (fn && TREE_CODE (fn) == FUNCTION_DECL)
{
@@ -1398,18 +1449,15 @@ dump_expr (tree t, int flags)
dump_decl (fn, 0);
}
else
- dump_expr (TREE_OPERAND (t, 0), 0);
+ dump_expr (AGGR_INIT_EXPR_FN (t), 0);
}
- pp_cxx_left_paren (cxx_pp);
- if (TREE_OPERAND (t, 1))
- dump_expr_list (TREE_CHAIN (TREE_OPERAND (t, 1)), flags);
- pp_cxx_right_paren (cxx_pp);
+ dump_aggr_init_expr_args (t, flags, false);
break;
case CALL_EXPR:
{
- tree fn = TREE_OPERAND (t, 0);
- tree args = TREE_OPERAND (t, 1);
+ tree fn = CALL_EXPR_FN (t);
+ bool skipfirst = false;
if (TREE_CODE (fn) == ADDR_EXPR)
fn = TREE_OPERAND (fn, 0);
@@ -1420,7 +1468,7 @@ dump_expr (tree t, int flags)
if (TREE_TYPE (fn) != NULL_TREE && NEXT_CODE (fn) == METHOD_TYPE)
{
- tree ob = TREE_VALUE (args);
+ tree ob = CALL_EXPR_ARG (t, 0);
if (TREE_CODE (ob) == ADDR_EXPR)
{
dump_expr (TREE_OPERAND (ob, 0), flags | TFF_EXPR_IN_PARENS);
@@ -1432,12 +1480,10 @@ dump_expr (tree t, int flags)
dump_expr (ob, flags | TFF_EXPR_IN_PARENS);
pp_arrow (cxx_pp);
}
- args = TREE_CHAIN (args);
+ skipfirst = true;
}
dump_expr (fn, flags | TFF_EXPR_IN_PARENS);
- pp_cxx_left_paren (cxx_pp);
- dump_expr_list (args, flags);
- pp_cxx_right_paren (cxx_pp);
+ dump_call_expr_args (t, flags, skipfirst);
}
break;
@@ -1581,10 +1627,8 @@ dump_expr (tree t, int flags)
{
t = TREE_OPERAND (t, 0);
gcc_assert (TREE_CODE (t) == CALL_EXPR);
- dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
- pp_cxx_left_paren (cxx_pp);
- dump_expr_list (TREE_CHAIN (TREE_OPERAND (t, 1)), flags);
- pp_cxx_right_paren (cxx_pp);
+ dump_expr (CALL_EXPR_FN (t), flags | TFF_EXPR_IN_PARENS);
+ dump_call_expr_args (t, flags, true);
}
else
{