Commit a84a98ca by Paolo Carlini Committed by Paolo Carlini

error.c (dump_expr): Don't deal directly with NEW_EXPR (and VEC_NEW_EXPR),…

error.c (dump_expr): Don't deal directly with NEW_EXPR (and VEC_NEW_EXPR), forward to pp_expression.

2008-02-24  Paolo Carlini  <pcarlini@suse.de>

	* error.c (dump_expr): Don't deal directly with NEW_EXPR (and
	VEC_NEW_EXPR), forward to pp_expression.
	* cxx-pretty-print.c (pp_cxx_new_expression): Fix FIXME.

From-SVN: r132595
parent 98d778a6
2008-02-24 Paolo Carlini <pcarlini@suse.de>
* error.c (dump_expr): Don't deal directly with NEW_EXPR (and
VEC_NEW_EXPR), forward to pp_expression.
* cxx-pretty-print.c (pp_cxx_new_expression): Fix FIXME.
2008-02-24 Danny Smith <dannysmith@users.sourceforge.net> 2008-02-24 Danny Smith <dannysmith@users.sourceforge.net>
PR c++/34749 PR c++/34749
......
/* Implementation of subroutines for the GNU C++ pretty-printer. /* Implementation of subroutines for the GNU C++ pretty-printer.
Copyright (C) 2003, 2004, 2005, 2007 Free Software Foundation, Inc. Copyright (C) 2003, 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net> Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
This file is part of GCC. This file is part of GCC.
...@@ -636,6 +636,8 @@ static void ...@@ -636,6 +636,8 @@ static void
pp_cxx_new_expression (cxx_pretty_printer *pp, tree t) pp_cxx_new_expression (cxx_pretty_printer *pp, tree t)
{ {
enum tree_code code = TREE_CODE (t); enum tree_code code = TREE_CODE (t);
tree type = TREE_OPERAND (t, 1);
tree init = TREE_OPERAND (t, 2);
switch (code) switch (code)
{ {
case NEW_EXPR: case NEW_EXPR:
...@@ -648,18 +650,22 @@ pp_cxx_new_expression (cxx_pretty_printer *pp, tree t) ...@@ -648,18 +650,22 @@ pp_cxx_new_expression (cxx_pretty_printer *pp, tree t)
pp_cxx_call_argument_list (pp, TREE_OPERAND (t, 0)); pp_cxx_call_argument_list (pp, TREE_OPERAND (t, 0));
pp_space (pp); pp_space (pp);
} }
/* FIXME: array-types are built with one more element. */ if (TREE_CODE (type) == ARRAY_REF)
pp_cxx_type_id (pp, TREE_OPERAND (t, 1)); type = build_cplus_array_type
if (TREE_OPERAND (t, 2)) (TREE_OPERAND (type, 0),
build_index_type (fold_build2 (MINUS_EXPR, integer_type_node,
TREE_OPERAND (type, 1),
integer_one_node)));
pp_cxx_type_id (pp, type);
if (init)
{ {
pp_left_paren (pp); pp_left_paren (pp);
t = TREE_OPERAND (t, 2); if (TREE_CODE (init) == TREE_LIST)
if (TREE_CODE (t) == TREE_LIST) pp_c_expression_list (pp_c_base (pp), init);
pp_c_expression_list (pp_c_base (pp), t); else if (init == void_zero_node)
else if (t == void_zero_node)
; /* OK, empty initializer list. */ ; /* OK, empty initializer list. */
else else
pp_cxx_expression (pp, t); pp_cxx_expression (pp, init);
pp_right_paren (pp); pp_right_paren (pp);
} }
break; break;
......
...@@ -1583,43 +1583,6 @@ dump_expr (tree t, int flags) ...@@ -1583,43 +1583,6 @@ dump_expr (tree t, int flags)
} }
break; break;
case NEW_EXPR:
{
tree type = TREE_OPERAND (t, 1);
tree init = TREE_OPERAND (t, 2);
if (NEW_EXPR_USE_GLOBAL (t))
pp_cxx_colon_colon (cxx_pp);
pp_cxx_identifier (cxx_pp, "new");
if (TREE_OPERAND (t, 0))
{
pp_cxx_left_paren (cxx_pp);
dump_expr_list (TREE_OPERAND (t, 0), flags);
pp_cxx_right_paren (cxx_pp);
pp_cxx_whitespace (cxx_pp);
}
if (TREE_CODE (type) == ARRAY_REF)
type = build_cplus_array_type
(TREE_OPERAND (type, 0),
build_index_type (fold_build2 (MINUS_EXPR, integer_type_node,
TREE_OPERAND (type, 1),
integer_one_node)));
dump_type (type, flags);
if (init)
{
pp_cxx_left_paren (cxx_pp);
if (TREE_CODE (init) == TREE_LIST)
dump_expr_list (init, flags);
else if (init == void_zero_node)
/* This representation indicates an empty initializer,
e.g.: "new int()". */
;
else
dump_expr (init, flags);
pp_cxx_right_paren (cxx_pp);
}
}
break;
case TARGET_EXPR: case TARGET_EXPR:
/* Note that this only works for G++ target exprs. If somebody /* Note that this only works for G++ target exprs. If somebody
builds a general TARGET_EXPR, there's no way to represent that builds a general TARGET_EXPR, there's no way to represent that
...@@ -2075,6 +2038,8 @@ dump_expr (tree t, int flags) ...@@ -2075,6 +2038,8 @@ dump_expr (tree t, int flags)
case TYPEID_EXPR: case TYPEID_EXPR:
case MEMBER_REF: case MEMBER_REF:
case DOTSTAR_EXPR: case DOTSTAR_EXPR:
case NEW_EXPR:
case VEC_NEW_EXPR:
case DELETE_EXPR: case DELETE_EXPR:
case VEC_DELETE_EXPR: case VEC_DELETE_EXPR:
case MODOP_EXPR: case MODOP_EXPR:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment