From: Diego Novillo Date: Mon, 6 Jul 2009 17:04:34 +0000 (-0400) Subject: tree-pretty-print.c (dump_generic_node): Protect against NULL op0. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e923c8ea8cd61a186e7082a12864a97df0dde748;p=platform%2Fupstream%2Fgcc.git 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7a035f6..0c740eb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2009-07-06 Diego Novillo + + * tree-pretty-print.c (dump_generic_node): Protect + against NULL op0. + (debug_tree_chain): Handle cycles. + 2009-07-06 Nick Clifton DJ Delorie 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 = "->";