aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-pretty-print.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2009-01-02 15:38:05 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2009-01-02 15:38:05 +0100
commit0cf0d02be54d74af357414f6a1531ad3b9319855 (patch)
tree77592e561a3eb185ce8cb757924ea596164cef4e /gcc/tree-pretty-print.c
parente3606f3bda110bcec675134174c8d72f09cce75d (diff)
downloadgcc-0cf0d02be54d74af357414f6a1531ad3b9319855.zip
gcc-0cf0d02be54d74af357414f6a1531ad3b9319855.tar.gz
gcc-0cf0d02be54d74af357414f6a1531ad3b9319855.tar.bz2
re PR middle-end/38690 (Missing parentheses for (a-1)/2 in final_cleanup)
PR middle-end/38690 * tree-flow.h (op_code_prio, op_prio): New prototypes. * tree-pretty-print.c (op_code_prio): New function. (op_prio): No longer static. Use op_code_prio. * gimple-pretty-print.c (dump_unary_rhs, dump_binary_rhs): Use op_prio and op_code_prio to determine if () should be printed around operand(s) or not. * gimple-pretty-print.c (dump_unary_rhs, dump_binary_rhs, dump_gimple_call, dump_gimple_switch, dump_gimple_cond, dump_gimple_label, dump_gimple_try, dump_symbols, dump_gimple_phi, dump_gimple_mem_ops, dump_bb_header, dump_bb_end, pp_cfg_jump): Use pp_character instead of pp_string for single letter printing. From-SVN: r143012
Diffstat (limited to 'gcc/tree-pretty-print.c')
-rw-r--r--gcc/tree-pretty-print.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c
index 5708eed..ff45ecc 100644
--- a/gcc/tree-pretty-print.c
+++ b/gcc/tree-pretty-print.c
@@ -1,5 +1,5 @@
/* Pretty formatting of GENERIC trees in C syntax.
- Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+ Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
Free Software Foundation, Inc.
Adapted from c-pretty-print.c by Diego Novillo <dnovillo@redhat.com>
@@ -38,7 +38,6 @@ along with GCC; see the file COPYING3. If not see
#include "predict.h"
/* Local functions, macros and variables. */
-static int op_prio (const_tree);
static const char *op_symbol (const_tree);
static void pretty_print_string (pretty_printer *, const char*);
static void print_call_name (pretty_printer *, const_tree);
@@ -2223,7 +2222,7 @@ print_struct_decl (pretty_printer *buffer, const_tree node, int spc, int flags)
pp_character (buffer, '}');
}
-/* Return the priority of the operator OP.
+/* Return the priority of the operator CODE.
From lowest to highest precedence with either left-to-right (L-R)
or right-to-left (R-L) associativity]:
@@ -2247,13 +2246,10 @@ print_struct_decl (pretty_printer *buffer, const_tree node, int spc, int flags)
unary +, - and * have higher precedence than the corresponding binary
operators. */
-static int
-op_prio (const_tree op)
+int
+op_code_prio (enum tree_code code)
{
- if (op == NULL)
- return 9999;
-
- switch (TREE_CODE (op))
+ switch (code)
{
case TREE_LIST:
case COMPOUND_EXPR:
@@ -2374,10 +2370,6 @@ op_prio (const_tree op)
case VEC_PACK_SAT_EXPR:
return 16;
- case SAVE_EXPR:
- case NON_LVALUE_EXPR:
- return op_prio (TREE_OPERAND (op, 0));
-
default:
/* Return an arbitrarily high precedence to avoid surrounding single
VAR_DECLs in ()s. */
@@ -2385,6 +2377,22 @@ op_prio (const_tree op)
}
}
+/* Return the priority of the operator OP. */
+
+int
+op_prio (const_tree op)
+{
+ enum tree_code code;
+
+ if (op == NULL)
+ return 9999;
+
+ code = TREE_CODE (op);
+ if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
+ return op_prio (TREE_OPERAND (op, 0));
+
+ return op_code_prio (code);
+}
/* Return the symbol associated with operator CODE. */