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]

[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.
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.

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);

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