diff options
author | Diego Novillo <dnovillo@google.com> | 2009-07-06 13:04:34 -0400 |
---|---|---|
committer | Diego Novillo <dnovillo@gcc.gnu.org> | 2009-07-06 13:04:34 -0400 |
commit | e923c8ea8cd61a186e7082a12864a97df0dde748 (patch) | |
tree | da30ecfc5ea26303c889456d1b4acfc28ad86266 /gcc/tree-pretty-print.c | |
parent | b824522ad40d558e595d2ef529a9ddad8c78c8bf (diff) | |
download | gcc-e923c8ea8cd61a186e7082a12864a97df0dde748.zip gcc-e923c8ea8cd61a186e7082a12864a97df0dde748.tar.gz gcc-e923c8ea8cd61a186e7082a12864a97df0dde748.tar.bz2 |
tree-pretty-print.c (dump_generic_node): Protect against NULL op0.
* tree-pretty-print.c (dump_generic_node): Protect
against NULL op0.
(debug_tree_chain): Handle cycles.
From-SVN: r149289
Diffstat (limited to 'gcc/tree-pretty-print.c')
-rw-r--r-- | gcc/tree-pretty-print.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c index 1426907..faf23c6 100644 --- a/gcc/tree-pretty-print.c +++ b/gcc/tree-pretty-print.c @@ -99,13 +99,24 @@ debug_generic_stmt (tree t) void debug_tree_chain (tree t) { + struct pointer_set_t *seen = pointer_set_create (); + while (t) - { - print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID); - fprintf(stderr, " "); - t = TREE_CHAIN (t); - } + { + print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID); + fprintf (stderr, " "); + t = TREE_CHAIN (t); + if (pointer_set_insert (seen, t)) + { + fprintf (stderr, "... [cycled back to "); + print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID); + fprintf (stderr, "]"); + break; + } + } fprintf (stderr, "\n"); + + pointer_set_destroy (seen); } /* Prints declaration DECL to the FILE with details specified by FLAGS. */ @@ -1051,7 +1062,7 @@ dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags, case COMPONENT_REF: op0 = TREE_OPERAND (node, 0); str = "."; - if (TREE_CODE (op0) == INDIRECT_REF) + if (op0 && TREE_CODE (op0) == INDIRECT_REF) { op0 = TREE_OPERAND (op0, 0); str = "->"; |