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]

Add type suffixes to INT_CSTs in tree-pretty-print.c


While investigating if PR 19334 was a problem in the Fortran frontend, I
needed the tree dumps to include information if an integer constant was of the
actual type I expected it to be.  To this end I added code to
tree-pretty-print.c which adds a type suffix to an integer constant in a way
modeled after the Fortran way of doing this kind of things.

Basically, "1234_U32" means "constant of value 1234, of an unsigned type with
TYPE_PRECISION == 32 bits".  For a signed type 'S' replaces the 'U'.

I'm not sure about the testing requirements for this kind of patch, as this is
on a codepath that should not be hit during normal operation: I bubblestrapped
a c,f95-only compiler with this, and ran the Fortran testsuite with this,
without any changes, I also visually verified that the tree dumps read what I
think they should.  Anything more I should do?  I don't know if this will
affect testcases which verify the output of tree dumpers, and I'm not so much
attached to this patch that I will want to wait the time a bootstrap +
testsuite run with all languages enabled takes on my box (c,f95-only already
takes ~ 2 hrs without runnning the testsuite)

- Tobi

2005-01-09  Tobias Schl"uter  <tobias.schlueter@physik.uni-muenchen.de>

	* tree-pretty-print.c (dump_generic_node): Add type suffix in output
	for INT_CST nodes.

Index: tree-pretty-print.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-pretty-print.c,v
retrieving revision 2.52
diff -u -p -r2.52 tree-pretty-print.c
--- tree-pretty-print.c	9 Dec 2004 10:54:36 -0000	2.52
+++ tree-pretty-print.c	9 Jan 2005 16:49:58 -0000
@@ -532,6 +532,14 @@ dump_generic_node (pretty_printer *buffe
 	}
       else
 	pp_wide_integer (buffer, TREE_INT_CST_LOW (node));
+
+      /* Print a suffix to the constant indicating the bit width
+	 of the constant and whether it is signed or not.  */
+      if (TYPE_UNSIGNED (TREE_TYPE (node)))
+	pp_string (buffer, "_U");
+      else
+	pp_string (buffer, "_S");
+      pp_wide_integer (buffer, TYPE_PRECISION (TREE_TYPE (node)));
       break;
 
     case REAL_CST:

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