This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[ast-optimizer-branch] PATCH to pretty-printer
- From: "Frank Ch. Eigler" <fche at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 12 Jun 2002 15:05:02 -0400
- Subject: [ast-optimizer-branch] PATCH to pretty-printer
Hi -
I'm planning to commit the following patch. It fixes the printing of
expressions like
char *p;
int *q;
p[8] = 'a';
p[7] = 5;
where the 8/7 indices were not both correctly printed because the
size of the pointed-to type was accounted for improperly.
- FChE
2002-06-12 Frank Ch. Eigler <fche@redhat.com>
* c-pretty-print.c (dump_c_node): Correct scaling of pointer-type
integer constants by type precision.
Index: c-pretty-print.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/c-pretty-print.c,v
retrieving revision 1.1.2.16
diff -u -r1.1.2.16 c-pretty-print.c
--- c-pretty-print.c 10 Jun 2002 14:26:03 -0000 1.1.2.16
+++ c-pretty-print.c 12 Jun 2002 18:47:33 -0000
@@ -1,5 +1,5 @@
/* Pretty formatting of a tree in C syntax.
- Copyright (C) 2001 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002 Free Software Foundation, Inc.
Contributed by Sebastian Pop <s.pop@laposte.net>
This file is part of GCC.
@@ -339,10 +339,10 @@
case INTEGER_CST:
if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE)
- /* In the case of a pointer, divise by the size of the pointed type. */
+ /* In the case of a pointer, divide by the size of the pointed-to type. */
output_decimal (buffer,
- TREE_INT_CST_LOW (node) /
- TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node))));
+ TREE_INT_CST_LOW (node) * BITS_PER_UNIT /
+ (TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node)))));
else
output_decimal (buffer, TREE_INT_CST_LOW (node));
break;