Commit abda8efe by Mark Mitchell Committed by Mark Mitchell

re PR c++/9112 (new C++ parser rejects code older parsers accepted)

	PR c++/9112
	* parser.c (cp_parser_direct_declarator): Handle erroneous
	parenthesized declarators correctly.

	PR c++/9112
	* g++.dg/parse/expr1.C: New test.

From-SVN: r60706
parent 9e56a932
2002-12-31 Mark Mitchell <mark@codesourcery.com>
PR c++/9112
* parser.c (cp_parser_direct_declarator): Handle erroneous
parenthesized declarators correctly.
2002-12-31 Gabriel Dos Reis <gdr@integrable-solutions.net> 2002-12-31 Gabriel Dos Reis <gdr@integrable-solutions.net>
* cp-tree.h (pending_lang_change): Declare. * cp-tree.h (pending_lang_change): Declare.
......
...@@ -10023,6 +10023,8 @@ cp_parser_direct_declarator (parser, abstract_p, ctor_dtor_or_conv_p) ...@@ -10023,6 +10023,8 @@ cp_parser_direct_declarator (parser, abstract_p, ctor_dtor_or_conv_p)
declarator. */ declarator. */
if (token->type == CPP_OPEN_PAREN) if (token->type == CPP_OPEN_PAREN)
{ {
bool error_p;
/* For an abstract declarator we do not know whether we are /* For an abstract declarator we do not know whether we are
looking at the beginning of a parameter-declaration-clause, looking at the beginning of a parameter-declaration-clause,
or at a parenthesized abstract declarator. For example, if or at a parenthesized abstract declarator. For example, if
...@@ -10041,7 +10043,7 @@ cp_parser_direct_declarator (parser, abstract_p, ctor_dtor_or_conv_p) ...@@ -10041,7 +10043,7 @@ cp_parser_direct_declarator (parser, abstract_p, ctor_dtor_or_conv_p)
declarator declarator
= cp_parser_declarator (parser, abstract_p, ctor_dtor_or_conv_p); = cp_parser_declarator (parser, abstract_p, ctor_dtor_or_conv_p);
/* Expect a `)'. */ /* Expect a `)'. */
cp_parser_require (parser, CPP_CLOSE_PAREN, "`)'"); error_p = !cp_parser_require (parser, CPP_CLOSE_PAREN, "`)'");
/* If parsing a parenthesized abstract declarator didn't work, /* If parsing a parenthesized abstract declarator didn't work,
try a parameter-declaration-clause. */ try a parameter-declaration-clause. */
...@@ -10050,7 +10052,8 @@ cp_parser_direct_declarator (parser, abstract_p, ctor_dtor_or_conv_p) ...@@ -10050,7 +10052,8 @@ cp_parser_direct_declarator (parser, abstract_p, ctor_dtor_or_conv_p)
/* If we were not parsing an abstract declarator, but failed to /* If we were not parsing an abstract declarator, but failed to
find a satisfactory nested declarator, then an error has find a satisfactory nested declarator, then an error has
occurred. */ occurred. */
else if (!abstract_p && declarator == error_mark_node) else if (!abstract_p
&& (declarator == error_mark_node || error_p))
return error_mark_node; return error_mark_node;
/* Default args cannot appear in an abstract decl. */ /* Default args cannot appear in an abstract decl. */
parser->default_arg_ok_p = false; parser->default_arg_ok_p = false;
......
2002-12-31 Mark Mitchell <mark@codesourcery.com>
PR c++/9112
* g++.dg/parse/expr1.C: New test.
2002-12-30 Daniel Jacobowitz <drow@mvista.com> 2002-12-30 Daniel Jacobowitz <drow@mvista.com>
* gcc.c-torture/compile/20021230-1.c: New test. * gcc.c-torture/compile/20021230-1.c: New test.
......
struct A {
A (int, int);
void f ();
};
void f (int a) {
A (a, a).f ();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment