Commit 3aecd443 by Jakub Jelinek Committed by Jakub Jelinek

tree-pretty-print.c (dump_generic_code): Print [idx]= and [idx1 ...

	* tree-pretty-print.c (dump_generic_code) <case CONSTRUCTOR>: Print
	[idx]= and [idx1 ... idx2]= before initializers if needed for
	array initializers.

From-SVN: r175748
parent 7474f719
2011-07-01 Jakub Jelinek <jakub@redhat.com>
* tree-pretty-print.c (dump_generic_code) <case CONSTRUCTOR>: Print
[idx]= and [idx1 ... idx2]= before initializers if needed for
array initializers.
2011-07-01 Chen Liqin <liqin.gcc@gmail.com> 2011-07-01 Chen Liqin <liqin.gcc@gmail.com>
* config.gcc (score-*-elf): Remove score7.o. * config.gcc (score-*-elf): Remove score7.o.
......
/* Pretty formatting of GENERIC trees in C syntax. /* Pretty formatting of GENERIC trees in C syntax.
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
Free Software Foundation, Inc. 2011 Free Software Foundation, Inc.
Adapted from c-pretty-print.c by Diego Novillo <dnovillo@redhat.com> Adapted from c-pretty-print.c by Diego Novillo <dnovillo@redhat.com>
This file is part of GCC. This file is part of GCC.
...@@ -1250,19 +1250,58 @@ dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags, ...@@ -1250,19 +1250,58 @@ dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags,
{ {
unsigned HOST_WIDE_INT ix; unsigned HOST_WIDE_INT ix;
tree field, val; tree field, val;
bool is_struct_init = FALSE; bool is_struct_init = false;
bool is_array_init = false;
double_int curidx = double_int_zero;
pp_character (buffer, '{'); pp_character (buffer, '{');
if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
|| TREE_CODE (TREE_TYPE (node)) == UNION_TYPE) || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
is_struct_init = TRUE; is_struct_init = true;
else if (TREE_CODE (TREE_TYPE (node)) == ARRAY_TYPE
&& TYPE_DOMAIN (TREE_TYPE (node))
&& TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)))
&& TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))))
== INTEGER_CST)
{
tree minv = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)));
is_array_init = true;
curidx = tree_to_double_int (minv);
}
FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val) FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
{ {
if (field && is_struct_init) if (field)
{ {
pp_character (buffer, '.'); if (is_struct_init)
dump_generic_node (buffer, field, spc, flags, false); {
pp_string (buffer, "="); pp_character (buffer, '.');
dump_generic_node (buffer, field, spc, flags, false);
pp_character (buffer, '=');
}
else if (is_array_init
&& (TREE_CODE (field) != INTEGER_CST
|| !double_int_equal_p (tree_to_double_int (field),
curidx)))
{
pp_character (buffer, '[');
if (TREE_CODE (field) == RANGE_EXPR)
{
dump_generic_node (buffer, TREE_OPERAND (field, 0), spc,
flags, false);
pp_string (buffer, " ... ");
dump_generic_node (buffer, TREE_OPERAND (field, 1), spc,
flags, false);
if (TREE_CODE (TREE_OPERAND (field, 1)) == INTEGER_CST)
curidx = tree_to_double_int (TREE_OPERAND (field, 1));
}
else
dump_generic_node (buffer, field, spc, flags, false);
if (TREE_CODE (field) == INTEGER_CST)
curidx = tree_to_double_int (field);
pp_string (buffer, "]=");
}
} }
if (is_array_init)
curidx = double_int_add (curidx, double_int_one);
if (val && TREE_CODE (val) == ADDR_EXPR) if (val && TREE_CODE (val) == ADDR_EXPR)
if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL) if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
val = TREE_OPERAND (val, 0); val = TREE_OPERAND (val, 0);
......
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