Hi Richard, hi all,

I wrote:
> @@ -1713,21 +1733,24 @@ dump_generic_node (pretty_printer *buffer, tree node, 
> int spc, int flags,
>     case BIND_EXPR:
...
>             for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
>               {
>-                print_declaration (buffer, op0, spc+2, flags);
>+                if (TREE_CODE(op0) == NAMELIST_DECL)
...

Richard Biener wrote:
> Works for me, but doesn't the simpler

> --- tree-pretty-print.c (revision 208066)
> +++ tree-pretty-print.c (working copy)
> @@ -1390,6 +1390,7 @@
>     case FIELD_DECL:
>     case DEBUG_EXPR_DECL:
>     case NAMESPACE_DECL:
>+    case NAMELIST_DECL:
>       dump_decl_name (buffer, node, flags);
>       break;
>
> also work?  It's odd that we need to do sth special just for namelist-decls.

It won't do - at least not like that. NAMELIST_DECL are stored in BIND_EXPR,
hence, one ends up in the code I quote above. That code calls
  print_declaration()

NAMELIST_DECL are created as
  decl = make_node (NAMELIST_DECL);
  TREE_TYPE (decl) = void_type_node;
  NAMELIST_DECL_ASSOCIATED_DECL (decl) = build_constructor (NULL_TREE, 
nml_decls);
Hence, TREE_TYPE() is void_type_node and dereferencing that one leads to an ICE.


However, the following should work - do you like it more?

Tobias


--- a/gcc/tree-pretty-print.c
+++ b/gcc/tree-pretty-print.c
@@ -2686,6 +2686,13 @@ print_declaration (pretty_printer *buffer, tree t, int 
spc, int flags)
 {
   INDENT (spc);

+  if (TREE_CODE(t) == NAMELIST_DECL)
+    {
+       pp_string(buffer, "namelist ");
+       dump_decl_name (buffer, t, flags);
+       goto done;
+    }
+
   if (TREE_CODE (t) == TYPE_DECL)
     pp_string (buffer, "typedef ");

@@ -2767,6 +2774,7 @@ print_declaration (pretty_printer *buffer, tree t, int 
spc, int flags)
       pp_right_bracket (buffer);
     }

+done:
   pp_semicolon (buffer);
 }

Reply via email to