[patch, c++] Patch for PR c++/35109

Steve Ellcey sje@cup.hp.com
Thu Dec 11 22:29:00 GMT 2008


Here is a patch for PR c++/35109.  All I did was to remove the assert.
It caused no regressions and the test case gives a reasonable error
message after removing the assert so I think it is a reasonable patch
but there could be ramifications that I am not aware of.

Tested on IA64 HP-UX and Linux.

OK for checkin?

Steve Ellcey
sje@cup.hp.com



2008-12-11  Steve Ellcey  <sje@cup.hp.com>

	PR  c++/35109
	* name-lookup.c (lookup_name_real): Remove assert.


2008-12-11  Steve Ellcey  <sje@cup.hp.com>

	PR c++/35109
	* g++.dg/other/crash-6.C: New test.


Index: name-lookup.c
===================================================================
--- name-lookup.c	(revision 142693)
+++ name-lookup.c	(working copy)
@@ -4150,9 +4150,11 @@ lookup_name_real (tree name, int prefer_
 		   found by name lookup until a matching declaration is
 		   provided in the innermost enclosing nonclass scope.
 		*/
+#if 0
+		/* Let it go and give an error later.  */
 		gcc_assert (current_class_type &&
 			    LOCAL_CLASS_P (current_class_type));
-
+#endif
 		/* This binding comes from a friend declaration in the local
 		   class. The standard (11.4.8) states that the lookup can
 		   only succeed if there is a non-hidden declaration in the



Index: g++.dg/other/crash-6.C
===================================================================
--- g++.dg/other/crash-6.C	(revision 0)
+++ g++.dg/other/crash-6.C	(revision 0)
@@ -0,0 +1,12 @@
+// Origin: PR c++/35109
+// { dg-do compile }
+
+void foo()
+{
+  struct A
+  {
+    friend class B;
+  };
+  B::B() {} // { dg-error "has not been declared" }
+// { dg-error "expected" "expected" { target *-*-* } 10 }
+}



More information about the Gcc-patches mailing list