+2002-10-23 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/7679
+ * spew.c (next_token): Do not return an endless stream of
+ END_OF_SAVED_INPUT tokens.
+ (snarf_method): Add three END_OF_SAVED_INPUT tokens to the end of
+ the cached token stream.
+ (snarf_defarg): Likewise.
+
2002-10-23 Zack Weinberg <zack@codesourcery.com>
* cp-lang.c (cp_var_mod_type_p): New: C++ hook for
return t->yychar;
}
- memcpy (t, &Teosi, sizeof (struct token));
- return END_OF_SAVED_INPUT;
+ return 0;
}
/* Shift the next token onto the fifo. */
: (interface_only ? 0 : 2)));
snarf_block (meth);
+ /* Add three END_OF_SAVED_INPUT tokens. We used to provide an
+ infinite stream of END_OF_SAVED_INPUT tokens -- but that can
+ cause the compiler to get stuck in an infinite loop when
+ encountering invalid code. We need more than one because the
+ parser sometimes peeks ahead several tokens. */
+ memcpy (space_for_token (meth), &Teosi, sizeof (struct token));
+ memcpy (space_for_token (meth), &Teosi, sizeof (struct token));
+ memcpy (space_for_token (meth), &Teosi, sizeof (struct token));
/* Happens when we get two declarations of the same function in the
same scope. */
/* Unget the last token. */
push_token (remove_last_token (buf));
+ /* Add three END_OF_SAVED_INPUT tokens. We used to provide an
+ infinite stream of END_OF_SAVED_INPUT tokens -- but that can
+ cause the compiler to get stuck in an infinite loop when
+ encountering invalid code. We need more than one because the
+ parser sometimes peeks ahead several tokens. */
+ memcpy (space_for_token (buf), &Teosi, sizeof (struct token));
+ memcpy (space_for_token (buf), &Teosi, sizeof (struct token));
+ memcpy (space_for_token (buf), &Teosi, sizeof (struct token));
done:
#ifdef SPEW_DEBUG