From: mmitchel Date: Wed, 23 Oct 2002 18:38:23 +0000 (+0000) Subject: PR c++/7679 X-Git-Tag: upstream/4.9.2~83749 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3d11cf7e7d77b4bb1b019552acf08a2f53dcaa51;p=platform%2Fupstream%2Flinaro-gcc.git 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. PR c++/7679 * g++.dg/parse/inline1.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@58465 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d6f7be71..bca3b4c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2002-10-23 Mark Mitchell + + 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 * cp-lang.c (cp_var_mod_type_p): New: C++ hook for diff --git a/gcc/cp/spew.c b/gcc/cp/spew.c index 1d67125..380d693 100644 --- a/gcc/cp/spew.c +++ b/gcc/cp/spew.c @@ -477,8 +477,7 @@ next_token (t) return t->yychar; } - memcpy (t, &Teosi, sizeof (struct token)); - return END_OF_SAVED_INPUT; + return 0; } /* Shift the next token onto the fifo. */ @@ -1195,6 +1194,14 @@ snarf_method (decl) : (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. */ @@ -1253,6 +1260,14 @@ snarf_defarg () /* 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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e350c3f..d0c5776 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2002-10-23 Mark Mitchell + + PR c++/7679 + * g++.dg/parse/inline1.C: New test. + 2002-10-23 Richard Henderson * g++.dg/inherit/thunk1.C: Enable for x86_64. diff --git a/gcc/testsuite/g++.dg/parse/inline1.C b/gcc/testsuite/g++.dg/parse/inline1.C new file mode 100644 index 0000000..5c3034c --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/inline1.C @@ -0,0 +1,7 @@ +struct f +{ + int oo() + { + return (2; // { dg-error "" } + } +};