From: Mark Mitchell Date: Wed, 23 Oct 2002 00:31:20 +0000 (+0000) Subject: spew.c (snarf_parenthesized_expression): New function. X-Git-Tag: releases/gcc-3.2.1~119 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1202486383a0ae822d6eeea30699bbbe55013512;p=thirdparty%2Fgcc.git spew.c (snarf_parenthesized_expression): New function. * spew.c (snarf_parenthesized_expression): New function. (snarf_block): Use it. * g++.dg/parse/stmtexpr3.C: New test. From-SVN: r58430 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index cf4c854637d4..e5a628c46947 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2002-10-22 Mark Mitchell + + PR c++/6579 + * spew.c (snarf_parenthesized_expression): New function. + (snarf_block): Use it. + 2002-10-21 Matthias Klose * Backport, without whitespace change: diff --git a/gcc/cp/spew.c b/gcc/cp/spew.c index 33fa441d4c62..93b8348b0293 100644 --- a/gcc/cp/spew.c +++ b/gcc/cp/spew.c @@ -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, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index eacd9c3c2c0b..011f9f4af0b3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2002-10-22 Mark Mitchell + + PR c++/6579 + * g++.dg/parse/stmtexpr3.C: New test. + 2002-10-22 Nathan Sidwell PR c++/7209