Patchwork [cilkplus-merge] Handle generic pretty printing of ARRAY_NOTATION_REF

login
register
mail settings
Submitter Aldy Hernandez
Date March 27, 2013, 4:31 p.m.
Message ID <51531EF0.4020102@redhat.com>
Download mbox | patch
Permalink /patch/231743/
State New
Headers show

Comments

Aldy Hernandez - March 27, 2013, 4:31 p.m.
While debugging some code I noticed that dump_generic_stmt() does not 
work on ARRAY_NOTATION_REFs.  Attached is a patch adding the smarts to 
tree-pretty-print.

There is no testcase because ARRAY_NOTATION_REFs are expanded by the 
parser, so by the time the tree dumps happen, there are no more 
ARRAY_NOTATION_REFs to look at.

I am using TREE_OPERAND instead of the preferred ARRAY_NOTATION_* 
accessors, because these accessors are defined in c-family/c-common.h. 
Perhaps when both the C and C++ array notations are contributed, we 
could move the accessors to tree.h or something.

Balaji, are you ok with these changes?  If you are ok, I will commit 
this as a fairly trivial and obvious change.
commit 6a865bd29f24f94039c9017766d82d05085f320f
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Wed Mar 27 11:19:56 2013 -0500

    Handle generic pretty printing of ARRAY_NOTATION_REF.
Iyer, Balaji V - March 27, 2013, 5:01 p.m.
Yes, it looks OK. 
Thanks,

Balaji V. Iyer.


> -----Original Message-----
> From: Aldy Hernandez [mailto:aldyh@redhat.com]
> Sent: Wednesday, March 27, 2013 12:32 PM
> To: gcc-patches; Iyer, Balaji V
> Subject: [cilkplus-merge] Handle generic pretty printing of
> ARRAY_NOTATION_REF
> 
> While debugging some code I noticed that dump_generic_stmt() does not work
> on ARRAY_NOTATION_REFs.  Attached is a patch adding the smarts to tree-
> pretty-print.
> 
> There is no testcase because ARRAY_NOTATION_REFs are expanded by the
> parser, so by the time the tree dumps happen, there are no more
> ARRAY_NOTATION_REFs to look at.
> 
> I am using TREE_OPERAND instead of the preferred ARRAY_NOTATION_*
> accessors, because these accessors are defined in c-family/c-common.h.
> Perhaps when both the C and C++ array notations are contributed, we could
> move the accessors to tree.h or something.
> 
> Balaji, are you ok with these changes?  If you are ok, I will commit this as a fairly
> trivial and obvious change.
Aldy Hernandez - March 27, 2013, 9:36 p.m.
On 03/27/13 12:01, Iyer, Balaji V wrote:
> Yes, it looks OK.
> Thanks,
>
> Balaji V. Iyer.

Ok, thanks.  Committed to branch.

Patch

diff --git a/gcc/ChangeLog.cilkplus b/gcc/ChangeLog.cilkplus
index 7c0834d..a0ecc76 100644
--- a/gcc/ChangeLog.cilkplus
+++ b/gcc/ChangeLog.cilkplus
@@ -8,3 +8,5 @@ 
 	ARRAY_NOTATION_REF storage.
 	* Makefile.in (C_COMMON_OBJS): Added
 	c-family/array-notation-common.o.
+	* tree-pretty-print.c (dump_generic_node): Add case for
+	ARRAY_NOTATION_REF.
diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c
index 1613142..36a9f5a 100644
--- a/gcc/tree-pretty-print.c
+++ b/gcc/tree-pretty-print.c
@@ -1266,6 +1266,17 @@  dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags,
       pp_string (buffer, ">");
       break;
 
+    case ARRAY_NOTATION_REF:
+      dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
+      pp_character (buffer, '[');
+      dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
+      pp_character (buffer, ':');
+      dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
+      pp_character (buffer, ':');
+      dump_generic_node (buffer, TREE_OPERAND (node, 3), spc, flags, false);
+      pp_character (buffer, ']');
+      break;
+
     case ARRAY_REF:
     case ARRAY_RANGE_REF:
       op0 = TREE_OPERAND (node, 0);