OSDN Git Service

PR c++/7679
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 23 Oct 2002 18:38:23 +0000 (18:38 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 23 Oct 2002 18:38:23 +0000 (18:38 +0000)
* 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

gcc/cp/ChangeLog
gcc/cp/spew.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/inline1.C [new file with mode: 0644]

index d6f7be7..bca3b4c 100644 (file)
@@ -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
index 1d67125..380d693 100644 (file)
@@ -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
index e350c3f..d0c5776 100644 (file)
@@ -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 (file)
index 0000000..5c3034c
--- /dev/null
@@ -0,0 +1,7 @@
+struct f
+{
+  int oo()
+  {
+    return (2; // { dg-error "" }
+  }
+};