public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [pph] Fix cp_debug_parser (issue4571058)
@ 2011-06-09  2:20 Diego Novillo
  0 siblings, 0 replies; only message in thread
From: Diego Novillo @ 2011-06-09  2:20 UTC (permalink / raw)
  To: reply, crowl, gchare, gcc-patches


This fixes the ICE that Gab ran into while calling cp_debug_parser on a
test case.

We were not handling the case of empty token buffers and when the
caller set the starting token to NULL.

Additionally, the window of tokens to print was too small to be of any
real use.


	* parser.c (cp_lexer_dump_tokens): If START_TOKEN is NULL,
	set it to the start of the token buffer.
	If BUFFER is NULL, do nothing.
	(cp_debug_parser): Increase token window size.

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 300fcba..e241cc7 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -265,10 +265,16 @@ cp_lexer_dump_tokens (FILE *file, VEC(cp_token,gc) *buffer,
 
   fprintf (file, "%u tokens\n", VEC_length (cp_token, buffer));
 
+  if (buffer == NULL)
+    return;
+
   if (num == 0)
     num = VEC_length (cp_token, buffer);
 
-  if (start_token && start_token > VEC_address (cp_token, buffer))
+  if (start_token == NULL)
+    start_token = VEC_address (cp_token, buffer);
+
+  if (start_token > VEC_address (cp_token, buffer))
     {
       cp_lexer_print_token (file, VEC_index (cp_token, buffer, 0));
       fprintf (file, " ... ");
@@ -436,7 +442,7 @@ void
 cp_debug_parser (FILE *file, cp_parser *parser)
 {
   cp_token *start_token, *first_token, *next_token;
-  const size_t window_size = 20;
+  const size_t window_size = 200;
 
   if (file == NULL)
     file = stderr;

--
This patch is available for review at http://codereview.appspot.com/4571058

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-06-09  0:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-09  2:20 [pph] Fix cp_debug_parser (issue4571058) 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).