From b792a33ca458beea5f114eba261a5e8cd42145e3 Mon Sep 17 00:00:00 2001
From: Jakub Jelinek <jakub@redhat.com>
Date: Mon, 8 Jun 2009 18:48:11 +0200
Subject: [PATCH] re PR c++/40373 (ICE with invalid destructor call)

	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.

From-SVN: r148282
---
 gcc/cp/ChangeLog                      |  4 ++++
 gcc/cp/call.c                         |  2 +-
 gcc/testsuite/ChangeLog               |  3 +++
 gcc/testsuite/g++.dg/template/dtor7.C | 24 ++++++++++++++++++++++++
 4 files changed, 32 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/template/dtor7.C

diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 5c0d4730ce6d..d9327a9d379b 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
 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.
+
 	PR c++/40370
 	PR c++/40372
 	* parser.c (cp_parser_direct_declarator): Don't set TREE_SIDE_EFFECTS
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 1ab27c738e2e..db45ab0a30c7 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -242,7 +242,7 @@ check_dtor_name (tree basetype, tree name)
       return false;
     }
 
-  if (!name)
+  if (!name || name == error_mark_node)
     return false;
   return same_type_p (TYPE_MAIN_VARIANT (basetype), TYPE_MAIN_VARIANT (name));
 }
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2a32d8fa4b23..c6e7618254d2 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -4,6 +4,9 @@
 	* gcc.dg/builtin-object-size-4.c (test1): Adjust expected results.
 	* gcc.dg/builtin-object-size-6.c: New test.
 
+	PR c++/40373
+	* g++.dg/template/dtor7.C: New test.
+
 	PR c++/40370
 	PR c++/40372
 	* g++.dg/template/error41.C: New test.
diff --git a/gcc/testsuite/g++.dg/template/dtor7.C b/gcc/testsuite/g++.dg/template/dtor7.C
new file mode 100644
index 000000000000..0dac69e8948c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/dtor7.C
@@ -0,0 +1,24 @@
+// PR c++/40373
+// { dg-compile }
+
+struct A;	// { dg-bogus "candidates are" "" { xfail *-*-* } }
+namespace
+{
+  struct A;	// { dg-bogus "struct" "" { xfail *-*-* } }
+}
+
+struct B {};
+
+template <typename T> void
+foo (T t)
+{
+  t.~A ();	// { dg-error "does not match destructor name" }
+}
+
+void
+bar ()
+{
+  foo (B ());	// { dg-bogus "instantiated from here" "" { xfail *-*-* } }
+}
+
+// { dg-bogus "is ambiguous" "" { xfail *-*-* } 15 }
-- 
GitLab