This fixes the ICE that Gab ran into while calling cp_debug_parser on a test case. ...
13 years, 10 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
Issue 4571058: [pph] Fix cp_debug_parser
(Closed)
Created 13 years, 10 months ago by Diego Novillo
Modified 13 years, 8 months ago
Reviewers:
Base URL:
Comments: 0