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] Fix PR c++/27278: ICE with invalid operator declaration


On 28 Apr, Mark Mitchell wrote:
> Volker Reichelt wrote:
> 
>> I could have checked for error_mark_nodes in this loop. However, the
>> patch below goes for the more drastic fix and skips the whole function
>> on invalid arguments. This prevents future ICEs in that function and
>> bogus error messages based on bad guesses what was intended by the
>> invalid arguments.
> * decl.c (grok_op_properties): Skip operators with invalid args.
> 
> I think this is dangerous; we'll now have operators around, without
> appropriate properties set.  For example, we'll not call
> SET_OVERLOADED_OPERATOR_CODE on an operator.  I think that in this case,
> the safer fix is to do as you suggest: check for error_mark_node in the
> loop, and return.
> 
> That patch is pre-approved.

So here's what I committed to mainline, 4.1 branch and 4.0 branch.
Bootstrapped and regtested on x86_64-unknown-linux-gnu.

Regards,
Volker


2006-04-30  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>

	PR c++/27278
	* decl.c (grok_op_properties): Skip operators with invalid args
	when checking for class-type or enum-type args.

===================================================================
--- gcc/gcc/cp/decl.c	2006-04-23 04:48:46 +0200
+++ gcc/gcc/cp/decl.c	2006-04-23 04:49:17 +0200
@@ -9072,6 +9072,9 @@ grok_op_properties (tree decl, bool comp
 	      for (p = argtypes; p && p != void_list_node; p = TREE_CHAIN (p))
 		{
 		  tree arg = non_reference (TREE_VALUE (p));
+		  if (arg == error_mark_node)
+		    return;
+
 		  /* IS_AGGR_TYPE, rather than CLASS_TYPE_P, is used
 		     because these checks are performed even on
 		     template functions.  */
===================================================================

2006-04-30  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>

	PR c++/27278
	* g++.dg/parse/operator7.C: New test.

===================================================================
--- gcc/gcc/testsuite/g++.dg/parse/operator7.C	2005-08-29 00:25:44 +0200
+++ gcc/gcc/testsuite/g++.dg/parse/operator7.C	2006-04-24 11:36:49 +0200
@@ -0,0 +1,4 @@
+// PR c++/27278
+// { dg-do compile }
+
+int operator+(void,void);  // { dg-error "incomplete type|invalid use" }
===================================================================



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