This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH: PR 14278
- From: Mark Mitchell <mark at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 26 Feb 2004 16:32:24 -0800
- Subject: C++ PATCH: PR 14278
- Reply-to: mark at codesourcery dot com
This patch fixes an over-eager optimization in the parser causing us
to reject valid code.
Tested on i686-pc-linux-gnu, applied on the mainline and on the
branch.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
2004-02-26 Mark Mitchell <mark@codesourcery.com>
PR c++/14278
* parser.c (cp_parser_parameter_declaration_list): Commit
to fewer tentative parses.
2004-02-26 Mark Mitchell <mark@codesourcery.com>
PR c++/14278
* g++.dg/parse/comma1.C: New test.
Index: cp/parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.157.2.14
diff -c -5 -p -r1.157.2.14 parser.c
*** cp/parser.c 19 Feb 2004 03:20:19 -0000 1.157.2.14
--- cp/parser.c 27 Feb 2004 00:28:03 -0000
*************** cp_parser_parameter_declaration_list (cp
*** 11032,11041 ****
--- 11032,11042 ----
Due to the fact that the parsing of template arguments
(as specified to a template-id) requires backtracking we
cannot use this technique when inside a template argument
list. */
if (!parser->in_template_argument_list_p
+ && !parser->in_type_id_in_expr_p
&& cp_parser_parsing_tentatively (parser)
&& !cp_parser_committed_to_tentative_parse (parser)
/* However, a parameter-declaration of the form
"foat(f)" (which is a valid declaration of a
parameter "f") can also be interpreted as an
Index: testsuite/g++.dg/parse/comma1.C
===================================================================
RCS file: testsuite/g++.dg/parse/comma1.C
diff -N testsuite/g++.dg/parse/comma1.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/parse/comma1.C 27 Feb 2004 00:28:04 -0000
***************
*** 0 ****
--- 1,13 ----
+ // PR c++/14278
+
+ struct X {
+ X (int p);
+ };
+
+ struct A {
+ A(X);
+ };
+
+ void *p_fun;
+
+ A a(X ((*(int (*)(int, int)) p_fun)(0, 0)));