summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2002-10-23 18:38:23 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2002-10-23 18:38:23 +0000
commite6f052b7e6e0d3969b9e3b1357980e00403d62cc (patch)
treea026babb434289dd715599cb3c26a633d808ded5
parent16448fd4f0b1c5ef78e5b5e463cc77e8aec14c96 (diff)
downloadgcc-e6f052b7e6e0d3969b9e3b1357980e00403d62cc.tar.gz
re PR c++/7679 (The compiler crashes wen a right parentesis is missing)
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. From-SVN: r58465
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/spew.c19
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/parse/inline1.C7
4 files changed, 38 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index d6f7be711d9..bca3b4c3570 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,12 @@
+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
diff --git a/gcc/cp/spew.c b/gcc/cp/spew.c
index 1d671252126..380d6936b83 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 e350c3f3e89..d0c5776b5eb 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2002-10-23 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/7679
+ * g++.dg/parse/inline1.C: New test.
+
2002-10-23 Richard Henderson <rth@redhat.com>
* 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 00000000000..5c3034c6ec2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/inline1.C
@@ -0,0 +1,7 @@
+struct f
+{
+ int oo()
+ {
+ return (2; // { dg-error "" }
+ }
+};