Patch for regression PR c++/28432

Steve Ellcey sje@cup.hp.com
Thu Jul 27 21:11:00 GMT 2006


My earlier patch to PR 28304 (an ICE) caused the duplicate error
messages that is reported in PR 28432.  This patch undoes the patch for
PR 28304 (the decl2.c change) and replaces it with the search.c change.

As a side effect the error message that test pr28304.C gives changed
from one about 'no member' to 'no matching call'.  I think this is OK.

Tested on IA64 HP-UX, OK for checkin?

Since the original patch for PR 28304 was backported to 4.0 and 4.1
branches, I intend to do the same with this one if it is approved.

Steve Ellcey
sje@cup.hp.com

2006-07-27  Steve Ellcey  <sje@cup.hp.com>

	PR c++/28432
	* decl2.c (check_classfn): Remove early return.
	* search.c (lookup_member): Return NULL with bad type.

Index: decl2.c
===================================================================
--- decl2.c	(revision 115770)
+++ decl2.c	(working copy)
@@ -676,7 +676,6 @@ check_classfn (tree ctype, tree function
     {
       error ("no %q#D member function declared in class %qT",
 	     function, ctype);
-      return NULL_TREE;
     }
 
   /* If we did not find the method in the class, add it to avoid

Index: search.c
===================================================================
--- search.c	(revision 115770)
+++ search.c	(working copy)
@@ -1209,7 +1209,8 @@ lookup_member (tree xbasetype, tree name
     }
   else
     {
-      gcc_assert (IS_AGGR_TYPE_CODE (TREE_CODE (xbasetype)));
+      if (!IS_AGGR_TYPE_CODE (TREE_CODE (xbasetype)))
+	return NULL_TREE;
       type = xbasetype;
       xbasetype = NULL_TREE;
     }
2006-07-27  Steve Ellcey  <sje@cup.hp.com>

	PR c++/28432
	* g++.dg/other/pr28304.C: Change expected error message.
	* g++.dg/other/pr28432.C: New test.
Index: g++.dg/other/pr28304.C
===================================================================
--- g++.dg/other/pr28304.C	(revision 115770)
+++ g++.dg/other/pr28304.C	(working copy)
@@ -7,5 +7,5 @@ template<typename T> void A::foo(T) {}  
 
 void bar()
 {
-    A::foo(1); // { dg-error "not a member" }
+    A::foo(1); // { dg-error "no matching function for call" }
 }
Index: g++.dg/other/pr28432.C
===================================================================
--- g++.dg/other/pr28432.C	(revision 0)
+++ g++.dg/other/pr28432.C	(revision 0)
@@ -0,0 +1,7 @@
+
+// Test to make sure we do not ICE on this invalid program.
+
+// { dg-options "" }
+
+struct A {};
+void A::foo(); // { dg-error "member function declared in class|outside of class is not definition" }



More information about the Gcc-patches mailing list