* [pph] Add debugging for namespace_decl (issue4368079)
@ 2011-04-12 19:53 Diego Novillo
0 siblings, 0 replies; only message in thread
From: Diego Novillo @ 2011-04-12 19:53 UTC (permalink / raw)
To: reply, crowl, gcc-patches
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-04-12 19:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-12 19:53 [pph] Add debugging for namespace_decl (issue4368079) Diego Novillo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).