This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: PR c++/39060: [4.4 regression] ICE with lots of invalid member functions


On Sat, Mar 07, 2009 at 02:45:39PM -0800, H.J. Lu wrote:
> On Sat, Mar 7, 2009 at 1:46 PM, Jason Merrill <jason@redhat.com> wrote:
> > H.J. Lu wrote:
> >>
> >> On Sat, Mar 7, 2009 at 1:23 PM, Jason Merrill <jason@redhat.com> wrote:
> >>>
> >>> H.J. Lu wrote:
> >>>>
> >>>> This patch returns NULL if default_argument is error_mark_node.
> >>>
> >>> So if parsing the default argument fails, we pretend the parameter itself
> >>> didn't exist? ÂWhy does that work better than just setting
> >>> default_argument
> >>> to NULL_TREE?
> >
> >> I still got
> >
> >> /tmp/x.ii:19: internal compiler error: canonical types differ for
> >> identical types void (A::)(void*) and void (A::)(void*)
> >
> > Yes, I expected that it wouldn't work better, I was curious why it makes a
> > difference. ÂIt seems that the problem is coming in when we build the method
> > type.
> 
> I think we are trying too hard to recover from error. Do we really need to
> make C++ front end so complex just to recover from fatal errors? Icc
> generates:
> 

Here is a different patch. Now I got

/tmp/x.ii:7: error: âA::A(void*)â cannot be overloaded
/tmp/x.ii:6: error: with âA::A(void*)â
/tmp/x.ii:8: error: âA::A(void*)â cannot be overloaded
/tmp/x.ii:6: error: with âA::A(void*)â
/tmp/x.ii:10: error: âvoid A::operator+(void*)â cannot have default arguments
/tmp/x.ii:12: error: expected identifier before â=â token
/tmp/x.ii:13: error: expected identifier before â=â token
/tmp/x.ii:14: error: expected identifier before â=â token
/tmp/x.ii:15: error: expected identifier before â=â token
/tmp/x.ii:16: error: expected identifier before â=â token
/tmp/x.ii:17: error: expected primary-expression at end of input
/tmp/x.ii:17: error: expected primary-expression at end of input
/tmp/x.ii:17: error: expected primary-expression at end of input
/tmp/x.ii:17: error: expected primary-expression at end of input
/tmp/x.ii:17: error: expected primary-expression at end of input
/tmp/x.ii:17: error: expected primary-expression at end of input
/tmp/x.ii:17: error: expected primary-expression at end of input
/tmp/x.ii:17: error: expected primary-expression at end of input
/tmp/x.ii:19: error: expected primary-expression before â)â token
/tmp/x.ii:19: error: default argument given for parameter 1 of âA::A(void*)â
/tmp/x.ii:6: error: after previous specification in âA::A(void*)â

OK for trunk if there are no regressions?

Thanks.


H.J.
---
gcc/cp/

2009-03-07  H.J. Lu  <hongjiu.lu@intel.com>

	PR c++/39060
	* parser.c (cp_parser_late_parsing_default_args): Continue
	the loop when cp_parser_assignment_expression returns
	error_mark_node.

gcc/testsuite/

2009-03-07  H.J. Lu  <hongjiu.lu@intel.com>

	PR c++/39060
	* g++.dg/other/pr39060.C: New.

--- gcc/cp/parser.c.pr39060	2009-03-06 08:49:42.000000000 -0800
+++ gcc/cp/parser.c	2009-03-07 16:05:48.000000000 -0800
@@ -18291,6 +18291,11 @@ cp_parser_late_parsing_default_args (cp_
 
       /* Parse the assignment-expression.  */
       parsed_arg = cp_parser_assignment_expression (parser, /*cast_p=*/false, NULL);
+      if (parsed_arg == error_mark_node)
+	{
+	  cp_parser_pop_lexer (parser);
+	  continue;
+	}
 
       if (!processing_template_decl)
 	parsed_arg = check_default_argument (TREE_VALUE (parm), parsed_arg);
--- gcc/testsuite/g++.dg/other/pr39060.C.pr39060	2009-03-07 11:16:00.000000000 -0800
+++ gcc/testsuite/g++.dg/other/pr39060.C	2009-03-07 16:07:25.000000000 -0800
@@ -0,0 +1,19 @@
+// PR c++/39060
+// { dg-do compile }
+
+struct A
+{
+  A(void* i=);	// { dg-error "with|specification" }
+  A(void* i=);	// { dg-error "overloaded" }
+  A(void* i=);	// { dg-error "overloaded" }
+
+  void operator+ (void* i=);	// { dg-error "arguments" }
+
+  virtual void foo1(=);	// { dg-error "identifier" }
+  void foo2(=);		// { dg-error "identifier" }
+  void foo3(=);		// { dg-error "identifier" }
+  void foo4(=);		// { dg-error "identifier" }
+  void foo5(=);		// { dg-error "identifier" }
+};	// { dg-error "primary-expression" }
+
+A::A (void* i=) {}	// { dg-error "primary-expression|argument" }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]