]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
spew.c (snarf_parenthesized_expression): New function.
authorMark Mitchell <mark@codesourcery.com>
Wed, 23 Oct 2002 00:31:20 +0000 (00:31 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Wed, 23 Oct 2002 00:31:20 +0000 (00:31 +0000)
* spew.c (snarf_parenthesized_expression): New function.
(snarf_block): Use it.

* g++.dg/parse/stmtexpr3.C: New test.

From-SVN: r58430

gcc/cp/ChangeLog
gcc/cp/spew.c
gcc/testsuite/ChangeLog

index cf4c854637d4e07401e190e61733783ab0f1787e..e5a628c469473d98b39e3ec2d07f0bdc45832781 100644 (file)
@@ -1,3 +1,9 @@
+2002-10-22  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/6579
+       * spew.c (snarf_parenthesized_expression): New function.
+       (snarf_block): Use it.
+
 2002-10-21  Matthias Klose  <doko@debian.org>
 
        * Backport, without whitespace change:
index 33fa441d4c62c07c7e1672e24ed1a9e3bdaf7705..93b8348b02931c11d831ce9a6246ccbab55e97e1 100644 (file)
@@ -115,6 +115,7 @@ static SPEW_INLINE int read_process_identifier PARAMS ((YYSTYPE *));
 static SPEW_INLINE void feed_input PARAMS ((struct unparsed_text *));
 static SPEW_INLINE void snarf_block PARAMS ((const char *, int));
 static tree snarf_defarg PARAMS ((void));
+static void snarf_parenthesized_expression PARAMS ((const char *, int));
 static int frob_id PARAMS ((int, int, tree *));
 
 /* The list of inline functions being held off until we reach the end of
@@ -1032,6 +1033,38 @@ process_next_inline (i)
 }
 
 
+/* Accumulate the tokens that make up a parenthesized expression in T,
+   having already read the opening parenthesis.  */
+
+static void
+snarf_parenthesized_expression (starting_file, starting_line)
+     const char *starting_file;
+     int starting_line;
+{
+  int yyc;
+  int level = 1;
+
+  while (1)
+    {
+      size_t point;
+
+      point = obstack_object_size (&inline_text_obstack);
+      obstack_blank (&inline_text_obstack, sizeof (struct token));
+      yyc = add_token ((struct token *)
+                      (obstack_base (&inline_text_obstack) + point));
+      if (yyc == '(')
+       ++level;
+      else if (yyc == ')' && --level == 0)
+       break;
+      else if (yyc == 0)
+       {
+         error_with_file_and_line (starting_file, starting_line,
+                                   "end of file read inside definition");
+         break;
+       }
+    }
+}
+
 /* Subroutine of snarf_method, deals with actual absorption of the block.  */
 
 static SPEW_INLINE void
@@ -1114,6 +1147,8 @@ snarf_block (starting_file, starting_line)
          else if (look_for_semicolon && blev == 0)
            break;
        }
+      else if (yyc == '(' && blev == 0)
+       snarf_parenthesized_expression (starting_file, starting_line);
       else if (yyc == 0)
        {
          error_with_file_and_line (starting_file, starting_line,
index eacd9c3c2c0b411e016b83793d52b6d4a71fcb77..011f9f4af0b3ea0288b0eedb559e0514ad9def6c 100644 (file)
@@ -1,3 +1,8 @@
+2002-10-22  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/6579
+       * g++.dg/parse/stmtexpr3.C: New test.
+
 2002-10-22  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/7209