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]

[C++ PATCH] Fix ICE in check_dtor_name (PR c++/40373)


Hi!

Since PR23287 (r143502) check_dtor_name may be (as shown on the testcase
below) called with name IDENTIFIER_NODE, for which get_type_lvalue returns
error_mark_node (as the lookup was ambiguous).
TYPE_MAIN_VARIANT (error_mark_node) is invalid though.
error_operand_p would not be IMHO appropriate here, as name in this place is a
TYPE_P or error_mark_node.

Fixed by checking for error_mark_node, bootstrapped/regtested on
x86_64-linux, ok for trunk?

2009-06-08  Jakub Jelinek  <jakub@redhat.com>

	PR c++/40373
	* call.c (check_dtor_name): Return false even if
	get_type_value (name) is error_mark_node.

	* g++.dg/template/dtor7.C: New test.

--- gcc/cp/call.c.jj	2009-06-08 11:53:51.000000000 +0200
+++ gcc/cp/call.c	2009-06-08 16:38:31.000000000 +0200
@@ -242,7 +242,7 @@ check_dtor_name (tree basetype, tree nam
       return false;
     }
 
-  if (!name)
+  if (!name || name == error_mark_node)
     return false;
   return same_type_p (TYPE_MAIN_VARIANT (basetype), TYPE_MAIN_VARIANT (name));
 }
--- gcc/testsuite/g++.dg/template/dtor7.C.jj	2009-06-08 16:43:32.000000000 +0200
+++ gcc/testsuite/g++.dg/template/dtor7.C	2009-06-08 16:44:21.000000000 +0200
@@ -0,0 +1,24 @@
+// PR c++/40373
+// { dg-compile }
+
+struct A;	// { dg-error "candidates are" }
+namespace
+{
+  struct A;	// { dg-error "struct" }
+}
+
+struct B {};
+
+template <typename T> void
+foo (T t)
+{
+  t.~A ();	// { dg-error "is ambiguous" }
+}
+
+void
+bar ()
+{
+  foo (B ());	// { dg-message "instantiated from here" }
+}
+
+// { dg-error "does not match destructor name" "" { target *-*-* } 15 }

	Jakub


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