Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2290)

Issue 4368079: [pph] Add debugging for namespace_decl (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
13 years, 2 months ago by Diego Novillo
Modified:
13 years, 1 month ago
Reviewers:
CC:
Lawrence Crowl, gcc-patches_gcc.gnu.org
Visibility:
Public.

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+18 lines, -1 line) Patch
M gcc/cp/cp-tree.h View 1 chunk +1 line, -0 lines 0 comments Download
M gcc/cp/name-lookup.c View 1 chunk +15 lines, -0 lines 0 comments Download
M gcc/cp/parser.c View 2 chunks +2 lines, -1 line 0 comments Download

Messages

Total messages: 1
Diego Novillo
13 years, 2 months ago (2011-04-12 19:53:26 UTC) #1
This patch adds some debugging support for printing namespace_decls and 
their associated binding level.

Committed to pph branch.

2011-04-12  Diego Novillo  <dnovillo@google.com>

	* cp-tree.h (print_namespace): Declare.
	* name-lookup.c (print_namespace): New.
	* parser.c (cp_debug_print_context_stack): Increment loop counter.

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 9ce164b..1fcd0d7 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -4758,6 +4758,7 @@ extern void print_other_binding_stack		(struct
cp_binding_level *);
 extern tree maybe_push_decl			(tree);
 extern tree current_decl_namespace		(void);
 extern cxx_binding *cxx_binding_make            (tree, tree);
+extern void print_namespace                     (tree);
 
 /* decl.c */
 extern tree poplevel				(int, int, int);
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index d4fd216..e39456e 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -1751,6 +1751,21 @@ print_binding_level (struct cp_binding_level* lvl)
     }
 }
 
+
+/* Print the given namespace decl NS to stderr.  */
+
+void
+print_namespace (tree ns)
+{
+  struct cp_binding_level *level = NAMESPACE_LEVEL (ns);
+
+  fprintf (stderr, "Namespace name: ");
+  print_generic_expr (stderr, ns, 0);
+  fprintf (stderr, "\nBinding contour\n");
+  print_binding_level (level);
+}
+
+
 void
 print_other_binding_stack (struct cp_binding_level *stack)
 {
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index fd2da62..32c81a4 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -352,6 +352,7 @@ cp_debug_print_context (FILE *file, cp_parser_context *c)
 
 
 /* Print the stack of parsing contexts to FILE starting with FIRST.  */
+
 static void
 cp_debug_print_context_stack (FILE *file, cp_parser_context *first)
 {
@@ -359,7 +360,7 @@ cp_debug_print_context_stack (FILE *file, cp_parser_context
*first)
   cp_parser_context *c;
 
   fprintf (file, "Parsing context stack:\n");
-  for (i = 0, c = first; c; c = c->next)
+  for (i = 0, c = first; c; c = c->next, i++)
     {
       fprintf (file, "\t#%u: ", i);
       cp_debug_print_context (file, c);

--
This patch is available for review at http://codereview.appspot.com/4368079
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b