From dfe2b0b3b51f0596fe3bd27a3adc8bf432babacd Mon Sep 17 00:00:00 2001
From: Mark Mitchell <mark@codesourcery.com>
Date: Wed, 18 Aug 1999 22:11:10 +0000
Subject: [PATCH] search.c (setup_class_bindings): Robustify.

	* search.c (setup_class_bindings): Robustify.
	* typeck.c (common_type): Use same_type_p, not pointer equality,
	to compare types.

From-SVN: r28756
---
 gcc/cp/ChangeLog                            |  4 ++++
 gcc/cp/search.c                             |  2 +-
 gcc/cp/typeck.c                             |  2 +-
 gcc/testsuite/g++.old-deja/g++.pt/crash46.C |  8 ++++++++
 gcc/testsuite/g++.old-deja/g++.pt/crash47.C | 17 +++++++++++++++++
 5 files changed, 31 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.old-deja/g++.pt/crash46.C
 create mode 100644 gcc/testsuite/g++.old-deja/g++.pt/crash47.C

diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 0e1012f81717..6e44c4fcf62d 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
 1999-08-18  Mark Mitchell  <mark@codesourcery.com>
 
+	* search.c (setup_class_bindings): Robustify.
+	* typeck.c (common_type): Use same_type_p, not pointer equality,
+	to compare types.
+
         * cp-tree.h (build_lang_field_decl): Remove.
 	* class.c (build_vtable): Replace calls to build_lang_field_decl
 	with build_lang_decl.
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index 300d7107cf4a..62fa4024b9ba 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -2960,7 +2960,7 @@ setup_class_bindings (name, type_binding_p)
        binding.  This means that we already processed this binding
        above.  */
     my_friendly_assert (type_binding_p, 19990401);
-  else
+  else if (value_binding)
     {
       if (TREE_CODE (value_binding) == TREE_LIST 
 	  && TREE_TYPE (value_binding) == error_mark_node)
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 5d12bee3ada6..716fe19323d0 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -698,7 +698,7 @@ common_type (t1, t2)
 	tt1 = TYPE_MAIN_VARIANT (tt1);
 	tt2 = TYPE_MAIN_VARIANT (tt2);
 
-	if (tt1 == tt2)
+	if (same_type_p (tt1, tt2))
 	  target = tt1;
 	else if (b1)
 	  {
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash46.C b/gcc/testsuite/g++.old-deja/g++.pt/crash46.C
new file mode 100644
index 000000000000..e226559429d5
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.pt/crash46.C
@@ -0,0 +1,8 @@
+// Build don't link:
+// Origin: Leon Bottou <leonb@research.att.com>
+
+class AA { protected:
+  template <class T> struct BB { T x; BB(const T &x) : x(x) { }; };
+  template <class T> struct CC : public BB<T> { CC(const T &x) : BB<T>(x) { };
+};
+};
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash47.C b/gcc/testsuite/g++.old-deja/g++.pt/crash47.C
new file mode 100644
index 000000000000..96a23fd5c273
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.pt/crash47.C
@@ -0,0 +1,17 @@
+// Build don't link:
+// Origin: Rick Campbell <rick.campbell@db.com>
+
+template <class Owner, typename Type>
+struct DataMember
+{
+    inline DataMember (Type Owner::* data_member);
+
+    Type Owner::* _data_member;
+};
+
+template <class Owner, typename Type>
+inline
+DataMember<Owner,Type>::DataMember (Type Owner::* data_member)
+    : _data_member (data_member)
+{
+}
-- 
GitLab