[PR,lto/84105] handle TYPE_IDENTIFIERs for FUNCTION_TYPEs in the gimple pretty printer

Message ID f7b31d48-1514-72d5-c70b-584ff121f81c@redhat.com
State New
Headers show
Series
  • [PR,lto/84105] handle TYPE_IDENTIFIERs for FUNCTION_TYPEs in the gimple pretty printer
Related show

Commit Message

Aldy Hernandez Jan. 30, 2018, 6:29 p.m.
Hi!

As discussed in the PR, the ICE here happens in dump_generic_node:

     case FUNCTION_TYPE:
     case METHOD_TYPE:
...
       if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
	dump_decl_name (pp, TYPE_NAME (node), flags);

(gdb) print node
$21 = <function_type 0x7fffef652dc8 printfn_t>
(gdb) print node.type_common.name
$22 = <identifier_node 0x7fffef654730 printfn_t>

TYPE_NAME is an IDENTIFIER_NODE, whereas we're expecting a DECL_P, and 
bad things happen.

OK pending tests?

Comments

Richard Biener Jan. 31, 2018, 10:32 a.m. | #1
On Tue, Jan 30, 2018 at 7:29 PM, Aldy Hernandez <aldyh@redhat.com> wrote:
> Hi!

>

> As discussed in the PR, the ICE here happens in dump_generic_node:

>

>     case FUNCTION_TYPE:

>     case METHOD_TYPE:

> ...

>       if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))

>         dump_decl_name (pp, TYPE_NAME (node), flags);

>

> (gdb) print node

> $21 = <function_type 0x7fffef652dc8 printfn_t>

> (gdb) print node.type_common.name

> $22 = <identifier_node 0x7fffef654730 printfn_t>

>

> TYPE_NAME is an IDENTIFIER_NODE, whereas we're expecting a DECL_P, and bad

> things happen.

>

> OK pending tests?


OK.

Patch

gcc/

	PR lto/84105
	* tree-pretty-print.c (dump_generic_node): Handle a TYPE_NAME with
	an IDENTIFIER_NODE for FUNCTION_TYPE's.

diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c
index 54a8dfa3b6f..73eb27c8e8f 100644
--- a/gcc/tree-pretty-print.c
+++ b/gcc/tree-pretty-print.c
@@ -1822,7 +1822,9 @@  dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags,
 	    pp_string (pp, "<null method basetype>");
 	  pp_colon_colon (pp);
 	}
-      if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
+      if (TYPE_IDENTIFIER (node))
+	dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
+      else if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
 	dump_decl_name (pp, TYPE_NAME (node), flags);
       else if (flags & TDF_NOUID)
 	pp_printf (pp, "<Txxxx>");