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

Issue 4571058: [pph] Fix cp_debug_parser (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 11 months ago by Diego Novillo
Modified:
12 years, 9 months ago
Reviewers:
CC:
Lawrence Crowl, Gabriel Charette, gcc-patches_gcc.gnu.org
Visibility:
Public.

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+8 lines, -2 lines) Patch
M gcc/cp/parser.c View 2 chunks +8 lines, -2 lines 0 comments Download

Messages

Total messages: 1
Diego Novillo
12 years, 11 months ago (2011-06-09 00:52:38 UTC) #1
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
Sign in to reply to this message.

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