diff mbox

PR60147: fix ICE with DECL_NAMELIST and tree-pretty-printer.c

Message ID 53086730.5090500@net-b.de
State New
Headers show

Commit Message

Tobias Burnus Feb. 22, 2014, 9 a.m. UTC
Since GCC 4.9, gfortran generates a DECL_NAMELIST (for DWARF's 
DW_TAG_namelist) - they are stored in the BIND_EXPR. Namelists are a bit 
boring: They only group variable names and the namelist name is only 
used in I/O statements (READ, WRITE) to permit a fancy data input [and 
output] - and for the debugger.

Due to DW_TAG_namelist, namelists are now exposed to the middle end - 
and I forgot to handle them also in the tree pretty printer - hence 
-fdump-tree-original now ICEs.

For the pretty printer one has two options: Ignoring (or "NYI;") the 
decl or dumping it. The attached patch does the latter.

Bootstrapped (C/C++/Fortran) and regtested on x86-64-gnu-linux.
OK for the trunk?

Tobias
diff mbox

Patch

2014-02-22  Tobias Burnus  <burnus@net-b.de>

	PR middle-end/60147
	* tree-pretty-print.c (dump_generic_node): Handle
	NAMELIST_DECL.

diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c
index 0595499..80c59a6 100644
--- a/gcc/tree-pretty-print.c
+++ b/gcc/tree-pretty-print.c
@@ -1386,20 +1386,40 @@  dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags,
       break;
 
     case VAR_DECL:
     case PARM_DECL:
     case FIELD_DECL:
     case DEBUG_EXPR_DECL:
     case NAMESPACE_DECL:
       dump_decl_name (buffer, node, flags);
       break;
 
+    case NAMELIST_DECL:
+      {
+	unsigned i;
+	tree value;
+        INDENT (spc);
+	pp_string (buffer, "namelist /");
+	dump_decl_name (buffer, node, flags);
+	pp_string (buffer, "/ ");
+	op0 = NAMELIST_DECL_ASSOCIATED_DECL(node);
+	FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (op0), i, value)
+	  {
+	    if (i != 0)
+	      pp_string (buffer, ", ");
+	    if (value)
+	      dump_decl_name (buffer, value, flags);
+	  }
+	pp_semicolon (buffer);
+	break;
+      }
+
     case RESULT_DECL:
       pp_string (buffer, "<retval>");
       break;
 
     case COMPONENT_REF:
       op0 = TREE_OPERAND (node, 0);
       str = ".";
       if (op0
 	  && (TREE_CODE (op0) == INDIRECT_REF
 	      || (TREE_CODE (op0) == MEM_REF
@@ -1713,21 +1733,24 @@  dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags,
     case BIND_EXPR:
       pp_left_brace (buffer);
       if (!(flags & TDF_SLIM))
 	{
 	  if (BIND_EXPR_VARS (node))
 	    {
 	      pp_newline (buffer);
 
 	      for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
 		{
-		  print_declaration (buffer, op0, spc+2, flags);
+		  if (TREE_CODE(op0) == NAMELIST_DECL)
+		    dump_generic_node (buffer, op0, spc+2, flags, false);
+		  else
+		    print_declaration (buffer, op0, spc+2, flags);
 		  pp_newline (buffer);
 		}
 	    }
 
 	  newline_and_indent (buffer, spc+2);
 	  dump_generic_node (buffer, BIND_EXPR_BODY (node), spc+2, flags, true);
 	  newline_and_indent (buffer, spc);
 	  pp_right_brace (buffer);
 	}
       is_expr = false;