From: dnovillo@google.com (Diego Novillo)
To: reply@codereview.appspotmail.com, crowl@google.com,
gcc-patches@gcc.gnu.org
Subject: [pph] Add debugging for namespace_decl (issue4368079)
Date: Tue, 12 Apr 2011 19:53:00 -0000 [thread overview]
Message-ID: <20110412195323.3B1DB1DA1BE@topo.tor.corp.google.com> (raw)
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
reply other threads:[~2011-04-12 19:53 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110412195323.3B1DB1DA1BE@topo.tor.corp.google.com \
--to=dnovillo@google.com \
--cc=crowl@google.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=reply@codereview.appspotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).