This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix pretty-printing of array decls


We were printing the bounds of multi-dimensional arrays incorrectly
since they were being done *both* by recursion and iteration and the
"bounds" were really the number of elements.

2004-07-05  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>

	* tree-pretty-print.c (dump_generic_node, case ARRAY_TYPE): Properly
	print bounds.

*** tree-pretty-print.c	2 Jul 2004 01:15:30 -0000	2.18
--- tree-pretty-print.c	5 Jul 2004 13:34:20 -0000
*************** dump_generic_node (pretty_printer *buffe
*** 379,403 ****
  	tree tmp;
  
! 	/* Print the array type.  */
! 	dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
  
  	/* Print the dimensions.  */
! 	tmp = node;
! 	while (tmp && TREE_CODE (tmp) == ARRAY_TYPE)
  	  {
  	    pp_character (buffer, '[');
! 	    if (TYPE_SIZE (tmp))
  	      {
! 		tree size = TYPE_SIZE (tmp);
! 		if (TREE_CODE (size) == INTEGER_CST)
! 		  pp_wide_integer (buffer,
! 				  TREE_INT_CST_LOW (TYPE_SIZE (tmp)) /
! 				  TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (tmp))));
! 		else if (TREE_CODE (size) == MULT_EXPR)
! 		  dump_generic_node (buffer, TREE_OPERAND (size, 0), spc, flags, false);
! 		/* else punt.  */
  	      }
  	    pp_character (buffer, ']');
- 	    tmp = TREE_TYPE (tmp);
  	  }
  	break;
--- 379,413 ----
  	tree tmp;
  
! 	/* Print the innermost component type.  */
! 	for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
! 	     tmp = TREE_TYPE (tmp))
! 	  ;
! 	dump_generic_node (buffer, tmp, spc, flags, false);
  
  	/* Print the dimensions.  */
! 	for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE;
! 	     tmp = TREE_TYPE (tmp))
  	  {
+ 	    tree domain = TYPE_DOMAIN (tmp);
+ 
  	    pp_character (buffer, '[');
! 	    if (domain)
  	      {
! 		if (TYPE_MIN_VALUE (domain)
! 		    && !integer_zerop (TYPE_MIN_VALUE (domain)))
! 		  {
! 		    dump_generic_node (buffer, TYPE_MIN_VALUE (domain),
! 				       spc, flags, false);
! 		    pp_string (buffer, " .. ");
! 		  }
! 
! 		if (TYPE_MAX_VALUE (domain))
! 		  dump_generic_node (buffer, TYPE_MAX_VALUE (domain),
! 				     spc, flags, false);
  	      }
+ 	    else
+ 	      pp_string (buffer, "<unknown>");
+ 
  	    pp_character (buffer, ']');
  	  }
  	break;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]